OSDN Git Service

AppliStation-GUI,インストール確認ダイアログでの「すべて選択/非選択」の高速化
authorttp <ttp@users.sourceforge.jp>
Thu, 8 Apr 2010 17:04:54 +0000 (02:04 +0900)
committerttp <ttp@users.sourceforge.jp>
Thu, 8 Apr 2010 17:04:54 +0000 (02:04 +0900)
(更新処理中のアイテム選択状態切り替え動作が動かないようにした)

AppliStation/InstallationConfirmForm.cs

index 4233484..f6afea9 100644 (file)
@@ -19,6 +19,8 @@ namespace AppliStation
                private Installation[] requiredInstallations = null;\r
                \r
                private PackageListsManager pkgListMan;\r
+               \r
+               private ushort instslistviewitemcheckedguardcounter = 0;\r
 \r
                public IEnumerable<Installation> Installations {\r
                        get {\r
@@ -92,7 +94,7 @@ namespace AppliStation
                        addInstsListItemPerGroup(selectedInstallations, instsListView.Groups["install"], false);\r
                        addInstsListItemPerGroup(updateInstallations, instsListView.Groups["update"], false);\r
                        \r
-                       InstsListViewItemChecked(instsListView, null);\r
+                       updateCheckBoxStatuses();\r
                        updateSilentInstallAsPossibleCheckBox();\r
                        \r
                        instsListView.EndUpdate();\r
@@ -109,6 +111,8 @@ namespace AppliStation
                        // まず所属グループのアイテムをすべて削除する\r
                        if (insts == null) return;\r
                        \r
+                       instsListView.BeginUpdate();\r
+                       \r
                        List<ListViewItem> itemsToAdd = new List<ListViewItem>();\r
                        foreach (Installation inst in insts) {\r
                                Package pkg = inst.InstalledPackage;\r
@@ -145,6 +149,8 @@ namespace AppliStation
                        } else {\r
                                instsListView.Items.AddRange(itemsToAdd.ToArray());\r
                        }\r
+                       \r
+                       instsListView.EndUpdate();\r
                }\r
 \r
                #endregion\r
@@ -208,11 +214,13 @@ namespace AppliStation
                \r
                #endregion\r
                \r
-               void InstsListViewItemChecked(object sender, ItemCheckedEventArgs e)\r
+               private void updateCheckBoxStatuses()\r
                {\r
                        System.Windows.Forms.ListView.ListViewItemCollection items = instsListView.Items;\r
                        System.Windows.Forms.ListView.CheckedListViewItemCollection checkeds = instsListView.CheckedItems;\r
                        \r
+                       instslistviewitemcheckedguardcounter ++;\r
+                       \r
                        // すべて選択/非選択\r
                        selectAllCheckBox.CheckState =\r
                                (checkeds == null || checkeds.Count == 0)? CheckState.Unchecked :\r
@@ -227,6 +235,15 @@ namespace AppliStation
                        okButton.Enabled = (checkeds != null) && (checkeds.Count > 0);\r
                        \r
                        checkUnselectedDependencies();\r
+                       \r
+                       instslistviewitemcheckedguardcounter --;\r
+               }\r
+               \r
+               void InstsListViewItemChecked(object sender, ItemCheckedEventArgs e)\r
+               {\r
+                       if (instslistviewitemcheckedguardcounter == 0) {\r
+                               updateCheckBoxStatuses();\r
+                       }\r
                }\r
                \r
                void InstsListViewContextMenuStripOpening(object sender, System.ComponentModel.CancelEventArgs e)\r
@@ -272,6 +289,9 @@ namespace AppliStation
                void SelectAllCheckBoxCheckedChanged(object sender, EventArgs e)\r
                {\r
                        instsListView.BeginUpdate();\r
+                       \r
+                       instslistviewitemcheckedguardcounter ++;\r
+                       \r
                        if (selectAllCheckBox.CheckState == CheckState.Checked) {\r
                                foreach (ListViewItem item in instsListView.Items) {\r
                                        item.Checked = true;\r
@@ -282,6 +302,11 @@ namespace AppliStation
                                        item.Checked = false;\r
                                }\r
                        }\r
+                       \r
+                       instslistviewitemcheckedguardcounter --;\r
+                       \r
+                       updateCheckBoxStatuses();\r
+                       \r
                        instsListView.EndUpdate();\r
                }\r
                \r
@@ -372,7 +397,7 @@ namespace AppliStation
                                \r
                                addInstsListItemPerGroup(requiredInstallations, instsListView.Groups["requires"], true);\r
                                \r
-                               InstsListViewItemChecked(instsListView, null);\r
+                               updateCheckBoxStatuses();\r
                                updateSilentInstallAsPossibleCheckBox();\r
                                instsListView.EndUpdate();\r
                        }\r