예제 #1
0
        public RecordingViewModel(RecordingModel RecordingModel,
                                  Settings Settings,
                                  TimerModel TimerModel,
                                  WebcamModel WebcamModel,
                                  VideoSourcesViewModel VideoSourcesViewModel)
        {
            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 != Models.RecorderState.NotRecording)
            }
            .CombineLatest(M => !M[0] && M[1])
            .ToReactiveCommand()
            .WithSubscribe(RecordingModel.OnPauseExecute);

            RecorderState = RecordingModel
                            .ObserveProperty(M => M.RecorderState)
                            .ToReadOnlyReactivePropertySlim();
        }
        public ScreenShotViewModel(LanguageManager Loc,
                                   Settings Settings,
                                   DiskWriter DiskWriter,
                                   ClipboardWriter ClipboardWriter,
                                   ImageUploadWriter ImgurWriter,
                                   ScreenShotModel ScreenShotModel,
                                   VideoSourcesViewModel VideoSourcesViewModel,
                                   WebcamModel WebcamModel,
                                   IPlatformServices PlatformServices) : base(Settings, Loc)
        {
            this.DiskWriter      = DiskWriter;
            this.ClipboardWriter = ClipboardWriter;
            this.ImgurWriter     = ImgurWriter;

            ScreenShotCommand = new[]
            {
                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 noVideo    = M[0];
                var webcamMode = M[1];
                var noWebcam   = M[2];

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

                return(!noVideo);
            })
            .ToReactiveCommand()
            .WithSubscribe(M => ScreenShotModel.CaptureScreenShot());

            async Task ScreenShotWindow(IWindow Window)
            {
                var img = ScreenShotModel.ScreenShotWindow(Window);

                await ScreenShotModel.SaveScreenShot(img);
            }

            ScreenShotActiveCommand  = new DelegateCommand(async() => await ScreenShotWindow(PlatformServices.ForegroundWindow));
            ScreenShotDesktopCommand = new DelegateCommand(async() => await ScreenShotWindow(PlatformServices.DesktopWindow));
            ScreenshotRegionCommand  = new DelegateCommand(async() => await ScreenShotModel.ScreenshotRegion());
            ScreenshotWindowCommand  = new DelegateCommand(async() => await ScreenShotModel.ScreenshotWindow());
            ScreenshotScreenCommand  = new DelegateCommand(async() => await ScreenShotModel.ScreenshotScreen());
        }
예제 #3
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;
                }
            };
        }
예제 #5
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();
                }
            };
        }
예제 #6
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();
        }