private void Game_StateChanged(object sender, StateChangeEventArg e) { stbCurrent.Text = String.Format("Current Color: {0}", e.CurrentColor); stbMoves.Text = String.Format("Moves: {0}", e.Moves); if (!String.IsNullOrEmpty(e.Winner)) { Text = Text + " [ Winner: " + e.Winner + " ]"; MessageBox.Show(String.Format("Winner: {0}", e.Winner), Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Raise state change event /// </summary> private void RaiseStateChanged() { if (StateChanged == null || isAnimate == true) { return; } StateChangeEventArg arg = new StateChangeEventArg() { CurrentColor = currentColor.Name, Moves = GetMovesCount(), }; if (isWon == true) { arg.Winner = (currentColor == firstColor ? secondColor.Name : firstColor.Name); } else { arg.Winner = String.Empty; } StateChanged(this, arg); }