Exemplo n.º 1
0
        private void DrawBoard(Graphics g)
        {
            int square = PositionAndPixels.square;

            for (int i = 0; i < 9; i++)
            {
                // Vertical lines
                Point p1 = new Point(square / 2, square / 2 + square * i);
                Point p2 = new Point(square / 2 + square * 8, square / 2 + square * i);
                g.DrawLine(Pens.Black, p1, p2);

                // Horizontal lines
                Point p3 = new Point(square / 2 + square * i, square / 2);
                Point p4 = new Point(square / 2 + square * i, square / 2 + square * 8);
                g.DrawLine(Pens.Black, p3, p4);
            }
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    int p1 = square / 2 + (i * square);
                    int p2 = square / 2 + (j * square);
                    if (aBoard.GetBoard()[i, j].SquareIsDark())
                    {
                        g.FillRectangle(aBlackSquareBrushes, p1, p2, square, square);
                    }
                    else
                    {
                        g.FillRectangle(aWhiteSquareBrushes, p1, p2, square, square);
                    }
                }
            }
            if (aFirstPlayer.Equals(Piece.Color.BLACK))
            {
                for (int i = 1; i < 9; i++)
                {
                    g.DrawString((i).ToString(), font, aBlackSquareBrushes, square / 16, square * i - (square / 4));
                    g.DrawString(Char.ConvertFromUtf32(65 + i - 1), font, aBlackSquareBrushes, square * i - (square / 4), square / 16);
                }
            }
            else
            {
                for (int i = 1; i < 9; i++)
                {
                    g.DrawString(((9 - i)).ToString(), font, aBlackSquareBrushes, square / 16, square * i - (square / 4));
                    g.DrawString(Char.ConvertFromUtf32(65 + (9 - i) - 1), font, aBlackSquareBrushes, square * i - (square / 4), square / 16);
                }
            }
        }
Exemplo n.º 2
0
 public static Piece.Color OtherColor(Piece.Color pColor)
 {
     if (pColor.Equals(Piece.Color.WHITE))
     {
         return(Piece.Color.BLACK);
     }
     else
     {
         return(Piece.Color.WHITE);
     }
 }