From: ttp Date: Sun, 13 Dec 2009 05:56:18 +0000 (+0900) Subject: AppliStation-GUI,インストール確認ダイアログで「すべて選択/非選択」と「サイレントインストールする/しない」を追加。 X-Git-Tag: v1.3.2b1~12 X-Git-Url: http://git.sourceforge.jp/view?p=applistation%2FAppliStation.git;a=commitdiff_plain;h=5b73d3e12675548c8444dc4056b3545dac79d83c AppliStation-GUI,インストール確認ダイアログで「すべて選択/非選択」と「サイレントインストールする/しない」を追加。 あわせてりすとびゅーのコンテクストメニューから「すべて選択/非選択」を削除 --- diff --git a/AppliStation/InstallationConfirmForm.Designer.cs b/AppliStation/InstallationConfirmForm.Designer.cs index 5ac57e1..c0988c1 100644 --- a/AppliStation/InstallationConfirmForm.Designer.cs +++ b/AppliStation/InstallationConfirmForm.Designer.cs @@ -30,10 +30,10 @@ namespace AppliStation private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InstallationConfirmForm)); System.Windows.Forms.ListViewGroup listViewGroup1 = new System.Windows.Forms.ListViewGroup("インストールするソフト", System.Windows.Forms.HorizontalAlignment.Left); System.Windows.Forms.ListViewGroup listViewGroup2 = new System.Windows.Forms.ListViewGroup("アップデートするソフト", System.Windows.Forms.HorizontalAlignment.Left); System.Windows.Forms.ListViewGroup listViewGroup3 = new System.Windows.Forms.ListViewGroup("動作させるのに必要なソフト", System.Windows.Forms.HorizontalAlignment.Left); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InstallationConfirmForm)); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.btnPanel = new System.Windows.Forms.FlowLayoutPanel(); this.runasCheckBox = new System.Windows.Forms.CheckBox(); @@ -48,30 +48,33 @@ namespace AppliStation this.pkgListNameColumnHeader = new System.Windows.Forms.ColumnHeader(); this.instListViewContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); this.silentInstallStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.instListToolStripSeparator = new System.Windows.Forms.ToolStripSeparator(); - this.selectAllInstsStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.unselectAllInstsStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.selectAllCheckBox = new System.Windows.Forms.CheckBox(); + this.silentInstallAsPossibleCheckBox = new System.Windows.Forms.CheckBox(); this.instListViewSilentInstallImageList = new System.Windows.Forms.ImageList(this.components); this.tableLayoutPanel1.SuspendLayout(); this.btnPanel.SuspendLayout(); this.instListViewContextMenuStrip.SuspendLayout(); + this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // tableLayoutPanel1 // this.tableLayoutPanel1.ColumnCount = 1; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel1.Controls.Add(this.btnPanel, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.btnPanel, 0, 3); this.tableLayoutPanel1.Controls.Add(this.label, 0, 0); this.tableLayoutPanel1.Controls.Add(this.instsListView, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 2); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 3; + this.tableLayoutPanel1.RowCount = 4; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel1.Size = new System.Drawing.Size(392, 266); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.Size = new System.Drawing.Size(392, 279); this.tableLayoutPanel1.TabIndex = 0; // // btnPanel @@ -81,7 +84,7 @@ namespace AppliStation this.btnPanel.Controls.Add(this.okButton); this.btnPanel.Controls.Add(this.cancelButton); this.btnPanel.Dock = System.Windows.Forms.DockStyle.Right; - this.btnPanel.Location = new System.Drawing.Point(84, 234); + this.btnPanel.Location = new System.Drawing.Point(84, 247); this.btnPanel.Name = "btnPanel"; this.btnPanel.Size = new System.Drawing.Size(305, 29); this.btnPanel.TabIndex = 0; @@ -95,7 +98,7 @@ namespace AppliStation this.runasCheckBox.Location = new System.Drawing.Point(3, 6); this.runasCheckBox.Name = "runasCheckBox"; this.runasCheckBox.Size = new System.Drawing.Size(126, 16); - this.runasCheckBox.TabIndex = 2; + this.runasCheckBox.TabIndex = 0; this.runasCheckBox.Text = "管理者として実行(&A)"; this.runasCheckBox.UseVisualStyleBackColor = true; this.runasCheckBox.CheckedChanged += new System.EventHandler(this.RunasCheckBoxCheckedChanged); @@ -107,7 +110,7 @@ namespace AppliStation this.okButton.Location = new System.Drawing.Point(135, 3); this.okButton.Name = "okButton"; this.okButton.Size = new System.Drawing.Size(86, 23); - this.okButton.TabIndex = 0; + this.okButton.TabIndex = 1; this.okButton.Text = "インストール"; // // cancelButton @@ -117,7 +120,7 @@ namespace AppliStation this.cancelButton.Location = new System.Drawing.Point(227, 3); this.cancelButton.Name = "cancelButton"; this.cancelButton.Size = new System.Drawing.Size(75, 23); - this.cancelButton.TabIndex = 1; + this.cancelButton.TabIndex = 2; this.cancelButton.Text = "キャンセル"; // // label @@ -127,7 +130,7 @@ namespace AppliStation this.label.Margin = new System.Windows.Forms.Padding(10); this.label.Name = "label"; this.label.Size = new System.Drawing.Size(372, 30); - this.label.TabIndex = 1; + this.label.TabIndex = 0; this.label.Text = "以下のソフトをインストールしようとしています。インストールするソフトをチェックしてください"; // // instsListView @@ -158,8 +161,8 @@ namespace AppliStation this.instsListView.Name = "instsListView"; this.instsListView.OwnerDraw = true; this.instsListView.ShowItemToolTips = true; - this.instsListView.Size = new System.Drawing.Size(382, 173); - this.instsListView.TabIndex = 2; + this.instsListView.Size = new System.Drawing.Size(382, 158); + this.instsListView.TabIndex = 1; this.instsListView.UseCompatibleStateImageBehavior = false; this.instsListView.View = System.Windows.Forms.View.Details; this.instsListView.DrawColumnHeader += new System.Windows.Forms.DrawListViewColumnHeaderEventHandler(this.InstsListViewDrawColumnHeader); @@ -193,12 +196,9 @@ namespace AppliStation // instListViewContextMenuStrip // this.instListViewContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.silentInstallStripMenuItem, - this.instListToolStripSeparator, - this.selectAllInstsStripMenuItem, - this.unselectAllInstsStripMenuItem}); + this.silentInstallStripMenuItem}); this.instListViewContextMenuStrip.Name = "packageListViewContextMenuStrip"; - this.instListViewContextMenuStrip.Size = new System.Drawing.Size(263, 76); + this.instListViewContextMenuStrip.Size = new System.Drawing.Size(263, 26); this.instListViewContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.InstsListViewContextMenuStripOpening); // // silentInstallStripMenuItem @@ -208,24 +208,37 @@ namespace AppliStation this.silentInstallStripMenuItem.Text = "サイレントインストールをする(&S)"; this.silentInstallStripMenuItem.Click += new System.EventHandler(this.SilentInstallStripMenuItemClick); // - // instListToolStripSeparator - // - this.instListToolStripSeparator.Name = "instListToolStripSeparator"; - this.instListToolStripSeparator.Size = new System.Drawing.Size(259, 6); - // - // selectAllInstsStripMenuItem - // - this.selectAllInstsStripMenuItem.Name = "selectAllInstsStripMenuItem"; - this.selectAllInstsStripMenuItem.Size = new System.Drawing.Size(262, 22); - this.selectAllInstsStripMenuItem.Text = "全て選択(&A)"; - this.selectAllInstsStripMenuItem.Click += new System.EventHandler(this.SelectAllInstsStripMenuItemClick); - // - // unselectAllInstsStripMenuItem - // - this.unselectAllInstsStripMenuItem.Name = "unselectAllInstsStripMenuItem"; - this.unselectAllInstsStripMenuItem.Size = new System.Drawing.Size(262, 22); - this.unselectAllInstsStripMenuItem.Text = "全ての選択を解除(&U)"; - this.unselectAllInstsStripMenuItem.Click += new System.EventHandler(this.UnselectAllInstsStripMenuItemClick); + // flowLayoutPanel1 + // + this.flowLayoutPanel1.AutoSize = true; + this.flowLayoutPanel1.Controls.Add(this.selectAllCheckBox); + this.flowLayoutPanel1.Controls.Add(this.silentInstallAsPossibleCheckBox); + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 219); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(386, 22); + this.flowLayoutPanel1.TabIndex = 3; + // + // selectAllCheckBox + // + this.selectAllCheckBox.AutoSize = true; + this.selectAllCheckBox.Location = new System.Drawing.Point(3, 3); + this.selectAllCheckBox.Name = "selectAllCheckBox"; + this.selectAllCheckBox.Size = new System.Drawing.Size(133, 16); + this.selectAllCheckBox.TabIndex = 0; + this.selectAllCheckBox.Text = "すべて選択/非選択(&L)"; + this.selectAllCheckBox.CheckedChanged += new System.EventHandler(this.SelectAllCheckBoxCheckedChanged); + // + // silentInstallAsPossibleCheckBox + // + this.silentInstallAsPossibleCheckBox.AutoSize = true; + this.silentInstallAsPossibleCheckBox.Location = new System.Drawing.Point(142, 3); + this.silentInstallAsPossibleCheckBox.Name = "silentInstallAsPossibleCheckBox"; + this.silentInstallAsPossibleCheckBox.Size = new System.Drawing.Size(193, 16); + this.silentInstallAsPossibleCheckBox.TabIndex = 1; + this.silentInstallAsPossibleCheckBox.Text = "サイレントインストールする/しない(&S)"; + this.silentInstallAsPossibleCheckBox.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.silentInstallAsPossibleCheckBox.CheckedChanged += new System.EventHandler(this.SilentInstallAsPossibleCheckBoxCheckedChanged); // // instListViewSilentInstallImageList // @@ -239,7 +252,7 @@ namespace AppliStation this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(392, 266); + this.ClientSize = new System.Drawing.Size(392, 279); this.Controls.Add(this.tableLayoutPanel1); this.MaximizeBox = false; this.Name = "InstallationConfirmForm"; @@ -253,15 +266,17 @@ namespace AppliStation this.btnPanel.ResumeLayout(false); this.btnPanel.PerformLayout(); this.instListViewContextMenuStrip.ResumeLayout(false); + this.flowLayoutPanel1.ResumeLayout(false); + this.flowLayoutPanel1.PerformLayout(); this.ResumeLayout(false); } + private System.Windows.Forms.CheckBox silentInstallAsPossibleCheckBox; + private System.Windows.Forms.CheckBox selectAllCheckBox; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.ColumnHeader pkgListNameColumnHeader; private System.Windows.Forms.ImageList instListViewSilentInstallImageList; private System.Windows.Forms.ColumnHeader silentInstColumnHeader; - private System.Windows.Forms.ToolStripSeparator instListToolStripSeparator; private System.Windows.Forms.ToolStripMenuItem silentInstallStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem unselectAllInstsStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem selectAllInstsStripMenuItem; private System.Windows.Forms.ContextMenuStrip instListViewContextMenuStrip; private System.Windows.Forms.CheckBox runasCheckBox; private System.Windows.Forms.ColumnHeader currentVersionColumnHeader; diff --git a/AppliStation/InstallationConfirmForm.cs b/AppliStation/InstallationConfirmForm.cs index 017f58e..0d43aab 100644 --- a/AppliStation/InstallationConfirmForm.cs +++ b/AppliStation/InstallationConfirmForm.cs @@ -82,6 +82,8 @@ namespace AppliStation /// private void updateInstsListView() { + instsListView.BeginUpdate(); + if (instsListView.Items.Count > 0) { instsListView.Items.Clear(); } @@ -91,7 +93,9 @@ namespace AppliStation addInstsListItemPerGroup(updateInstallations, instsListView.Groups["update"], false); InstsListViewItemChecked(instsListView, null); - instsListView.Refresh(); + updateSilentInstallAsPossibleCheckBox(); + + instsListView.EndUpdate(); } /// @@ -115,7 +119,7 @@ namespace AppliStation inst.Silent = true; // silent install as possible! Package curPkg = null; - if (pkgListMan != null) { + if (pkgListMan != null) { curPkg = pkgListMan.InstalledPkgList.GetPackageForName(pkg.Name) ?? pkgListMan.SystemInstalledPkgList.GetPackageForName(pkg.Name); } @@ -206,16 +210,25 @@ namespace AppliStation void InstsListViewItemChecked(object sender, ItemCheckedEventArgs e) { + System.Windows.Forms.ListView.ListViewItemCollection items = instsListView.Items; System.Windows.Forms.ListView.CheckedListViewItemCollection checkeds = instsListView.CheckedItems; + // すべて選択/非選択 + selectAllCheckBox.CheckState = + (checkeds == null || checkeds.Count == 0)? CheckState.Unchecked : + (checkeds.Count == items.Count)? CheckState.Checked : + CheckState.Indeterminate; + + // runas情報 runasCheckBox.Checked = GetShouldUseRunas(); updateUseRunas(); - + + // インストール可能か okButton.Enabled = (checkeds != null) && (checkeds.Count > 0); checkUnselectedDependencies(); } - + void InstsListViewContextMenuStripOpening(object sender, System.ComponentModel.CancelEventArgs e) { System.Windows.Forms.ListView.CheckedIndexCollection chkIdxes = instsListView.CheckedIndices; @@ -240,36 +253,92 @@ namespace AppliStation } } } - instListToolStripSeparator.Visible = selIdxes.Count > 0; - - - selectAllInstsStripMenuItem.Enabled = chkIdxes.Count < instsListView.Items.Count; - unselectAllInstsStripMenuItem.Enabled = chkIdxes.Count > 0; } void SilentInstallStripMenuItemClick(object sender, EventArgs e) { + instsListView.BeginUpdate(); bool silent = ! silentInstallStripMenuItem.Checked; foreach (ListViewItem item in instsListView.SelectedItems) { ((Installation) item.Tag).Silent = silent; instViewUpdateSilentInstallView(item); } + updateSilentInstallAsPossibleCheckBox(); + instsListView.EndUpdate(); } - - void SelectAllInstsStripMenuItemClick(object sender, EventArgs e) + + void SelectAllCheckBoxCheckedChanged(object sender, EventArgs e) { + instsListView.BeginUpdate(); + if (selectAllCheckBox.CheckState == CheckState.Checked) { + foreach (ListViewItem item in instsListView.Items) { + item.Checked = true; + } + } + if (selectAllCheckBox.CheckState == CheckState.Unchecked) { + foreach (ListViewItem item in instsListView.Items) { + item.Checked = false; + } + } + instsListView.EndUpdate(); + } + + void updateSilentInstallAsPossibleCheckBox() + { + bool isAllSilentAsPossible = true; + bool isAllNotSilentAsPossible = true; + bool canChangeSilent = false; + foreach (ListViewItem item in instsListView.Items) { - item.Checked = true; + Installation inst = item.Tag as Installation; + if (inst != null) { + if (inst.Silent) { + isAllNotSilentAsPossible = false; + if (! inst.SupportsSilentOnly) { + canChangeSilent = true; + } + } else { + isAllSilentAsPossible = false; + if (inst.IsSupportsSilent) { + canChangeSilent = true; + } + } + } } - instsListView.Refresh(); + + silentInstallAsPossibleCheckBox.Enabled = canChangeSilent; + silentInstallAsPossibleCheckBox.CheckState = + (isAllSilentAsPossible)? CheckState.Checked : + (isAllNotSilentAsPossible)? CheckState.Unchecked : + CheckState.Indeterminate; } - void UnselectAllInstsStripMenuItemClick(object sender, EventArgs e) + void SilentInstallAsPossibleCheckBoxCheckedChanged(object sender, EventArgs e) { - foreach (ListViewItem item in instsListView.CheckedItems) { - item.Checked = false; + instsListView.BeginUpdate(); + if (silentInstallAsPossibleCheckBox.CheckState == CheckState.Checked) { + foreach (ListViewItem item in instsListView.Items) { + Installation inst = item.Tag as Installation; + if (inst != null) { + if (inst.IsSupportsSilent && inst.Silent == false) { + inst.Silent = true; + instViewUpdateSilentInstallView(item); + } + } + } + } + if (silentInstallAsPossibleCheckBox.CheckState == CheckState.Unchecked) { + foreach (ListViewItem item in instsListView.Items) { + Installation inst = item.Tag as Installation; + if (inst != null) { + if ((!inst.SupportsSilentOnly) && inst.Silent == true) { + inst.Silent = false; + instViewUpdateSilentInstallView(item); + } + } + } } - instsListView.Refresh(); + instsListView.EndUpdate(); } void InstallationConfirmFormShown(object sender, EventArgs e) @@ -289,6 +358,8 @@ namespace AppliStation if (requiredInstallations == null) { Installation[] resolved, dependencies; + instsListView.BeginUpdate(); + DependeciesResolver.ResolveInstallations( selectedInstallations, pkgListMan, @@ -300,7 +371,8 @@ namespace AppliStation addInstsListItemPerGroup(requiredInstallations, instsListView.Groups["requires"], true); InstsListViewItemChecked(instsListView, null); - instsListView.Refresh(); + updateSilentInstallAsPossibleCheckBox(); + instsListView.EndUpdate(); } } @@ -330,7 +402,7 @@ namespace AppliStation } else { item.ForeColor = Color.Empty; } - + } return retVal; } @@ -371,10 +443,10 @@ namespace AppliStation { if (NaGet.Utils.IsAdministrators()) { // 管理者権限で動いている場合は不要 - return false; + return false; } else if (NaGet.Utils.IsUACEnabled()) { // UACが適用されている場合は標準では不要とする - return false; + return false; } // ひとつでもPCターゲットなインストーラーがあれば必要とする