diff --git a/DockerForm/Form1.cs b/DockerForm/Form1.cs index fa2388a..cb8c5b0 100644 --- a/DockerForm/Form1.cs +++ b/DockerForm/Form1.cs @@ -407,27 +407,26 @@ public static void UpdateFormIcons() public void InsertOrUpdateGameItem(DockerGame game, bool Update = true) { - exListBoxItem newitem = new exListBoxItem(game); - if (!DatabaseManager.GameDB.ContainsKey(game.GUID)) { + exListBoxItem newitem = new exListBoxItem(game); GameList.Items.Add(newitem); DatabaseManager.GameDB[game.GUID] = game; LogManager.UpdateLog("[" + game.Name + "] profile has been added to the database"); } else if (Update) { - for (int i = 0; i < GameList.Items.Count; i++) - { - exListBoxItem item = (exListBoxItem)GameList.Items[i]; - if (item.Guid == game.GUID) - { - GameList.Items[i] = newitem; - DatabaseManager.GameDB[game.GUID] = game; - LogManager.UpdateLog("[" + game.Name + "] profile has been updated"); - break; - } - } + exListBoxItem item = GameList.GetItemFromGuid(game.GUID); + if (item == null) + return; + + DockerGame list_game = DatabaseManager.GameDB[game.GUID]; + list_game.Uri = game.Uri; + list_game.Version = game.Version; + list_game.LastCheck = game.LastCheck; + list_game.SanityCheck(); + item.Enabled = list_game.Enabled; + LogManager.UpdateLog("[" + list_game.Name + "] profile has been updated"); } // Update current title @@ -833,7 +832,7 @@ private void automaticDetectionToolStripMenuItem_Click(object sender, EventArgs { DialogResult dialogResult = MessageBox.Show("Do you want to add [" + game.Name + "] to your Database ? ", "(Beta) Automatic Detection", MessageBoxButtons.YesNoCancel); if (dialogResult == DialogResult.Yes) - InsertOrUpdateGameItem(game, false); + InsertOrUpdateGameItem(game, true); else if (dialogResult == DialogResult.No) { // Properties.Settings.Default.Blacklist.Add(game.Name); diff --git a/DockerForm/exListBox.cs b/DockerForm/exListBox.cs index a3dc886..eda1af9 100644 --- a/DockerForm/exListBox.cs +++ b/DockerForm/exListBox.cs @@ -112,6 +112,17 @@ protected override void OnDrawItem(DrawItemEventArgs e) catch (Exception) { } } + public exListBoxItem GetItemFromGuid(string guid) + { + for (int i = 0; i < Items.Count; i++) + { + exListBoxItem item = (exListBoxItem)Items[i]; + if (item.Guid == guid) + return item; + } + return null; + } + public void Sort() { if (Items.Count > 1)