コード例 #1
0
        public SoundQuestionWindowView(SoundQuestionWindowViewModel viewModel)
        {
            InitializeComponent();
            this.DataContext = viewModel;

            closeEvent = viewModel.EventAggregator.GetEvent<CloseEvent>();
            token = closeEvent.Subscribe((o) =>
                                                                                   {
                                                                                       System.Diagnostics.Trace.WriteLine("Close stop event");
                                                                                       viewModel.Stop();
                                                                                       viewModel.Dispose();

                                                                                       this.Close();
                                                                                       this.Close();
                                                                                       this.Close();
                                                                                   }, ThreadOption.UIThread, true);
            System.Diagnostics.Trace.WriteLine(token);

            this.PreviewKeyDown += ((QuestionWindowViewModel)DataContext).InputService.ButtonDownEventHandler;
            this.PreviewKeyUp += ((QuestionWindowViewModel)DataContext).InputService.ButtonUpEventHandler;
        }
コード例 #2
0
ファイル: MainViewModel.cs プロジェクト: ludoleif/JeBuzzdy
        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();
            }
        }