示例#1
0
        private void Field_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            if (e.Source is Button)
            {
                if (e.Source != clicked)
                {
                    return;
                }

                clicked = null;

                int i = Field.Children.IndexOf(e.Source as UIElement) % Field.Columns;
                int j = Field.Children.IndexOf(e.Source as UIElement) / Field.Columns;

                if (LeftButton == true)
                {
                    game.DemineCell(i, j);
                }

                if (LeftButton == false)
                {
                    game.PutAFlag(i, j);
                }

                UpdField();

                if (game.GameOver)
                {
                    MessageBox.Show("U won the game!", "Congratulations!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
        }