public void Reveal(bool win = false) { if (win && IsMine) { Flag(true); } else if (!IsFlagged && !IsRevealed) { IsClickable = false; IsRevealed = true; BackgroundColor = new SolidColorBrush(Colors.White); SetContent(); if (adjacentCount == 0) { wnd.ExpandReveal(X, Y); } wnd.CheckWin(true); } NotifyPropertyChanged("IsClickable"); NotifyPropertyChanged("BackgroundColor"); }
// //AFTER PRESSING LEFT MOUSE BUTTON, DISABLE FIELD AND SHOW ITS CONTENT // public void CheckField() { if (isClicked || isFlagSet) { return; } fieldButton.Enabled = false; //if there is bomb on a field, player loses if (isBomb) { fieldButton.Text = "X"; fieldButton.ForeColor = Color.Red; fieldButton.Font = new Font(fieldButton.Font.FontFamily, fieldButton.Font.Size, FontStyle.Bold); fieldButton.FlatAppearance.BorderColor = Color.FromArgb(0, 0, 0); MessageBox.Show("Bomb! You died..."); _form.Close(); } //entering 'else' if there is no bomb on a field else { if (isClicked || isFlagSet) { return; } if (bombsNearby != 0) { fieldButton.Text = bombsNearby.ToString(); } else { _form.CheckNearFields(fieldX, fieldY); } isClicked = true; fieldButton.BackColor = Color.FromArgb(255, 204, 204); _form.CheckWin(); } }