private void ButtonStartGame_Click(object sender, RoutedEventArgs e) { string color1 = ComboBoxColorFirst.SelectedIndex == -1 ? "" : ComboBoxColorFirst.SelectedValue.ToString(); string color2 = ComboBoxCOlorSecond.SelectedIndex == -1? "" : ComboBoxCOlorSecond.SelectedValue.ToString(); if (color1 == "" || color2 == "") { System.Windows.MessageBox.Show("Choose forms for the game", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } int round = LINQFactory.Round(UserId); Match match = Championship.playRound(userId, round); //Game sp.Stop(); FootballGameForm f = new FootballGameForm(match.TeamName1, match.TeamName2, LINQFactory.GetNamesById(match.PlayersOne), LINQFactory.GetNamesById(match.PlayersTwo), settings.Time, settings.Level, false, match.ScorersOne, match.ScorersTwo, color1, color2); f.ShowDialog(); sp = new SoundPlayer(RandomMusic.GetRandomMusic()); sp.Play(); match.ScorersOne = f.MyRep.ScoredFirstTeam; match.ScorersTwo = f.MyRep.ScoredSecondTeam; Championship.SaveMyMatch(match, round, userId); ListViewTable.ItemsSource = Sorting.Sort(LINQFactory.GetTeamsByUser(UserId)); ListViewResults.ItemsSource = LINQFactory.GetResults(UserId, LINQFactory.Round(UserId) - 1); if (round == Repository.Cnt - 1) { SendToEmail send = new SendToEmail(LINQFactory.GetPointsById(userId)); send.Show(); ButtonStartGame.Content = "Tournament ended!"; ButtonStartGame.IsEnabled = false; LabelTeam1.Content = ""; LabelTeam2.Content = ""; } else { List <string> Teams = LINQFactory.GetMyMatch(userId, round + 1); LabelTeam1.Content = Teams[0]; LabelTeam2.Content = Teams[1]; } }
private void ButtonOK_Click(object sender, RoutedEventArgs e) { string name1 = ComboBoxFirstTeam.SelectedIndex == -1 ? "" : ComboBoxFirstTeam.SelectedValue.ToString(); string name2 = ComboBoxSecondTeam.SelectedIndex == -1 ? "" : ComboBoxSecondTeam.SelectedValue.ToString(); if (name1 == "" || name2 == "") { System.Windows.MessageBox.Show("Choose teams please!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } string form1 = ComboBoxColorFirst.SelectedIndex == -1 ? "" : ComboBoxColorFirst.SelectedValue.ToString(); string form2 = ComboBoxColorSecond.SelectedIndex == -1 ? "" : ComboBoxColorSecond.SelectedValue.ToString(); if (form1 == "" || form2 == "") { System.Windows.MessageBox.Show("Choose colors please!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } string t = ComboBoxTime.SelectedIndex == -1 ? "" : ComboBoxTime.SelectedValue.ToString(); if (t == "") { System.Windows.MessageBox.Show("Choose time please!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } List <string> FirstScorers = new List <string>(); List <string> SecondScorers = new List <string>(); sp.Stop(); FootballGameForm f = new FootballGameForm(name1, name2, MultiPlayerServise.GetNames(MultiPlayerServise.GetSquadFromName(name1)), MultiPlayerServise.GetNames(MultiPlayerServise.GetSquadFromName(name2)), int.Parse(t), 0, true, FirstScorers, SecondScorers, form1, form2); f.ShowDialog(); this.Close(); sp = new SoundPlayer(RandomMusic.GetRandomMusic()); sp.Play(); }