public ViewConditionsModel(VideoSourcesViewModel VideoSourcesViewModel, VideoWritersViewModel VideoWritersViewModel, Settings Settings, RecordingModel RecordingModel, AudioSource AudioSource) { IsRegionMode = VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is RegionSourceProvider) .ToReadOnlyReactivePropertySlim(); IsAudioMode = VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is NoVideoSourceProvider) .ToReadOnlyReactivePropertySlim(); MultipleVideoWriters = VideoWritersViewModel.AvailableVideoWriters .ObserveProperty(M => M.Count) .Select(M => M > 1) .ToReadOnlyReactivePropertySlim(); IsFFmpeg = VideoWritersViewModel .ObserveProperty(M => M.SelectedVideoWriterKind) .Select(M => M is FFmpegWriterProvider || M is StreamingWriterProvider) .ToReadOnlyReactivePropertySlim(); IsVideoQuality = VideoWritersViewModel .ObserveProperty(M => M.SelectedVideoWriterKind) .Select(M => !(M is DiscardWriterProvider)) .ToReadOnlyReactivePropertySlim(); CanChangeWebcam = new[] { RecordingModel .ObserveProperty(M => M.RecorderState) .Select(M => M == RecorderState.NotRecording), Settings.WebcamOverlay .ObserveProperty(M => M.SeparateFile) } .CombineLatest(M => !M[1] || M[0]) // Not SeparateFile or NotRecording .ToReadOnlyReactivePropertySlim(); CanChangeAudioSources = new[] { RecordingModel .ObserveProperty(M => M.RecorderState) .Select(M => M == RecorderState.NotRecording), Settings.Audio .ObserveProperty(M => M.SeparateFilePerSource) } .CombineLatest(M => AudioSource.CanChangeSourcesDuringRecording || !M[1] || M[0]) // Not SeparateFilePerSource or NotRecording .ToReadOnlyReactivePropertySlim(); IsEnabled = RecordingModel .ObserveProperty(M => M.RecorderState) .Select(M => M == RecorderState.NotRecording) .ToReadOnlyReactivePropertySlim(); }
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 MainViewModel(Settings Settings, LanguageManager LanguageManager, HotKeyManager HotKeyManager, IPreviewWindow PreviewWindow, IDialogService DialogService, RecordingModel RecordingModel, MainModel MainModel) : base(Settings, LanguageManager) { _dialogService = DialogService; ShowPreviewCommand = new DelegateCommand(PreviewWindow.Show); #region Commands RefreshCommand = RecordingModel .ObserveProperty(M => M.RecorderState) .Select(M => M == RecorderState.NotRecording) .ToReactiveCommand() .WithSubscribe(() => { MainModel.Refresh(); Refreshed?.Invoke(); }); OpenOutputFolderCommand = new DelegateCommand(OpenOutputFolder); SelectOutputFolderCommand = new DelegateCommand(SelectOutputFolder); ResetFFmpegFolderCommand = new DelegateCommand(() => Settings.FFmpeg.FolderPath = ""); TrayLeftClickCommand = new DelegateCommand(() => HotKeyManager.FakeHotkey(Settings.Tray.LeftClickAction)); #endregion }
public MainViewModel(Settings Settings, ILocalizationProvider Loc, HotKeyManager HotKeyManager, IPreviewWindow PreviewWindow, IDialogService DialogService, RecordingModel RecordingModel, IEnumerable <IRefreshable> Refreshables, IFFmpegViewsProvider FFmpegViewsProvider, RememberByName RememberByName) : base(Settings, Loc) { _dialogService = DialogService; _rememberByName = RememberByName; OutFolderDisplay = Settings .ObserveProperty(M => M.OutPath) .Select(M => Settings.GetOutputPath()) .ToReadOnlyReactivePropertySlim(); ShowPreviewCommand = new ReactiveCommand() .WithSubscribe(PreviewWindow.Show); SelectFFmpegFolderCommand = new ReactiveCommand() .WithSubscribe(FFmpegViewsProvider.PickFolder); #region Commands RefreshCommand = RecordingModel .ObserveProperty(M => M.RecorderState) .Select(M => M == RecorderState.NotRecording) .ToReactiveCommand() .WithSubscribe(() => { foreach (var refreshable in Refreshables) { refreshable.Refresh(); } Refreshed?.Invoke(); }); OpenOutputFolderCommand = new ReactiveCommand() .WithSubscribe(OpenOutputFolder); SelectOutputFolderCommand = new ReactiveCommand() .WithSubscribe(SelectOutputFolder); ResetFFmpegFolderCommand = new ReactiveCommand() .WithSubscribe(() => Settings.FFmpeg.FolderPath = ""); TrayLeftClickCommand = new ReactiveCommand() .WithSubscribe(() => HotKeyManager.FakeHotkey(Settings.Tray.LeftClickAction)); #endregion }
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; } }; }
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 ViewConditionsModel(VideoSourcesViewModel VideoSourcesViewModel, VideoWritersViewModel VideoWritersViewModel, Settings Settings, RecordingModel RecordingModel, AudioSourceViewModel AudioSourceViewModel) { IsRegionMode = VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is RegionSourceProvider) .ToReadOnlyReactivePropertySlim(); IsAudioMode = VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is NoVideoSourceProvider) .ToReadOnlyReactivePropertySlim(); MultipleVideoWriters = VideoWritersViewModel.AvailableVideoWriters .ObserveProperty(M => M.Count) .Select(M => M > 1) .ToReadOnlyReactivePropertySlim(); IsFFmpeg = VideoWritersViewModel .ObserveProperty(M => M.SelectedVideoWriterKind) .Select(M => M is FFmpegWriterProvider || M is StreamingWriterProvider) .ToReadOnlyReactivePropertySlim(); IsVideoQuality = VideoWritersViewModel .ObserveProperty(M => M.SelectedVideoWriterKind) .Select(M => M is DiscardWriterProvider) .Select(M => !M) .ToReadOnlyReactivePropertySlim(); IsReplayMode = Settings .Video .ObserveProperty(M => M.RecorderMode) .Select(M => M == RecorderMode.Replay) .ToReadOnlyReactivePropertySlim(); CanChangeWebcam = new[] { RecordingModel .ObserveProperty(M => M.RecorderState) .Select(M => M == RecorderState.NotRecording), Settings.WebcamOverlay .ObserveProperty(M => M.SeparateFile), VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is WebcamSourceProvider) } .CombineLatest(M => { var notRecording = M[0]; var separateFile = M[1]; var webcamMode = M[2]; if (webcamMode) { return(notRecording); } return(!separateFile || notRecording); }) .ToReadOnlyReactivePropertySlim(); IsEnabled = RecordingModel .ObserveProperty(M => M.RecorderState) .Select(M => M == RecorderState.NotRecording) .ToReadOnlyReactivePropertySlim(); CanWebcamSeparateFile = VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is WebcamSourceProvider) .Select(M => !M) .ToReadOnlyReactivePropertySlim(); IsAroundMouseMode = VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is AroundMouseSourceProvider) .ToReadOnlyReactivePropertySlim(); ShowSourceNameBox = VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is RegionSourceProvider || M is AroundMouseSourceProvider) .Select(M => !M) .ToReadOnlyReactivePropertySlim(); }
public ViewConditionsModel(VideoSourcesViewModel VideoSourcesViewModel, VideoWritersViewModel VideoWritersViewModel, Settings Settings, RecordingModel RecordingModel, AudioSourceViewModel AudioSourceViewModel) { IsRegionMode = VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is RegionSourceProvider) .ToReadOnlyReactivePropertySlim(); IsAudioMode = VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is NoVideoSourceProvider) .ToReadOnlyReactivePropertySlim(); IsStepsMode = Settings .Video .ObserveProperty(M => M.RecorderMode) .Select(M => M == RecorderMode.Steps) .ToReadOnlyReactivePropertySlim(); IsNotAudioOrStepsMode = new[] { VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is NoVideoSourceProvider), IsStepsMode } .CombineLatest(M => { var audioMode = M[0]; var stepsMode = M[1]; return(!audioMode && !stepsMode); }) .ToReadOnlyReactivePropertySlim(); MultipleVideoWriters = VideoWritersViewModel.AvailableVideoWriters .ObserveProperty(M => M.Count) .Select(M => M > 1) .ToReadOnlyReactivePropertySlim(); IsFFmpeg = VideoWritersViewModel .ObserveProperty(M => M.SelectedVideoWriterKind) .Select(M => M is FFmpegWriterProvider || M is StreamingWriterProvider) .ToReadOnlyReactivePropertySlim(); IsVideoQuality = VideoWritersViewModel .ObserveProperty(M => M.SelectedVideoWriterKind) .Select(M => M is DiscardWriterProvider) .Select(M => !M) .ToReadOnlyReactivePropertySlim(); IsReplayMode = Settings .Video .ObserveProperty(M => M.RecorderMode) .Select(M => M == RecorderMode.Replay) .ToReadOnlyReactivePropertySlim(); CanChangeWebcam = new[] { RecordingModel .ObserveProperty(M => M.RecorderState) .Select(M => M == RecorderState.NotRecording), Settings.WebcamOverlay .ObserveProperty(M => M.SeparateFile), VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is WebcamSourceProvider) } .CombineLatest(M => { var notRecording = M[0]; var separateFile = M[1]; var webcamMode = M[2]; if (webcamMode) { return(notRecording); } return(!separateFile || notRecording); }) .ToReadOnlyReactivePropertySlim(); IsEnabled = RecordingModel .ObserveProperty(M => M.RecorderState) .Select(M => M == RecorderState.NotRecording) .ToReadOnlyReactivePropertySlim(); CanWebcamSeparateFile = VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is WebcamSourceProvider) .Select(M => !M) .ToReadOnlyReactivePropertySlim(); IsAroundMouseMode = VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is AroundMouseSourceProvider) .ToReadOnlyReactivePropertySlim(); IsWebcamMode = VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is WebcamSourceProvider) .ToReadOnlyReactivePropertySlim(); ShowSourceNameBox = VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M is RegionSourceProvider || M is AroundMouseSourceProvider) .Select(M => !M) .ToReadOnlyReactivePropertySlim(); StepsBtnEnabled = new[] { IsEnabled, VideoSourcesViewModel .ObserveProperty(M => M.SelectedVideoSourceKind) .Select(M => M.SupportsStepsMode) } .CombineLatestValuesAreAllTrue() .ToReadOnlyReactivePropertySlim(); FpsVisibility = RecordingModel.ObserveProperty(M => M.RecorderState) .CombineLatest(IsNotAudioOrStepsMode, (RecorderState, IsNotAudioOrStepsMode) => RecorderState == RecorderState.Recording && IsNotAudioOrStepsMode) .Select(M => M ? Visibility.Visible : Visibility.Hidden) .ToReadOnlyReactivePropertySlim(); }
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; } }; }
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(); } }; }
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(); }