/// <summary> /// Give the winner of the "battle" /// </summary> private void getWinner(Key player1, Key player2) { switch(player1) { case (Key.Q): if (player2 == Key.L) m_winner = m_joueur2; else if (player2 == Key.M) m_winner = m_joueur1; break; case (Key.S): if (player2 == Key.M) m_winner = m_joueur2; else if (player2 == Key.K) m_winner = m_joueur1; break; case (Key.D): if (player2 == Key.K) m_winner = m_joueur2; else if (player2 == Key.L) m_winner = m_joueur1; break; } if(m_winner == null) { // Egalité egalite.Visibility = Visibility.Visible; winner.Visibility = Visibility.Hidden; egalite.MouseLeftButtonDown += launchAgain; } else { // A winner is defined JediViewModel jvm = new JediViewModel(m_winner); JediReadUserControl winner_uc = new JediReadUserControl(jvm); resultsGrid.Children.Add(winner_uc); winner.Visibility = Visibility.Visible; winner.Text = m_winner.Nom + " gagne !"; winner_uc.SetValue(Grid.ColumnProperty, 3); winner_uc.SetValue(Grid.RowProperty, 3); winner_uc.Margin = new Thickness(10); m_timer.Interval = new TimeSpan(0, 0, 3); m_timer.Tick -= new EventHandler(doGame); m_timer.Tick += new EventHandler(endingGame); m_timer.Start(); // TODO : update match and tournament table // TODO : go to the next match } }
public JediReadUserControl(JediViewModel jvm) { InitializeComponent(); DataContext = jvm; }