public bool RegisterHotKey(KeyHandler key) { bool _keyRegistered = false; if (key.Registered) { _keyRegistered = true; } else { _keyRegistered = key.Register(); } if (_keyRegistered) { RegisterHotKeyEvent?.Invoke(key, RegisterStatus.SUCCESS); hotKeys.Add(key); } else { RegisterHotKeyEvent?.Invoke(key, RegisterStatus.FAILURE); } return(_keyRegistered); }
public void UnregisterAllHotKey() { // unregister foreach (KeyHandler key in hotKeys) { if (!key.Registered) { continue; } bool result = key.Unregiser(); RegisterHotKeyEvent?.Invoke(key, result? RegisterStatus.UNREGISTERED:RegisterStatus.UNREGISTER_FAILED); } hotKeys.Clear(); }