public PictureQuestionWindowView(PictureQuestionWindowViewModel viewModel) { InitializeComponent(); this.DataContext = viewModel; viewModel.EventAggregator.GetEvent<CloseEvent>().Subscribe((o) => this.Close()); this.PreviewKeyDown += ((QuestionWindowViewModel)DataContext).InputService.ButtonDownEventHandler; this.PreviewKeyUp += ((QuestionWindowViewModel)DataContext).InputService.ButtonUpEventHandler; }
public void CategoryClicked(string category) { string cat = category.Substring(1, 1); string points = category.Substring(3, 1); if(!CanSelect(cat, points)) return; var key = int.Parse(cat)-1; var value = int.Parse(points)-1; _eventAggregator.GetEvent<CategoryClickedEvent>().Publish(new KeyValuePair<int, int>(key, value)); var q = _roundService.CurrentRound.Questions[new KeyValuePair<int, int>(key, value)]; var qtype = q.GetType(); if(qtype == typeof(TextQuestion)) { var viewModel = new TextQuestionWindowViewModel(_eventAggregator, _standingsService, _inputService); var view = new TextQuestionWindowView(viewModel) { Owner = _owner, Left = _owner.Left - 1, Width = _owner.ActualWidth, Top = _owner.Top, Height = _owner.ActualHeight }; view.Show(); } if (qtype == typeof(PictureQuestion)) { var viewModel = new PictureQuestionWindowViewModel(_eventAggregator, _standingsService, _inputService) { Path = ((PictureQuestion) q).Path, IsActive = false }; var view = new PictureQuestionWindowView(viewModel) { Owner = _owner, Left = _owner.Left - 1, Width = _owner.ActualWidth, Top = _owner.Top, Height = _owner.ActualHeight }; view.Show(); } if (qtype == typeof(SoundQuestion)) { var viewModel = new SoundQuestionWindowViewModel(_eventAggregator, _standingsService, _inputService) { Path = ((SoundQuestion)q).Path, IsActive = false }; var view = new SoundQuestionWindowView(viewModel) { Owner = _owner, Left = _owner.Left - 1, Width = _owner.ActualWidth, Top = _owner.Top, Height = _owner.ActualHeight }; view.Show(); } if (qtype == typeof(VideoQuestion)) { var viewModel = new VideoQuestionWindowViewModel(_eventAggregator, _standingsService, _inputService) { Path = ((VideoQuestion)q).Path, IsActive = false }; var view = new VideoQuestionWindowView(viewModel) { Owner = _owner, Left = _owner.Left - 1, Width = _owner.ActualWidth, Top = _owner.Top, Height = _owner.ActualHeight }; view.Show(); } }