public static int RegisterKey(Hotkey hotkey, HotkeyActivated callback, Window window) { IntPtr hwnd = new WindowInteropHelper(window).Handle; if (RegisterHotKey(hwnd, nextKeyId, hotkey.Mod, hotkey.Key)) { Hotkeys.Add(hotkey, new HotkeyData { Callback = callback, ID = nextKeyId }); } else { return(-1); } return(nextKeyId++); // return then increase }
protected void OnHotkeyActivated(EventArgs e) { HotkeyActivated?.Invoke(this, e); }
protected virtual void OnKeyPressed(KeyEventArgs e) { HotkeyActivated?.Invoke(this, e); }