Exemple #1
0
        private Dictionary <Piece, Bitmap> PieceImages; //BlackPawn,WhitePawn,BlackRook,WhiteRook,BlackKnight,WhiteKnight,BlackBishop,WhiteBishop
                                                        //,BlackKing, WhiteKing, BlackQueen, WhiteQueen;


        internal Chessboard(Color Light, Color Dark, ChessGame Game)
        {
            InitializeComponent();

            PieceImages = new Dictionary <Piece, Bitmap>();
            PieceImages.Add(Piece.BPAWN, new Bitmap(new Bitmap(@"bp.png"), new Size(64, 64)));
            PieceImages.Add(Piece.WPAWN, new Bitmap(new Bitmap(@"wp.png"), new Size(64, 64)));
            PieceImages.Add(Piece.BROOK, new Bitmap(new Bitmap(@"br.png"), new Size(64, 64)));
            PieceImages.Add(Piece.WROOK, new Bitmap(new Bitmap(@"wr.png"), new Size(64, 64)));
            PieceImages.Add(Piece.BKNIGHT, new Bitmap(new Bitmap(@"bkn.png"), new Size(64, 64)));
            PieceImages.Add(Piece.WKNIGHT, new Bitmap(new Bitmap(@"wkn.png"), new Size(64, 64)));
            PieceImages.Add(Piece.BBISHOP, new Bitmap(new Bitmap(@"bb.png"), new Size(64, 64)));
            PieceImages.Add(Piece.WBISHOP, new Bitmap(new Bitmap(@"wb.png"), new Size(64, 64)));
            PieceImages.Add(Piece.BKING, new Bitmap(new Bitmap(@"bk.png"), new Size(64, 64)));
            PieceImages.Add(Piece.WKING, new Bitmap(new Bitmap(@"wk.png"), new Size(64, 64)));
            PieceImages.Add(Piece.BQUEEN, new Bitmap(new Bitmap(@"bq.png"), new Size(64, 64)));
            PieceImages.Add(Piece.WQUEEN, new Bitmap(new Bitmap(@"wq.png"), new Size(64, 64)));
            LightColor          = new SolidBrush(Light);
            DarkColor           = new SolidBrush(Dark);
            Highlighted         = new SolidBrush(Color.FromArgb(100, Color.FromName("yellow")));
            this.Game           = Game;
            Player1.Text        = Game.Player1Name;
            Player2.Text        = Game.Player2Name;
            Game.Promote       += Game_Promote;
            Game.Check_in_Game += Game_Check;
            Game.Move_Pieces   += Game_Moves;
            Game.Checkmate     += Game_Checkmate;
            Game.StalemateGame += Game_Stalemate;
            Game.Capture       += Game_Capture;
            player_check        = new SoundPlayer(@"Resources\check.wav");
            player_checkmate    = new SoundPlayer(@"Resources\checkmate.wav");
            player_stalemate    = new SoundPlayer(@"Resources\checkmate.wav");
            player_time_left    = new SoundPlayer(@"Resources\time_left_clock.wav");
            player_move         = new SoundPlayer(@"Resources\chess_move.wav");
            player_capture      = new SoundPlayer(@"Resources\captures.wav");
            Picked              = new Square(0, 'z');
            Dropped             = new Square(0, 'z');
            Board.Image         = new Bitmap(512, 512);
            Board_Paint(null, null);
            this.listBox1.DataSource = Game.Moves;
            Player1Time.Text         = Game.WhiteTimeLimit.ToString();
            Player2Time.Text         = Game.BlackTimeLimit.ToString();
        }
Exemple #2
0
        private Dictionary <Piece, Bitmap> PieceImages; //BlackPawn,WhitePawn,BlackRook,WhiteRook,BlackKnight,WhiteKnight,BlackBishop,WhiteBishop
                                                        //,BlackKing, WhiteKing, BlackQueen, WhiteQueen;


        internal Chessboard(Color Light, Color Dark, ChessGame Game)
        {
            InitializeComponent();

            PieceImages = new Dictionary <Piece, Bitmap>();
            PieceImages.Add(Piece.BPAWN, new Bitmap(new Bitmap(@"bp.png"), new Size(64, 64)));
            PieceImages.Add(Piece.WPAWN, new Bitmap(new Bitmap(@"wp.png"), new Size(64, 64)));
            PieceImages.Add(Piece.BROOK, new Bitmap(new Bitmap(@"br.png"), new Size(64, 64)));
            PieceImages.Add(Piece.WROOK, new Bitmap(new Bitmap(@"wr.png"), new Size(64, 64)));
            PieceImages.Add(Piece.BKNIGHT, new Bitmap(new Bitmap(@"bkn.png"), new Size(64, 64)));
            PieceImages.Add(Piece.WKNIGHT, new Bitmap(new Bitmap(@"wkn.png"), new Size(64, 64)));
            PieceImages.Add(Piece.BBISHOP, new Bitmap(new Bitmap(@"bb.png"), new Size(64, 64)));
            PieceImages.Add(Piece.WBISHOP, new Bitmap(new Bitmap(@"wb.png"), new Size(64, 64)));
            PieceImages.Add(Piece.BKING, new Bitmap(new Bitmap(@"bk.png"), new Size(64, 64)));
            PieceImages.Add(Piece.WKING, new Bitmap(new Bitmap(@"wk.png"), new Size(64, 64)));
            PieceImages.Add(Piece.BQUEEN, new Bitmap(new Bitmap(@"bq.png"), new Size(64, 64)));
            PieceImages.Add(Piece.WQUEEN, new Bitmap(new Bitmap(@"wq.png"), new Size(64, 64)));
            LightColor    = new SolidBrush(Light);
            DarkColor     = new SolidBrush(Dark);
            Highlighted   = new SolidBrush(Color.FromArgb(100, Color.FromName("yellow")));
            this.Game     = Game;
            Player1.Text  = Game.Player1Name;
            Player2.Text  = Game.Player2Name;
            Game.Promote += Game_Promote;
            Picked        = new Square(0, 'z');
            Dropped       = new Square(0, 'z');
            Board.Image   = new Bitmap(512, 512);
            Board_Paint(null, null);

            // Initializing the Timers.
            this.Player2Time.Text = Game.BlackTimeLimit;
            this.Player1Time.Text = Game.WhiteTimeLimit;

            // Stoping The Timer So It Starts In the First White Move .
            MainTimer.Stop();
        }