private void btnEditHotkey_Click(object sender, EventArgs e) { var form = new EditHotKeyForm(); var currentHkc = HotKeyCombination.GetFromConfig(AppSettings); var dialogResult = form.ShowDialog(); if (dialogResult == DialogResult.OK) { var newHkc = HotKeyCombination.GetFromConfig(AppSettings); if (newHkc.ToString() != currentHkc.ToString()) { InitHotKeys(); } } }
private void InitHotKeys() { var hkc = HotKeyCombination.GetFromConfig(AppSettings); this.txtHotkey.Text = hkc.ToString(); hotKeysHelper.UnregisterHotKeys(); try { hotKeysHelper.RegisterHotKey(hkc.ModifierKeys, hkc.Key); } catch (Exception ex) { log.Error(ex, "Error when tried to register hot key: {0}.", ex.Message); MessageBox.Show("Application was unable to register hot key\r\nperhaps it is already in use by other app.\r\nPlease pick different hot key.", "WinSetApplicationTitle", MessageBoxButtons.OK, MessageBoxIcon.Error); } }