/// <summary> /// Must unregister registered hot keys before destroying the native driver window. /// </summary> public void Dispose() { if (isDisposed) { return; } if (window != null) { foreach (HotKey key in keys.Values) { KeyInterops.UnregisterHotKey(window.Handle, key.HotId); } } if (keys != null) { keys.Clear(); keys = null; } if (window != null) { window.KeyPressed -= DoKeyPressed; window.Dispose(); window = null; } isDisposed = true; GC.SuppressFinalize(this); }
/// <summary> /// Unregisters the given key sequence as a known hot key. /// </summary> /// <param name="code">The primary keyboard key-code identifier.</param> /// <param name="modifier">The secondary keyboard modifiers bit mask.</param> public void UnregisterHotKey(Keys code, KeyModifier modifier) { HotKey key = keys.Values .FirstOrDefault(p => (p.Code == code) && (p.Modifier == modifier)); if (key != null) { keys.Remove(key.Action); if ((key.Code != Keys.None) && (key.Modifier != KeyModifier.None)) { if (!KeyInterops.UnregisterHotKey(window.Handle, key.HotId)) { MessageWindow.Show(string.Format( Resx.HotKeyNotUnregistered, key.Action, key)); } } } }