Esempio n. 1
0
 private async void RefreshShortcuts()
 {
     var modifierKey = GetSelectedModifierKey();
     VSShortcutQueryEngine engine    = new VSShortcutQueryEngine(ServiceProvider);
     var             selectedscope   = (Scope)cmbScopeList.SelectedItem;
     Guid            scopeGuid       = Guid.Parse(selectedscope.ID); // Get Guid Scope
     BindingSequence bindingSequence = BindingSequence.Empty;        // TODO: This is if there is a Chord, otherwise BindingSequence.EMPTY
     const bool      includeGlobals  = true;
     IDictionary <string, IEnumerable <Tuple <CommandBinding, Command> > > bindingsMap = await engine.GetBindingsForModifiersAsync(scopeGuid, ModifierKeys.None, bindingSequence, includeGlobals);
 }
        private async void RefreshShortcuts()
        {
            try
            {
                var modifierKeys                = GetSelectedModifierKeys();
                VSShortcutQueryEngine engine    = new VSShortcutQueryEngine(ServiceProvider);
                var             selectedscope   = (Scope)cmbScopeList.SelectedItem;
                Guid            scopeGuid       = (selectedscope != null) ? Guid.Parse(selectedscope.ID) : Guid.Empty;
                BindingSequence bindingSequence = BindingSequence.Empty; // TODO: This is if there is a Chord, otherwise BindingSequence.EMPTY
                const bool      includeGlobals  = true;
                IDictionary <string, IEnumerable <Tuple <CommandBinding, Command> > > matchingShortcuts = await engine.GetBindingsForModifiersAsync(scopeGuid, modifierKeys, bindingSequence, includeGlobals);

                foreach (var matchingShortcut in matchingShortcuts)
                {
                    var key             = matchingShortcut.Key;
                    var commandBindings = matchingShortcut.Value;
                    var commandString   = String.Join(",", commandBindings.Select(commandBinding => commandBinding.Item2.DisplayName));
                    UpdateShortcutValue(key, commandString);
                }
            }
            catch (Exception ex)
            {
            }
        }
        private async void RefreshShortcuts()
        {
            try
            {
                //Reset the old commands to blank before assigning new commands
                viewModel.ResetShortCutKeystoDefaultValue();

                var modifierKeys                = GetSelectedModifierKeys();
                VSShortcutQueryEngine engine    = new VSShortcutQueryEngine(ServiceProvider);
                var             selectedscope   = (Scope)cmbScopeList.SelectedItem;
                Guid            scopeGuid       = (selectedscope != null) ? Guid.Parse(selectedscope.ID) : Guid.Empty;
                BindingSequence bindingSequence = BindingSequence.Empty; // TODO: This is if there is a Chord, otherwise BindingSequence.EMPTY
                const bool      includeGlobals  = true;
                IDictionary <string, IEnumerable <Tuple <CommandBinding, Command> > > matchingShortcuts = await engine.GetBindingsForModifiersAsync(scopeGuid, modifierKeys, bindingSequence, includeGlobals);

                foreach (var matchingShortcut in matchingShortcuts)
                {
                    string key = matchingShortcut.Key;
                    IEnumerable <Tuple <CommandBinding, Command> > commandBindings = matchingShortcut.Value;
                    int?   sequenceCountofFirstCommandBinding = commandBindings.FirstOrDefault()?.Item1.Sequences.Count;
                    string commandString = "";
                    if (sequenceCountofFirstCommandBinding == 1)
                    {
                        commandString = commandBindings.FirstOrDefault().Item2.DisplayName;
                    }
                    else if (sequenceCountofFirstCommandBinding > 1)
                    {
                        commandString = "<Chord>";
                    }
                    UpdateShortcutValue(key, commandString);
                }
            }
            catch (Exception ex)
            {
            }
        }