OSDN Git Service

AppliStation-GUI,インストール確認ダイアログで「すべて選択/非選択」と「サイレントインストールする/しない」を追加。
authorttp <ttp@users.sourceforge.jp>
Sun, 13 Dec 2009 05:56:18 +0000 (14:56 +0900)
committerttp <ttp@users.sourceforge.jp>
Sun, 13 Dec 2009 05:56:18 +0000 (14:56 +0900)
あわせてりすとびゅーのコンテクストメニューから「すべて選択/非選択」を削除

AppliStation/InstallationConfirmForm.Designer.cs
AppliStation/InstallationConfirmForm.cs

index 5ac57e1..c0988c1 100644 (file)
@@ -30,10 +30,10 @@ namespace AppliStation
                private void InitializeComponent()\r
                {\r
                        this.components = new System.ComponentModel.Container();\r
-                       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InstallationConfirmForm));\r
                        System.Windows.Forms.ListViewGroup listViewGroup1 = new System.Windows.Forms.ListViewGroup("インストールするソフト", System.Windows.Forms.HorizontalAlignment.Left);\r
                        System.Windows.Forms.ListViewGroup listViewGroup2 = new System.Windows.Forms.ListViewGroup("アップデートするソフト", System.Windows.Forms.HorizontalAlignment.Left);\r
                        System.Windows.Forms.ListViewGroup listViewGroup3 = new System.Windows.Forms.ListViewGroup("動作させるのに必要なソフト", System.Windows.Forms.HorizontalAlignment.Left);\r
+                       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InstallationConfirmForm));\r
                        this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();\r
                        this.btnPanel = new System.Windows.Forms.FlowLayoutPanel();\r
                        this.runasCheckBox = new System.Windows.Forms.CheckBox();\r
@@ -48,30 +48,33 @@ namespace AppliStation
                        this.pkgListNameColumnHeader = new System.Windows.Forms.ColumnHeader();\r
                        this.instListViewContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);\r
                        this.silentInstallStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
-                       this.instListToolStripSeparator = new System.Windows.Forms.ToolStripSeparator();\r
-                       this.selectAllInstsStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
-                       this.unselectAllInstsStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
+                       this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();\r
+                       this.selectAllCheckBox = new System.Windows.Forms.CheckBox();\r
+                       this.silentInstallAsPossibleCheckBox = new System.Windows.Forms.CheckBox();\r
                        this.instListViewSilentInstallImageList = new System.Windows.Forms.ImageList(this.components);\r
                        this.tableLayoutPanel1.SuspendLayout();\r
                        this.btnPanel.SuspendLayout();\r
                        this.instListViewContextMenuStrip.SuspendLayout();\r
+                       this.flowLayoutPanel1.SuspendLayout();\r
                        this.SuspendLayout();\r
                        // \r
                        // tableLayoutPanel1\r
                        // \r
                        this.tableLayoutPanel1.ColumnCount = 1;\r
                        this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
-                       this.tableLayoutPanel1.Controls.Add(this.btnPanel, 0, 2);\r
+                       this.tableLayoutPanel1.Controls.Add(this.btnPanel, 0, 3);\r
                        this.tableLayoutPanel1.Controls.Add(this.label, 0, 0);\r
                        this.tableLayoutPanel1.Controls.Add(this.instsListView, 0, 1);\r
+                       this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 2);\r
                        this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;\r
                        this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);\r
                        this.tableLayoutPanel1.Name = "tableLayoutPanel1";\r
-                       this.tableLayoutPanel1.RowCount = 3;\r
+                       this.tableLayoutPanel1.RowCount = 4;\r
                        this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F));\r
                        this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));\r
                        this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
-                       this.tableLayoutPanel1.Size = new System.Drawing.Size(392, 266);\r
+                       this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+                       this.tableLayoutPanel1.Size = new System.Drawing.Size(392, 279);\r
                        this.tableLayoutPanel1.TabIndex = 0;\r
                        // \r
                        // btnPanel\r
@@ -81,7 +84,7 @@ namespace AppliStation
                        this.btnPanel.Controls.Add(this.okButton);\r
                        this.btnPanel.Controls.Add(this.cancelButton);\r
                        this.btnPanel.Dock = System.Windows.Forms.DockStyle.Right;\r
-                       this.btnPanel.Location = new System.Drawing.Point(84, 234);\r
+                       this.btnPanel.Location = new System.Drawing.Point(84, 247);\r
                        this.btnPanel.Name = "btnPanel";\r
                        this.btnPanel.Size = new System.Drawing.Size(305, 29);\r
                        this.btnPanel.TabIndex = 0;\r
@@ -95,7 +98,7 @@ namespace AppliStation
                        this.runasCheckBox.Location = new System.Drawing.Point(3, 6);\r
                        this.runasCheckBox.Name = "runasCheckBox";\r
                        this.runasCheckBox.Size = new System.Drawing.Size(126, 16);\r
-                       this.runasCheckBox.TabIndex = 2;\r
+                       this.runasCheckBox.TabIndex = 0;\r
                        this.runasCheckBox.Text = "管理者として実行(&A)";\r
                        this.runasCheckBox.UseVisualStyleBackColor = true;\r
                        this.runasCheckBox.CheckedChanged += new System.EventHandler(this.RunasCheckBoxCheckedChanged);\r
@@ -107,7 +110,7 @@ namespace AppliStation
                        this.okButton.Location = new System.Drawing.Point(135, 3);\r
                        this.okButton.Name = "okButton";\r
                        this.okButton.Size = new System.Drawing.Size(86, 23);\r
-                       this.okButton.TabIndex = 0;\r
+                       this.okButton.TabIndex = 1;\r
                        this.okButton.Text = "インストール";\r
                        // \r
                        // cancelButton\r
@@ -117,7 +120,7 @@ namespace AppliStation
                        this.cancelButton.Location = new System.Drawing.Point(227, 3);\r
                        this.cancelButton.Name = "cancelButton";\r
                        this.cancelButton.Size = new System.Drawing.Size(75, 23);\r
-                       this.cancelButton.TabIndex = 1;\r
+                       this.cancelButton.TabIndex = 2;\r
                        this.cancelButton.Text = "キャンセル";\r
                        // \r
                        // label\r
@@ -127,7 +130,7 @@ namespace AppliStation
                        this.label.Margin = new System.Windows.Forms.Padding(10);\r
                        this.label.Name = "label";\r
                        this.label.Size = new System.Drawing.Size(372, 30);\r
-                       this.label.TabIndex = 1;\r
+                       this.label.TabIndex = 0;\r
                        this.label.Text = "以下のソフトをインストールしようとしています。インストールするソフトをチェックしてください";\r
                        // \r
                        // instsListView\r
@@ -158,8 +161,8 @@ namespace AppliStation
                        this.instsListView.Name = "instsListView";\r
                        this.instsListView.OwnerDraw = true;\r
                        this.instsListView.ShowItemToolTips = true;\r
-                       this.instsListView.Size = new System.Drawing.Size(382, 173);\r
-                       this.instsListView.TabIndex = 2;\r
+                       this.instsListView.Size = new System.Drawing.Size(382, 158);\r
+                       this.instsListView.TabIndex = 1;\r
                        this.instsListView.UseCompatibleStateImageBehavior = false;\r
                        this.instsListView.View = System.Windows.Forms.View.Details;\r
                        this.instsListView.DrawColumnHeader += new System.Windows.Forms.DrawListViewColumnHeaderEventHandler(this.InstsListViewDrawColumnHeader);\r
@@ -193,12 +196,9 @@ namespace AppliStation
                        // instListViewContextMenuStrip\r
                        // \r
                        this.instListViewContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
-                                                                       this.silentInstallStripMenuItem,\r
-                                                                       this.instListToolStripSeparator,\r
-                                                                       this.selectAllInstsStripMenuItem,\r
-                                                                       this.unselectAllInstsStripMenuItem});\r
+                                                                       this.silentInstallStripMenuItem});\r
                        this.instListViewContextMenuStrip.Name = "packageListViewContextMenuStrip";\r
-                       this.instListViewContextMenuStrip.Size = new System.Drawing.Size(263, 76);\r
+                       this.instListViewContextMenuStrip.Size = new System.Drawing.Size(263, 26);\r
                        this.instListViewContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.InstsListViewContextMenuStripOpening);\r
                        // \r
                        // silentInstallStripMenuItem\r
@@ -208,24 +208,37 @@ namespace AppliStation
                        this.silentInstallStripMenuItem.Text = "サイレントインストールをする(&S)";\r
                        this.silentInstallStripMenuItem.Click += new System.EventHandler(this.SilentInstallStripMenuItemClick);\r
                        // \r
-                       // instListToolStripSeparator\r
-                       // \r
-                       this.instListToolStripSeparator.Name = "instListToolStripSeparator";\r
-                       this.instListToolStripSeparator.Size = new System.Drawing.Size(259, 6);\r
-                       // \r
-                       // selectAllInstsStripMenuItem\r
-                       // \r
-                       this.selectAllInstsStripMenuItem.Name = "selectAllInstsStripMenuItem";\r
-                       this.selectAllInstsStripMenuItem.Size = new System.Drawing.Size(262, 22);\r
-                       this.selectAllInstsStripMenuItem.Text = "全て選択(&A)";\r
-                       this.selectAllInstsStripMenuItem.Click += new System.EventHandler(this.SelectAllInstsStripMenuItemClick);\r
-                       // \r
-                       // unselectAllInstsStripMenuItem\r
-                       // \r
-                       this.unselectAllInstsStripMenuItem.Name = "unselectAllInstsStripMenuItem";\r
-                       this.unselectAllInstsStripMenuItem.Size = new System.Drawing.Size(262, 22);\r
-                       this.unselectAllInstsStripMenuItem.Text = "全ての選択を解除(&U)";\r
-                       this.unselectAllInstsStripMenuItem.Click += new System.EventHandler(this.UnselectAllInstsStripMenuItemClick);\r
+                       // flowLayoutPanel1\r
+                       // \r
+                       this.flowLayoutPanel1.AutoSize = true;\r
+                       this.flowLayoutPanel1.Controls.Add(this.selectAllCheckBox);\r
+                       this.flowLayoutPanel1.Controls.Add(this.silentInstallAsPossibleCheckBox);\r
+                       this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;\r
+                       this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 219);\r
+                       this.flowLayoutPanel1.Name = "flowLayoutPanel1";\r
+                       this.flowLayoutPanel1.Size = new System.Drawing.Size(386, 22);\r
+                       this.flowLayoutPanel1.TabIndex = 3;\r
+                       // \r
+                       // selectAllCheckBox\r
+                       // \r
+                       this.selectAllCheckBox.AutoSize = true;\r
+                       this.selectAllCheckBox.Location = new System.Drawing.Point(3, 3);\r
+                       this.selectAllCheckBox.Name = "selectAllCheckBox";\r
+                       this.selectAllCheckBox.Size = new System.Drawing.Size(133, 16);\r
+                       this.selectAllCheckBox.TabIndex = 0;\r
+                       this.selectAllCheckBox.Text = "すべて選択/非選択(&L)";\r
+                       this.selectAllCheckBox.CheckedChanged += new System.EventHandler(this.SelectAllCheckBoxCheckedChanged);\r
+                       // \r
+                       // silentInstallAsPossibleCheckBox\r
+                       // \r
+                       this.silentInstallAsPossibleCheckBox.AutoSize = true;\r
+                       this.silentInstallAsPossibleCheckBox.Location = new System.Drawing.Point(142, 3);\r
+                       this.silentInstallAsPossibleCheckBox.Name = "silentInstallAsPossibleCheckBox";\r
+                       this.silentInstallAsPossibleCheckBox.Size = new System.Drawing.Size(193, 16);\r
+                       this.silentInstallAsPossibleCheckBox.TabIndex = 1;\r
+                       this.silentInstallAsPossibleCheckBox.Text = "サイレントインストールする/しない(&S)";\r
+                       this.silentInstallAsPossibleCheckBox.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;\r
+                       this.silentInstallAsPossibleCheckBox.CheckedChanged += new System.EventHandler(this.SilentInstallAsPossibleCheckBoxCheckedChanged);\r
                        // \r
                        // instListViewSilentInstallImageList\r
                        // \r
@@ -239,7 +252,7 @@ namespace AppliStation
                        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);\r
                        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
                        this.CancelButton = this.cancelButton;\r
-                       this.ClientSize = new System.Drawing.Size(392, 266);\r
+                       this.ClientSize = new System.Drawing.Size(392, 279);\r
                        this.Controls.Add(this.tableLayoutPanel1);\r
                        this.MaximizeBox = false;\r
                        this.Name = "InstallationConfirmForm";\r
@@ -253,15 +266,17 @@ namespace AppliStation
                        this.btnPanel.ResumeLayout(false);\r
                        this.btnPanel.PerformLayout();\r
                        this.instListViewContextMenuStrip.ResumeLayout(false);\r
+                       this.flowLayoutPanel1.ResumeLayout(false);\r
+                       this.flowLayoutPanel1.PerformLayout();\r
                        this.ResumeLayout(false);\r
                }\r
+               private System.Windows.Forms.CheckBox silentInstallAsPossibleCheckBox;\r
+               private System.Windows.Forms.CheckBox selectAllCheckBox;\r
+               private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;\r
                private System.Windows.Forms.ColumnHeader pkgListNameColumnHeader;\r
                private System.Windows.Forms.ImageList instListViewSilentInstallImageList;\r
                private System.Windows.Forms.ColumnHeader silentInstColumnHeader;\r
-               private System.Windows.Forms.ToolStripSeparator instListToolStripSeparator;\r
                private System.Windows.Forms.ToolStripMenuItem silentInstallStripMenuItem;\r
-               private System.Windows.Forms.ToolStripMenuItem unselectAllInstsStripMenuItem;\r
-               private System.Windows.Forms.ToolStripMenuItem selectAllInstsStripMenuItem;\r
                private System.Windows.Forms.ContextMenuStrip instListViewContextMenuStrip;\r
                private System.Windows.Forms.CheckBox runasCheckBox;\r
                private System.Windows.Forms.ColumnHeader currentVersionColumnHeader;\r
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