Esempio n. 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            ApplyTransform(g);

            if (ai.numSpacesLeft() < 9)
            {
                this.computerStartsToolStripMenuItem.Enabled = false;
            }

            // Draw board
            g.DrawLine(Pens.Black, block, 0, block, lineLength);
            g.DrawLine(Pens.Black, 2 * block, 0, 2 * block, lineLength);
            g.DrawLine(Pens.Black, 0, block, lineLength, block);
            g.DrawLine(Pens.Black, 0, 2 * block, lineLength, 2 * block);
            AI.CellSelection[,] grid = ai.currentGrid();

            for (int i = 0; i < 3; ++i)
            {
                for (int j = 0; j < 3; ++j)
                {
                    if (grid[i, j] == AI.CellSelection.O)
                    {
                        DrawO(i, j, g);
                    }
                    else if (grid[i, j] == AI.CellSelection.X)
                    {
                        DrawX(i, j, g);
                    }
                }
            }
        }