Esempio n. 1
0
 /// <summary>
 /// Equality based on <see cref="Name"/> and <see cref="HotKey"/>
 /// </summary>
 public override int GetHashCode()
 {
     unchecked
     {
         return((HotKey.GetHashCode() * 397) ^ (Name != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(Name) : 0));
     }
 }
Esempio n. 2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (int)Type;
         hashCode = (hashCode * 397) ^ (WindowName != null ? WindowName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ApplicationPath != null ? ApplicationPath.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (HotKey != null ? HotKey.GetHashCode() : 0);
         return(hashCode);
     }
 }
        public override int GetHashCode()
        {
            unchecked
            {
                int hash = 17;

                hash += 13 * Name.GetHashCode();
                hash += 13 * Path.GetHashCode();
                hash += 13 * Arguments.GetHashCode();
                hash += 13 * HotKey.GetHashCode();

                if (Commands != null)
                {
                    hash += 13 * Commands.GetHashCode();
                }

                return(hash);
            }
        }
Esempio n. 4
0
        public bool RegisterHotKey(string id, HotKey hk, Action <HotKeyEventArgs> callback)
        {
            Debug.WriteLine("RegisterHotKey: " + id + " " + hk.ToString());
            if (_idToHotKey.ContainsKey(id))
            {
                UnRegisterHotKeyById_internal(id);
            }

            // register the hot key.
            if (User32.RegisterHotKey(_window.Handle, hk.GetHashCode(), (int)hk.modifiers, (int)hk.key))
            {
                _keyToAction.Add(hk, callback);
                _idToHotKey.Add(id, hk);

                if (HotKeyRegistered != null)
                {
                    HotKeyRegistered(id, hk);
                }
                return(true);
            }

            return(false);
        }
Esempio n. 5
0
        /*public void UnRegisterHotKey(ModifierKeys modifiers, Keys key)
         * {
         *  UnRegisterHotKey(new HotKey() { modifiers = modifiers, key = key });
         * }*/

        private void UnRegisterHotKey(HotKey hk)
        {
            User32.UnregisterHotKey(_window.Handle, hk.GetHashCode());
            _keyToAction.Remove(hk);
        }