private void HotkeyRecorder_OnKeyDown(object sender, KeyEventArgs e)
        {
            if (!_recording || Hotkeys == null)
            {
                Hotkeys = null;
                Hotkeys = new List <Key>();
            }

            if (Hotkeys.Contains(e.Key))
            {
                return;
            }

            Hotkeys.Add(e.Key);

            _recording = true;

            KeyString.Content = HotkeyString;
            e.Handled         = true;
        }
Пример #2
0
        public void RegisterHotkey(HotkeySettings hotkeySetting)
        {
            UnregisterHotkey(hotkeySetting, false);

            if (hotkeySetting.HotkeyInfo.Status != HotkeyStatus.Registered && hotkeySetting.HotkeyInfo.IsValidHotkey)
            {
                hotkeyForm.RegisterHotkey(hotkeySetting.HotkeyInfo);

                if (hotkeySetting.HotkeyInfo.Status == HotkeyStatus.Registered)
                {
                    DebugHelper.WriteLine("Hotkey registered: " + hotkeySetting);
                }
                else if (hotkeySetting.HotkeyInfo.Status == HotkeyStatus.Failed)
                {
                    DebugHelper.WriteLine("Hotkey register failed: " + hotkeySetting);
                }
            }

            if (!Hotkeys.Contains(hotkeySetting))
            {
                Hotkeys.Add(hotkeySetting);
            }
        }