private void Button_Click(object sender, RoutedEventArgs e) { if (timerRunning == false) { timer.Start(); timerRunning = true; } if (gameEnd == true) { return; } bool lost = false; int b_n = Convert.ToInt32((sender as Button).Name.Replace("B", "")); if (flagged[game.GetRowFromPos(b_n), game.GetColFromPos(b_n)] == true) { return; } else { lost = game.OpenCell(b_n); } UpdateWindow(); if (lost == false) { timer.Stop(); gameEnd = true; } else if (game.Finished() == true) { timer.Stop(); gameEnd = true; } }