Пример #1
0
        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(model => model.RecorderState)
                             .Select(recorderState => recorderState == 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
        }
Пример #2
0
        public RecordingViewModel(RecordingModel recordingModel,
                                  Settings settings,
                                  TimerModel timerModel,
                                  VideoSourcesViewModel videoSourcesViewModel)
        {
            _recordingModel = recordingModel;

            RecordCommand = new[]
            {
                settings.Audio
                .ObserveProperty(audioSettings => audioSettings.Enabled),
                videoSourcesViewModel
                .ObserveProperty(sourcesViewModel => sourcesViewModel.SelectedVideoSourceKind)
                .Select(videoSourceProvider => !(videoSourceProvider is NoVideoSourceProvider))
            }
            .CombineLatest(bools => bools[0] || bools[1])
            .ToReactiveCommand()
            .WithSubscribe(recordingModel.OnRecordExecute);

            PauseCommand = new[]
            {
                timerModel
                .ObserveProperty(model => model.Waiting),
                recordingModel
                .ObserveProperty(model => model.RecorderState)
                .Select(recorderState => recorderState != RecorderState.NotRecording)
            }
            .CombineLatest(bools => !bools[0] && bools[1])
            .ToReactiveCommand()
            .WithSubscribe(recordingModel.OnPauseExecute);

            recordingModel.PropertyChanged += (sender, e) =>
            {
                switch (e.PropertyName)
                {
                case "":
                case null:
                case nameof(RecorderState):
                    RaisePropertyChanged(nameof(RecorderState));
                    break;
                }
            };
        }