/// <summary> /// Unregisters all the registered Hotkeys. /// </summary> private void Unregister() { foreach (KeyValuePair <int, string> hotKey in Hotkeys) { HotkeyCore.UnregisterKey(this, hotKey.Key); HotkeyCore.GlobalDeleteAtom(hotKey.Key); } Hotkeys.Clear(); }
/// <summary> /// Unregisters any registered Hotkeys. /// </summary> /// <param name="hotkey">The registered Hotkey.</param> private void Unregister(string hotkey) { int intKey = 0; foreach (KeyValuePair <int, string> hotKey in Hotkeys) { if (hotKey.Value == hotkey) { intKey = hotKey.Key; HotkeyCore.UnregisterKey(this, hotKey.Key); HotkeyCore.GlobalDeleteAtom(hotKey.Key); break; } } if (intKey > 0) { Hotkeys.Remove(intKey); } }
/// <summary> /// Validates and registers any given Hotkey. /// </summary> /// <param name="hotkey">The Hotkey string.</param> private bool Register(string hotkey) { this.Unregister(hotkey); int hotKeyId = HotkeyCore.GlobalAddAtom("RE:" + hotkey); if (hotKeyId == 0) { throw new Exception( string.Format( "Could not register atom for {0} Hotkey. " + "Please try another Hotkey.", hotkey)); } if (HotkeyCore.RegisterKey(this, hotKeyId, hotkey)) { Hotkeys.Add(hotKeyId, hotkey); return(true); } return(false); }