private void NewChampion_Click(object sender, RoutedEventArgs e) { RepoPC.UpdateAvailableChampions(); int before = RepoPC.ChampionList.Count; NewChampion newchamp = new NewChampion(); newchamp.ShowDialog(); RepoPC.UpdateAvailableChampions(); int after = RepoPC.ChampionList.Count; if (after == before + 1) { ChampionSelction.ItemsSource = new string[] { "You Can't See Me" }; ChampionSelction.ItemsSource = RepoPC.ResourceNamesList; ChampionSelction.SelectedIndex = RepoPC.ResourceList.Count - 1; } else { MessageBox.Show("Champion Creation cancelled by User", "Message", MessageBoxButton.OK); } UpdateView(); }
private void DeleteChampion_Click(object sender, RoutedEventArgs e) { int indexBefore = ChampionSelction.SelectedIndex; MessageBoxResult result = MessageBox.Show("Are you sure you want to delete the selected Champion?", "Warning", MessageBoxButton.YesNo); try { if (result == MessageBoxResult.Yes) { RepoPC.DeleteChampion(RepoPC.ChampionList[indexBefore]); ChampionSelction.ItemsSource = new string[] { "You Can't See Me" }; RepoPC.UpdateAvailableChampions(); ChampionSelction.ItemsSource = RepoPC.ChampionNamesList; ChampionSelction.SelectedIndex = indexBefore - 1; UpdateView(); } } catch (Exception ex) { MessageBox.Show("Something went wrong - " + ex.Message, "Error", MessageBoxButton.OK); } }