Example #1
0
        public void Init(bool Persist, bool Timer, bool Remembered, bool Hotkeys)
        {
            _persist = Persist;
            _hotkeys = Hotkeys;

            if (Timer)
            {
                _timer          = new Timer(500);
                _timer.Elapsed += TimerOnElapsed;
            }

            // Register Hotkeys if not console
            if (_hotkeys)
            {
                HotKeyManager.RegisterAll();
            }

            VideoViewModel.Init();

            if (Remembered)
            {
                RestoreRemembered();
            }

            if (AudioSource is NoAudioSource)
            {
                ServiceProvider.MessageProvider.ShowError(
                    "Could not find bass.dll or bassmix.dll.\nAudio Recording will not be available.", "No Audio");
            }
        }
Example #2
0
        public void Init(bool Persist, bool Timer, bool Remembered, bool Hotkeys)
        {
            _persist = Persist;
            _hotkeys = Hotkeys;

            if (Timer)
            {
                _timer          = new Timer(500);
                _timer.Elapsed += TimerOnElapsed;
            }

            // Register Hotkeys if not console
            if (_hotkeys)
            {
                HotKeyManager.RegisterAll();
            }

            VideoViewModel.Init();

            if (Remembered)
            {
                _remembered = true;

                RestoreRemembered();
            }
        }
Example #3
0
        public ScreenShotViewModel(VideoViewModel VideoViewModel,
                                   RecentViewModel RecentViewModel,
                                   ISystemTray SystemTray,
                                   LanguageManager Loc,
                                   Settings Settings,
                                   IRegionProvider RegionProvider,
                                   IMainWindow MainWindow,
                                   DiskWriter DiskWriter,
                                   ClipboardWriter ClipboardWriter,
                                   ImgurWriter ImgurWriter,
                                   IVideoSourcePicker SourcePicker) : base(Settings, Loc)
        {
            _videoViewModel      = VideoViewModel;
            _recentViewModel     = RecentViewModel;
            _systemTray          = SystemTray;
            _regionProvider      = RegionProvider;
            _mainWindow          = MainWindow;
            _sourcePicker        = SourcePicker;
            this.DiskWriter      = DiskWriter;
            this.ClipboardWriter = ClipboardWriter;
            this.ImgurWriter     = ImgurWriter;

            ScreenShotCommand = new DelegateCommand(() => CaptureScreenShot());

            ScreenShotActiveCommand = new DelegateCommand(async() => await SaveScreenShot(ScreenShotWindow(Window.ForegroundWindow)));

            ScreenShotDesktopCommand = new DelegateCommand(async() => await SaveScreenShot(ScreenShotWindow(Window.DesktopWindow)));

            ScreenshotRegionCommand = new DelegateCommand(async() => await ScreenshotRegion());

            ScreenshotWindowCommand = new DelegateCommand(async() => await ScreenshotWindow());

            ScreenshotScreenCommand = new DelegateCommand(async() => await ScreenshotScreen());
        }
Example #4
0
        public void Init(bool Persist, bool Timer, bool Remembered, bool Hotkeys)
        {
            _persist = Persist;
            _hotkeys = Hotkeys;

            if (Timer)
            {
                RecordingViewModel.InitTimer();
            }

            // Register Hotkeys if not console
            if (_hotkeys)
            {
                HotKeyManager.RegisterAll();
            }

            VideoViewModel.Init();

            if (Remembered)
            {
                _remembered = true;

                _rememberByName.RestoreRemembered();
            }
        }
Example #5
0
        public RecordingViewModel(Settings Settings,
                                  LanguageManager LanguageManager,
                                  CustomOverlaysViewModel CustomOverlays,
                                  CustomImageOverlaysViewModel CustomImageOverlays,
                                  CensorOverlaysViewModel CensorOverlays,
                                  ISystemTray SystemTray,
                                  IRegionProvider RegionProvider,
                                  WebcamOverlay WebcamOverlay,
                                  IMainWindow MainWindow,
                                  IPreviewWindow PreviewWindow,
                                  VideoViewModel VideoViewModel,
                                  AudioSource AudioSource,
                                  RecentViewModel RecentViewModel,
                                  IWebCamProvider WebCamProvider) : base(Settings, LanguageManager)
        {
            this.CustomOverlays      = CustomOverlays;
            this.CustomImageOverlays = CustomImageOverlays;
            this.CensorOverlays      = CensorOverlays;
            _systemTray      = SystemTray;
            _regionProvider  = RegionProvider;
            _webcamOverlay   = WebcamOverlay;
            _mainWindow      = MainWindow;
            _previewWindow   = PreviewWindow;
            _videoViewModel  = VideoViewModel;
            _audioSource     = AudioSource;
            _recentViewModel = RecentViewModel;
            _webCamProvider  = WebCamProvider;

            RecordCommand = new DelegateCommand(OnRecordExecute);

            PauseCommand = new DelegateCommand(OnPauseExecute, false);

            SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
        }
Example #6
0
        void OnRefresh()
        {
            #region Video Codec
            var lastVideoCodecName = VideoViewModel.SelectedVideoWriter?.ToString();

            VideoViewModel.RefreshCodecs();

            var matchingVideoCodec = VideoViewModel.AvailableVideoWriters.FirstOrDefault(M => M.ToString() == lastVideoCodecName);

            if (matchingVideoCodec != null)
            {
                VideoViewModel.SelectedVideoWriter = matchingVideoCodec;
            }
            #endregion

            #region Audio
            var lastMicNames = AudioSource.AvailableRecordingSources
                               .Where(M => M.Active)
                               .Select(M => M.Name)
                               .ToArray();

            var lastSpeakerNames = AudioSource.AvailableLoopbackSources
                                   .Where(M => M.Active)
                                   .Select(M => M.Name)
                                   .ToArray();

            AudioSource.Refresh();

            foreach (var source in AudioSource.AvailableRecordingSources)
            {
                source.Active = lastMicNames.Contains(source.Name);
            }

            foreach (var source in AudioSource.AvailableLoopbackSources)
            {
                source.Active = lastSpeakerNames.Contains(source.Name);
            }
            #endregion

            #region Webcam
            var lastWebcamName = WebCamProvider.SelectedCam?.Name;

            WebCamProvider.Refresh();

            var matchingWebcam = WebCamProvider.AvailableCams.FirstOrDefault(M => M.Name == lastWebcamName);

            if (matchingWebcam != null)
            {
                WebCamProvider.SelectedCam = matchingWebcam;
            }
            #endregion

            Refreshed?.Invoke();
        }
Example #7
0
        void OnRefresh()
        {
            WindowProvider.RefreshDesktopSize();

            VideoViewModel.RefreshVideoSources();

            VideoViewModel.RefreshCodecs();

            AudioSource.Refresh();

            WebCamProvider.Refresh();

            Status.LocalizationKey = nameof(LanguageManager.Refreshed);
        }
Example #8
0
        public ScreenShotViewModel(VideoViewModel VideoViewModel,
                                   RecentViewModel RecentViewModel,
                                   ISystemTray SystemTray,
                                   LanguageManager Loc,
                                   Settings Settings,
                                   IRegionProvider RegionProvider,
                                   IMainWindow MainWindow) : base(Settings, Loc)
        {
            _videoViewModel  = VideoViewModel;
            _recentViewModel = RecentViewModel;
            _systemTray      = SystemTray;
            _regionProvider  = RegionProvider;
            _mainWindow      = MainWindow;

            ScreenShotCommand = new DelegateCommand(() => CaptureScreenShot());

            ScreenShotActiveCommand = new DelegateCommand(async() => await SaveScreenShot(ScreenShotWindow(Window.ForegroundWindow)));

            ScreenShotDesktopCommand = new DelegateCommand(async() => await SaveScreenShot(ScreenShotWindow(Window.DesktopWindow)));
        }
Example #9
0
        public MainViewModel(AudioSource AudioSource,
                             VideoViewModel VideoViewModel,
                             ISystemTray SystemTray,
                             IRegionProvider RegionProvider,
                             IWebCamProvider WebCamProvider,
                             WebcamOverlay WebcamOverlay,
                             IMainWindow MainWindow,
                             Settings Settings,
                             RecentViewModel RecentViewModel,
                             LanguageManager LanguageManager,
                             HotKeyManager HotKeyManager,
                             CustomOverlaysViewModel CustomOverlays,
                             CustomImageOverlaysViewModel CustomImageOverlays,
                             IPreviewWindow PreviewWindow,
                             CensorOverlaysViewModel CensorOverlays,
                             FFmpegLog FFmpegLog,
                             IDialogService DialogService) : base(Settings, LanguageManager)
        {
            this.AudioSource         = AudioSource;
            this.VideoViewModel      = VideoViewModel;
            _systemTray              = SystemTray;
            _regionProvider          = RegionProvider;
            this.WebCamProvider      = WebCamProvider;
            _webcamOverlay           = WebcamOverlay;
            _mainWindow              = MainWindow;
            this.RecentViewModel     = RecentViewModel;
            this.HotKeyManager       = HotKeyManager;
            this.CustomOverlays      = CustomOverlays;
            this.CustomImageOverlays = CustomImageOverlays;
            _previewWindow           = PreviewWindow;
            _dialogService           = DialogService;
            this.CensorOverlays      = CensorOverlays;
            this.FFmpegLog           = FFmpegLog;

            ShowPreviewCommand = new DelegateCommand(() => _previewWindow.Show());

            #region Commands
            ScreenShotCommand = new DelegateCommand(() => CaptureScreenShot());

            ScreenShotActiveCommand = new DelegateCommand(async() => await SaveScreenShot(ScreenShotWindow(Window.ForegroundWindow)));

            ScreenShotDesktopCommand = new DelegateCommand(async() => await SaveScreenShot(ScreenShotWindow(Window.DesktopWindow)));

            RecordCommand = new DelegateCommand(OnRecordExecute);

            RefreshCommand = new DelegateCommand(OnRefresh);

            PauseCommand = new DelegateCommand(OnPauseExecute, false);

            OpenOutputFolderCommand = new DelegateCommand(OpenOutputFolder);

            SelectOutputFolderCommand = new DelegateCommand(SelectOutputFolder);

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

            SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;

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

            VideoViewModel.PropertyChanged += (Sender, Args) =>
            {
                switch (Args.PropertyName)
                {
                case nameof(VideoViewModel.SelectedVideoSourceKind):
                case nameof(VideoViewModel.SelectedVideoSource):
                case null:
                case "":
                    CheckFunctionalityAvailability();
                    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
            HotKeyManager.HotkeyPressed += Service =>
            {
                switch (Service)
                {
                case ServiceName.Recording:
                    RecordCommand?.ExecuteIfCan();
                    break;

                case ServiceName.Pause:
                    PauseCommand?.ExecuteIfCan();
                    break;

                case ServiceName.ScreenShot:
                    ScreenShotCommand?.ExecuteIfCan();
                    break;

                case ServiceName.ActiveScreenShot:
                    ScreenShotActiveCommand?.ExecuteIfCan();
                    break;

                case ServiceName.DesktopScreenShot:
                    ScreenShotDesktopCommand?.ExecuteIfCan();
                    break;

                case ServiceName.ToggleMouseClicks:
                    Settings.Clicks.Display = !Settings.Clicks.Display;
                    break;

                case ServiceName.ToggleKeystrokes:
                    Settings.Keystrokes.Display = !Settings.Keystrokes.Display;
                    break;
                }
            };
        }
Example #10
0
        void OnRefresh()
        {
            WindowProvider.RefreshDesktopSize();

            #region Video Source
            var lastVideoSourceName = VideoViewModel.SelectedVideoSource?.Name;

            VideoViewModel.RefreshVideoSources();

            var matchingVideoSource = VideoViewModel.AvailableVideoSources.FirstOrDefault(M => M.Name == lastVideoSourceName);

            if (matchingVideoSource != null)
            {
                VideoViewModel.SelectedVideoSource = matchingVideoSource;
            }
            #endregion

            #region Video Codec
            var lastVideoCodecName = VideoViewModel.SelectedVideoWriter?.ToString();

            VideoViewModel.RefreshCodecs();

            var matchingVideoCodec = VideoViewModel.AvailableVideoWriters.FirstOrDefault(M => M.ToString() == lastVideoCodecName);

            if (matchingVideoCodec != null)
            {
                VideoViewModel.SelectedVideoWriter = matchingVideoCodec;
            }
            #endregion

            #region Audio
            var lastMicNames = AudioSource.AvailableRecordingSources
                               .Where(M => M.Active)
                               .Select(M => M.Name)
                               .ToArray();

            var lastSpeakerNames = AudioSource.AvailableLoopbackSources
                                   .Where(M => M.Active)
                                   .Select(M => M.Name)
                                   .ToArray();

            AudioSource.Refresh();

            foreach (var source in AudioSource.AvailableRecordingSources)
            {
                source.Active = lastMicNames.Contains(source.Name);
            }

            foreach (var source in AudioSource.AvailableLoopbackSources)
            {
                source.Active = lastSpeakerNames.Contains(source.Name);
            }
            #endregion

            #region Webcam
            var lastWebcamName = WebCamProvider.SelectedCam?.Name;

            WebCamProvider.Refresh();

            var matchingWebcam = WebCamProvider.AvailableCams.FirstOrDefault(M => M.Name == lastWebcamName);

            if (matchingWebcam != null)
            {
                WebCamProvider.SelectedCam = matchingWebcam;
            }
            #endregion

            Status.LocalizationKey = nameof(LanguageManager.Refreshed);
        }
Example #11
0
        public MainViewModel(AudioSource AudioSource,
                             VideoViewModel VideoViewModel,
                             IWebCamProvider WebCamProvider,
                             Settings Settings,
                             RecentViewModel RecentViewModel,
                             LanguageManager LanguageManager,
                             HotKeyManager HotKeyManager,
                             IPreviewWindow PreviewWindow,
                             FFmpegLog FFmpegLog,
                             IDialogService DialogService,
                             RememberByName RememberByName,
                             ScreenShotViewModel ScreenShotViewModel,
                             RecordingViewModel RecordingViewModel) : base(Settings, LanguageManager)
        {
            this.AudioSource         = AudioSource;
            this.VideoViewModel      = VideoViewModel;
            this.WebCamProvider      = WebCamProvider;
            this.RecentViewModel     = RecentViewModel;
            this.HotKeyManager       = HotKeyManager;
            _dialogService           = DialogService;
            _rememberByName          = RememberByName;
            this.ScreenShotViewModel = ScreenShotViewModel;
            this.RecordingViewModel  = RecordingViewModel;
            this.FFmpegLog           = FFmpegLog;

            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 = "");
            #endregion

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

            VideoViewModel.PropertyChanged += (Sender, Args) =>
            {
                switch (Args.PropertyName)
                {
                case nameof(VideoViewModel.SelectedVideoSourceKind):
                case nameof(VideoViewModel.SelectedVideoSource):
                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
            HotKeyManager.HotkeyPressed += Service =>
            {
                switch (Service)
                {
                case ServiceName.Recording:
                    RecordingViewModel.RecordCommand.ExecuteIfCan();
                    break;

                case ServiceName.Pause:
                    RecordingViewModel.PauseCommand.ExecuteIfCan();
                    break;

                case ServiceName.ScreenShot:
                    ScreenShotViewModel.ScreenShotCommand.ExecuteIfCan();
                    break;

                case ServiceName.ActiveScreenShot:
                    ScreenShotViewModel.ScreenShotActiveCommand.ExecuteIfCan();
                    break;

                case ServiceName.DesktopScreenShot:
                    ScreenShotViewModel.ScreenShotDesktopCommand.ExecuteIfCan();
                    break;

                case ServiceName.ToggleMouseClicks:
                    Settings.Clicks.Display = !Settings.Clicks.Display;
                    break;

                case ServiceName.ToggleKeystrokes:
                    Settings.Keystrokes.Display = !Settings.Keystrokes.Display;
                    break;
                }
            };
        }
Example #12
0
        public MainViewModel(AudioSource AudioSource,
                             VideoViewModel VideoViewModel,
                             IWebCamProvider WebCamProvider,
                             Settings Settings,
                             RecentViewModel RecentViewModel,
                             LanguageManager LanguageManager,
                             HotKeyManager HotKeyManager,
                             IPreviewWindow PreviewWindow,
                             IDialogService DialogService,
                             RememberByName RememberByName,
                             ScreenShotViewModel ScreenShotViewModel,
                             RecordingViewModel RecordingViewModel,
                             HotkeyActionRegisterer HotkeyActionRegisterer) : base(Settings, LanguageManager)
        {
            this.AudioSource         = AudioSource;
            this.VideoViewModel      = VideoViewModel;
            this.WebCamProvider      = WebCamProvider;
            this.RecentViewModel     = RecentViewModel;
            this.HotKeyManager       = HotKeyManager;
            _dialogService           = DialogService;
            _rememberByName          = RememberByName;
            this.ScreenShotViewModel = ScreenShotViewModel;
            this.RecordingViewModel  = RecordingViewModel;

            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;
                }
            };

            VideoViewModel.PropertyChanged += (Sender, Args) =>
            {
                switch (Args.PropertyName)
                {
                case nameof(VideoViewModel.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), "AyatRecorder");
            }

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

            // Handle Hoykeys
            HotkeyActionRegisterer.Register();
        }