/// <summary> /// ChessBoardStatic /// </summary> /// <param name="aChessBoardBox"></param> /// <returns></returns> public ChessBoard(ChessBoardImageGenerator aChessBoardImageGenerator, PictureBox aPictureBox) { chessBoardImageGenerator = aChessBoardImageGenerator; if (aPictureBox.Handle == null) { throw new Exception("Bad PictureBox"); } chessBoardBox = aPictureBox; squareList = new ArrayList(); whitePieceList = new ArrayList(); blackPieceList = new ArrayList(); chessPieceFactory = new ChessPieceFactory(); squareFactory = new ChessSquareFactory(); squareLocator = new ChessSquareLocator(); chessBoardInitializer = new ChessBoardInitializer( this, squareList, whitePieceList, blackPieceList, squareFactory, chessPieceFactory, squareLocator); chessBoardInitializer.Initialize(); chessBoardBox.Paint += new PaintEventHandler(paint); chessLocationCalculatorFactory = new ChessLocationCalculatorFactory(this); }
/// <summary> /// ChessBoardInitializer Constructor /// </summary> /// <param name="aChessBoard"></param> /// <param name="aChessFENString"></param> /// <param name="aSquareList"></param> /// <param name="aWhitePieceList"></param> /// <param name="aBlackPieceList"></param> /// <param name="aSquareFactory"></param> /// <param name="aPieceFactory"></param> /// <param name="aSquareLocator"></param> public ChessBoardInitializer(ChessBoard aChessBoard, ArrayList aSquareList, ArrayList aWhitePieceList, ArrayList aBlackPieceList, ChessSquareFactory aSquareFactory, ChessPieceFactory aPieceFactory, ChessSquareLocator aSquareLocator) { chessBoard = aChessBoard; squareList = aSquareList; whitePieceList = aWhitePieceList; blackPieceList = aBlackPieceList; squareFactory = aSquareFactory; pieceFactory = aPieceFactory; squareLocator = aSquareLocator; }
/// <summary> /// Draw Method /// </summary> /// <param name="g"></param> /// <param name="aChessPieceFactory"></param> internal void Draw(Graphics g, ChessPieceFactory aChessPieceFactory) { ChessPieceRectangle chessPieceRectangle = aChessPieceFactory.GetChessPieceRectangle(chessPieceType, chessPieceColor); if (chessPieceRectangle != null) { location.X = this.GetStartLocation().X; location.Y = this.GetStartLocation().Y; chessPieceRectangle.Draw(g, location); } }