Exemplo n.º 1
0
        public SquareVM(Square square, BoardVM board)
        {
            Board  = board;
            Square = square;

            Square.PieceChanged             += (sender, e) => { this.RaisePropertyChanged(nameof(Piece)); };
            Square.ControlledByBlackChanged += (sender, e) => { this.RaisePropertyChanged(nameof(IsControlledByBlack)); };
            Square.ControlledByWhiteChanged += (sender, e) => { this.RaisePropertyChanged(nameof(IsControlledByWhite)); };
        }
Exemplo n.º 2
0
        public BoardControl(BoardVM vm,
                            IImagesFactory piecesImageFactory)
        {
            InitializeComponent();

            Border.BorderBrush  = new ImageBrush(new BitmapImage(BORDER_URI));
            _piecesImageFactory = piecesImageFactory;

            _vm         = vm;
            DataContext = vm;
            Init();
        }
Exemplo n.º 3
0
        public BoardCellControl(SquareVM vm,
                                IImagesFactory imagesFactory)
        {
            _vm           = vm;
            _board        = vm.Board;
            DataContext   = vm;
            _imageFactory = imagesFactory;

            Position    = vm.Position;
            Background  = GetColorFromVM(vm.Color);
            BorderBrush = System.Windows.Media.Brushes.Black;
            SetGridCoordinate();

            InitializeComponent();

            vm.WhenAny(x => x.Piece, x => x.Value)
            .Subscribe(SetImage);
        }
Exemplo n.º 4
0
 public MainWindowVM(IBoardFactory boardFactory,
                     IStartingPiecesSetFactory pieceFactory)
 {
     Board = new BoardVM(boardFactory.GetBoard(pieceFactory));
 }