예제 #1
0
 protected override void OnKeyDown(KeyEventArgs kevent)
 {
     kevent.SuppressKeyPress = true;
     if (Editing)
     {
         if (kevent.KeyData == Keys.Escape)
         {
             Editing   = false;
             Highlight = false;
             HotKey    = PreHk;
             SetHkText();
             OnHotKeyCanceled(this, EventArgs.Empty);
             return;
         }
         Key    = kevent.KeyData;
         HotKey = new HotKeyData(Key);
         if (!HotKey.IsValidHotkey)
         {
             SetHkText(); return;
         }
         SetHkText();
         OnHotKeyChanged(this, EventArgs.Empty);
         Editing   = false;
         Highlight = false;
     }
     base.OnKeyDown(kevent);
 }
예제 #2
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                //here we turn on/off editing mode.
                Editing   = !Editing;
                Highlight = Editing;
                if (Editing)
                {
                    PreHk = HotKey;
                    OnHotKeyClicked(this, EventArgs.Empty);
                }
                else
                {
                    OnHotKeyCanceled(this, EventArgs.Empty);
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                Editing   = false;
                Highlight = false;
                Key       = Keys.None;
                HotKey    = new HotKeyData(Keys.None);
                SetHkText();
                OnHotKeyChanged(this, EventArgs.Empty);
            }


            base.OnMouseUp(e);
        }
        /// <inheritdoc />
        public HotKeyDataBinder(HotKeyManager hotKeyManager, HotKeyData hotKeyData)
        {
            _hotKeyManager = hotKeyManager;

            HotKeyData = hotKeyData;
            HotKey     = hotKeyData.ActualHotKey?.ToMahApps();
        }
예제 #4
0
        public void UnregisterHotKey(Keys key, HotKeyModifiers modifiers)
        {
            HotKeyData hkData = FindHotKey(key, modifiers);

            if (!hkData.Equals(HotKeyData.Empty))
            {
                unregisterHotKey(hkData);
                hotkeys.Remove(hkData);
            }
        }
예제 #5
0
 protected override void OnKeyUp(KeyEventArgs kevent)
 {
     kevent.SuppressKeyPress = true;
     if (Editing)
     {
         //only if printscreen because it's not triggered on keydown.
         if (kevent.KeyCode == Keys.PrintScreen)
         {
             Key    = kevent.KeyData;
             HotKey = new HotKeyData(Key);
             if (!HotKey.IsValidHotkey)
             {
                 SetHkText(); return;
             }
             SetHkText();
             OnHotKeyChanged(this, EventArgs.Empty);
             Editing   = false;
             Highlight = false;
         }
     }
     base.OnKeyUp(kevent);
 }
예제 #6
0
 private void unregisterHotKey(HotKeyData hk)
 {
     UnregisterHotKey(this.Handle, hk.AtomID.ToInt32());
     GlobalDeleteAtom(hk.AtomID);
 }
예제 #7
0
 public bool AtomID_Equals(HotKeyData hk)
 {
     return this.AtomID == hk.AtomID;
 }
예제 #8
0
 private void unregisterHotKey(HotKeyData hk)
 {
     UnregisterHotKey(this.Handle, hk.AtomID.ToInt32());
     GlobalDeleteAtom(hk.AtomID);
 }