Exemplo n.º 1
0
        private CurrentCommandsContainer GetCombinations(ModifierKeys modifierKeys)
        {
            // Get combinations for pressed modifier keys
            if (modifierKeys == ModifierKeys.None)
            {
                return(null);
            }

            var currentCommandsSet = new CurrentCommandsContainer(this.packageSettings);

            foreach (var scope in this.commandScopeService.GetCurrentScopes())
            {
                foreach (var commandInfo in this.commandInfos.Filter(modifierKeys, scope))
                {
                    CommandBinding commandBinding = commandInfo.CommandBinding;

                    if (commandBinding.KeyCombinations.Length == 1)
                    {
                        currentCommandsSet.Add(commandInfo.Name, commandBinding.Scope, commandBinding.KeyCombinations[0]);
                    }
                    else
                    {
                        currentCommandsSet.AddChordCandidate(commandBinding.KeyCombinations[0]);
                    }
                }
            }

            return(currentCommandsSet);
        }
Exemplo n.º 2
0
        private CurrentCommandsContainer GetChordCombinations(ModifierKeys modifierKeys, Key key)
        {
            // Filter command infos by specific modifier keys and key
            // And find in them only chord combinations
            Debug.Assert(modifierKeys != ModifierKeys.None, "modifierKeys != ModifierKeys.None");

            var commandsSet = new CurrentCommandsContainer(this.packageSettings);

            foreach (var scope in this.commandScopeService.GetCurrentScopes())
            {
                foreach (var commandInfo in this.commandInfos.Filter(modifierKeys, scope, key))
                {
                    CommandBinding commandBinding = commandInfo.CommandBinding;

                    if (commandBinding.KeyCombinations.Length == 1)
                    {
                        return(null);
                    }

                    commandsSet.Add(commandInfo.Name, commandBinding.Scope, commandBinding.KeyCombinations[1]);
                }
            }

            return(commandsSet);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandInfo"/> class.
 /// </summary>
 /// <param name="vsCommand">The VS instance of a command.</param>
 /// <param name="commandBinding">The command bindings.</param>
 public CommandInfo(Command vsCommand, CommandBinding commandBinding)
 {
     this.Name           = this.GetCommandName(vsCommand);
     this.VsCommand      = vsCommand;
     this.CommandBinding = commandBinding;
 }