Beispiel #1
0
        public MenuViewModel(MainViewModel mainViewModel, RuleSetViewModel ruleSet)
        {
            _mainViewModel = mainViewModel;
            _ruleSet       = ruleSet;

            Exit    = new RelayCommand(ExitGame);
            Options = new RelayCommand(NavigateToOptionsView);
            NewGame = new RelayCommand(StartNewGame);
        }
        public GameViewModel(MainViewModel mainViewModel, MenuViewModel menuViewModel, RuleSetViewModel ruleSet)
        {
            _mainViewModel = mainViewModel;
            _menuViewModel = menuViewModel;
            _ruleSet       = ruleSet;

            _transparentCard = new CardViewModel()
            {
                CardPath = Properties.Resources.EmptyCardPath
            };
            _transparentContainer = new ContainerViewModel()
            {
                CardPath = _transparentCard.CardPath
            };
            _backCard = new CardViewModel()
            {
                CardPath = Properties.Resources.BackCardPath
            };

            TakeCardEventResource = new EventResource(EventName.MouseLeftButtonDownEvent);

            CreateClosedDecks();
            CreateOpenDecks();

            Deal  = new RelayCommand(DealCard);
            Reset = new RelayCommand(ResetGame);
            Back  = new RelayCommand(BackToMenu);
            Undo  = new RelayCommand(UndoLastCard);

            if (_ruleSet.TimerEnabled)
            {
                _timer          = new Timer(1000);
                _timer.Elapsed += _timer_Elapsed;
                _timeSpan       = TimeSpan.FromSeconds(1);
                _timer.Start();
                _timer_Elapsed(this, null);
            }

            UndoBtnEnabled = false;
            if (!_ruleSet.UndoEnabled)
            {
                UndoBtnVisibility = Visibility.Hidden;
            }
        }
Beispiel #3
0
        public MainViewModel()
        {
            RuleSetViewModel = new RuleSetViewModel();

            SwitchToMenuView(new MenuViewModel(this, RuleSetViewModel));
        }