public void AddHotKey(HotKey hotkey) { if (hotkey == null) return; RemoveHotkey(hotkey); Keys.Add(hotkey); if (OnChange != null) OnChange(this, EventArgs.Empty); }
public void UpdateHotKey(HotKey key) { if( _settings.hotKeys.Keys.ToList().Exists( hk => hk.Title == key.Title )) { var i = _settings.hotKeys.Keys.IndexOf((HotKey)listHotKeys.SelectedItem); if (i >= 0) { _settings.hotKeys.Keys[i] = key; } else { _settings.hotKeys.Keys.Add(key); } _hotkeyBindingSrc = null; SetupHotkeyList(); } checkBoxHotKey.Checked = false; checkBoxHotKey.Enabled = true; listHotKeys.Enabled = true; checkBoxHold.Enabled = true; }
public void RemoveHotkey(HotKey hotkey) { var todelete = Keys.FirstOrDefault(hk => hk.Title == hotkey.Title); if (todelete != null) Keys.Remove(todelete); }
public HotKeyArgs(HotKey hotkey) { HotKey = hotkey; }
public HotKey GetHotKey(HotKey key) { if (key == null) { _currentHotkey = null; return null; } _currentHotkey = key; foreach (var joy in Joysticks.Where(d => d.Type == DeviceType.Physical)) joy.OnButtonDown += new EventHandler<CustomEventArgs<DirectInputData>>(hotkey_OnButton); Keyboards.ForEach(keyboard => keyboard.OnKeyUp += new EventHandler<CustomEventArgs<DirectInputData>>(hotkey_OnButton)); Mouses.ForEach(mouse => mouse.OnButtonDown += new EventHandler<CustomEventArgs<DirectInputData>>(hotkey_OnButton)); _currentHotkey.Key = null; while (_currentHotkey.Key == null) { Thread.Sleep(50); } return _currentHotkey; }