Skip to content

Commit

Permalink
Invoke controls accesses in UpdateModList
Browse files Browse the repository at this point in the history
  • Loading branch information
DasSkelett committed Jan 10, 2019
1 parent 5434adb commit 37d1b6b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
43 changes: 25 additions & 18 deletions GUI/MainModList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,25 +230,32 @@ private void _UpdateModsList(bool repo_updated, IEnumerable<ModChange> mc)
mainModList.full_list_of_mod_rows.Values.Select(row => row.Tag as GUIMod).ToList());

AddLogMessage("Updating filters...");
//TODO Consider using smart enumeration pattern so stuff like this is easier
FilterToolButton.DropDownItems[0].Text = String.Format("Compatible ({0})",
mainModList.CountModsByFilter(GUIModFilter.Compatible));
FilterToolButton.DropDownItems[1].Text = String.Format("Installed ({0})",
mainModList.CountModsByFilter(GUIModFilter.Installed));
FilterToolButton.DropDownItems[2].Text = String.Format("Upgradeable ({0})",
mainModList.CountModsByFilter(GUIModFilter.InstalledUpdateAvailable));
FilterToolButton.DropDownItems[3].Text = String.Format("Cached ({0})",
mainModList.CountModsByFilter(GUIModFilter.Cached));
FilterToolButton.DropDownItems[4].Text = String.Format("Newly compatible ({0})",
mainModList.CountModsByFilter(GUIModFilter.NewInRepository));
FilterToolButton.DropDownItems[5].Text = String.Format("Not installed ({0})",
mainModList.CountModsByFilter(GUIModFilter.NotInstalled));
FilterToolButton.DropDownItems[6].Text = String.Format("Incompatible ({0})",
mainModList.CountModsByFilter(GUIModFilter.Incompatible));
FilterToolButton.DropDownItems[7].Text = String.Format("All ({0})",
mainModList.CountModsByFilter(GUIModFilter.All));

var has_any_updates = gui_mods.Any(mod => mod.HasUpdate);
UpdateAllToolButton.Enabled = has_any_updates;

//TODO Consider using smart enumeration pattern so stuff like this is easier
Util.Invoke(menuStrip2, () =>
{
FilterToolButton.DropDownItems[0].Text = String.Format("Compatible ({0})",
mainModList.CountModsByFilter(GUIModFilter.Compatible));
FilterToolButton.DropDownItems[1].Text = String.Format("Installed ({0})",
mainModList.CountModsByFilter(GUIModFilter.Installed));
FilterToolButton.DropDownItems[2].Text = String.Format("Upgradeable ({0})",
mainModList.CountModsByFilter(GUIModFilter.InstalledUpdateAvailable));
FilterToolButton.DropDownItems[3].Text = String.Format("Cached ({0})",
mainModList.CountModsByFilter(GUIModFilter.Cached));
FilterToolButton.DropDownItems[4].Text = String.Format("Newly compatible ({0})",
mainModList.CountModsByFilter(GUIModFilter.NewInRepository));
FilterToolButton.DropDownItems[5].Text = String.Format("Not installed ({0})",
mainModList.CountModsByFilter(GUIModFilter.NotInstalled));
FilterToolButton.DropDownItems[6].Text = String.Format("Incompatible ({0})",
mainModList.CountModsByFilter(GUIModFilter.Incompatible));
FilterToolButton.DropDownItems[7].Text = String.Format("All ({0})",
mainModList.CountModsByFilter(GUIModFilter.All));

UpdateAllToolButton.Enabled = has_any_updates;
});

UpdateFilters(this);

AddLogMessage("Updating tray...");
Expand Down
5 changes: 2 additions & 3 deletions GUI/MainWait.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@ public void ShowWaitDialog(bool cancelable = true)
{
tabController.ShowTab("WaitTabPage", 2);

CancelCurrentActionButton.Enabled = cancelable;

DialogProgressBar.Value = 0;
DialogProgressBar.Minimum = 0;
DialogProgressBar.Maximum = 100;
DialogProgressBar.Style = ProgressBarStyle.Marquee;
MessageTextBox.Text = "Please wait";
});
Util.Invoke(statusStrip1, () =>
{
StatusProgress.Value = 0;
StatusProgress.Style = ProgressBarStyle.Marquee;
StatusProgress.Visible = true;
});
Util.Invoke(CancelCurrentActionButton, () => CancelCurrentActionButton.Enabled = cancelable);
Util.Invoke(MessageTextBox, () => MessageTextBox.Text = "Please wait");
}

public void HideWaitDialog(bool success)
Expand Down

0 comments on commit 37d1b6b

Please sign in to comment.