/// <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); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); int example = 0; // Change this to test various valid string while (example < 5) { // Setup Objects ChessBoardForm cbbForm = new ChessBoardForm(); ChessBoardImageGenerator cbbImgGen = new ChessBoardImageGenerator(cbbForm); cbbForm.ImageGenerator = cbbImgGen; // Setup Output Fields cbbImgGen.FileNameImageFormat = ImageFormat.Png; cbbImgGen.ImageFileName = @"..\..\DigitalAssets\GameBoardImage.png"; // Setup Input Fields cbbImgGen.WhitePlayerButtonText = cbbImgGen.WhitePlayerName = "Zach"; cbbImgGen.BlackPlayerButtonText = cbbImgGen.BlackPlayerName = "Joe"; if (cbbImgGen.ImageFileName.Length > 0) { int index = cbbImgGen.ImageFileName.IndexOf(".png"); string newFileName = cbbImgGen.ImageFileName.Insert(index, example.ToString()); cbbImgGen.ImageFileName = newFileName; } else { throw new Exception("ERROR: Bad Image Filename"); } // Expected Chess Board States in Forsyth-Edwards Notation string gameState = ""; switch (example) { case 0: // Rank 1 Rank 2 3 4 5 6 Rank 7 Rank 8 gameState = "RNBQKBNR/PPPPPPPP/8/8/8/8/pppppppp/rnbqkbnr w KQkq - 0 1"; // Initial state - White has the Honor break; case 1: gameState = "RNBQKBNR/PPPP1PPP/8/4P3/8/8/pppppppp/rnbqkbnr b KQkq e3 0 1"; // Another state - White's Turn break; case 2: gameState = "RNBQKBNR/PPPP1PPP/8/4P3/2p5/8/pp1ppppp/rnbqkbnr w KQkq c6 0 2"; // Another state - Black's Turn break; case 3: gameState = "RNBQKB1R/PPPP1PPP/5N2/4P3/2p5/8/pppp1ppp/rnbqkbnr b KQkq - 1 2"; // Another state - White's Turn break; case 4: gameState = "RNBQKB1R/PPPP1PPP/5N2/4P3/2p5/5n2/pppp1ppp/rnbqkb1r w KQkq - 1 2"; // Another state - Black's Turn break; default: gameState = "RNBQKBNR/PPPPPPPP/8/8/8/8/pppppppp/rnbqkbnr w KQkq - 0 1"; // Initial state - White has the Honor break; } cbbForm.ChessBoardStateFEN = gameState; Application.Run(cbbForm); Application.Exit(); example++; } }