public RecordingViewModel(RecordingModel RecordingModel, Settings Settings, TimerModel TimerModel, VideoSourcesViewModel VideoSourcesViewModel, VideoWritersViewModel VideoWritersViewModel, ISystemTray SystemTray, IMainWindow MainWindow, IAudioPlayer AudioPlayer, IRecentList RecentList, AudioSourceViewModel AudioSourceViewModel) : base(Settings) { _recordingModel = RecordingModel; _timerModel = TimerModel; _videoSourcesViewModel = VideoSourcesViewModel; _videoWritersViewModel = VideoWritersViewModel; _systemTray = SystemTray; _mainWindow = MainWindow; _audioPlayer = AudioPlayer; _recentList = RecentList; _audioSourceViewModel = AudioSourceViewModel; this.RecordingModel = RecordingModel; TimerModel.DurationElapsed += () => { _syncContext.Run(async() => await StopRecording(), true); }; }
//private readonly ServiceLocator serviceLocator; public RecordStreamViewModel(Settings Settings, ILocalizationProvider Loc, VideoSourcesViewModel VideoSourcesViewModel, VideoWritersViewModel VideoWritersViewModel, AudioSourceViewModel AudioSourceViewModel, RecordingViewModel RecordingViewModel) : base(Settings, Loc) { //Init(); //serviceLocator = new ServiceLocator(); //RecordCommand = serviceLocator.RecordingViewModel.RecordCommand; //PauseCommand = serviceLocator.RecordingViewModel.PauseCommand; //serviceLocator.VideoSourcesViewModel.SelectedVideoSourceKind = // serviceLocator.VideoSourcesViewModel.VideoSources.FirstOrDefault(M => M is FullScreenSourceProvider); //serviceLocator.VideoWritersViewModel.SelectedVideoWriterKind = // serviceLocator.VideoWritersViewModel.VideoWriterProviders.FirstOrDefault(M => // M is FFmpegWriterProvider); //serviceLocator.VideoWritersViewModel.SelectedVideoWriter = // serviceLocator.VideoWritersViewModel.AvailableVideoWriters.FirstOrDefault(M => M is X264VideoCodec); //foreach (var availableSpeaker in serviceLocator.AudioSourceViewModel.AvailableSpeakers) //{ // Console.WriteLine("Speaker name: " + availableSpeaker.Name); //} //Console.WriteLine("Speaker : " + serviceLocator.AudioSourceViewModel.AvailableSpeakers[1].Name); //serviceLocator.RecordingViewModel.Settings.Audio.RecordSpeaker = true; //serviceLocator.AudioSourceViewModel.SelectedSpeaker = // serviceLocator.AudioSourceViewModel.AvailableSpeakers[1]; videoSourceViewModel = VideoSourcesViewModel; videoWriterViewmoModel = VideoWritersViewModel; audioSourceViewModel = AudioSourceViewModel; recordingViewModel = RecordingViewModel; RecordCommand = RecordingViewModel.RecordCommand; PauseCommand = RecordingViewModel.PauseCommand; ConfigDefault(); }
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(); }