Ejemplo n.º 1
0
        public void Setup()
        {
            _hotKeyManager.RegisterAll();

            _hotkeyActionRegisterer.Register();

            var listener = new HotkeyListener();

            var hotkeyManager = ServiceProvider.Get <HotKeyManager>();

            listener.HotkeyReceived += Id => hotkeyManager.ProcessHotkey(Id);

            ServiceProvider.Get <HotKeyManager>().HotkeyPressed += Service =>
            {
                switch (Service)
                {
                case ServiceName.OpenImageEditor:
                    new ImageEditorWindow().ShowAndFocus();
                    break;

                case ServiceName.ShowMainWindow:
                    MainWindow.Instance.ShowAndFocus();
                    break;
                }
            };
        }
Ejemplo n.º 2
0
        MainViewModel()
        {
            _timer          = new Timer(1000);
            _timer.Elapsed += TimerOnElapsed;

            #region Commands
            ScreenShotCommand = new DelegateCommand(CaptureScreenShot);

            RecordCommand = new DelegateCommand(() =>
            {
                if (RecorderState == RecorderState.NotRecording)
                {
                    StartRecording();
                }
                else
                {
                    StopRecording();
                }
            });

            RefreshCommand = new DelegateCommand(() =>
            {
                VideoViewModel.RefreshVideoSources();

                VideoViewModel.RefreshCodecs();

                AudioViewModel.AudioSource.Refresh();

                Status = "Refreshed";
            });

            OpenOutputFolderCommand = new DelegateCommand(() =>
            {
                EnsureOutPath();

                Process.Start(Settings.OutPath);
            });

            PauseCommand = new DelegateCommand(() =>
            {
                if (RecorderState == RecorderState.Paused)
                {
                    _recorder.Start();
                    _timer.Start();

                    RecorderState = RecorderState.Recording;
                    Status        = "Recording...";
                }
                else
                {
                    _recorder.Stop();
                    _timer.Stop();

                    RecorderState = RecorderState.Paused;
                    Status        = "Paused";

                    SystemTrayManager.ShowNotification("Recording Paused", " ", 500, null);
                }
            }, false);

            SelectOutputFolderCommand = new DelegateCommand(() =>
            {
                var dlg = new FolderBrowserDialog
                {
                    SelectedPath = Settings.OutPath,
                    Description  = "Select Output Folder"
                };

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    Settings.OutPath = dlg.SelectedPath;
                }
            });
            #endregion

            //Populate Available Codecs, Audio and Video Sources ComboBoxes
            RefreshCommand.Execute(null);

            AudioViewModel.AudioSource.PropertyChanged += (Sender, Args) =>
            {
                if (Args.PropertyName == nameof(AudioViewModel.AudioSource.SelectedRecordingSource) ||
                    Args.PropertyName == nameof(AudioViewModel.AudioSource.SelectedLoopbackSource))
                {
                    CheckFunctionalityAvailability();
                }
            };

            VideoViewModel.PropertyChanged += (Sender, Args) =>
            {
                if (Args.PropertyName == nameof(VideoViewModel.SelectedVideoSource))
                {
                    CheckFunctionalityAvailability();
                }
            };

            _cursor = new MouseCursor(Settings.IncludeCursor);

            Settings.PropertyChanged += (Sender, Args) =>
            {
                switch (Args.PropertyName)
                {
                case nameof(Settings.IncludeCursor):
                    _cursor.Include = Settings.IncludeCursor;
                    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
            if (!Directory.Exists(Settings.OutPath))
            {
                Directory.CreateDirectory(Settings.OutPath);
            }

            HotKeyManager.RegisterAll();
            SystemTrayManager.Init();
        }
Ejemplo n.º 3
0
 public void Setup()
 {
     _hotKeyManager.RegisterAll();
 }