/// <summary> /// Unregister all registered hot keys /// </summary> private void UnregisterAll() { foreach (KeyValuePair <int, string> hotKey in _idToHotKey) { HotKeyUtils.UnregisterKey(this, hotKey.Key); HotKeyUtils.GlobalDeleteAtom(hotKey.Key); } _idToHotKey.Clear(); }
// ------------------------------ // private // ------------------------------ /// <summary> /// Rregister the given hotkey /// </summary> /// <param name="strHotKey">hotkey</param> /// <returns>success flag of register action</returns> private bool Register(string strHotKey) { Unregister(strHotKey); var hotKeyId = HotKeyUtils.GlobalAddAtom("RE:" + strHotKey); if (hotKeyId == 0) { throw new Exception(string.Format("Could not register atom for {0} hotkey", strHotKey)); } if (HotKeyUtils.RegisterKey(this, hotKeyId, strHotKey)) { _idToHotKey.Add(hotKeyId, strHotKey); return(true); } return(false); }
/// <summary> /// Unregister the specified registered hot keys /// </summary> /// <param name="strKey">registered hotkey</param> private void Unregister(string strKey) { int intKey = 0; foreach (KeyValuePair <int, string> hotKey in _idToHotKey) { if (hotKey.Value == strKey) { intKey = hotKey.Key; HotKeyUtils.UnregisterKey(this, hotKey.Key); HotKeyUtils.GlobalDeleteAtom(hotKey.Key); break; } } if (intKey > 0) { _idToHotKey.Remove(intKey); } }