OSDN Git Service

振り分けルール移動・コピー時のエラーチェック強化
authorsyo68k <syo68k@users.sourceforge.jp>
Fri, 30 Jul 2010 09:20:46 +0000 (09:20 +0000)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Feb 2012 14:14:21 +0000 (23:14 +0900)
git-svn-id: http://svn.sourceforge.jp/svnroot/tween/trunk@631 e39ad16e-3079-482e-bb30-4b4d378143b6

Tween/FilterDialog.vb

index fdcd122..40aca78 100644 (file)
@@ -897,55 +897,59 @@ Public Class FilterDialog
     End Sub
 
     Private Sub ButtonRuleCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonRuleCopy.Click
-        tabdialog.Text = My.Resources.ButtonRuleCopy_ClickText1
-        If tabdialog.ShowDialog = Windows.Forms.DialogResult.Cancel Then
-            Exit Sub
-        End If
-        Dim tabname As String = ListTabs.SelectedItem.ToString
-        Dim tabs As StringCollection = tabdialog.SelectedTabNames
-        Dim filters As New Generic.List(Of FiltersClass)
-
-        For Each idx As Integer In ListFilters.SelectedIndices
-            filters.Add(_sts.Tabs(tabname).Filters(idx).CopyTo(New FiltersClass))
-        Next
-        For Each tb As String In tabs
-            If tb <> tabname Then
-                For Each flt As FiltersClass In filters
-                    If Not _sts.Tabs(tb).Filters.Contains(flt) Then
-                        _sts.Tabs(tb).AddFilter(flt.CopyTo(New FiltersClass))
-                    End If
-                Next
+        If ListTabs.SelectedIndex > -1 AndAlso ListFilters.SelectedItem IsNot Nothing Then
+            tabdialog.Text = My.Resources.ButtonRuleCopy_ClickText1
+            If tabdialog.ShowDialog = Windows.Forms.DialogResult.Cancel Then
+                Exit Sub
             End If
-        Next
-    End Sub
+            Dim tabname As String = ListTabs.SelectedItem.ToString
+            Dim tabs As StringCollection = tabdialog.SelectedTabNames
+            Dim filters As New Generic.List(Of FiltersClass)
 
-    Private Sub ButtonRuleMove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonRuleMove.Click
-        tabdialog.Text = My.Resources.ButtonRuleMove_ClickText1
-        If tabdialog.ShowDialog = Windows.Forms.DialogResult.Cancel Then
-            Exit Sub
+            For Each idx As Integer In ListFilters.SelectedIndices
+                filters.Add(_sts.Tabs(tabname).Filters(idx).CopyTo(New FiltersClass))
+            Next
+            For Each tb As String In tabs
+                If tb <> tabname Then
+                    For Each flt As FiltersClass In filters
+                        If Not _sts.Tabs(tb).Filters.Contains(flt) Then
+                            _sts.Tabs(tb).AddFilter(flt.CopyTo(New FiltersClass))
+                        End If
+                    Next
+                End If
+            Next
         End If
-        Dim tabname As String = ListTabs.SelectedItem.ToString
-        Dim tabs As StringCollection = tabdialog.SelectedTabNames
-        Dim filters As New Generic.List(Of FiltersClass)
+    End Sub
 
-        For Each idx As Integer In ListFilters.SelectedIndices
-            filters.Add(_sts.Tabs(tabname).Filters(idx).CopyTo(New FiltersClass))
-        Next
-        If tabs.Count = 1 AndAlso tabs(0) = tabname Then Exit Sub
-        For Each tb As String In tabs
-            If tb <> tabname Then
-                For Each flt As FiltersClass In filters
-                    If Not _sts.Tabs(tb).Filters.Contains(flt) Then
-                        _sts.Tabs(tb).AddFilter(flt.CopyTo(New FiltersClass))
-                    End If
-                Next
-            End If
-        Next
-        For idx As Integer = ListFilters.Items.Count - 1 To 0 Step -1
-            If ListFilters.GetSelected(idx) Then
-                _sts.Tabs(ListTabs.SelectedItem.ToString()).RemoveFilter(DirectCast(ListFilters.Items(idx), FiltersClass))
-                ListFilters.Items.RemoveAt(idx)
+    Private Sub ButtonRuleMove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonRuleMove.Click
+        If ListTabs.SelectedIndex > -1 AndAlso ListFilters.SelectedItem IsNot Nothing Then
+            tabdialog.Text = My.Resources.ButtonRuleMove_ClickText1
+            If tabdialog.ShowDialog = Windows.Forms.DialogResult.Cancel Then
+                Exit Sub
             End If
-        Next
+            Dim tabname As String = ListTabs.SelectedItem.ToString
+            Dim tabs As StringCollection = tabdialog.SelectedTabNames
+            Dim filters As New Generic.List(Of FiltersClass)
+
+            For Each idx As Integer In ListFilters.SelectedIndices
+                filters.Add(_sts.Tabs(tabname).Filters(idx).CopyTo(New FiltersClass))
+            Next
+            If tabs.Count = 1 AndAlso tabs(0) = tabname Then Exit Sub
+            For Each tb As String In tabs
+                If tb <> tabname Then
+                    For Each flt As FiltersClass In filters
+                        If Not _sts.Tabs(tb).Filters.Contains(flt) Then
+                            _sts.Tabs(tb).AddFilter(flt.CopyTo(New FiltersClass))
+                        End If
+                    Next
+                End If
+            Next
+            For idx As Integer = ListFilters.Items.Count - 1 To 0 Step -1
+                If ListFilters.GetSelected(idx) Then
+                    _sts.Tabs(ListTabs.SelectedItem.ToString()).RemoveFilter(DirectCast(ListFilters.Items(idx), FiltersClass))
+                    ListFilters.Items.RemoveAt(idx)
+                End If
+            Next
+        End If
     End Sub
 End Class