private void button1_Click(object sender, EventArgs e) { if (_configContent == null) { return; } //MessageBox.Show("Not implemented yet!","Not Implemented",MessageBoxButtons.OK,MessageBoxIcon.Warning); DialogResult dlgRes = MessageBox.Show("Do you want to restore default short cuts for all actions?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlgRes == DialogResult.No) { return; } _newShortcuts.Clear(); string[] actionNames = Enum.GetNames(typeof(ScriptEditorActions)); foreach (string actionName in actionNames) { ScriptEditorActions action = (ScriptEditorActions)Enum.Parse(typeof(ScriptEditorActions), actionName); Keys defShortcut = ScriptEditorShortcutKeysProvider.GetDefaultShortCut(action); if (_newShortcuts.ContainsKey(action)) { _newShortcuts[action] = defShortcut; } else { _newShortcuts.Add(action, defShortcut); } } LoadFrom(_newShortcuts); panEdit.Enabled = false; _isModified = true; }
private void btnSet_Click(object sender, EventArgs e) { if (lv.SelectedItems.Count == 0) { MessageBox.Show("No shortcut is currently selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } ListViewItem item = lv.SelectedItems[0]; ScriptEditorActions action = (ScriptEditorActions)Enum.Parse(typeof(ScriptEditorActions), item.Text); Keys result = CreateKeysFromUserInput(); item.Tag = result; item.SubItems[1].Text = ScriptEditorShortcutKeysProvider.ShortcutKeysAsStringFromKeys(result); _isModified = true; if (_newShortcuts.ContainsKey(action)) { _newShortcuts[action] = result; } else { _newShortcuts.Add(action, result); } }
private void LoadInitial( ) { lv.Items.Clear(); Array values = Enum.GetValues(typeof(ScriptEditorActions)); foreach (ScriptEditorActions action in values) { ListViewItem item = lv.Items.Add(action.ToString()); item.SubItems.Add(ScriptEditorShortcutKeysProvider.ShortcutKeysAsStringFromAction(action)); item.Tag = ScriptEditorShortcutKeysProvider.GetShortCut(action); } }
public static string ShortcutKeysAsStringFromAction(ScriptEditorActions action) { string result = String.Empty; Keys keys = ScriptEditorShortcutKeysProvider.GetShortCut(action); Keys modKeys = Keys.Modifiers & keys; //Ctrl+Alt+Shift+M if ((Keys.Control & modKeys) == Keys.Control) { result += "Ctrl"; } if ((Keys.Alt & modKeys) == Keys.Alt) { if (!String.IsNullOrEmpty(result)) { result += "+Alt"; } else { result += "Alt"; } } if ((Keys.Shift & modKeys) == Keys.Shift) { if (!String.IsNullOrEmpty(result)) { result += "+Shift"; } else { result += "Shift"; } } Keys key = Keys.KeyCode & keys; if (String.IsNullOrEmpty(result)) { result += Enum.GetName(typeof(Keys), key); } else { result += "+" + Enum.GetName(typeof(Keys), key); } return(result); }
private void LoadFrom(SerializableDictionary <ScriptEditorActions, Keys> source) { lv.Items.Clear(); Array values = Enum.GetValues(typeof(ScriptEditorActions)); foreach (ScriptEditorActions action in source.Keys) { ListViewItem item = lv.Items.Add(action.ToString()); item.SubItems.Add(ScriptEditorShortcutKeysProvider.ShortcutKeysAsStringFromKeys(source[action])); item.Tag = source[action]; } }
public bool SaveContent( ) { foreach (ScriptEditorActions action in _newShortcuts.Keys) { _scriptEditorShortcuts[action] = _newShortcuts[action]; ScriptEditorShortcutKeysProvider.SetShortCut(action, _newShortcuts[action]); } ScriptEditorShortcutKeysProvider.LoadFrom(_scriptEditorShortcuts); _newShortcuts.Clear(); _isModified = false; return(true); }