Example #1
0
        private void MarkerChangedHandler(object sender, TheBrain.TicTacToeGame.MarkerChangedArgs e)
        {
            var buttonName = $"btnSquare{e.RowID}{e.ColID}";

            foreach (var control in this.pnlButtons.Controls)
            {
                if (control is Button button)
                {
                    if (button.Name == buttonName)
                    {
                        switch (e.CellOwner)
                        {
                        case CellOwners.Error:
                            button.Text = "#";
                            break;

                        case CellOwners.Open:
                            button.Text = "?";
                            break;

                        case CellOwners.Human:
                            button.Text = "X";
                            break;

                        case CellOwners.Computer:
                            button.Text = "O";
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }
                }
            }
        }
Example #2
0
 private void MarkerChangedHandler(object sender, TheBrain.TicTacToeGame.MarkerChangedArgs e)
 {
     foreach (var item in this.tableLayoutPanel1.Controls)
     {
         if (!(item is GameCell gameCell))
         {
             continue;
         }
         if ((gameCell.CellRowNo != e.RowID) || (gameCell.CellColNo != e.ColID))
         {
             continue;
         }
         gameCell.CellOwner = e.CellOwner;
     }
 }