private void _shortcutEdt_KeyDown(object sender, KeyEventArgs e) { // Ignore initial Shift + Control + Alt keys if (e.KeyCode == Keys.ShiftKey) { e.Handled = true; } else if (e.KeyCode == Keys.ControlKey) { e.Handled = true; } else if (e.KeyCode == Keys.Menu) { e.Handled = true; } else { e.Handled = true; ExternalToolConfig tmp = new SnakeTail.ExternalToolConfig(); tmp.ShortcutKeyEnum = Control.ModifierKeys | e.KeyCode; _shortcutEdt.Text = tmp.ShortcutKey; _shortcutEdt.Select(0, 0); try { ToolStripMenuItem tempItem = new ToolStripMenuItem(); tempItem.ShortcutKeys = tmp.ShortcutKeyEnum.Value; } catch { MessageBox.Show(this, string.Format("'{0}' cannot be used as shortcut", tmp.ShortcutKey), this.Text + " - Invalid shortcut", MessageBoxButtons.OK); _shortcutEdt.Text = string.Empty; } } }
private void _shortcutEdt_KeyDown(object sender, KeyEventArgs e) { // Ignore initial Shift + Control + Alt keys if (e.KeyCode == Keys.ShiftKey) e.Handled = true; else if (e.KeyCode == Keys.ControlKey) e.Handled = true; else if (e.KeyCode == Keys.Menu) e.Handled = true; else { e.Handled = true; ExternalToolConfig tmp = new SnakeTail.ExternalToolConfig(); tmp.ShortcutKeyEnum = Control.ModifierKeys | e.KeyCode; _shortcutEdt.Text = tmp.ShortcutKey; _shortcutEdt.Select(0, 0); try { ToolStripMenuItem tempItem = new ToolStripMenuItem(); tempItem.ShortcutKeys = tmp.ShortcutKeyEnum.Value; } catch { MessageBox.Show(this, string.Format("'{0}' cannot be used as shortcut", tmp.ShortcutKey), this.Text + " - Invalid shortcut", MessageBoxButtons.OK); _shortcutEdt.Text = string.Empty; } } }