Esempio n. 1
0
        public MainViewModel(Window owner, IEventAggregator eventAggregator, RoundService roundService, StandingsService standingsService, InputService inputService)
        {
            _owner = owner;
            _eventAggregator = eventAggregator;
            _roundService = roundService;
            _standingsService = standingsService;
            _inputService = inputService;

            _roundService.PropertyChanged += (s, e) =>
                                                 {
                                                     if (e.PropertyName.Equals("CurrentRound"))
                                                     {
                                                         RaisePropertyChanged(() => Category1);
                                                         RaisePropertyChanged(() => Category2);
                                                         RaisePropertyChanged(() => Category3);
                                                         RaisePropertyChanged(() => Category4);
                                                         RaisePropertyChanged(() => Category5);
                                                     }
                                                 };

            _standingsService.PropertyChanged += (s, e) =>
                                                     {
                                                         if(e.PropertyName.Equals("IsScoresShown"))
                                                         {
                                                             RaisePropertyChanged(() => IsScoresShown);
                                                         }
                                                     };
        }
Esempio n. 2
0
        public AdminAreaViewModel(IEventAggregator eventAggregator, QuestionGridViewModel questionGridViewModel, 
            RoundService roundService, StandingsService standingsService, InputService inputService)
        {
            _eventAggregator = eventAggregator;
            _roundService = roundService;
            _standingsService = standingsService;
            _inputService = inputService;
            QuestionGridViewModel = questionGridViewModel;
            _round = 1;
            ChangeRoundCommand = new DelegateCommand<object>(ChangedRound);
            ShowScoresCommand = new DelegateCommand(() => _standingsService.ToggleShowScores());
            IsSelecting = _standingsService.Players[new Random().Next(0, 4)];
            _eventAggregator.GetEvent<CategoryClickedEvent>().Subscribe(DisplayQuestion);
            _eventAggregator.GetEvent<ActivePlayerChangedEvent>().Subscribe(ActivePlayerChangedEventHandler);

            _eventAggregator.GetEvent<NewSelectorEvent>().Subscribe((i) =>
                {
                    IsSelecting = _standingsService.Players[i - 1];
                });

            _inputService.PropertyChanged +=
                (s, e) =>
                    {
                        if(e.PropertyName.Equals("ActiveController"))
                            RaisePropertyChanged(() => CurrentActive);
                    };

            _standingsService.PropertyChanged +=
                (s, e) =>
                    {
                        if (e.PropertyName.Equals("TimeLeft"))
                            RaisePropertyChanged(() => TimeLeft);
                    };
        }
Esempio n. 3
0
        public QuestionGridViewModel(IEventAggregator eventAggregator, RoundService roundService, StandingsService standingsService)
        {
            _eventAggregator = eventAggregator;
            _roundService = roundService;
            _standingsService = standingsService;

            AddCommand = new DelegateCommand<object>(AddPoints);
            SubstractCommand = new DelegateCommand<object>(Substract);

            StartCommand = new DelegateCommand(Start);
            StopCommand = new DelegateCommand(Stop);
            BonusCommand = new DelegateCommand(Bonus);
            WrongCommand = new DelegateCommand(Wrong);
            CorrectCommand = new DelegateCommand(Correct);
            CloseCommand = new DelegateCommand(Close);
            BonusAddCommand = new DelegateCommand<object>(AddBonusPoints);

            _showEvent = _eventAggregator.GetEvent<ShowEvent>();
            _activateEvent = _eventAggregator.GetEvent<ActivateEvent>();
            _stopEvent = _eventAggregator.GetEvent<StopEvent>();
            _bonusEvent = _eventAggregator.GetEvent<BonusEvent>();
            _closeEvent = _eventAggregator.GetEvent<CloseEvent>();

            _newSelectorEvent = _eventAggregator.GetEvent<NewSelectorEvent>();
        }
Esempio n. 4
0
        public Window1()
        {
            InitializeComponent();
            var eventAggregator = new EventAggregator();

            _standingsService = new StandingsService(5);
            _roundService = new RoundService();
            //var names = new List<string> {"Emil", "CJ", "Rune", "Andreas", "Kristoffer"};
            var counter = 1;
            foreach (var p in _standingsService.Players)
            {
                p.Name = "P" + counter++;
                //p.Name = names[counter - 1];
                //p.Points = counter*100;
                //counter++;
            }
            _inputService = new InputService(eventAggregator, _standingsService);

            _questionGridViewModel = new QuestionGridViewModel(eventAggregator, _roundService, _standingsService);

            _adminAreaViewModel = new AdminAreaViewModel(eventAggregator, _questionGridViewModel, _roundService, _standingsService, _inputService);
            _adminArea = new AdminAreaView(_adminAreaViewModel);
            _adminArea.Show();
            var mainViewModel = new MainViewModel(this, eventAggregator, _roundService, _standingsService, _inputService);
            MainView.DataContext = mainViewModel;

            this.PreviewKeyDown += _inputService.ButtonDownEventHandler;
            this.PreviewKeyUp += _inputService.ButtonUpEventHandler;

            new System.Threading.Tasks.TaskFactory().StartNew(() => { System.Threading.Thread.Sleep(100);
                                                                        UIHelperService.ExecuteUIAction(() =>
                                                                                                        this.WindowState
                                                                                                        =
                                                                                                        WindowState.
                                                                                                            Minimized);
            });
        }