Пример #1
0
        public ScreenShotViewModel(LanguageManager loc,
                                   Settings settings,
                                   DiskWriter diskWriter,
                                   ClipboardWriter clipboardWriter,
                                   ImageUploadWriter imgurWriter,
                                   ScreenShotModel screenShotModel,
                                   VideoSourcesViewModel videoSourcesViewModel,
                                   IPlatformServices platformServices) : base(settings, loc)
        {
            DiskWriter      = diskWriter;
            ClipboardWriter = clipboardWriter;
            ImgurWriter     = imgurWriter;

            ScreenShotCommand = videoSourcesViewModel
                                .ObserveProperty(sourcesViewModel => sourcesViewModel.SelectedVideoSourceKind)
                                .Select(videoSourceProvider => !(videoSourceProvider is NoVideoSourceProvider))
                                .ToReactiveCommand()
                                .WithSubscribe(() => 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());
        }
Пример #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;
                }
            };
        }