Esempio n. 1
0
        private List <ConflictTableData> PrepareConflictsTableData(string shortcutcommand, string shortcutScopeText, string shortcutKeysText)
        {
            // Convert text like "Text Editor" and "Ctrl+R, Ctrl+O" into objects representing the Scope and key bindings
            KeybindingScope scope = ShortcutQueryEngine.GetScopeByName(shortcutScopeText);
            IEnumerable <BindingSequence> shortcutChords = ShortcutQueryEngine.GetBindingSequencesFromBindingString(shortcutKeysText);

            List <ConflictTableData> conflictList = new List <ConflictTableData>();

            ThreadHelper.JoinableTaskFactory.Run(async() =>
            {
                // Fetch all the conflict data for the give nScope/Shortcut combination
                IEnumerable <BindingConflict> conflicts = await ShortcutQueryEngine.GetConflictsAsync(AllCommandsCache, scope, shortcutChords);

                // Put each conflict into the backing object to use on the UI display
                foreach (BindingConflict conflict in conflicts)
                {
                    // Handle all the conflicts for this conflict type
                    ConflictType conflictType = conflict.Type;

                    foreach (Tuple <CommandBinding, Command> binding in conflict.AffectedBindings)
                    {
                        conflictList.Add(new ConflictTableData
                        {
                            ConflictType = GetConflictTypeText(conflictType),
                            Command      = binding.Item2.CanonicalName,
                            Scope        = binding.Item1.Scope.Name,
                            Shortcut     = binding.Item1.OriginalDTEString
                        });
                    }
                }
            });
            return(conflictList);
        }
Esempio n. 2
0
 private void btnAddShortcut_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string shortcutcommand = cmbCommandList.SelectedValue.ToString();
         string shortcutScope   = cmbScopeList.SelectedValue.ToString();
         string shortcutKeys    = txtShortcut.Text;
         string shortcutBinding = shortcutScope + "::" + shortcutKeys;
         //Check if potential conflicts available
         if (listConflicts.Items.Count > 0)
         {
             if (seekConfirm(shortcutScope, shortcutKeys) == MessageBoxResult.Yes)
             {
                 ShortcutQueryEngine.BindShortcut(shortcutcommand, shortcutBinding);
                 MessageBox.Show("Shortcut added succesfully");
             }
         }
         else
         {
             ShortcutQueryEngine.BindShortcut(shortcutcommand, shortcutBinding);
             MessageBox.Show("Shortcut added succesfully");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 3
0
        private IEnumerable <KeybindingScope> GetAllKeybindingScopes()
        {
            IEnumerable <KeybindingScope> result = null;

            ThreadHelper.JoinableTaskFactory.Run(async() =>
            {
                result = await ShortcutQueryEngine.GetAllBindingScopesAsync();
            });
            return(result);
        }