private void DrawSquare(System.Windows.Forms.PaintEventArgs e, Graphics surface, BoardLocation boardLocation, int x, int y) { //draw bounding black square surface.DrawRectangle(PenBorder, x, y, 64, 64); //draw light or dark square background surface.FillRectangle( boardLocation.Color() == BoardLocationColor.Light ? LightSquareBrush: DarkSquareBrush, x + 1, y + 1, 63, 63); //draw square as a valid move square if (MovingPiece != ChessPiece.None) { if (IsValidMove(boardLocation)) { surface.FillRectangle(LegalMoveBrush, x + 1, y + 1, 63, 63); } } //Draw the legend for squares (a-h and 1-8) if (boardLocation.Column() == 0) { surface.DrawString(Convert.ToString((boardLocation.Row() + 1)), Font, BlackBoardTextbrush, x + 3, y + 25); } if (boardLocation.Row() == 0) {//ascii A=65 surface.DrawString(Convert.ToChar(65 + boardLocation.Column()).ToString(), Font, BlackBoardTextbrush, x + 27, y + 48); } //dont draw piece if its being moved... if ((MovingPiece != ChessPiece.None) && (boardLocation == MovingPieceBoardLocation)) { return; } //draw the icon on the board.. if (Game.Board[boardLocation] != ChessPiece.None) { surface.DrawImage( imageList32.Images[ToImageIndex(boardLocation)], x + 16, y + 16, 32, 32); } }