OSDN Git Service

AppliStation-GUI,インストール確認ダイアログで「すべて選択/非選択」と「サイレントインストールする/しない」を追加。
[applistation/AppliStation.git] / AppliStation / InstallationConfirmForm.cs
index 017f58e..0d43aab 100644 (file)
@@ -82,6 +82,8 @@ namespace AppliStation
                /// </summary>\r
                private void updateInstsListView()\r
                {\r
+                       instsListView.BeginUpdate();\r
+                       \r
                        if (instsListView.Items.Count > 0) {\r
                                instsListView.Items.Clear();\r
                        }\r
@@ -91,7 +93,9 @@ namespace AppliStation
                        addInstsListItemPerGroup(updateInstallations, instsListView.Groups["update"], false);\r
                        \r
                        InstsListViewItemChecked(instsListView, null);\r
-                       instsListView.Refresh();\r
+                       updateSilentInstallAsPossibleCheckBox();\r
+                       \r
+                       instsListView.EndUpdate();\r
                }\r
 \r
                /// <summary>\r
@@ -115,7 +119,7 @@ namespace AppliStation
                                inst.Silent = true; // silent install as possible!\r
                                \r
                                Package curPkg = null;\r
-                               if (pkgListMan != null) {       \r
+                               if (pkgListMan != null) {\r
                                        curPkg = pkgListMan.InstalledPkgList.GetPackageForName(pkg.Name) ??\r
                                                pkgListMan.SystemInstalledPkgList.GetPackageForName(pkg.Name);\r
                                }\r
@@ -206,16 +210,25 @@ namespace AppliStation
                \r
                void InstsListViewItemChecked(object sender, ItemCheckedEventArgs e)\r
                {\r
+                       System.Windows.Forms.ListView.ListViewItemCollection items = instsListView.Items;\r
                        System.Windows.Forms.ListView.CheckedListViewItemCollection checkeds = instsListView.CheckedItems;\r
                        \r
+                       // すべて選択/非選択\r
+                       selectAllCheckBox.CheckState =\r
+                               (checkeds == null || checkeds.Count == 0)? CheckState.Unchecked :\r
+                               (checkeds.Count == items.Count)? CheckState.Checked :\r
+                               CheckState.Indeterminate;\r
+                       \r
+                       // runas情報\r
                        runasCheckBox.Checked = GetShouldUseRunas();\r
                        updateUseRunas();\r
-                                               \r
+                       \r
+                       // インストール可能か\r
                        okButton.Enabled = (checkeds != null) && (checkeds.Count > 0);\r
                        \r
                        checkUnselectedDependencies();\r
                }\r
-                               \r
+               \r
                void InstsListViewContextMenuStripOpening(object sender, System.ComponentModel.CancelEventArgs e)\r
                {\r
                        System.Windows.Forms.ListView.CheckedIndexCollection  chkIdxes = instsListView.CheckedIndices;\r
@@ -240,36 +253,92 @@ namespace AppliStation
                                        }\r
                                }\r
                        }\r
-                       instListToolStripSeparator.Visible = selIdxes.Count > 0;\r
-               \r
-                       \r
-                       selectAllInstsStripMenuItem.Enabled = chkIdxes.Count < instsListView.Items.Count;\r
-                       unselectAllInstsStripMenuItem.Enabled = chkIdxes.Count > 0;\r
                }\r
                \r
                void SilentInstallStripMenuItemClick(object sender, EventArgs e)\r
                {\r
+                       instsListView.BeginUpdate();\r
                        bool silent = ! silentInstallStripMenuItem.Checked;\r
                        foreach (ListViewItem item in instsListView.SelectedItems) {\r
                                ((Installation) item.Tag).Silent = silent;\r
                                instViewUpdateSilentInstallView(item);\r
                        }\r
+                       updateSilentInstallAsPossibleCheckBox();\r
+                       instsListView.EndUpdate();\r
                }\r
-                               \r
-               void SelectAllInstsStripMenuItemClick(object sender, EventArgs e)\r
+               \r
+               void SelectAllCheckBoxCheckedChanged(object sender, EventArgs e)\r
                {\r
+                       instsListView.BeginUpdate();\r
+                       if (selectAllCheckBox.CheckState == CheckState.Checked) {\r
+                               foreach (ListViewItem item in instsListView.Items) {\r
+                                       item.Checked = true;\r
+                               }\r
+                       }\r
+                       if (selectAllCheckBox.CheckState == CheckState.Unchecked) {\r
+                               foreach (ListViewItem item in instsListView.Items) {\r
+                                       item.Checked = false;\r
+                               }\r
+                       }\r
+                       instsListView.EndUpdate();\r
+               }\r
+               \r
+               void updateSilentInstallAsPossibleCheckBox()\r
+               {\r
+                       bool isAllSilentAsPossible = true;\r
+                       bool isAllNotSilentAsPossible = true;\r
+                       bool canChangeSilent = false;\r
+                       \r
                        foreach (ListViewItem item in instsListView.Items) {\r
-                               item.Checked = true;\r
+                               Installation inst = item.Tag as Installation;\r
+                               if (inst != null) {\r
+                                       if (inst.Silent) {\r
+                                               isAllNotSilentAsPossible = false;\r
+                                               if (! inst.SupportsSilentOnly) {\r
+                                                       canChangeSilent = true;\r
+                                               }\r
+                                       } else {\r
+                                               isAllSilentAsPossible = false;\r
+                                               if (inst.IsSupportsSilent) {\r
+                                                       canChangeSilent = true;\r
+                                               }\r
+                                       }\r
+                               }\r
                        }\r
-                       instsListView.Refresh();\r
+                       \r
+                       silentInstallAsPossibleCheckBox.Enabled = canChangeSilent;\r
+                       silentInstallAsPossibleCheckBox.CheckState =\r
+                               (isAllSilentAsPossible)? CheckState.Checked :\r
+                               (isAllNotSilentAsPossible)? CheckState.Unchecked :\r
+                               CheckState.Indeterminate;\r
                }\r
                \r
-               void UnselectAllInstsStripMenuItemClick(object sender, EventArgs e)\r
+               void SilentInstallAsPossibleCheckBoxCheckedChanged(object sender, EventArgs e)\r
                {\r
-                       foreach (ListViewItem item in instsListView.CheckedItems) {\r
-                               item.Checked = false;\r
+                       instsListView.BeginUpdate();\r
+                       if (silentInstallAsPossibleCheckBox.CheckState == CheckState.Checked) {\r
+                               foreach (ListViewItem item in instsListView.Items) {\r
+                                       Installation inst = item.Tag as Installation;\r
+                                       if (inst != null) {\r
+                                               if (inst.IsSupportsSilent && inst.Silent == false) {\r
+                                                       inst.Silent = true;\r
+                                                       instViewUpdateSilentInstallView(item);\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+                       if (silentInstallAsPossibleCheckBox.CheckState == CheckState.Unchecked) {\r
+                               foreach (ListViewItem item in instsListView.Items) {\r
+                                       Installation inst = item.Tag as Installation;\r
+                                       if (inst != null) {\r
+                                               if ((!inst.SupportsSilentOnly) && inst.Silent == true) {\r
+                                                       inst.Silent = false;\r
+                                                       instViewUpdateSilentInstallView(item);\r
+                                               }\r
+                                       }\r
+                               }\r
                        }\r
-                       instsListView.Refresh();\r
+                       instsListView.EndUpdate();\r
                }\r
 \r
                void InstallationConfirmFormShown(object sender, EventArgs e)\r
@@ -289,6 +358,8 @@ namespace AppliStation
                        if (requiredInstallations == null) {\r
                                Installation[] resolved, dependencies;\r
                                \r
+                               instsListView.BeginUpdate();\r
+                               \r
                                DependeciesResolver.ResolveInstallations(\r
                                        selectedInstallations,\r
                                        pkgListMan,\r
@@ -300,7 +371,8 @@ namespace AppliStation
                                addInstsListItemPerGroup(requiredInstallations, instsListView.Groups["requires"], true);\r
                                \r
                                InstsListViewItemChecked(instsListView, null);\r
-                               instsListView.Refresh();\r
+                               updateSilentInstallAsPossibleCheckBox();\r
+                               instsListView.EndUpdate();\r
                        }\r
                }\r
                \r
@@ -330,7 +402,7 @@ namespace AppliStation
                                } else {\r
                                        item.ForeColor = Color.Empty;\r
                                }\r
-                       \r
+                               \r
                        }\r
                        return retVal;\r
                }\r
@@ -371,10 +443,10 @@ namespace AppliStation
                {\r
                        if (NaGet.Utils.IsAdministrators()) {\r
                                // 管理者権限で動いている場合は不要\r
-                               return false;   \r
+                               return false;\r
                        } else if (NaGet.Utils.IsUACEnabled()) {\r
                                // UACが適用されている場合は標準では不要とする\r
-                               return false;   \r
+                               return false;\r
                        }\r
                        \r
                        // ひとつでもPCターゲットなインストーラーがあれば必要とする\r