private void BoardPaint(object sender, PaintEventArgs e) { char[,] boardTab = lastBoardArr; Graphics g = e.Graphics; SolidBrush brush = new SolidBrush(lightColor); for (int i = 0; i < nbBoxEdge; i++) { for (int j = 0; j < nbBoxEdge; j++) { if ((i % 2 == 0 && j % 2 == 0) || (i % 2 != 0 && j % 2 != 0)) { brush.Color = lightColor; } else { brush.Color = darkColor; } Rectangle rect = new Rectangle(i * boxSize, j * boxSize, boxSize, boxSize); g.FillRectangle(brush, rect); } } SolidBrush brushCircle = new SolidBrush(Color.Gray); int radius = boxSize / 2; foreach (string move in movesToDisp) { List <int> coordIj = board.CoordToIj(move); Rectangle moveRect = new Rectangle(coordIj[1] * boxSize + radius / 2, coordIj[0] * boxSize + radius / 2, radius, radius); g.FillEllipse(brushCircle, moveRect); } RectangleF boxRect = new RectangleF(0, 0, boxSize, boxSize); GraphicsUnit units = GraphicsUnit.Pixel; for (int i = 0; i < nbBoxEdge; i++) { for (int j = 0; j < nbBoxEdge; j++) { if (boardTab[i, j] != ' ') { g.DrawImage(piecesImage[(PieceEnum)boardTab[i, j]], j * boxSize, i * boxSize, boxRect, units); } } } }
protected List <string> GetLineMove(int vertInc = 0, int horInc = 0) { List <int> IjCoord = board.CoordToIj(pos); List <string> lineMove = new List <string>(); int i, j; for (int n = 1; n < board.GetBoardEdgeLen(); n++) { i = IjCoord[0] + n * vertInc; j = IjCoord[1] + n * horInc; if (board.InBoard(i, j)) { if (board.IsVoid(i, j)) { lineMove.Add(board.IjToCoord(i, j)); } else { if (board.IsKillable(board.IjToCoord(i, j), color)) { lineMove.Add(board.IjToCoord(i, j)); } break; } } else { break; } } return(lineMove); }