private void btnPlayerEdit_Click(object sender, RoutedEventArgs e) { Player playerToEdit = this.dgPointsTable.SelectedItem as Player; if (playerToEdit == null) return; playerToEdit.Clone(); bool edited = false; while (!edited) { PlayerWindow frmPlayer = new PlayerWindow(playerToEdit) { Owner = this }; if (frmPlayer.ShowDialog() == true) { if (this.tournament.PointsTable.Where(p => p.Alias == playerToEdit.Alias).Count() > 1) { new PMW(StringTable.MainWindow_PlayerExists); continue; } edited = true; continue; } else { playerToEdit.Restore(); edited = true; continue; } } this.dgPointsTable.Items.Refresh(); }
private void btnPlayerAdd_Click(object sender, RoutedEventArgs e) { try { Player playerToAdd = new Player() { Place = this.tournament.PointsTable.Count + 1 }; bool added = false; while (!added) { PlayerWindow frmPlayer = new PlayerWindow(playerToAdd) { Owner = this }; if (frmPlayer.ShowDialog() == true) { if (this.tournament.PointsTable.Where(p => p.Alias == playerToAdd.Alias).Count() > 0) { new PMW(StringTable.MainWindow_PlayerExists); continue; } this.tournament.AddPlayer(playerToAdd); added = true; continue; } else { added = true; continue; } } } catch (Exception ex) { new PME("Błąd dodawania gracza." + Environment.NewLine + ex.Message + Environment.NewLine + (ex.InnerException == null ? "" : ex.InnerException.Message)); } }