private void btnAdd_Click(object sender, EventArgs e) { if (_mode == HotKeyFormMode.Normal && HotKeyManager.DuplicateHotKey(_hotkey)) { return; } if (_mode == HotKeyFormMode.Edit) { HotKeyManager.DeleteHotKey(_linkedHotKey); } //Add HK if (HotKeyManager.AddHotKey(_hotkey)) { DialogResult = DialogResult.OK; Close(); } else { errorProvider1.SetError(txtHotKey, "Hot Key is already registered"); } }
private void txtHotKey_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.ShiftKey || e.KeyCode == Keys.ControlKey || e.KeyCode == Keys.Menu) { return; } _hotkey.Key = e.KeyCode; _hotkey.Modifiers = Modifiers.None; if (e.Control) { _hotkey.Modifiers = _hotkey.Modifiers | Modifiers.Control; } if (e.Alt) { _hotkey.Modifiers = _hotkey.Modifiers | Modifiers.Alt; } if (e.Shift) { _hotkey.Modifiers = _hotkey.Modifiers | Modifiers.Shift; } if (e.Modifiers == Keys.LWin || e.Modifiers == Keys.RWin) { _hotkey.Modifiers = _hotkey.Modifiers | Modifiers.Win; } txtHotKey.Text = _hotkey.HotKeyString; if (_mode != HotKeyFormMode.Edit && HotKeyManager.DuplicateHotKey(_hotkey)) { errorProvider1.SetError(txtHotKey, "Duplicate Hot Key Detected"); } }
private void txtHotKey_KeyUp(object sender, KeyEventArgs e) { if (Recording) { hotkey.Key = e.KeyCode; hotkey.Modifiers = Modifiers.None; if (e.Control) { hotkey.Modifiers = hotkey.Modifiers | Modifiers.Control; } if (e.Alt) { hotkey.Modifiers = hotkey.Modifiers | Modifiers.Alt; } if (e.Shift) { hotkey.Modifiers = hotkey.Modifiers | Modifiers.Shift; } if (e.Modifiers == Keys.LWin || e.Modifiers == Keys.RWin) { hotkey.Modifiers = hotkey.Modifiers | Modifiers.Win; } txtHotKey.Text = hotkey.HotKeyString; Recording = false; if (Mode != HotKeyFormMode.Edit && HotKeyManager.DuplicateHotKey(hotkey)) { errorProvider1.SetError(txtHotKey, "Duplicate Hot Key Detected"); } } }