public PromotionPicturebox(Control parent, ChessClient chessClient, Move move, ChessController.Pieces.ChessPiece.Colors color)
        {
            Bitmap board = chessClient.GetImageOfBoard();

            Location = new Point(0, 0);
            Size     = parent.Size;
            Parent   = parent;
            Parent.Controls.Add(this);


            Graphics g = Graphics.FromImage(board);
            Brush    b = new SolidBrush(Color.FromArgb(128, 0, 0, 0));

            g.FillRectangle(b, new Rectangle(0, 0, board.Width, board.Height));
            Image = board;

            SizeMode = PictureBoxSizeMode.StretchImage;
            BringToFront();

            this.chessClient = chessClient;
            this.move        = move;

            rook   = new ChessController.Pieces.Rook(color);
            knight = new ChessController.Pieces.Knight(color);
            bishop = new ChessController.Pieces.Bishop(color);
            queen  = new ChessController.Pieces.Queen(color);

            DrawAll();

            Rook.MouseDown   += (sender, args) => SetPromotion(rook);
            Knight.MouseDown += (sender, args) => SetPromotion(knight);
            Bishop.MouseDown += (sender, args) => SetPromotion(bishop);
            Queen.MouseDown  += (sender, args) => SetPromotion(queen);
        }
예제 #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            Rectangle screen = Screen.PrimaryScreen.Bounds;

            int boardSize = (screen.Height / 2) / 8 * 8;

            pictureBox1.Width  = boardSize;
            pictureBox1.Height = boardSize;
            Height             = boardSize + 43;
            Width = (int)(1.75 * boardSize);
            pictureBox2.Location = new Point(boardSize, 0);


            chessClient = new ChessClient(pictureBox1);
        }