예제 #1
0
파일: Board.cs 프로젝트: mariocervera/Chess
        public void redrawBoard()
        {
            for (int i = 0; i < NUM_ROWS; i++)
            {
                for (int j = 0; j < NUM_ROWS; j++)
                {
                    if ((i + j) % 2 == 0)
                    {
                        matrix[i, j].BackgroundImage = Image.FromFile(path + "//WhiteWood.gif");
                    }
                    else
                    {
                        matrix[i, j].BackgroundImage = Image.FromFile(path + "//BlackWood.gif");
                    }
                    matrix[i, j].Image = null;
                }
            }

            Iterator it = whitePieces.getIterator();

            while (it.MoveNext())
            {
                drawPiece(it.Current as Piece);
            }

            it = blackPieces.getIterator();
            while (it.MoveNext())
            {
                drawPiece(it.Current as Piece);
            }
        }
예제 #2
0
파일: Board.cs 프로젝트: mariocervera/Chess
        //Methods for painting squares

        private void paintAllowedMovements(List positions)
        {
            int row, column;

            Iterator it = positions.getIterator();

            while (it.MoveNext())
            {
                row    = (it.Current as Position).getRow();
                column = (it.Current as Position).getColumn();
                matrix[row, column].BackgroundImage = null;
                matrix[row, column].BackColor       = Color.LightGreen;
            }
        }
예제 #3
0
        /*
         * Checks whether a given position is valid as a next move.
         */
        public bool isvalidMove(Position newPosition)
        {
            Iterator iterator = allowedMovements.getIterator();

            while (iterator.MoveNext())
            {
                Position p = iterator.Current as Position;
                if (p.Equals(newPosition))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #4
0
파일: Board.cs 프로젝트: mariocervera/Chess
        public void deleteAllowedMovements(List positions)
        {
            int row, column;

            Iterator it = positions.getIterator();

            while (it.MoveNext())
            {
                row    = (it.Current as Position).getRow();
                column = (it.Current as Position).getColumn();
                matrix[row, column].BackColor = Color.Empty;
                if ((row + column) % 2 == 0)
                {
                    matrix[row, column].BackgroundImage = Image.FromFile(Board.getInstance().getPath() + "//WhiteWood.gif");
                }
                else
                {
                    matrix[row, column].BackgroundImage = Image.FromFile(Board.getInstance().getPath() + "//BlackWood.gif");
                }
            }
        }
예제 #5
0
파일: Board.cs 프로젝트: mariocervera/Chess
        public void deleteAllowedMovements(List positions)
        {
            int row, column;

            Iterator it = positions.getIterator();

            while (it.MoveNext())
            {
                row = (it.Current as Position).getRow();
                column = (it.Current as Position).getColumn();
                matrix[row, column].BackColor = Color.Empty;
                if ((row + column) % 2 == 0)
                {
                    matrix[row, column].BackgroundImage = Image.FromFile(Board.getInstance().getPath() + "//WhiteWood.gif");
                }
                else {
                    matrix[row, column].BackgroundImage = Image.FromFile(Board.getInstance().getPath() + "//BlackWood.gif");
                }
            }
        }
예제 #6
0
파일: Board.cs 프로젝트: mariocervera/Chess
        //Methods for painting squares

        private void paintAllowedMovements(List positions)
        {
            int row, column;

            Iterator it = positions.getIterator();

            while (it.MoveNext())
            {
                row = (it.Current as Position).getRow();
                column = (it.Current as Position).getColumn();
                matrix[row, column].BackgroundImage = null;
                matrix[row, column].BackColor = Color.LightGreen;
            }
        }