Ejemplo n.º 1
0
 private bool IsSquareWhite(BoardIndices loc)
 {
     //simplified from (row % 2 == 0 && col % 2 == 0 || row % 2 == 1 && col % 2 == 1);
     return (loc.Row % 2 == 0 ^ loc.Column % 2 == 1);
 }
Ejemplo n.º 2
0
 private void DrawSquare(Graphics g, BoardIndices loc)
 {
     using (Brush b = new SolidBrush(IsSquareWhite(loc) ? Color.LightGray : Color.Gray))
     {
         g.FillRectangle(b, new Rectangle(GetLeftmostX(loc.Column), GetTopmostY(loc.Row), SQUARE_LENGTH, SQUARE_LENGTH));
     }
 }
Ejemplo n.º 3
0
 private void ChangeSquareBorderColor(Graphics g, Color color, BoardIndices loc)
 {
     int width = Math.Max(BORDER_WIDTH / 2, 1);
     using (Pen p = new Pen(color))
     {
         g.DrawRectangle(p, new Rectangle(GetLeftmostX(loc.Column) - width, GetTopmostY(loc.Row) - width, SQUARE_LENGTH + width, SQUARE_LENGTH + width));
     }
 }
Ejemplo n.º 4
0
 private void DrawPiece(Graphics g, BoardIndices loc, bool white, PieceType type)
 {
     Image img = white ? ChessPieceImageFactory.GetWhitePiece(type) : ChessPieceImageFactory.GetBlackPiece(type);
     int iconWidth = img.Width, iconHeight = img.Height;
     g.DrawImage(img,
             GetLeftmostX(loc.Column) + SQUARE_LENGTH / 2 - iconWidth / 2,
             GetTopmostY(loc.Row) + SQUARE_LENGTH / 2 - iconHeight / 2, iconWidth, iconHeight);
 }
Ejemplo n.º 5
0
 internal SquareCoordinates(bool whiteOnBottom, BoardIndices loc)
 {
     file = whiteOnBottom ? loc.Column : (7 - loc.Column);
     rank = whiteOnBottom ? (7 - loc.Row) : loc.Row;
 }