예제 #1
0
        public RecordingModel(Settings Settings,
                              LanguageManager LanguageManager,
                              ISystemTray SystemTray,
                              IRegionProvider RegionProvider,
                              WebcamOverlay WebcamOverlay,
                              IMainWindow MainWindow,
                              IPreviewWindow PreviewWindow,
                              VideoSourcesViewModel VideoSourcesViewModel,
                              VideoWritersViewModel VideoWritersViewModel,
                              AudioSource AudioSource,
                              IWebCamProvider WebCamProvider,
                              KeymapViewModel Keymap,
                              IAudioPlayer AudioPlayer,
                              IRecentList RecentList,
                              TimerModel TimerModel) : base(Settings, LanguageManager)
        {
            _systemTray            = SystemTray;
            _regionProvider        = RegionProvider;
            _webcamOverlay         = WebcamOverlay;
            _mainWindow            = MainWindow;
            _previewWindow         = PreviewWindow;
            _videoSourcesViewModel = VideoSourcesViewModel;
            _videoWritersViewModel = VideoWritersViewModel;
            _audioSource           = AudioSource;
            _webCamProvider        = WebCamProvider;
            _keymap      = Keymap;
            _audioPlayer = AudioPlayer;
            _recentList  = RecentList;
            _timerModel  = TimerModel;

            SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;

            TimerModel.CountdownElapsed += InternalStartRecording;
            TimerModel.DurationElapsed  += async() =>
            {
                if (_syncContext != null)
                {
                    _syncContext.Post(async State => await StopRecording(), null);
                }
                else
                {
                    await StopRecording();
                }
            };
        }
예제 #2
0
        public RecordingViewModel(RecordingModel RecordingModel,
                                  Settings Settings,
                                  TimerModel TimerModel,
                                  VideoSourcesViewModel VideoSourcesViewModel)
        {
            _recordingModel = RecordingModel;

            RecordCommand = new[]
            {
                Settings.Audio
                .ObserveProperty(M => M.Enabled),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => !(M is NoVideoSourceProvider))
            }
            .CombineLatest(M => M[0] || M[1])
            .ToReactiveCommand()
            .WithSubscribe(RecordingModel.OnRecordExecute);

            PauseCommand = new[]
            {
                TimerModel
                .ObserveProperty(M => M.Waiting),
                RecordingModel
                .ObserveProperty(M => M.RecorderState)
                .Select(M => M != RecorderState.NotRecording)
            }
            .CombineLatest(M => !M[0] && M[1])
            .ToReactiveCommand()
            .WithSubscribe(RecordingModel.OnPauseExecute);

            RecordingModel.PropertyChanged += (S, E) =>
            {
                switch (E.PropertyName)
                {
                case "":
                case null:
                case nameof(RecorderState):
                    RaisePropertyChanged(nameof(RecorderState));
                    break;
                }
            };
        }
예제 #3
0
        public RecordingModel(Settings Settings,
                              ILocalizationProvider Loc,
                              ISystemTray SystemTray,
                              WebcamOverlay WebcamOverlay,
                              IPreviewWindow PreviewWindow,
                              VideoSourcesViewModel VideoSourcesViewModel,
                              VideoWritersViewModel VideoWritersViewModel,
                              AudioSource AudioSource,
                              WebcamModel WebcamModel,
                              KeymapViewModel Keymap,
                              IRecentList RecentList,
                              TimerModel TimerModel,
                              IMessageProvider MessageProvider,
                              IFFmpegViewsProvider FFmpegViewsProvider) : base(Settings, Loc)
        {
            _systemTray            = SystemTray;
            _webcamOverlay         = WebcamOverlay;
            _previewWindow         = PreviewWindow;
            _videoSourcesViewModel = VideoSourcesViewModel;
            _videoWritersViewModel = VideoWritersViewModel;
            _audioSource           = AudioSource;
            _webcamModel           = WebcamModel;
            _keymap              = Keymap;
            _recentList          = RecentList;
            _timerModel          = TimerModel;
            _messageProvider     = MessageProvider;
            _ffmpegViewsProvider = FFmpegViewsProvider;

            SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;

            TimerModel.CountdownElapsed += InternalStartRecording;
            TimerModel.DurationElapsed  += async() =>
            {
                if (_syncContext != null)
                {
                    _syncContext.Post(async State => await StopRecording(), null);
                }
                else
                {
                    await StopRecording();
                }
            };
        }
예제 #4
0
        public RecordingModel(Settings Settings,
                              ISystemTray SystemTray,
                              IPreviewWindow PreviewWindow,
                              IAudioSource AudioSource,
                              KeymapViewModel Keymap,
                              TimerModel TimerModel,
                              IFpsManager FpsManager) : base(Settings)
        {
            _systemTray    = SystemTray;
            _previewWindow = PreviewWindow;
            _audioSource   = AudioSource;
            _keymap        = Keymap;
            _timerModel    = TimerModel;
            _fpsManager    = FpsManager;

            SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;

            TimerModel.CountdownElapsed += InternalStartRecording;
        }
예제 #5
0
        public RecordingModel(Settings Settings,
                              ILocalizationProvider Loc,
                              ISystemTray SystemTray,
                              IPreviewWindow PreviewWindow,
                              IAudioSource AudioSource,
                              WebcamModel WebcamModel,
                              KeymapViewModel Keymap,
                              TimerModel TimerModel,
                              IMessageProvider MessageProvider,
                              IFFmpegViewsProvider FFmpegViewsProvider) : base(Settings, Loc)
        {
            _systemTray          = SystemTray;
            _previewWindow       = PreviewWindow;
            _audioSource         = AudioSource;
            _webcamModel         = WebcamModel;
            _keymap              = Keymap;
            _timerModel          = TimerModel;
            _messageProvider     = MessageProvider;
            _ffmpegViewsProvider = FFmpegViewsProvider;

            SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;

            TimerModel.CountdownElapsed += InternalStartRecording;
        }
예제 #6
0
        public RecordingViewModel(RecordingModel RecordingModel,
                                  Settings Settings,
                                  TimerModel TimerModel,
                                  WebcamModel WebcamModel,
                                  VideoSourcesViewModel VideoSourcesViewModel,
                                  VideoWritersViewModel VideoWritersViewModel,
                                  ISystemTray SystemTray,
                                  IMainWindow MainWindow,
                                  ILocalizationProvider Loc,
                                  IAudioPlayer AudioPlayer,
                                  IRecentList RecentList,
                                  IMessageProvider MessageProvider,
                                  AudioSourceViewModel AudioSourceViewModel,
                                  IFFmpegViewsProvider FFmpegViewsProvider) : base(Settings, Loc)
        {
            _recordingModel        = RecordingModel;
            _timerModel            = TimerModel;
            _videoSourcesViewModel = VideoSourcesViewModel;
            _videoWritersViewModel = VideoWritersViewModel;
            _systemTray            = SystemTray;
            _mainWindow            = MainWindow;
            _audioPlayer           = AudioPlayer;
            _recentList            = RecentList;
            _messageProvider       = MessageProvider;
            _audioSourceViewModel  = AudioSourceViewModel;
            _ffmpegViewsProvider   = FFmpegViewsProvider;

            var hasAudio = new[]
            {
                Settings
                .Audio
                .ObserveProperty(M => M.RecordMicrophone),
                Settings
                .Audio
                .ObserveProperty(M => M.RecordSpeaker)
            }
            .CombineLatest(M => M[0] || M[1]);

            RecordCommand = new[]
            {
                hasAudio,
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is NoVideoSourceProvider),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is WebcamSourceProvider),
                WebcamModel
                .ObserveProperty(M => M.SelectedCam)
                .Select(M => M is NoWebcamItem),
                Settings
                .Video
                .ObserveProperty(M => M.RecorderMode)
                .Select(M => M == RecorderMode.Steps),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M.SupportsStepsMode),
            }
            .CombineLatest(M =>
            {
                var audioEnabled      = M[0];
                var audioOnlyMode     = M[1];
                var webcamMode        = M[2];
                var noWebcam          = M[3];
                var stepsMode         = M[4];
                var supportsStepsMode = M[5];

                if (stepsMode)
                {
                    return(supportsStepsMode);
                }

                if (audioOnlyMode)
                {
                    return(audioEnabled);
                }

                if (webcamMode)
                {
                    return(!noWebcam);
                }

                return(true);
            })
            .ToReactiveCommand()
            .WithSubscribe(OnRecordExecute);

            PauseCommand = new[]
            {
                TimerModel
                .ObserveProperty(M => M.Waiting),
                RecordingModel
                .ObserveProperty(M => M.RecorderState)
                .Select(M => M != Models.RecorderState.NotRecording)
            }
            .CombineLatest(M => !M[0] && M[1])
            .ToReactiveCommand()
            .WithSubscribe(() =>
            {
                _audioPlayer.Play(SoundKind.Pause);

                RecordingModel.OnPauseExecute();
            });

            RecorderState = RecordingModel
                            .ObserveProperty(M => M.RecorderState)
                            .ToReadOnlyReactivePropertySlim();

            TimerModel.DurationElapsed += () =>
            {
                _syncContext.Run(async() => await StopRecording(), true);
            };
        }
        public RecordingViewModel(RecordingModel RecordingModel,
                                  Settings Settings,
                                  TimerModel TimerModel,
                                  WebcamModel WebcamModel,
                                  VideoSourcesViewModel VideoSourcesViewModel)
        {
            _recordingModel = RecordingModel;

            RecordCommand = new[]
            {
                Settings.Audio
                .ObserveProperty(M => M.Enabled),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is NoVideoSourceProvider),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is WebcamSourceProvider),
                WebcamModel
                .ObserveProperty(M => M.SelectedCam)
                .Select(M => M is NoWebcamItem)
            }
            .CombineLatest(M =>
            {
                var audioEnabled  = M[0];
                var audioOnlyMode = M[1];
                var webcamMode    = M[2];
                var noWebcam      = M[3];

                if (audioOnlyMode)
                {
                    return(audioEnabled);
                }

                if (webcamMode)
                {
                    return(!noWebcam);
                }

                return(true);
            })
            .ToReactiveCommand()
            .WithSubscribe(RecordingModel.OnRecordExecute);

            PauseCommand = new[]
            {
                TimerModel
                .ObserveProperty(M => M.Waiting),
                RecordingModel
                .ObserveProperty(M => M.RecorderState)
                .Select(M => M != RecorderState.NotRecording)
            }
            .CombineLatest(M => !M[0] && M[1])
            .ToReactiveCommand()
            .WithSubscribe(RecordingModel.OnPauseExecute);

            RecordingModel.PropertyChanged += (S, E) =>
            {
                switch (E.PropertyName)
                {
                case "":
                case null:
                case nameof(RecorderState):
                    RaisePropertyChanged(nameof(RecorderState));
                    break;
                }
            };
        }
예제 #8
0
        public RecordingViewModel(RecordingModel RecordingModel,
                                  Settings Settings,
                                  TimerModel TimerModel,
                                  WebcamModel WebcamModel,
                                  VideoSourcesViewModel VideoSourcesViewModel,
                                  VideoWritersViewModel VideoWritersViewModel,
                                  ISystemTray SystemTray,
                                  IMainWindow MainWindow,
                                  ILocalizationProvider Loc,
                                  IAudioPlayer AudioPlayer,
                                  IRecentList RecentList,
                                  IMessageProvider MessageProvider) : base(Settings, Loc)
        {
            _recordingModel        = RecordingModel;
            _timerModel            = TimerModel;
            _videoSourcesViewModel = VideoSourcesViewModel;
            _videoWritersViewModel = VideoWritersViewModel;
            _systemTray            = SystemTray;
            _mainWindow            = MainWindow;
            _audioPlayer           = AudioPlayer;
            _recentList            = RecentList;
            _messageProvider       = MessageProvider;

            RecordCommand = new[]
            {
                Settings.Audio
                .ObserveProperty(M => M.Enabled),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is NoVideoSourceProvider),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is WebcamSourceProvider),
                WebcamModel
                .ObserveProperty(M => M.SelectedCam)
                .Select(M => M is NoWebcamItem)
            }
            .CombineLatest(M =>
            {
                var audioEnabled  = M[0];
                var audioOnlyMode = M[1];
                var webcamMode    = M[2];
                var noWebcam      = M[3];

                if (audioOnlyMode)
                {
                    return(audioEnabled);
                }

                if (webcamMode)
                {
                    return(!noWebcam);
                }

                return(true);
            })
            .ToReactiveCommand()
            .WithSubscribe(OnRecordExecute);

            PauseCommand = new[]
            {
                TimerModel
                .ObserveProperty(M => M.Waiting),
                RecordingModel
                .ObserveProperty(M => M.RecorderState)
                .Select(M => M != Models.RecorderState.NotRecording)
            }
            .CombineLatest(M => !M[0] && M[1])
            .ToReactiveCommand()
            .WithSubscribe(() =>
            {
                _audioPlayer.Play(SoundKind.Pause);

                RecordingModel.OnPauseExecute();
            });

            RecorderState = RecordingModel
                            .ObserveProperty(M => M.RecorderState)
                            .ToReadOnlyReactivePropertySlim();

            TimerModel.DurationElapsed += async() =>
            {
                if (_syncContext != null)
                {
                    _syncContext.Post(async State => await StopRecording(), null);
                }
                else
                {
                    await StopRecording();
                }
            };
        }
예제 #9
0
        public RecordingViewModel(RecordingModel RecordingModel,
                                  Settings Settings,
                                  TimerModel TimerModel,
                                  WebcamModel WebcamModel,
                                  VideoSourcesViewModel VideoSourcesViewModel,
                                  ISystemTray SystemTray,
                                  IMainWindow MainWindow,
                                  ILocalizationProvider Loc,
                                  IAudioPlayer AudioPlayer) : base(Settings, Loc)
        {
            _recordingModel = RecordingModel;
            _systemTray     = SystemTray;
            _mainWindow     = MainWindow;
            _audioPlayer    = AudioPlayer;

            RecordCommand = new[]
            {
                Settings.Audio
                .ObserveProperty(M => M.Enabled),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is NoVideoSourceProvider),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is WebcamSourceProvider),
                WebcamModel
                .ObserveProperty(M => M.SelectedCam)
                .Select(M => M is NoWebcamItem)
            }
            .CombineLatest(M =>
            {
                var audioEnabled  = M[0];
                var audioOnlyMode = M[1];
                var webcamMode    = M[2];
                var noWebcam      = M[3];

                if (audioOnlyMode)
                {
                    return(audioEnabled);
                }

                if (webcamMode)
                {
                    return(!noWebcam);
                }

                return(true);
            })
            .ToReactiveCommand()
            .WithSubscribe(OnRecordExecute);

            PauseCommand = new[]
            {
                TimerModel
                .ObserveProperty(M => M.Waiting),
                RecordingModel
                .ObserveProperty(M => M.RecorderState)
                .Select(M => M != Models.RecorderState.NotRecording)
            }
            .CombineLatest(M => !M[0] && M[1])
            .ToReactiveCommand()
            .WithSubscribe(() =>
            {
                _audioPlayer.Play(SoundKind.Pause);

                RecordingModel.OnPauseExecute();
            });

            RecorderState = RecordingModel
                            .ObserveProperty(M => M.RecorderState)
                            .ToReadOnlyReactivePropertySlim();
        }