From dfafc271b32ea274ad8caf753563ada5091f74eb Mon Sep 17 00:00:00 2001 From: Martin J Date: Sat, 15 Aug 2015 14:07:33 +0200 Subject: [PATCH 1/6] Bulk selection features added. Adds menu items for "selecting all installed" and "deselect all selected". Also adds a checkbox to the recommended/suggested mods page for toggling all mods in the list. Implements #1148. --- GUI/Main.Designer.cs | 47 ++++++++++++++++++++++++++++++++++++++++++++ GUI/Main.cs | 38 +++++++++++++++++++++++++++++++++++ GUI/MainInstall.cs | 2 ++ 3 files changed, 87 insertions(+) diff --git a/GUI/Main.Designer.cs b/GUI/Main.Designer.cs index 14901dc773..1899d1c32c 100644 --- a/GUI/Main.Designer.cs +++ b/GUI/Main.Designer.cs @@ -43,6 +43,9 @@ private void InitializeComponent() this.cKANSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.pluginsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.kSPCommandlineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.selectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.selectAllInstalledModsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.deselectAllSelectedModsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); @@ -112,6 +115,7 @@ private void InitializeComponent() this.ChooseRecommendedModsTabPage = new System.Windows.Forms.TabPage(); this.RecommendedModsCancelButton = new System.Windows.Forms.Button(); this.RecommendedModsContinueButton = new System.Windows.Forms.Button(); + this.RecommendedModsToggleCheckbox = new System.Windows.Forms.CheckBox(); this.RecommendedDialogLabel = new System.Windows.Forms.Label(); this.RecommendedModsListView = new System.Windows.Forms.ListView(); this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -164,6 +168,7 @@ private void InitializeComponent() this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem, this.settingsToolStripMenuItem, + this.selectionToolStripMenuItem, this.helpToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; @@ -254,6 +259,31 @@ private void InitializeComponent() this.kSPCommandlineToolStripMenuItem.Size = new System.Drawing.Size(176, 22); this.kSPCommandlineToolStripMenuItem.Text = "KSP command-line"; this.kSPCommandlineToolStripMenuItem.Click += new System.EventHandler(this.KSPCommandlineToolStripMenuItem_Click); + // + // selectionToolStripMenuItem + // + this.selectionToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] + { + this.selectAllInstalledModsToolStripMenuItem, + this.deselectAllSelectedModsToolStripMenuItem + }); + this.selectionToolStripMenuItem.Name = "selectionToolStripMenuItem"; + this.selectionToolStripMenuItem.Size = new System.Drawing.Size(61, 22); + this.selectionToolStripMenuItem.Text = "Selection"; + // + // selectAllInstalledModsToolStripMenuItem + // + this.selectAllInstalledModsToolStripMenuItem.Name = "selectAllInstalledModsToolStripMenuItem"; + this.selectAllInstalledModsToolStripMenuItem.Size = new System.Drawing.Size(61, 22); + this.selectAllInstalledModsToolStripMenuItem.Text = "Select all installed mods"; + this.selectAllInstalledModsToolStripMenuItem.Click += new System.EventHandler(this.selectAllInstalledModsToolStripMenuItem_Click); + // + // deselectAllSelectedModsToolStripMenuItem + // + this.deselectAllSelectedModsToolStripMenuItem.Name = "deselectAllSelectedModsToolStripMenuItem"; + this.deselectAllSelectedModsToolStripMenuItem.Size = new System.Drawing.Size(61, 22); + this.deselectAllSelectedModsToolStripMenuItem.Text = "Deselect all selected mods"; + this.deselectAllSelectedModsToolStripMenuItem.Click += new System.EventHandler(this.deselectAllSelectedModsToolStripMenuItem_Click); // // helpToolStripMenuItem // @@ -1007,6 +1037,7 @@ private void InitializeComponent() // this.ChooseRecommendedModsTabPage.Controls.Add(this.RecommendedModsCancelButton); this.ChooseRecommendedModsTabPage.Controls.Add(this.RecommendedModsContinueButton); + this.ChooseRecommendedModsTabPage.Controls.Add(this.RecommendedModsToggleCheckbox); this.ChooseRecommendedModsTabPage.Controls.Add(this.RecommendedDialogLabel); this.ChooseRecommendedModsTabPage.Controls.Add(this.RecommendedModsListView); this.ChooseRecommendedModsTabPage.Location = new System.Drawing.Point(4, 22); @@ -1040,6 +1071,18 @@ private void InitializeComponent() this.RecommendedModsContinueButton.Text = "Continue"; this.RecommendedModsContinueButton.UseVisualStyleBackColor = true; this.RecommendedModsContinueButton.Click += new System.EventHandler(this.RecommendedModsContinueButton_Click); + // + // RecommendedModsToggleCheckbox + // + this.RecommendedModsToggleCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom) | (System.Windows.Forms.AnchorStyles.Left))); + this.RecommendedModsToggleCheckbox.FlatStyle = FlatStyle.Flat; + this.RecommendedModsToggleCheckbox.Location = new System.Drawing.Point(10, 617); + this.RecommendedModsToggleCheckbox.Name = "RecommendedModsToggleCheckbox"; + this.RecommendedModsToggleCheckbox.Size = new System.Drawing.Size(100,23); + this.RecommendedModsToggleCheckbox.Text = "Toggle * Mods"; + this.RecommendedModsToggleCheckbox.Checked = true; + this.RecommendedModsToggleCheckbox.UseVisualStyleBackColor = true; + this.RecommendedModsToggleCheckbox.CheckedChanged += new System.EventHandler(this.RecommendedModsToggleCheckbox_CheckedChanged); // // RecommendedDialogLabel // @@ -1317,6 +1360,9 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem RefreshToolButton; private System.Windows.Forms.ToolStripMenuItem UpdateAllToolButton; private System.Windows.Forms.ToolStripMenuItem ApplyToolButton; + private ToolStripMenuItem selectionToolStripMenuItem; + private ToolStripMenuItem selectAllInstalledModsToolStripMenuItem; + private ToolStripMenuItem deselectAllSelectedModsToolStripMenuItem; private ToolStripMenuItem aboutToolStripMenuItem; private SplitContainer splitContainer1; private Panel StatusPanel; @@ -1379,6 +1425,7 @@ private void InitializeComponent() private ColumnHeader columnHeader5; private Button RecommendedModsCancelButton; private Button RecommendedModsContinueButton; + private CheckBox RecommendedModsToggleCheckbox; private TabPage ChooseProvidedModsTabPage; private Label ChooseProvidedModsLabel; private ListView ChooseProvidedModsListView; diff --git a/GUI/Main.cs b/GUI/Main.cs index cefa885e69..18cec7e7cc 100644 --- a/GUI/Main.cs +++ b/GUI/Main.cs @@ -1042,6 +1042,44 @@ private void FocusMod(string key, bool exactMatch) this.AddStatusMessage("Not found"); } } + + private void selectAllInstalledModsToolStripMenuItem_Click(object sender, EventArgs e) + { + foreach (InstalledModule installedMod in CurrentInstance.Registry.InstalledModules) + { + MarkModForInstall(installedMod.identifier, false); + } + ModList.Refresh(); + } + + private void deselectAllSelectedModsToolStripMenuItem_Click(object sender, EventArgs e) + { + foreach (DataGridViewRow row in ModList.Rows) + { + var mod = ((GUIMod)row.Tag); + if (row.Cells[0] is DataGridViewCheckBoxCell && (bool)row.Cells[0].Value) + { + MarkModForInstall(mod.Identifier, (bool)row.Cells[0].Value); + //ApplyToolButton.Enabled = true; + } + } + ApplyToolButton.Enabled = (ChangeSet.Any()); + ModList.Refresh(); + } + + private void RecommendedModsToggleCheckbox_CheckedChanged(object sender, EventArgs e) + { + var state = ((CheckBox)sender).Checked; + foreach (ListViewItem item in RecommendedModsListView.Items) + { + if (item.Checked != state) + { + item.Checked = state; + } + } + RecommendedModsListView.Refresh(); + } + } public class GUIUser : NullUser diff --git a/GUI/MainInstall.cs b/GUI/MainInstall.cs index 7c6c8902af..851b5143c9 100644 --- a/GUI/MainInstall.cs +++ b/GUI/MainInstall.cs @@ -482,12 +482,14 @@ private void UpdateRecommendedDialog(Dictionary> mods, bool RecommendedDialogLabel.Text = "The following modules have been recommended by one or more of the chosen modules:"; RecommendedModsListView.Columns[1].Text = "Recommended by:"; + RecommendedModsToggleCheckbox.Text = "(De-)select all recommended mods."; } else { RecommendedDialogLabel.Text = "The following modules have been suggested by one or more of the chosen modules:"; RecommendedModsListView.Columns[1].Text = "Suggested by:"; + RecommendedModsToggleCheckbox.Text = "(De-)select all suggested mods."; } From 3c9d98084ccdffee19a3c107e6cbe642b2f63024 Mon Sep 17 00:00:00 2001 From: Martin J Date: Sat, 15 Aug 2015 17:00:53 +0200 Subject: [PATCH 2/6] Fixed the misaligned checkbox. --- GUI/Main.Designer.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/GUI/Main.Designer.cs b/GUI/Main.Designer.cs index 1899d1c32c..ae7324328d 100644 --- a/GUI/Main.Designer.cs +++ b/GUI/Main.Designer.cs @@ -268,20 +268,20 @@ private void InitializeComponent() this.deselectAllSelectedModsToolStripMenuItem }); this.selectionToolStripMenuItem.Name = "selectionToolStripMenuItem"; - this.selectionToolStripMenuItem.Size = new System.Drawing.Size(61, 22); + this.selectionToolStripMenuItem.Size = new System.Drawing.Size(67, 20); this.selectionToolStripMenuItem.Text = "Selection"; // // selectAllInstalledModsToolStripMenuItem // this.selectAllInstalledModsToolStripMenuItem.Name = "selectAllInstalledModsToolStripMenuItem"; - this.selectAllInstalledModsToolStripMenuItem.Size = new System.Drawing.Size(61, 22); + this.selectAllInstalledModsToolStripMenuItem.Size = new System.Drawing.Size(212, 22); this.selectAllInstalledModsToolStripMenuItem.Text = "Select all installed mods"; this.selectAllInstalledModsToolStripMenuItem.Click += new System.EventHandler(this.selectAllInstalledModsToolStripMenuItem_Click); // // deselectAllSelectedModsToolStripMenuItem // this.deselectAllSelectedModsToolStripMenuItem.Name = "deselectAllSelectedModsToolStripMenuItem"; - this.deselectAllSelectedModsToolStripMenuItem.Size = new System.Drawing.Size(61, 22); + this.deselectAllSelectedModsToolStripMenuItem.Size = new System.Drawing.Size(212, 22); this.deselectAllSelectedModsToolStripMenuItem.Text = "Deselect all selected mods"; this.deselectAllSelectedModsToolStripMenuItem.Click += new System.EventHandler(this.deselectAllSelectedModsToolStripMenuItem_Click); // @@ -1076,9 +1076,11 @@ private void InitializeComponent() // this.RecommendedModsToggleCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom) | (System.Windows.Forms.AnchorStyles.Left))); this.RecommendedModsToggleCheckbox.FlatStyle = FlatStyle.Flat; - this.RecommendedModsToggleCheckbox.Location = new System.Drawing.Point(10, 617); + this.RecommendedModsToggleCheckbox.AutoSize = true; + this.RecommendedModsToggleCheckbox.Location = new System.Drawing.Point(8, 620); this.RecommendedModsToggleCheckbox.Name = "RecommendedModsToggleCheckbox"; - this.RecommendedModsToggleCheckbox.Size = new System.Drawing.Size(100,23); + this.RecommendedModsToggleCheckbox.Size = new System.Drawing.Size(92, 17); + this.RecommendedModsToggleCheckbox.TabIndex = 9; this.RecommendedModsToggleCheckbox.Text = "Toggle * Mods"; this.RecommendedModsToggleCheckbox.Checked = true; this.RecommendedModsToggleCheckbox.UseVisualStyleBackColor = true; From 5b50aae0ee99e01838f3b970dc901f711e1a5421 Mon Sep 17 00:00:00 2001 From: Martin J Date: Sat, 15 Aug 2015 17:04:18 +0200 Subject: [PATCH 3/6] Fixed crash when ChangeSet is null. --- GUI/Main.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/GUI/Main.cs b/GUI/Main.cs index 18cec7e7cc..cc151da468 100644 --- a/GUI/Main.cs +++ b/GUI/Main.cs @@ -1060,10 +1060,9 @@ private void deselectAllSelectedModsToolStripMenuItem_Click(object sender, Event if (row.Cells[0] is DataGridViewCheckBoxCell && (bool)row.Cells[0].Value) { MarkModForInstall(mod.Identifier, (bool)row.Cells[0].Value); - //ApplyToolButton.Enabled = true; } } - ApplyToolButton.Enabled = (ChangeSet.Any()); + ApplyToolButton.Enabled = ChangeSet != null && (ChangeSet.Any()); ModList.Refresh(); } From c2bf4dbfa18a88fa14d6cc7f791be61e6f8eb054 Mon Sep 17 00:00:00 2001 From: Martin J Date: Sat, 15 Aug 2015 18:23:29 +0200 Subject: [PATCH 4/6] Skip cell value reading for all uninstalls. --- GUI/Main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GUI/Main.cs b/GUI/Main.cs index cc151da468..2d23f7e002 100644 --- a/GUI/Main.cs +++ b/GUI/Main.cs @@ -1059,7 +1059,7 @@ private void deselectAllSelectedModsToolStripMenuItem_Click(object sender, Event var mod = ((GUIMod)row.Tag); if (row.Cells[0] is DataGridViewCheckBoxCell && (bool)row.Cells[0].Value) { - MarkModForInstall(mod.Identifier, (bool)row.Cells[0].Value); + MarkModForInstall(mod.Identifier, true);//(bool)row.Cells[0].Value); } } ApplyToolButton.Enabled = ChangeSet != null && (ChangeSet.Any()); From ad284b20ef12ec991677bc669dc7b8b07ce51b4c Mon Sep 17 00:00:00 2001 From: Martin J Date: Sat, 15 Aug 2015 19:02:05 +0200 Subject: [PATCH 5/6] Calculate changeset after (de)selections. Prevents inconsistency errors due to dependencies being marked for uninstall before the dependant. --- GUI/Main.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GUI/Main.cs b/GUI/Main.cs index 2d23f7e002..9a65d709be 100644 --- a/GUI/Main.cs +++ b/GUI/Main.cs @@ -1049,6 +1049,7 @@ private void selectAllInstalledModsToolStripMenuItem_Click(object sender, EventA { MarkModForInstall(installedMod.identifier, false); } + mainModList.ComputeUserChangeSet(); ModList.Refresh(); } @@ -1062,6 +1063,7 @@ private void deselectAllSelectedModsToolStripMenuItem_Click(object sender, Event MarkModForInstall(mod.Identifier, true);//(bool)row.Cells[0].Value); } } + mainModList.ComputeUserChangeSet(); ApplyToolButton.Enabled = ChangeSet != null && (ChangeSet.Any()); ModList.Refresh(); } From 5df5ccd3102297191ac6c09e8e2556cfb138502c Mon Sep 17 00:00:00 2001 From: Martin J Date: Sat, 15 Aug 2015 19:11:59 +0200 Subject: [PATCH 6/6] Actually assigns new changeset. Duh. --- GUI/Main.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GUI/Main.cs b/GUI/Main.cs index 9a65d709be..530d10d79b 100644 --- a/GUI/Main.cs +++ b/GUI/Main.cs @@ -1049,7 +1049,7 @@ private void selectAllInstalledModsToolStripMenuItem_Click(object sender, EventA { MarkModForInstall(installedMod.identifier, false); } - mainModList.ComputeUserChangeSet(); + ChangeSet = mainModList.ComputeUserChangeSet(); ModList.Refresh(); } @@ -1063,7 +1063,7 @@ private void deselectAllSelectedModsToolStripMenuItem_Click(object sender, Event MarkModForInstall(mod.Identifier, true);//(bool)row.Cells[0].Value); } } - mainModList.ComputeUserChangeSet(); + ChangeSet = mainModList.ComputeUserChangeSet(); ApplyToolButton.Enabled = ChangeSet != null && (ChangeSet.Any()); ModList.Refresh(); }