Esempio n. 1
0
 private void CloseCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e)
 {
     if (game.IsGameOver())
     {
         e.CanExecute = true;
     }
     else
     {
         e.CanExecute = false;
     }
 }
Esempio n. 2
0
        private void Rect_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // Get row and column from Rectangle's Tag
            Rectangle rect   = sender as Rectangle;
            var       rowCol = (Point)rect.Tag;
            int       row    = (int)rowCol.X;
            int       col    = (int)rowCol.Y;

            game.Move(row, col);

            // Redraw the board
            DrawGrid();

            if (game.IsGameOver())
            {
                MessageBox.Show(this, "Congratulations!  You've won!", "Lights Out!",
                                MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }