public static void SetNewGlobalHotkeyIfChanged(LoadedSettings loadedSettings, LoadedGlobalHotkey loadedGlobalHotkey, HotKeyManager hkManager) { if (loadedGlobalHotkey == loadedSettings.General.LoadedGlobalHotkey) return; UnregisterGlobalHotkey(hkManager, loadedGlobalHotkey); RegisterGlobalHotkey(hkManager, loadedSettings.General.LoadedGlobalHotkey); loadedGlobalHotkey = loadedSettings.General.LoadedGlobalHotkey; }
public static void UnregisterGlobalHotkey(HotKeyManager hkManager, LoadedGlobalHotkey hotkey) { if (hotkey.SecondModifierKey != ModifierKeys.None) { hkManager.Unregister(hotkey.Hotkey, hotkey.FirstModifierKey | hotkey.SecondModifierKey); } else { hkManager.Unregister(hotkey.Hotkey, hotkey.FirstModifierKey); } }
public static void PopulateGlobalHotkeyCombos(LoadedGlobalHotkey loadedHotkey, GlobalHotkeyObjectStruct globalHotkey) { var keyNames = Enum.GetNames(typeof (Key)); var modifierKeyNames = Enum.GetNames(typeof (ModifierKeys)); foreach (var keyName in keyNames) { globalHotkey.Hotkey.Items.Add(keyName); } foreach (var modifierKeyName in modifierKeyNames) { globalHotkey.FirstModifierKey.Items.Add(modifierKeyName); globalHotkey.SecondModifierKey.Items.Add(modifierKeyName); } globalHotkey.Hotkey.SelectedIndex = globalHotkey.Hotkey.Items.GetIndex(loadedHotkey.Hotkey.ToString()); globalHotkey.FirstModifierKey.SelectedIndex = globalHotkey.FirstModifierKey.Items.GetIndex(loadedHotkey.FirstModifierKey.ToString()); globalHotkey.SecondModifierKey.SelectedIndex = globalHotkey.SecondModifierKey.Items.GetIndex(loadedHotkey.SecondModifierKey.ToString()); }
private void LoadGlobalHotkey() { _hkManager.KeyPressed += HkManagerOnKeyPressed; GlobalHotkeyUtils.RegisterGlobalHotkey(_hkManager, _loadedSettings.General.LoadedGlobalHotkey); _currentLoadedGlobalHotkey = _loadedSettings.General.LoadedGlobalHotkey; }