private void ListBox_DoubleClick(object sender, EventArgs e) { ListBox listBox = (ListBox)sender; int index = listBox.SelectedIndex; if (listBox == ExpeditionsListBox) { // Show expedition history onExpeditionHistory?.Invoke(this, null); } else { // Rename the deck if (index >= 0) { GameRecord gr = (GameRecord)listBox.Items[index]; string deckName = gr.ToString(); int scoreIndex = deckName.LastIndexOf(" ("); if (scoreIndex > 0) { deckName = deckName.Substring(0, scoreIndex); } string result = Microsoft.VisualBasic.Interaction.InputBox("Name:", "Change Deck Name", deckName); if (!string.IsNullOrEmpty(result) && deckName != result) { if (!gr.IsExpedition()) { gr.MyDeckName = result; } GameHistory.SetDeckName(gr.GetDeckSignature(), result); if (!gr.IsExpedition()) { index = listBox.Items.Cast <GameRecord>().ToList().FindIndex(x => result == x.MyDeckName); int nextIndex = index; while (nextIndex >= 0 && nextIndex < listBox.Items.Count - 1) { nextIndex = listBox.Items.Cast <GameRecord>().ToList().FindIndex(nextIndex + 1, x => result == x.MyDeckName); if (nextIndex > index) { ((GameRecord)listBox.Items[index]).NumWins += ((GameRecord)listBox.Items[nextIndex]).NumWins; ((GameRecord)listBox.Items[index]).NumLosses += ((GameRecord)listBox.Items[nextIndex]).NumLosses; ((GameRecord)listBox.Items[index]).NumWinsVsAI += ((GameRecord)listBox.Items[nextIndex]).NumWinsVsAI; ((GameRecord)listBox.Items[index]).NumLossesVsAI += ((GameRecord)listBox.Items[nextIndex]).NumLossesVsAI; listBox.Items.RemoveAt(nextIndex); } } } ((GameRecord)listBox.Items[index]).DisplayString = result + GetWinLossRecordString((GameRecord)listBox.Items[index]); listBox.Items[index] = (GameRecord)listBox.Items[index]; listBox.SelectedIndex = index; listBox.Refresh(); ListBox_SelectedIndexChanged(sender, null); } } } }