private void OnButtonClick(object sender, EventArgs e) { var button = (Button)sender; int index = (int)button.Tag; board.MarkCell(index); UpdateUI(); if (board.IsGameOver()) { DisplayResult(); UpdateScore(); board.Clear(); } UpdateUI(); }