/// <summary> /// 注销 /// </summary> /// <param name="modifierKey">组合键</param> /// <param name="key">键</param> /// <returns></returns> public bool Unregister(Enumeration.ModifierKeys modifierKey, Keys key) { //热键ID ushort id = GlobalAtom.Find(this.GetHotKeyName(modifierKey, key)); //热键存在 if (this.HotKeyTable.ContainsKey(id)) { //注销 if (HotKeyManager.UnregisterHotKey(this.Owner.Handle, id)) { //从热键表中删除 this.HotKeyTable.Remove(id); //删除对应的全局原子 GlobalAtom.Delete(id); return(true); } else { return(false); } } else { //热键不存在 return(false); } }
/// <summary> /// 清空 /// </summary> public void Clear() { //轮循 foreach (ushort id in this.HotKeyTable.Keys) { //注销 HotKeyManager.UnregisterHotKey(this.Owner.Handle, id); //删除对应的全局原子 GlobalAtom.Delete(id); } //从热键表中删除 this.HotKeyTable.Clear(); }
/// <summary> /// 注册 /// </summary> /// <param name="modifierKey">组合键</param> /// <param name="key">键</param> /// <param name="hotKeyEventHandler">热键事件委托</param> /// <returns></returns> public bool Register(Enumeration.ModifierKeys modifierKey, Keys key, HotKeyEventHandler hotKeyEventHandler) { //热键ID ushort id = GlobalAtom.Add(this.GetHotKeyName(modifierKey, key)); //注册 if (HotKeyManager.RegisterHotKey(this.Owner.Handle, id, (uint)modifierKey, (uint)key)) { //保存到热键表中 this.HotKeyTable.Add(id, hotKeyEventHandler); return(true); } else { return(false); } }
/// <summary> /// 删除 /// </summary> /// <param name="value"></param> /// <returns></returns> public static bool Delete(ushort value) { return(GlobalAtom.GlobalDeleteAtom(value) == 0); }
/// <summary> /// 查询 /// </summary> /// <param name="key"></param> /// <returns></returns> public static ushort Find(string key) { return(GlobalAtom.GlobalFindAtom(key)); }
/// <summary> /// 添加 /// </summary> /// <param name="key"></param> /// <returns></returns> public static ushort Add(string key) { return(GlobalAtom.GlobalAddAtom(key)); }