diff --git a/SAM.Picker/GamePicker.Designer.cs b/SAM.Picker/GamePicker.Designer.cs index 0bb59b7..0346a70 100644 --- a/SAM.Picker/GamePicker.Designer.cs +++ b/SAM.Picker/GamePicker.Designer.cs @@ -178,7 +178,8 @@ this._GameListView.TileSize = new System.Drawing.Size(184, 69); this._GameListView.UseCompatibleStateImageBehavior = false; 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); // // _PickerStatusStrip diff --git a/SAM.Picker/GamePicker.cs b/SAM.Picker/GamePicker.cs index c8aee3b..e830494 100644 --- a/SAM.Picker/GamePicker.cs +++ b/SAM.Picker/GamePicker.cs @@ -42,6 +42,7 @@ namespace SAM.Picker private readonly List _Games; private readonly List _FilteredGames; + private int _SelectedGameIndex; public List Games { @@ -59,6 +60,7 @@ namespace SAM.Picker { this._Games = new List(); this._FilteredGames = new List(); + this._SelectedGameIndex = -1; this._LogosAttempted = new List(); this._LogoQueue = new ConcurrentQueue(); @@ -318,14 +320,32 @@ namespace SAM.Picker 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; } - 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) { return;