public void rightClickButton(object sender, RoutedEventArgs e) { Button pressed = (Button)sender; int index = ButtonGrid.Children.IndexOf(pressed); int pressedRow = index / table.Columns; int pressedCol = index % table.Columns; if (!table.getFields()[pressedRow, pressedCol].IsFlaged) { buttons[pressedRow, pressedCol].Background = Brushes.Red; remainingMines.Content = --table.Mines; table.getFields()[pressedRow, pressedCol].IsFlaged = true; } else { buttons[pressedRow, pressedCol].Background = Brushes.LightGray; remainingMines.Content = ++table.Mines; table.getFields()[pressedRow, pressedCol].IsFlaged = false; } if (checkFlaggedWin()) { timer.Stop(); Score window = new Score(seconds, Level); window.Show(); this.Close(); } }
public void hitButton(object sender, RoutedEventArgs e) { Button pressed = (Button)sender; int index = ButtonGrid.Children.IndexOf(pressed); int pressedRow = index / table.Columns; int pressedCol = index % table.Columns; buttonClicked(pressedRow, pressedCol); if (checkEverythingRevealedWin()) { timer.Stop(); Score window = new Score(seconds, Level); window.Show(); this.Close(); } }