From ef4977b310eabc44cf98afa52c477c0c96c83b0a Mon Sep 17 00:00:00 2001 From: DasSkelett Date: Thu, 26 Apr 2018 22:20:49 +0200 Subject: [PATCH 1/2] Fix `Apply changes`-button get enabled multiple times Removed some unnecessary calls to `ApplyToolButton.Enabled = true` as well as setting the update checkbox true a bunch of times. `ApplyToolButton.Enabled` gets set to true automatically because setting update-checkbox checked calls `ModList_CellValueChanged()`. --- GUI/Main.cs | 11 +---------- GUI/MainModList.cs | 14 ++++++-------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/GUI/Main.cs b/GUI/Main.cs index b2858176bf..5e841cd5aa 100644 --- a/GUI/Main.cs +++ b/GUI/Main.cs @@ -466,16 +466,7 @@ private void RefreshToolButton_Click(object sender, EventArgs e) private void MarkAllUpdatesToolButton_Click(object sender, EventArgs e) { - foreach (DataGridViewRow row in ModList.Rows) - { - var mod = (GUIMod)row.Tag; - if (mod.HasUpdate && row.Cells[1] is DataGridViewCheckBoxCell) - { - MarkModForUpdate(mod.Identifier); - mod.SetUpgradeChecked(row, true); - ApplyToolButton.Enabled = true; - } - } + MarkModsForUpdate(); // only sort by Update column if checkbox in settings checked if (Main.Instance.configuration.AutoSortByUpdate) diff --git a/GUI/MainModList.cs b/GUI/MainModList.cs index 22a8e21d41..bf8dadecd0 100644 --- a/GUI/MainModList.cs +++ b/GUI/MainModList.cs @@ -219,21 +219,19 @@ private void _MarkModForInstall(string identifier, bool uninstall) } } - public void MarkModForUpdate(string identifier) + public void MarkModsForUpdate() { - Util.Invoke(this, () => _MarkModForUpdate(identifier)); + Util.Invoke(this, () => _MarkModsForUpdate()); } - - - public void _MarkModForUpdate(string identifier) + + public void _MarkModsForUpdate() { foreach (DataGridViewRow row in ModList.Rows) { var mod = (GUIMod) row.Tag; - if (mod.Identifier == identifier) + if (mod.HasUpdate) { - (row.Cells[1] as DataGridViewCheckBoxCell).Value = true; - break; + mod.SetUpgradeChecked(row, true); } } } From 96dc5a3488931e152691b2a515c91a19dcf4e5f4 Mon Sep 17 00:00:00 2001 From: DasSkelett Date: Fri, 27 Apr 2018 15:58:22 +0200 Subject: [PATCH 2/2] Move loop to MarkAllUpdatesToolButton_Click() --- GUI/Main.cs | 11 ++++++++--- GUI/MainModList.cs | 17 ++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/GUI/Main.cs b/GUI/Main.cs index 5e841cd5aa..4aff6f041c 100644 --- a/GUI/Main.cs +++ b/GUI/Main.cs @@ -466,7 +466,14 @@ private void RefreshToolButton_Click(object sender, EventArgs e) private void MarkAllUpdatesToolButton_Click(object sender, EventArgs e) { - MarkModsForUpdate(); + foreach (DataGridViewRow row in ModList.Rows) + { + var mod = (GUIMod)row.Tag; + if (mod.HasUpdate) + { + MarkModForUpdate(mod.Identifier); + } + } // only sort by Update column if checkbox in settings checked if (Main.Instance.configuration.AutoSortByUpdate) @@ -487,8 +494,6 @@ private void MarkAllUpdatesToolButton_Click(object sender, EventArgs e) } ModList.Refresh(); - - } public void UpdateModContentsTree(CkanModule module, bool force = false) diff --git a/GUI/MainModList.cs b/GUI/MainModList.cs index bf8dadecd0..3e35980c56 100644 --- a/GUI/MainModList.cs +++ b/GUI/MainModList.cs @@ -219,21 +219,16 @@ private void _MarkModForInstall(string identifier, bool uninstall) } } - public void MarkModsForUpdate() + public void MarkModForUpdate(string identifier) { - Util.Invoke(this, () => _MarkModsForUpdate()); + Util.Invoke(this, () => _MarkModForUpdate(identifier)); } - public void _MarkModsForUpdate() + public void _MarkModForUpdate(string identifier) { - foreach (DataGridViewRow row in ModList.Rows) - { - var mod = (GUIMod) row.Tag; - if (mod.HasUpdate) - { - mod.SetUpgradeChecked(row, true); - } - } + DataGridViewRow row = mainModList.full_list_of_mod_rows[identifier]; + var mod = (GUIMod)row.Tag; + mod.SetUpgradeChecked(row, true); } private void ModList_SelectedIndexChanged(object sender, EventArgs e)