Пример #1
0
        private void SystemShutdownHandler(bool isClosed)
        {
            try
            {
                MsPlayer.CloseDevice();
            }
            catch { }
            try
            {
                syncVideoPlayState(false);
                _player.Stop();
            }
            catch { }

            try
            {
                PPTViewer.Close();
            }
            catch { }
            try
            {
                _desktopWindowCollector.PushingData -= _desktopWindowCollector_PushingData;
            }
            catch { }
            try
            {
                _desktopWindowCollector.Dispose();
            }
            catch { }
        }
Пример #2
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            var vm = this.DataContext as SpeechViewModel;

            if (vm != null)
            {
                PPTViewer.SetEventAggregator(vm.EventAggregator);

                _eventSubscriptionManager          = vm.EventSubscriptionManager;
                _desktopWindowCollector            = vm.DesktopWindowCollector;
                _setupVideoLiveAndRecordingDevices = vm.SetupVideoLiveAndRecordingDevices;

                _switchDemonstrationSceneEventSubscriptionToken = _eventSubscriptionManager.Subscribe <SwitchDemonstrationSceneEvent, SwitchDemonstrationSceneContext>(null, SwitchDemonstrationSceneEventHandler, null);

                _systemCloseEventSubscriptionToken = _eventSubscriptionManager.Subscribe <ShutDownEvent, bool>(null, SystemShutdownHandler, null);

                _pptClosedEventSubscriptionToken = _eventSubscriptionManager.Subscribe <PPTClosedEvent, bool>(null, PPTClosedEventHandler, null);

                _eventSubscriptionManager.Subscribe <SelectedDemonstrationWindowEvent, PreviewWindowInfo>(null, SwitchPreviewWindowSceneHandler, null);

                _eventSubscriptionManager.Subscribe <PlayVolumeChangeEvent, int>(null, (volume) =>
                {
                    _player.Volume = (double)volume / 100;
                }, null);
            }
            DefaultScene.Visibility = Visibility.Visible;
            _desktopWindowCollector.SetWindowHandle(DefaultScene.Handle);
            _setupVideoLiveAndRecordingDevices?.SetVideoDevice(_desktopWindowCollector);
        }
Пример #3
0
        private void SwitchDemonstrationSceneEventHandler(SwitchDemonstrationSceneContext context)
        {
            _desktopWindowCollector.PushingData -= _desktopWindowCollector_PushingData;

            switch (context.SceneType)
            {
            case DemonstratioType.PPT:
                AllSceneHidden();
                _player.Pause();
                PPTViewer.OpenPPT(context.UseDevice.ToString());
                DemonstrationPPTScene.Visibility = Visibility;
                _desktopWindowCollector.SetWindowHandle(DemonstrationPPTScene.Handle);
                break;

            case DemonstratioType.VideoDevice:
                AllSceneHidden();
                _player.Pause();
                DemonstrationVideoDeviceScene.Visibility = Visibility.Visible;
                MsPlayer.OpenDevice(context.UseDevice as IVideoDevice);
                _desktopWindowCollector.SetWindowHandle(DemonstrationVideoDeviceScene.Handle);
                break;

            case DemonstratioType.Image:
                _player.Pause();
                AllSceneHidden();
                if (_imagePath != context.UseDevice.ToString())
                {
                    _imagePath = context.UseDevice.ToString();
                    BitmapImage bitmap = new BitmapImage(new Uri(_imagePath));
                    ImageControl.ImageSource = bitmap;
                }
                DefaultScene.Visibility = Visibility.Visible;
                _desktopWindowCollector.SetWindowHandle(DefaultScene.Handle);
                break;

            case DemonstratioType.Video:
                if (context.UseDevice.ToString() != _videoPath)
                {
                    _videoPath = context.UseDevice.ToString();
                    AllSceneHidden();
                    _player.Open(new Uri(_videoPath));
                }
                _player.Play();
                DemonstrationVideoScene.Visibility = Visibility.Visible;
                _desktopWindowCollector.SetWindowHandle(DemonstrationVideoScene.Handle);
                break;

            default:
                AllSceneHidden();
                DefaultScene.Visibility = Visibility.Visible;
                _desktopWindowCollector.SetWindowHandle(DefaultScene.Handle);
                break;
            }
        }