Example #1
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            var main = new Rect(0, 0, ActualWidth, ActualHeight);

            drawingContext.DrawRectangle(Background, null, main);

            var size     = SquareSize * 8D;
            var left     = (main.Width - size) / 2D;
            var top      = (main.Height - size) / 2D;
            var area     = new Rect(left, top, size, size);
            var board    = Board ?? CBoard.GetDefaultBoard();
            var typeFace = new Typeface(FontFamily, FontStyle, FontWeight, FontStretch);

            for (var x = 0; x < 8; x++)
            {
                for (var y = 0; y < 8; y++)
                {
                    DrawField(drawingContext, board, area, x, y, typeFace, FontSize);
                }
            }
        }
Example #2
0
        private void Reset()
        {
            ChessBoard.Board = CBoard.GetDefaultBoard();
            _player          = EPlayer.White;

            //ChessBoard.Board = new CBoard
            //{
            //	["B7"] = new CPieceKing(EPlayer.White),
            //	["D7"] = new CPieceKing(EPlayer.Black),
            //	["E5"] = new CPieceQueen(EPlayer.White),
            //	["E6"] = new CPieceKnight(EPlayer.White),
            //	["E7"] = new CPieceBishop(EPlayer.Black),
            //};
            //_player = EPlayer.White;

            //ChessBoard.Board = new CBoard
            //{
            //	["H6"] = new CPieceKing(EPlayer.Black),
            //	["H8"] = new CPieceKing(EPlayer.White),
            //	["G1"] = new CPieceQueen(EPlayer.Black)
            //};
            //_player = EPlayer.White;

            //ChessBoard.Board = new CBoard
            //{
            //	["B6"] = new CPieceKnight(EPlayer.White),
            //	["B5"] = new CPieceKing(EPlayer.White),
            //	["C7"] = new CPieceKing(EPlayer.Black),
            //	["F7"] = new CPieceKnight(EPlayer.White),
            //	["H7"] = new CPieceQueen(EPlayer.White),
            //};
            //_player = EPlayer.White;

            _game = new CGame(ChessBoard.Board);
            ChessBoard.InvalidateVisual();
            ListBox.ItemsSource = null;
        }