Esempio n. 1
0
        public void draw(MoveHistory moveHistory)
        {
            this.whiteRemovedPieces.Controls.Clear();
            this.blackRemovedPieces.Controls.Clear();
            List <Piece> whiteRemovedPiece = new List <Piece>();
            List <Piece> blackRemovedPiece = new List <Piece>();

            foreach (Move move in moveHistory.getMoveHistory())
            {
                if (move.isAttack())
                {
                    Piece attackedPiece = move.getAttackedPiece();
                    if (attackedPiece.getSide() == Sides.WHITE)
                    {
                        whiteRemovedPiece.Add(attackedPiece);
                    }
                    else
                    {
                        blackRemovedPiece.Add(attackedPiece);
                    }
                }
            }


            foreach (Piece piece in whiteRemovedPiece)
            {
                Panel panel = new Panel();
                panel.Size   = new Size(60, 30);
                panel.Margin = new Padding(0);
                string alliance = piece.getSide() == Sides.WHITE ? "W" : "B";
                string type     = piece.getPieceType().getPieceName();
                panel.BackgroundImage       = Image.FromFile(Application.StartupPath + "\\images\\figures\\" + alliance + type + ".gif");
                panel.BackgroundImageLayout = ImageLayout.Zoom;
                whiteRemovedPieces.Controls.Add(panel);
            }

            foreach (Piece piece in blackRemovedPiece)
            {
                Panel panel = new Panel();
                panel.Size   = new Size(60, 30);
                panel.Margin = new Padding(0);
                string alliance = piece.getSide() == Sides.WHITE ? "W" : "B";
                string type     = piece.getPieceType().getPieceName();
                panel.BackgroundImage       = Image.FromFile(Application.StartupPath + "\\images\\figures\\" + alliance + type + ".gif");
                panel.BackgroundImageLayout = ImageLayout.Zoom;
                blackRemovedPieces.Controls.Add(panel);
            }

            this.Refresh();
        }