Skip to content

Commit 3d95bdc

Browse files
committed
Update game list combo box directly when list changes
(Required for better AutoSplitterCore integration, see #36)
1 parent 7effd4b commit 3d95bdc

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

Sources/AutoSplitterCoreModule.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using System;
2424
using System.Collections.Generic;
2525
using System.Collections.ObjectModel;
26+
using System.Collections.Specialized;
2627
using System.IO;
2728
using System.Reflection;
2829
using static HitCounterManager.IAutoSplitterCoreInterface;
@@ -227,6 +228,16 @@ public AutoSplitterCoreInterface(Form1 form)
227228
{
228229
form1 = form;
229230
profCtrl = form1.profCtrl;
231+
GameList.CollectionChanged += (object sender, NotifyCollectionChangedEventArgs e) =>
232+
{
233+
switch (e.Action)
234+
{
235+
case NotifyCollectionChangedAction.Add: foreach (string game in e.NewItems) form1.comboBoxGame.Items.Add(game); break;
236+
case NotifyCollectionChangedAction.Remove: foreach (string game in e.NewItems) form1.comboBoxGame.Items.Remove(game); break;
237+
case NotifyCollectionChangedAction.Reset: form1.comboBoxGame.Items.Clear(); break;
238+
default: break;
239+
}
240+
};
230241
}
231242

232243
public bool GetCurrentInGameTime(out long totalTimeMs)

Sources/Form1.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,6 @@ private void Form1_Load(object sender, EventArgs e)
8484
{
8585
profCtrl.InterfaceASC = InterfaceASC = new(this);
8686
AutoSplitterCoreModule.AutoSplitterRegisterInterface(InterfaceASC);
87-
comboBoxGame.Items.Clear();
88-
foreach (string game in InterfaceASC.GameList)
89-
{
90-
comboBoxGame.Items.Add(game);
91-
}
92-
9387
LoadAutoSplitterHotKeys();
9488
}
9589

0 commit comments

Comments
 (0)