Exemple #1
0
        private void save_tournament()
        {
            try
            {
                if (cb_sets.SelectedIndex != 0 && cb_goals.SelectedIndex != 0 && cb_ranked.SelectedIndex != 0)
                {
                    TMPersistenz.AddTournament(tb_tournament_name.Text,
                                               ApplicationState.GetValue <Client>("LoggedOnUser").Username, cb_game_mode.Text,
                                               int.Parse(cb_sets.Text), int.Parse(cb_goals.Text), Ranked());
                    ApplicationState.SetValue("CurrentTournament",
                                              TMPersistenz.FindTournament(tb_tournament_name.Text));
                    // MessageBox.Show("Das Turnier wurde erfolgreich erstellt. Jetzt Teilnehmer hinzufügen!", "KICKERCUP", MessageBoxButton.OK, MessageBoxImage.Information);

                    Tournament_Competitors tc = new Tournament_Competitors();
                    this.NavigationService.Navigate(tc);
                }
                else
                {
                    MessageBox.Show("Bitte Sätze pro Match und Tore pro Satz eingeben!", "KICKERCUP",
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch
            {
                MessageBox.Show("Es ist ein Fehler aufgetreten", "KICKERCUP", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Exemple #2
0
        //wenn der Nutzer auf Turnier starten klickt, werden die Elemente fuer das Eintragen der Ergebnisse eingeblendet
        private void b_start_tournament_Click(object sender, RoutedEventArgs e)
        {
            b_start_tournament.Visibility = Visibility.Hidden;
            b_start.Visibility            = Visibility.Hidden;
            b_stop.Visibility             = Visibility.Hidden;
            l_title.Visibility            = Visibility.Visible;
            i_pitch.Visibility            = Visibility.Visible;
            tbl_team1.Visibility          = Visibility.Visible;
            tbl_team2.Visibility          = Visibility.Visible;
            tbl_nr_set.Visibility         = Visibility.Visible;
            tb_team1.Visibility           = Visibility.Visible;
            tb_team2.Visibility           = Visibility.Visible;
            b_continue.Visibility         = Visibility.Visible;
            b_home.Visibility             = Visibility.Visible;
            tbl_chance_team1.Visibility   = Visibility.Visible;
            tbl_chance_team2.Visibility   = Visibility.Visible;

            try
            {
                tournament.StartTournament();
                teams                 = tournament.CurrentMatch.GetTeams();
                tbl_team1.Text        = teams.ElementAt(0).ToString();
                tbl_team2.Text        = teams.ElementAt(1).ToString();
                tbl_chance_team1.Text = "Gewinnchance: \n" +
                                        (tournament.CurrentMatch.GetWinExpectationThatTeamAWins()).ToString() + " %";
                tbl_chance_team2.Text = "Gewinnchance: \n" +
                                        (tournament.CurrentMatch.GetWinExpectationThatTeamBWins()).ToString() + " %";
            }
            catch (Exception ex)
            {
                if (ex is ArgumentOutOfRangeException)
                {
                    MessageBox.Show(
                        "Teilnehmeranzahl ist nicht korrekt für den ausgewählten Spielmodus " +
                        ApplicationState.GetValue <TournamentPers>("CurrentTournament").Gamemode + ".", "KICKERCUP",
                        MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    MessageBox.Show("Es ist ein schwerer Fehler aufgetreten");
                }

                if (this.NavigationService.CanGoBack)
                {
                    this.NavigationService.GoBack();
                }
                else
                {
                    Tournament_Competitors tc = new Tournament_Competitors();
                    this.NavigationService.Navigate(tc);
                }
            }
        }
 //noch nicht gespieltes Turnier fortsetzen
 private void b_continue_tournament_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (ApplicationState.GetValue <TournamentPers>("CurrentTournament").IsFinished == true)
         {
             MessageBox.Show("Das ausgewählte Turnier wurde bereits beendet!", "KICKERCUP", MessageBoxButton.OK,
                             MessageBoxImage.Error);
         }
         else
         {
             Tournament_Competitors tc = new Tournament_Competitors();
             this.NavigationService.Navigate(tc);
         }
     }
     catch
     {
         MessageBox.Show("Bitte zuerst ein Turnier auswählen!", "KICKERCUP", MessageBoxButton.OK,
                         MessageBoxImage.Error);
     }
 }