コード例 #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(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
        }
コード例 #2
0
        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
        }
コード例 #3
0
        public MainViewModel(AudioSource AudioSource,
                             VideoSourcesViewModel VideoSourcesViewModel,
                             VideoWritersViewModel VideoWritersViewModel,
                             IWebCamProvider WebCamProvider,
                             Settings Settings,
                             LanguageManager LanguageManager,
                             HotKeyManager HotKeyManager,
                             IPreviewWindow PreviewWindow,
                             IDialogService DialogService,
                             RememberByName RememberByName,
                             ScreenShotViewModel ScreenShotViewModel,
                             RecordingViewModel RecordingViewModel,
                             HotkeyActionRegisterer HotkeyActionRegisterer,
                             IRecentList RecentList) : base(Settings, LanguageManager)
        {
            this.AudioSource           = AudioSource;
            this.VideoSourcesViewModel = VideoSourcesViewModel;
            this.VideoWritersViewModel = VideoWritersViewModel;
            this.WebCamProvider        = WebCamProvider;
            this.HotKeyManager         = HotKeyManager;
            _dialogService             = DialogService;
            _rememberByName            = RememberByName;
            this.ScreenShotViewModel   = ScreenShotViewModel;
            this.RecordingViewModel    = RecordingViewModel;
            _recentList = RecentList;

            ShowPreviewCommand = new DelegateCommand(PreviewWindow.Show);

            #region Commands
            RefreshCommand = new DelegateCommand(OnRefresh);

            OpenOutputFolderCommand = new DelegateCommand(OpenOutputFolder);

            SelectOutputFolderCommand = new DelegateCommand(SelectOutputFolder);

            ResetFFmpegFolderCommand = new DelegateCommand(() => Settings.FFmpeg.FolderPath = "");

            TrayLeftClickCommand = new DelegateCommand(() => HotKeyManager.FakeHotkey(Settings.Tray.LeftClickAction));
            #endregion

            Settings.Audio.PropertyChanged += (Sender, Args) =>
            {
                switch (Args.PropertyName)
                {
                case nameof(Settings.Audio.Enabled):
                case null:
                case "":
                    CheckFunctionalityAvailability();
                    break;
                }
            };

            VideoSourcesViewModel.PropertyChanged += (Sender, Args) =>
            {
                switch (Args.PropertyName)
                {
                case nameof(VideoSourcesViewModel.SelectedVideoSourceKind):
                case null:
                case "":
                    CheckFunctionalityAvailability();
                    break;
                }
            };

            RecordingViewModel.PropertyChanged += (Sender, Args) =>
            {
                switch (Args.PropertyName)
                {
                case nameof(RecordingViewModel.RecorderState):
                case null:
                case "":
                    RefreshCommand.RaiseCanExecuteChanged(RecordingViewModel.RecorderState == RecorderState.NotRecording);
                    break;
                }
            };

            // If Output Dircetory is not set. Set it to Documents\Captura\
            if (string.IsNullOrWhiteSpace(Settings.OutPath))
            {
                Settings.OutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Captura");
            }

            // Create the Output Directory if it does not exist
            Settings.EnsureOutPath();

            // Handle Hoykeys
            HotkeyActionRegisterer.Register();
        }