Oops. That's what happens when you merge branches incorrectly. Fixes #6.

This commit is contained in:
gibbed
2017-11-24 09:19:41 -06:00
parent 94a92ed4b7
commit 97fee70fdb
2 changed files with 25 additions and 4 deletions

View File

@@ -178,7 +178,8 @@
this._GameListView.TileSize = new System.Drawing.Size(184, 69); this._GameListView.TileSize = new System.Drawing.Size(184, 69);
this._GameListView.UseCompatibleStateImageBehavior = false; this._GameListView.UseCompatibleStateImageBehavior = false;
this._GameListView.VirtualMode = true; this._GameListView.VirtualMode = true;
this._GameListView.ItemActivate += new System.EventHandler(this.OnSelectGame); this._GameListView.ItemActivate += new System.EventHandler(this.OnActivateGame);
this._GameListView.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.OnSelectGame);
this._GameListView.RetrieveVirtualItem += new System.Windows.Forms.RetrieveVirtualItemEventHandler(this.OnGameListViewRetrieveVirtualItem); this._GameListView.RetrieveVirtualItem += new System.Windows.Forms.RetrieveVirtualItemEventHandler(this.OnGameListViewRetrieveVirtualItem);
// //
// _PickerStatusStrip // _PickerStatusStrip

View File

@@ -42,6 +42,7 @@ namespace SAM.Picker
private readonly List<GameInfo> _Games; private readonly List<GameInfo> _Games;
private readonly List<GameInfo> _FilteredGames; private readonly List<GameInfo> _FilteredGames;
private int _SelectedGameIndex;
public List<GameInfo> Games public List<GameInfo> Games
{ {
@@ -59,6 +60,7 @@ namespace SAM.Picker
{ {
this._Games = new List<GameInfo>(); this._Games = new List<GameInfo>();
this._FilteredGames = new List<GameInfo>(); this._FilteredGames = new List<GameInfo>();
this._SelectedGameIndex = -1;
this._LogosAttempted = new List<string>(); this._LogosAttempted = new List<string>();
this._LogoQueue = new ConcurrentQueue<GameInfo>(); this._LogoQueue = new ConcurrentQueue<GameInfo>();
@@ -318,14 +320,32 @@ namespace SAM.Picker
this._CallbackTimer.Enabled = true; this._CallbackTimer.Enabled = true;
} }
private void OnSelectGame(object sender, EventArgs e) private void OnSelectGame(object sender, ListViewItemSelectionChangedEventArgs e)
{ {
if (this._GameListView.SelectedItems.Count == 0) if (e.IsSelected == true && e.ItemIndex != this._SelectedGameIndex)
{
this._SelectedGameIndex = e.ItemIndex;
}
else if (e.IsSelected == true && e.ItemIndex == this._SelectedGameIndex)
{
this._SelectedGameIndex = -1;
}
}
private void OnActivateGame(object sender, EventArgs e)
{
if (this._SelectedGameIndex < 0)
{ {
return; return;
} }
var info = this._GameListView.SelectedItems[0].Tag as GameInfo; var index = this._SelectedGameIndex;
if (index < 0 || index >= this._FilteredGames.Count)
{
return;
}
var info = this._FilteredGames[index];
if (info == null) if (info == null)
{ {
return; return;