Пример #1
0
        public async Task<IEnumerable<Command>> GetAllCommandsAsync()
        {
            List<Command> result = new List<Command>();
            if(this.commandIdToCTMCommandMap.Count == 0)
            {
                await this.PopulateCTMCommandsAsync();
            }

            foreach (EnvDTE.Command c in this.DTECommands)
            {
                List<CommandBinding> bindings = new List<CommandBinding>();

                if (c.Bindings != null && c.Bindings is object[] && ((object[])c.Bindings).Length > 0)
                {
                    object[] bindingsObj = (object[])c.Bindings;
                    foreach (string s in bindingsObj)
                    {
                        CommandBinding commandBinding = ParseBindingFromString(new Guid(c.Guid), c.ID, s);
                        if (commandBinding == null)
                        {
                            // Something went wrong with parsing (ie. Scope = "Unknown Editor") Skip this command.
                            continue;
                        }
                        bindings.Add(commandBinding);
                    }
                }

                CommandId id = new CommandId(Guid.Parse(c.Guid), c.ID);
                CommandTable.Command ctmCommand = this.commandIdToCTMCommandMap[id];
                string name = GetDisplayTextFromCTMCommand(ctmCommand);
                result.Add(new Command(id, name, c.Name, bindings));
            }

            return result;
        }
Пример #2
0
        private string GetDisplayTextFromCTMCommand(CommandId commandId)
        {
            CommandTable.Command command = this.commandIdToCTMCommandMap[commandId];

            string text = command.ItemText.ButtonText ?? command.ItemText.CommandWellText;

            return((string)AccessKeyRemovingConverter.Convert(text, typeof(string), null, CultureInfo.CurrentUICulture));
        }
Пример #3
0
        private string GetDisplayTextFromCTMCommand(CommandTable.Command command)
        {
            string text = null;

            if (command.ItemText.ButtonText != null)
                text = command.ItemText.ButtonText;
            else if (command.ItemText.CommandWellText != null)
                text = command.ItemText.CommandWellText;

            return (string)VSShortcutQueryEngine.AccessKeyRemovingConverter.Convert(text, typeof(string), null, CultureInfo.CurrentUICulture);
        }