public static void DeleteHotKey(HotKey hk) { //Ensure its unregistered hk.UnregsiterHotkey(); _hotkeys.Remove(hk); SaveHotKeys(); }
public static bool DuplicateHotKey(HotKey hk) { foreach (HotKey k in _hotkeys) { if (hk.Key == k.Key && hk.Modifiers == k.Modifiers) //((int)hk.Key & (int)hk.Modifiers) == ((int)k.Key & (int)k.Modifiers)) return true; } return false; }
public HotKeyForm(HotKey hk) : this() { linkedHotKey = hk; hotkey.DeviceID = hk.DeviceID; hotkey.Key = hk.Key; hotkey.Modifiers = hk.Modifiers; txtHotKey.Text = hk.HotKeyString; FirstFocus = false; Mode = HotKeyFormMode.Edit; btnAdd.Text = "Save"; }
public HotKeyForm() { InitializeComponent(); hotkey = new HotKey(); cmbDevices.Items.Clear(); foreach (AudioDevice ad in AudioDeviceManager.PlayBackDevices) cmbDevices.Items.Add(ad); foreach (AudioDevice ad in AudioDeviceManager.RecordingDevices) cmbDevices.Items.Add(ad); cmbDevices.DisplayMember = "FullName"; cmbDevices.ValueMember = "ID"; }
public HotKeyForm() { InitializeComponent(); _hotkey = new HotKey(); cmbDevices.Items.Clear(); foreach (var ad in AudioDeviceManager.Controller.GetPlaybackDevices()) cmbDevices.Items.Add(ad); foreach (var ad in AudioDeviceManager.Controller.GetCaptureDevices()) cmbDevices.Items.Add(ad); cmbDevices.DisplayMember = "FullName"; cmbDevices.ValueMember = "ID"; }
public HotKeyForm(HotKey hk) : this() { _linkedHotKey = hk; _hotkey.DeviceId = hk.DeviceId; _hotkey.Key = hk.Key; _hotkey.Modifiers = hk.Modifiers; txtHotKey.Text = hk.HotKeyString; _firstFocus = false; _mode = HotKeyFormMode.Edit; btnAdd.Text = "Save"; }
public static bool AddHotKey(HotKey hk) { //Check that there is no duplicate if (DuplicateHotKey(hk)) return false; hk.HotKeyPressed += hk_HotKeyPressed; hk.RegisterHotkey(); if (!hk.IsRegistered) return false; _hotkeys.Add(hk); SaveHotKeys(); return true; }
public static void LoadHotKeys() { try { foreach (HotKey hk in _hotkeys) { hk.UnregsiterHotkey(); } string hotkeydata = ConfigurationSettings.HotKeys; if (string.IsNullOrEmpty(hotkeydata)) return; string[] entries = hotkeydata.Split(new[] {",", "[", "]"}, StringSplitOptions.RemoveEmptyEntries); _hotkeys.Clear(); for (int i = 0; i < entries.Length; i++) { int key = int.Parse(entries[i++]); int modifiers = int.Parse(entries[i++]); var hk = new HotKey(); hk.DeviceID = entries[i]; hk.Modifiers = (Modifiers) modifiers; hk.Key = (Keys) key; _hotkeys.Add(hk); hk.HotKeyPressed += hk_HotKeyPressed; hk.RegisterHotkey(); } } catch { ConfigurationSettings.HotKeys = ""; } }
public HotKeyNativeWindow(HotKey owner) { Owner = owner; }
private void setHotKeyToolStripMenuItem_Click(object sender, EventArgs e) { HotKeyForm hkf = null; foreach (HotKey hk in HotKeyManager.HotKeys) { if (hk.DeviceID == SelectedRecordingDevice.ID) { hkf = new HotKeyForm(hk); hkf.ShowDialog(this); return; } } var newHotKey = new HotKey(); newHotKey.DeviceID = SelectedRecordingDevice.ID; hkf = new HotKeyForm(newHotKey); hkf.ShowDialog(this); }
public static bool DuplicateHotKey(HotKey hk) { return(_hotkeys.Any(k => hk.Key == k.Key && hk.Modifiers == k.Modifiers)); }
private void setHotKeyToolStripMenuItem_Click(object sender, EventArgs e) { if (SelectedRecordingDevice == null) return; var hotkey = HotKeyManager.HotKeys.FirstOrDefault(x => x.DeviceId == SelectedRecordingDevice.Id); if (hotkey == null) { hotkey = new HotKey(); hotkey.DeviceId = SelectedRecordingDevice.Id; } var hkf = new HotKeyForm(hotkey); hkf.ShowDialog(this); }
public static void LoadHotKeys() { try { foreach (var hk in _hotkeys) { hk.UnregsiterHotkey(); } _hotkeys.Clear(); var hotkeydata = Program.Settings.HotKeys; if (string.IsNullOrEmpty(hotkeydata)) { RefreshHotkeys(); return; } var entries = hotkeydata.Split(new[] { ",", "[", "]" }, StringSplitOptions.RemoveEmptyEntries); for (var i = 0; i < entries.Length; i++) { var key = int.Parse(entries[i++]); var modifiers = int.Parse(entries[i++]); var hk = new HotKey(); var r = new Regex(ConfigurationSettings.GUID_REGEX); var matches = r.Matches(entries[i]); if (matches.Count == 0) continue; hk.DeviceId = new Guid(matches[0].ToString()); hk.Modifiers = (Modifiers)modifiers; hk.Key = (Keys)key; _hotkeys.Add(hk); hk.HotKeyPressed += hk_HotKeyPressed; hk.RegisterHotkey(); } } catch { Program.Settings.HotKeys = ""; } }
public static bool DuplicateHotKey(HotKey hk) { return _hotkeys.Any(k => hk.Key == k.Key && hk.Modifiers == k.Modifiers); }