예제 #1
0
 private void RegisterHotkeys()
 {
     if (!HotkeyUtils.RegisterAllHotkeys(GuiHelper.GetWindowHandle(this), _config.GlobalHotkeys))
     {
         MessageBox.Show(Messages.GUIErrorHotkeys, Messages.GUIErrorCommon, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
예제 #2
0
        private void Window_Closing(object sender, CancelEventArgs e)
        {
            if (_config.CloseToTray && Visibility != Visibility.Hidden)
            {
                Hide();
                e.Cancel = true;
            }

            if (RecordingState != RecordingState.Stopped)
            {
                if (MessageBox.Show(Messages.GUIStopRecording, Messages.GUIStopRecordingTitle, MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
                {
                    e.Cancel = true;
                    return;
                }

                UpdateRecordingNumber();
            }

            _audioRecorder.Dispose();

            if (_isSizeChanged)
            {
                _config.SetWindowSize(Name, Width, Height);
            }

            if (_isSizeChanged || _config.HasChanges())
            {
                ConfigHandler.SaveConfig(_config);
            }

            HotkeyUtils.UnregisterAllHotkeys(GuiHelper.GetWindowHandle(this));
            HotkeyUtils.GlobalHoykeyPressed -= HotkeyUtils_GlobalHoykeyPressed;
        }
        protected virtual void RecordHotkeys()
        {
            hotkeyRecorded = true;

            if (newKey == Keys.None || HotkeyUtils.IsKeyValid(newKey) == false)
            {
                newKey       = Keys.None;
                newModifiers = Keys.None;
            }

            key       = newKey;
            modifiers = newModifiers;

            OnHotkeysChanged(new HotkeysEventArgs(Hotkeys));
            UpdateHotkeyName();
        }
        private void TextBoxKeyUp(object sender, KeyEventArgs e)
        {
            e.Handled          = true;
            e.SuppressKeyPress = true;

            if (HotkeyUtils.GetModifierKeys(e.KeyCode) == Keys.None)
            {
                RecordHotkeys();
                return;
            }

            if (hotkeyRecorded == false)
            {
                newModifiers = e.Modifiers;
            }

            UpdateHotkeyName();
        }
        private void TextBoxKeyDown(object sender, KeyEventArgs e)
        {
            e.Handled          = true;
            e.SuppressKeyPress = true;

            if (hotkeyRecorded == true)
            {
                hotkeyRecorded = false;
                newKey         = Keys.None;
                newModifiers   = Keys.None;
            }

            if (HotkeyUtils.GetModifierKeys(e.KeyCode) == Keys.None)
            {
                newKey = e.KeyCode;
            }

            newModifiers = e.Modifiers;

            UpdateHotkeyName();
        }
예제 #6
0
        private void settingsMenuItem_Click(object sender, RoutedEventArgs e)
        {
            SettingsWindow settingsWindow = new SettingsWindow(_config);

            Topmost = false;

            IntPtr windowHandle = GuiHelper.GetWindowHandle(this);

            HotkeyUtils.UnregisterAllHotkeys(windowHandle);
            if (settingsWindow.ShowDialog() == true)
            {
                _config = settingsWindow.Config;
                ApplySettings();

                if (_config.HasPropertyChanged(nameof(_config.OutputFormat)) ||
                    _config.HasPropertyChanged(nameof(_config.MP3EncodingPreset)))
                {
                    InitAudioDevices();
                }
            }
            HotkeyUtils.RegisterAllHotkeys(windowHandle, _config.GlobalHotkeys);
        }