public void ActionHashMap() { Action action; Dictionary <Hotkey, Action> actions = new Dictionary <Hotkey, Action>(); Hotkey hotkey = new Hotkey(System.Windows.Forms.Keys.D, ModifierKeys.Control, ModifierKeys.Shift); actions.Add(hotkey, new ButtonPressAction("")); Hotkey hotkey2 = new Hotkey(System.Windows.Forms.Keys.D, ModifierKeys.Control, ModifierKeys.Shift); Hotkey hotkey3 = new Hotkey(System.Windows.Forms.Keys.D, ModifierKeys.Shift, ModifierKeys.Control); Assert.AreEqual(hotkey.GetHashCode(), hotkey2.GetHashCode()); //Assert.IsTrue(hotkey.Equals(hotkey2)); uint shift = (uint)ModifierKeys.Shift; Assert.AreEqual(hotkey.GetModifiersUInt(), (uint)ModifierKeys.Shift | (uint)ModifierKeys.Control); actions.TryGetValue(hotkey, out action); Assert.NotNull(action); actions.TryGetValue(hotkey2, out action); Assert.NotNull(action); actions.TryGetValue(hotkey3, out action); Assert.NotNull(action); }
public void Remove(Hotkey hotkey) { _hotkeyActions.Remove(hotkey); if (!_app.Dispatcher.Invoke(() => UnregisterHotKey(IntPtr.Zero, hotkey.GetHashCode()))) { throw new HotkeyRegistrationException($"Failed to un-register hotkey {hotkey}."); } }
public void Add(Hotkey hotkey, Action action) { _hotkeyActions.Add(hotkey, action); var keyModifier = (int)hotkey.KeyModifier; var key = KeyInterop.VirtualKeyFromKey(hotkey.Key); if (!_app.Dispatcher.Invoke(() => RegisterHotKey(IntPtr.Zero, hotkey.GetHashCode(), keyModifier, key))) { throw new HotkeyRegistrationException($"Failed to register hotkey {hotkey}."); } }
public void Remove(Hotkey hotkey) { _hotkeyActions.Remove(hotkey); _app.Dispatcher.Invoke(() => { if (!UnregisterHotKey(IntPtr.Zero, hotkey.GetHashCode())) { throw new Win32Exception(Marshal.GetLastWin32Error()); } }); }
public void Add(Hotkey hotkey, Action action) { _hotkeyActions.Add(hotkey, action); var keyModifier = (int)hotkey.KeyModifier; var key = KeyInterop.VirtualKeyFromKey(hotkey.Key); _app.Dispatcher.Invoke(() => { if (!RegisterHotKey(IntPtr.Zero, hotkey.GetHashCode(), keyModifier, key)) { throw new Win32Exception(Marshal.GetLastWin32Error()); } }); }
public override int GetHashCode() { unchecked { int hashCode = Guid.GetHashCode(); hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (GuiArgs != null ? GuiArgs.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Commands != null ? Commands.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Active.GetHashCode(); hashCode = (hashCode * 397) ^ Count; hashCode = (hashCode * 397) ^ (Hotkey != null ? Hotkey.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Flags != null ? Flags.GetHashCode() : 0); return(hashCode); } }