Exemplo n.º 1
0
        private void panel_DragDrop(object sender, DragEventArgs e)
        {
            if (sender.Equals(panelMain))
            {
                return;
            }
            //debug("drag drop");
            //target control will accept data here
            Panel destination = (Panel)sender;

            //destination.MouseClick += new MouseEventHandler(MainForm_MouseClick);
            destination.BackgroundImage = (Bitmap)e.Data.GetData(typeof(Bitmap));
            PanelTag pt = (PanelTag)_sourceDrag.Tag;

            ((PanelTag)destination.Tag)._piece = (Piece)pt._piece.Clone();
            _sourceDrag = null;
            ((PanelTag)destination.Tag)._piece._square = ((PanelTag)destination.Tag)._square;
            //debug(((PanelTag)destination.Tag)._piece.ToString());
        }
Exemplo n.º 2
0
        private void addTagsToSidePanels()
        {
            //TODO add capabilty to remove pieces from the board by dragging them out
            panelMain.DragEnter += new System.Windows.Forms.DragEventHandler(this.panel_DragEnter);
            panelMain.DragDrop  += new System.Windows.Forms.DragEventHandler(this.panel_DragDrop);

            PanelTag kingWhiteTag   = new PanelTag(null, new King(null, Position.Players.White));
            PanelTag kingBlackTag   = new PanelTag(null, new King(null, Position.Players.Black));
            PanelTag queenWhiteTag  = new PanelTag(null, new Queen(null, Position.Players.White));
            PanelTag queenBlackTag  = new PanelTag(null, new Queen(null, Position.Players.Black));
            PanelTag rookWhiteTag   = new PanelTag(null, new Rook(null, Position.Players.White));
            PanelTag rookBlackTag   = new PanelTag(null, new Rook(null, Position.Players.Black));
            PanelTag bishopWhiteTag = new PanelTag(null, new Bishop(null, Position.Players.White));
            PanelTag bishopBlackTag = new PanelTag(null, new Bishop(null, Position.Players.Black));
            PanelTag knightWhiteTag = new PanelTag(null, new Knight(null, Position.Players.White));
            PanelTag knightBlackTag = new PanelTag(null, new Knight(null, Position.Players.Black));
            PanelTag pawnWhiteTag   = new PanelTag(null, new Pawn(null, Position.Players.White, null));
            PanelTag pawnBlackTag   = new PanelTag(null, new Pawn(null, Position.Players.Black, null));
            PanelTag panelMainTag   = new PanelTag(null, new Pawn(null, Position.Players.Black, null));

            whiteKing.Tag   = kingWhiteTag;
            blackKing.Tag   = kingBlackTag;
            whiteQueen.Tag  = queenWhiteTag;
            blackQueen.Tag  = queenBlackTag;
            whiteRook.Tag   = rookWhiteTag;
            blackRook.Tag   = rookBlackTag;
            whiteBishop.Tag = bishopWhiteTag;
            blackBishop.Tag = bishopBlackTag;
            whiteKnight.Tag = knightWhiteTag;
            blackKnight.Tag = knightBlackTag;
            whitePawn.Tag   = pawnWhiteTag;
            blackPawn.Tag   = pawnBlackTag;
            panelMain.Tag   = panelMainTag;
            //string s = @"C:\Users\zvika\Documents\Visual Studio 2008\Projects\ChessPuzzleSolver\ChessPuzzleSolver\";
            //blackPawn.BackgroundImage = new Bitmap(s+"bishopWhite.png");
        }
Exemplo n.º 3
0
        private void FillBoard(Position pos)
        {
            foreach (Piece p in pos.mWhitePieces)
            {
                int      file = p._square._file;
                int      rank = p._square._rank;
                PanelTag pt   = new PanelTag();
                pt._piece  = (Piece)p.Clone();
                pt._square = p._square;
                _grid[NUM_RANKS - rank, file - 1].Tag = pt;

                if (p is King)
                {
                    _grid[NUM_RANKS - rank, file - 1].BackgroundImage = global::ChessPuzzleSolver.Properties.Resources.kingWhite;
                }
                else if (p is Queen)
                {
                    _grid[NUM_RANKS - rank, file - 1].BackgroundImage = global::ChessPuzzleSolver.Properties.Resources.queenWhite;
                }
                else if (p is Rook)
                {
                    _grid[NUM_RANKS - rank, file - 1].BackgroundImage = global::ChessPuzzleSolver.Properties.Resources.rookWhite;
                }
                else if (p is Bishop)
                {
                    _grid[NUM_RANKS - rank, file - 1].BackgroundImage = global::ChessPuzzleSolver.Properties.Resources.bishopWhite;
                }
                else if (p is Knight)
                {
                    _grid[NUM_RANKS - rank, file - 1].BackgroundImage = global::ChessPuzzleSolver.Properties.Resources.knightWhite;
                }
                else if (p is Pawn)
                {
                    _grid[NUM_RANKS - rank, file - 1].BackgroundImage = global::ChessPuzzleSolver.Properties.Resources.pawnWhite;
                }
            }
            foreach (Piece p in pos.mBlackPieces)
            {
                int      file = p._square._file;
                int      rank = p._square._rank;
                PanelTag pt   = new PanelTag();
                pt._piece  = (Piece)p.Clone();
                pt._square = p._square;
                _grid[NUM_RANKS - rank, file - 1].Tag = pt;

                if (p is King)
                {
                    _grid[NUM_RANKS - rank, file - 1].BackgroundImage = global::ChessPuzzleSolver.Properties.Resources.kingBlack;
                }
                else if (p is Queen)
                {
                    _grid[NUM_RANKS - rank, file - 1].BackgroundImage = global::ChessPuzzleSolver.Properties.Resources.queenBlack;
                }
                else if (p is Rook)
                {
                    _grid[NUM_RANKS - rank, file - 1].BackgroundImage = global::ChessPuzzleSolver.Properties.Resources.rookBlack;
                }
                else if (p is Bishop)
                {
                    _grid[NUM_RANKS - rank, file - 1].BackgroundImage = global::ChessPuzzleSolver.Properties.Resources.bishopBlack;
                }
                else if (p is Knight)
                {
                    _grid[NUM_RANKS - rank, file - 1].BackgroundImage = global::ChessPuzzleSolver.Properties.Resources.knightBlack;
                }
                else if (p is Pawn)
                {
                    _grid[NUM_RANKS - rank, file - 1].BackgroundImage = global::ChessPuzzleSolver.Properties.Resources.pawnBlack;
                }
            }

            if (pos.mTurn == Position.Players.White)
            {
                whiteTurn.Checked = true;
            }
            else
            {
                blackTurn.Checked = true;
            }
        }