Exemplo n.º 1
0
 /// <summary>
 /// Registers the hotkey.
 /// </summary>
 /// <param name="hotkeyDescriptor">The hotkey registration.</param>
 /// <param name="callback">The callback.</param>
 public void RegisterHotkey(HotkeyDescriptor hotkeyDescriptor, Action callback)
 {
     var hotkey = GetHotKey(hotkeyDescriptor.Modifiers, hotkeyDescriptor.Key);
     if (null == hotkey)
     {
         hotkey = new HotKey(hotkeyDescriptor.Modifiers, hotkeyDescriptor.Key, HotkeyId);
         registeredHotkeys.Add(hotkey.Id, hotkey);
         HookHotkey(hotkey, hotkey.Id);
     }
     hotkey.RegisterCallback(callback);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Registers the hotkey.
        /// </summary>
        /// <param name="hotkeyDescriptor">The hotkey registration.</param>
        /// <param name="callback">The callback.</param>
        public void RegisterHotkey(HotkeyDescriptor hotkeyDescriptor, Action callback)
        {
            var hotkey = GetHotKey(hotkeyDescriptor.Modifiers, hotkeyDescriptor.Key);

            if (null == hotkey)
            {
                hotkey = new HotKey(hotkeyDescriptor.Modifiers, hotkeyDescriptor.Key, HotkeyId);
                registeredHotkeys.Add(hotkey.Id, hotkey);
                HookHotkey(hotkey, hotkey.Id);
            }
            hotkey.RegisterCallback(callback);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Res the register hotkey.
 /// </summary>
 /// <param name="oldDescriptor">The old descriptor.</param>
 /// <param name="newDescriptor">The new descriptor.</param>
 /// <param name="callback">The callback.</param>
 public void ReRegisterHotkey(HotkeyDescriptor oldDescriptor,
                              HotkeyDescriptor newDescriptor,
                              Action callback)
 {
     if (null != oldDescriptor)
     {
         UnregisterHotkey(oldDescriptor, callback);
     }
     if (null != newDescriptor)
     {
         RegisterHotkey(newDescriptor, callback);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Unregisters the hotkey.
        /// </summary>
        /// <param name="hotkeyDescriptor">The hotkey registration.</param>
        /// <param name="callback">The callback.</param>
        public void UnregisterHotkey(HotkeyDescriptor hotkeyDescriptor, Action callback)
        {
            var hotkey = GetHotKey(hotkeyDescriptor.Modifiers, hotkeyDescriptor.Key);

            if (null == hotkey)
            {
                return;
            }
            hotkey.UnRegisterCallback(callback);
            if (!hotkey.IsEmpty)
            {
                return;
            }
            UnregisterHotKey(source.Handle, hotkey.Id);
            registeredHotkeys.Remove(hotkey.Id);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Res the register hotkey.
 /// </summary>
 /// <param name="oldDescriptor">The old descriptor.</param>
 /// <param name="newDescriptor">The new descriptor.</param>
 /// <param name="callback">The callback.</param>
 public void ReRegisterHotkey(HotkeyDescriptor oldDescriptor,
                              HotkeyDescriptor newDescriptor,
                              Action callback)
 {
     if (null != oldDescriptor)
         UnregisterHotkey(oldDescriptor, callback);
     if (null != newDescriptor)
         RegisterHotkey(newDescriptor, callback);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Unregisters the hotkey.
 /// </summary>
 /// <param name="hotkeyDescriptor">The hotkey registration.</param>
 /// <param name="callback">The callback.</param>
 public void UnregisterHotkey(HotkeyDescriptor hotkeyDescriptor, Action callback)
 {
     var hotkey = GetHotKey(hotkeyDescriptor.Modifiers, hotkeyDescriptor.Key);
     if (null == hotkey) return;
     hotkey.UnRegisterCallback(callback);
     if (!hotkey.IsEmpty) return;
     UnregisterHotKey(source.Handle, hotkey.Id);
     registeredHotkeys.Remove(hotkey.Id);
 }