Exemplo n.º 1
0
        /// <summary>
        /// Creates a new Chess board
        /// </summary>
        public Board()
        {
            squares = new Dictionary <string, Square>(8 * 8);
            bool white = false;
            int  startx = 0, starty = 0;
            int  x = startx;
            int  y = starty;

            for (int r = 8; r > 0; r--)
            {
                white = !white;
                Square square = null;
                for (int c = 0; c < 8; c++)
                {
                    square = new Square(colLabels[c], r, white, x, y);
                    squares.Add(square.ToString(), square);
                    Program.display.AddSquare(square);
                    white = !white;
                    x    += square.Width;
                }
                x  = startx;
                y += square.Height;
            }
            AddPieces();
        }