Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            DataContext = Model.MainWindowViewModel;

            //Time handle
            _gameTimer          = new Timer(Helper.OneSecond);
            _gameTimer.Elapsed += (sender, e) => { Model.MainWindowViewModel.Seconds++; };
            _gameTimer.Start();

            #region Set window acording to the game mode

            UserControl capturedPiecesUc = null;
            switch (_gameMode)
            {
            case GameMode.ClassicChess:
                var classicChessGame = new ClassicChessGame();
                pieces = new List <Piece>(classicChessGame.Pieces);
                break;

            default:
                this.Close();
                break;
            }


            #endregion

            PopulateFields(pieces);             //Populate & bindings
        }
Ejemplo n.º 2
0
        private void OnGameModeChanged(GameMode changedto)
        {
            //Time handle
            Model.GameWindowModel.Seconds = 1;             //reset time
            _gameTimer          = new Timer(Helper.OneSecond);
            _gameTimer.Elapsed += (sender, e) => { Model.GameWindowModel.Seconds++; };
            _gameTimer.Start();

            #region Set window acording to the game mode

            UserControl capturedPiecesUc = null;
            switch (changedto)
            {
            case GameMode.ClassicChess:
                capturedPiecesUc = new ClassicChessCapturedPieces();
                var classicChessGame = new ClassicChessGame();
                pieces           = new List <Piece>(classicChessGame.Pieces);
                Helper.BoardSize = classicChessGame.BoardSize;
                break;

            case GameMode.OwnGameMode1:
                var ownGameMode1 = new OwnModeGame();
                pieces           = new List <Piece>(ownGameMode1.Pieces);
                Helper.BoardSize = ownGameMode1.BoardSize;
                break;

            default:
                //TODO LOG
                //this.Close();
                break;
            }

            if (capturedPiecesUc != null)
            {
                UC_CapturedPieces.Children.RemoveRange(0, UC_CapturedPieces.Children.Count);                 //Remove all
                UC_CapturedPieces.Children.Add(capturedPiecesUc);
            }

            #endregion

            PopulateFields(pieces);             //Populate & bindings
        }