private void keyCombinationHelper_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == (Keys.Control | Keys.ControlKey)) { return; } if (e.KeyData == (Keys.Alt | Keys.LMenu)) { return; } if (e.KeyData == (Keys.Alt | Keys.Control | Keys.Menu)) { return; } if (e.KeyData == (Keys.Shift | Keys.ShiftKey)) { return; } shortCutValue = KeysHelper.GetKeyCombination(e.KeyData); SetKeyText(); }
private void buttonGetGlobalKey_Click(object sender, EventArgs e) { var getShortCutKeyCode = new GetShortCutKeyCode(); getShortCutKeyCode.ShortCut = KeysHelper.GetKeyCombination(textBoxGlobalKey.Text); if (getShortCutKeyCode.ShowDialog() == DialogResult.OK) { textBoxGlobalKey.Text = getShortCutKeyCode.ShortCut.ToString(); settings.GlobalKey = textBoxGlobalKey.Text; } }
private void globalKeyButton_Click(object sender, EventArgs e) { var getShortCutKeyCode = new GetShortCutKeyCode(); getShortCutKeyCode.ShortCut = KeysHelper.GetKeyCombination(globalKeyTextBox.Text); if (getShortCutKeyCode.ShowDialog() == DialogResult.OK) { globalKeyTextBox.Text = getShortCutKeyCode.ShortCut.ToString(); selectedCommand.GlobalKey = globalKeyTextBox.Text; } }
public void LoadConfiguration() { ConfigurationHelper.LoadPlugins(); ClearRegisteredCommands(); //Register Root Command GlobalKeys.Add(KeysHelper.GetKeyCombination(Properties.Settings.Default.GlobalKey), rootCommand); var commands = ConfigurationHelper.GetCommands(globalKeys); if (commands != null) { foreach (var command in commands) { RegisterMainLevelCommand(command); } } ClearCommandStack(); OnCommandListChanged(EventArgs.Empty); }
public static IList <IKeyCommand> GetCommands(IDictionary <KeyCombination, IKeyCommand> globalCommands) { var result = new List <IKeyCommand>(); var commands = new Dictionary <string, IKeyCommand>(); var configCommands = GetConfigCommands(); foreach (var configCommand in configCommands) { IKeyCommand command = CreateCommand(configCommand); if (!String.IsNullOrWhiteSpace(configCommand.GlobalKey)) { globalCommands.Add(KeysHelper.GetKeyCombination(configCommand.GlobalKey), command); } if (command == null) { LogManager.Logger(typeof(ConfigurationHelper)) .WarnFormat("Nie powiodło się u instancji komendy [{0}], nie odnalezione typu '{1}'.", configCommand.Id, configCommand.CommandType); continue; } commands.Add(configCommand.Id, command); } foreach (var configCommand in configCommands) { var command = commands[configCommand.Id]; if (string.IsNullOrEmpty(configCommand.Parent)) { result.Add(command); } else { if (commands.ContainsKey(configCommand.Parent)) { var group = commands[configCommand.Parent] as IKeyCommandGroup; if (group != null) { group.SubCommands.Add(command); } else { LogManager.Logger(typeof(ConfigurationHelper)) .ErrorFormat("Komenda [{0}], nie implementuje interfejsu IKeyCommandGroup, nie można dodać potomka.", configCommand.Parent); LogManager.Logger(typeof(ConfigurationHelper)) .WarnFormat("Komenda [{0}] została pominięta.", configCommand.Id); } } else { LogManager.Logger(typeof(ConfigurationHelper)) .ErrorFormat("Komenda [{0}], nie istnieje, nie można dodać potomka.", configCommand.Parent); LogManager.Logger(typeof(ConfigurationHelper)) .WarnFormat("Komenda [{0}] została pominięta.", configCommand.Id); } } } return(result); }