private string GetText(string text, string actionId) { switch (actionId) { case "TextControl.Enter": return(null); // TODO: "Insert Live Template" // We only get this when someone uses Tab to insert a live template. // It would be nice to recognise that. We can't assume it, as any other // tab handler could be mis-recognised case "TextControl.Tab": return("Tab"); case "Synthetic.NextHotspot": return("Next Hotspot"); case "Synthetic.PreviousHotspot": return("Previous Hotspot"); case "Synthetic.CompleteItem.Enter": return(GetEnterCompleteItemText()); case "Synthetic.CompleteItem.Tab": return(GetTabCompleteItemText()); } var trim = MnemonicStore.RemoveMnemonicMark(text).Trim(TrimCharacters); return(string.IsNullOrEmpty(trim) ? actionId : trim); }
public CommandBarActionDef(VsShortcutFinder vsShortcutFinder, DTE dte, string actionId, CommandID commandId, CommandBarControl control, CommandBarPopup[] parentPopups) { ActionId = actionId; // Lazily initialise. Talking to the command bar objects is SLOOOOOOOWWWWWW. backingFields = Lazy.Of(() => { Assertion.AssertNotNull(control, "control != null"); var sb = new StringBuilder(); foreach (var popup in parentPopups) { sb.AppendFormat("{0} \u2192 ", popup.Caption); } var fields = new BackingFields { Text = MnemonicStore.RemoveMnemonicMark(control.Caption), Path = MnemonicStore.RemoveMnemonicMark(sb.ToString()) }; var command = VsCommandHelpers.TryGetVsCommandAutomationObject(commandId, dte); var vsShortcut = vsShortcutFinder.GetVsShortcut(command); if (vsShortcut != null) { var details = new ShortcutDetails[vsShortcut.KeyboardShortcuts.Length]; for (int i = 0; i < vsShortcut.KeyboardShortcuts.Length; i++) { var keyboardShortcut = vsShortcut.KeyboardShortcuts[i]; details[i] = new ShortcutDetails(KeyConverter.Convert(keyboardShortcut.Key), keyboardShortcut.Modifiers); } fields.VsShortcut = new ShortcutSequence(details); } return(fields); }, true); }
private string GetPath(IActionDefWithId def) { var path = actionPresentationHelper.GetPathPresentationToRoot(def); return(!string.IsNullOrEmpty(path) ? MnemonicStore.RemoveMnemonicMark(path) + " \u2192 " : string.Empty); }