private void inputPlayersToolStripMenuItem_Click(object sender, EventArgs e) { Tournament tournament = Config.Settings.GetTournament(lstEvents.SelectedItems[0].Text); var args = new TournamentPlayersEventArgs(tournament.Name, tournament.Players, tournament.PlayerFaction, PlayersAdded); foreach (FrmTournamentPlayers active in ActivePlayersWindows) { if (active.TournamentName == tournament.Name) { active.WindowState = FormWindowState.Normal; active.Focus(); return; } } var dialog = new FrmTournamentPlayers(args); dialog.MdiParent = MdiParent; dialog.Show(); ActivePlayersWindows.Add(dialog); }
private void btnNewEvent_Click(object sender, EventArgs e) { var selectedType = EventType.Unknown; using (var typeDialog = new frmEventType()) { if (typeDialog.ShowDialog() == DialogResult.Cancel) return; selectedType = typeDialog.Value; } if (selectedType == EventType.Tournament) { Tournament tournament = null; while (true) { using (var dialog = new frmTournamentOptions(tournament)) { if (dialog.ShowDialog() == DialogResult.OK) { tournament = dialog.Tournament; League checkLeague = Config.Settings.GetLeague(dialog.Name); Tournament checkTournament = Config.Settings.GetTournament(dialog.Name); if (checkTournament != null || checkLeague != null) if (MessageBox.Show("An event with the name \"" + tournament.Name + "\" already " + "exists. Event names must be unique.", "Validation Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1) == DialogResult.Cancel) return; else continue; Config.Settings.Tournaments.Add(tournament); Config.Settings.SaveEvents(); lstEvents.BeginUpdate(); var item = new ListViewItem(); item.Name = tournament.Name; item.Text = tournament.Name; item.SubItems.Add("Tournament"); item.SubItems.Add(tournament.Location); item.SubItems.Add(tournament.Date.ToShortDateString()); item.SubItems.Add(tournament.Players.Count.ToString()); item.SubItems.Add("Not Started"); lstEvents.Items.Add(item); lstEvents.Sort(); lstEvents.EndUpdate(); // Show the Add Players screen if wanted. if (!btnShowAddPlayers.Checked) return; var args = new TournamentPlayersEventArgs(tournament.Name, tournament.Players, tournament.PlayerFaction, PlayersAdded); var addPlayersDialog = new FrmTournamentPlayers(args); addPlayersDialog.MdiParent = MdiParent; addPlayersDialog.Show(); ActivePlayersWindows.Add(addPlayersDialog); return; } else return; } } } else if (selectedType == EventType.League) { League league = null; while (true) { using (var dialog = new frmLeagueOptions(league)) { if (dialog.ShowDialog() == DialogResult.OK) { league = dialog.League; League checkLeague = Config.Settings.GetLeague(dialog.Name); Tournament checkTournament = Config.Settings.GetTournament(dialog.Name); if (checkTournament != null || checkLeague != null) if (MessageBox.Show("An event with the name \"" + league.Name + "\" already " + "exists. Event names must be unique.", "Validation Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1) == DialogResult.Cancel) return; else continue; Config.Settings.Leagues.Add(league); Config.Settings.SaveEvents(); lstEvents.BeginUpdate(); var item = new ListViewItem(); item.Name = league.Name; item.Text = league.Name; item.SubItems.Add("League"); item.SubItems.Add(league.Location); item.SubItems.Add(league.StartDate.ToShortDateString()); item.SubItems.Add(league.Players.Count.ToString()); item.SubItems.Add("Not Started"); lstEvents.Items.Add(item); lstEvents.Sort(); lstEvents.EndUpdate(); return; } else return; } } } }