Ejemplo n.º 1
0
        private int RegisterHotkey(Hotkey hotkey, int? id, bool suppressEvent)
        {
            int idValue = _DefaultID;

            if (id == null) {
                while (_Hotkeys.ContainsKey(_DefaultID)) {
                    _DefaultID++;
                }
                idValue = _DefaultID;
                _DefaultID++;
            }

            uint modifiers = 0;
            foreach (Modifier mod in hotkey.Modifiers) {
                modifiers |= (uint)mod;
            }

            if (RegisterHotKey(_Window.Handle, idValue, modifiers, (uint)hotkey.Key)) {
                hotkey.ListenerWindow = _Window;
                hotkey.Pressed += (HotkeyPressedEventArgs args) => {
                    if (HotkeyPressed != null) {
                        HotkeyPressed(args);
                    }
                };
                _Hotkeys.Add(idValue, hotkey);
            }
            else {
                if (!suppressEvent && UnavailableHotkeyRegistered != null) {
                    UnavailableHotkeyRegistered(new HotkeyEventArgs(hotkey));
                }
                idValue = -1;
            }
            return idValue;
        }
Ejemplo n.º 2
0
        public bool IsHotkeyAvailable(Hotkey hotkey)
        {
            bool retVal = true;
            int hotkeyID = RegisterHotkey(hotkey, null, true);

            if (hotkeyID < 0) retVal = false;
            else UnregisterHotkey(hotkeyID);

            return retVal;
        }
Ejemplo n.º 3
0
 public void RegisterHotkey(Hotkey hotkey)
 {
     RegisterHotkey(hotkey, null, false);
 }
Ejemplo n.º 4
0
 // returns the ID of the registered hotkey
 public int RegisterHotkey(Hotkey hotkey, int? id)
 {
     return RegisterHotkey(hotkey, id, false);
 }
Ejemplo n.º 5
0
 public HotkeyEventArgs(Hotkey hotkey)
 {
     this.Hotkey = hotkey;
 }
Ejemplo n.º 6
0
 public HotkeyPressedEventArgs(Hotkey hotkey)
     : base(hotkey)
 {
 }