コード例 #1
0
 private void InitializeShortcutEngine(IServiceProvider serviceProvider)
 {
     if (ShortcutQueryEngine == null)
     {
         ShortcutQueryEngine = VSShortcutQueryEngine.GetInstance(serviceProvider);
     }
 }
コード例 #2
0
 public AddKeyboardShortcut(IServiceProvider serviceProvider)
 {
     InitializeComponent();
     _serviceProvider           = serviceProvider;
     _queryEngine               = new VSShortcutQueryEngine(_serviceProvider);
     cmbCommandList.ItemsSource = new CommandListViewModel(_serviceProvider).DataSource;
     cmbScopeList.ItemsSource   = new ScopeListViewModel(_serviceProvider).DataSource;
 }
コード例 #3
0
        private string GetLocalizedShortcutText(ObservableCollection <BindingSequence> bindingSequences)
        {
            // Localize the binding sequence (ie. "Control+D8" => "Ctrl+8")
            VSShortcutQueryEngine queryEngine = VSShortcutsManager.VSShortcutsManager.Instance.queryEngine;

            if (queryEngine == null)
            {
                // Abort!
                System.Diagnostics.Debug.WriteLine("VSShortcutQueryEngine not initialized.");
                return(string.Join(", ", bindingSequences));
            }

            return(queryEngine.GetLocalizedShortcutText(bindingSequences));
        }
コード例 #4
0
        //Done for Sample. to be replaced with acutal code with list of all commands
        public ScopeListViewModel(IServiceProvider serviceProvider)
        {
            data = new List <ScopeList>();
            VSShortcutQueryEngine queryEngine = new VSShortcutQueryEngine(serviceProvider);
            var allCommands = queryEngine.GetAllBindingScopesAsync().Result;

            foreach (var eachCommand in allCommands)
            {
                data.Add(new ScopeList()
                {
                    Name = eachCommand.Name, Guid = eachCommand.Guid.ToString()
                });
            }
        }
コード例 #5
0
        public IEnumerable <CommandList> DataSource(IServiceProvider serviceProvider)
        {
            data = new List <CommandList>();
            VSShortcutQueryEngine queryEngine = new VSShortcutQueryEngine(serviceProvider);
            var allCommands = queryEngine.GetAllCommandsAsync().Result;

            foreach (var eachCommand in allCommands)
            {
                data.Add(new CommandList()
                {
                    Name = eachCommand.DisplayName
                });
            }
            return(data);
        }
コード例 #6
0
 //Done for Sample. to be replaced with acutal code with list of all commands
 public CommandListViewModel(IServiceProvider serviceProvider)
 {
     ThreadHelper.JoinableTaskFactory.Run(async() =>
     {
         data = new List <CommandList>();
         VSShortcutQueryEngine queryEngine = new VSShortcutQueryEngine(serviceProvider);
         var allCommands = await queryEngine.GetAllCommandsAsync();
         foreach (var eachCommand in allCommands)
         {
             if (!string.IsNullOrEmpty(eachCommand.CanonicalName))
             {
                 CommandList item = new CommandList()
                 {
                     DisplayName = eachCommand.DisplayName, CommandName = eachCommand.CanonicalName
                 };
                 data.Add(item);
             }
         }
     });
 }