public void ShowInfoBar(string message) { var shell = _serviceProvider.GetService(typeof(SVsShell)) as IVsShell; if (shell != null) { shell.GetProperty((int)__VSSPROPID7.VSSPROPID_MainWindowInfoBarHost, out var obj); var host = (IVsInfoBarHost)obj; if (host == null) { return; } InfoBarTextSpan text = new InfoBarTextSpan(message); InfoBarHyperlink yes = new InfoBarHyperlink("Yes", "yes"); InfoBarHyperlink no = new InfoBarHyperlink("No", "no"); InfoBarTextSpan[] spans = new InfoBarTextSpan[] { text }; InfoBarActionItem[] actions = new InfoBarActionItem[] { yes, no }; InfoBarModel infoBarModel = new InfoBarModel(spans, actions, KnownMonikers.StatusInformation, isCloseButtonVisible: true); var factory = _serviceProvider.GetService(typeof(SVsInfoBarUIFactory)) as IVsInfoBarUIFactory; IVsInfoBarUIElement element = factory.CreateInfoBar(infoBarModel); element.Advise(this, out _cookie); host.AddInfoBar(element); } }
public void ShowInfoBar(string message, params InfoBarHyperlink[] hyperLinkObjects) { if (_serviceProvider.GetService(typeof(SVsShell)) is IVsShell shell) { shell.GetProperty((int)__VSSPROPID7.VSSPROPID_MainWindowInfoBarHost, out var obj); var host = (IVsInfoBarHost)obj; if (host == null) { return; } var text = new InfoBarTextSpan(message); var spans = new InfoBarTextSpan[] { text }; var actions = new InfoBarActionItem[hyperLinkObjects.Length]; for (int i = 0; i < hyperLinkObjects.Length; i++) { actions[i] = hyperLinkObjects[i]; } var infoBarModel = new InfoBarModel(spans, actions, KnownMonikers.StatusInformation, isCloseButtonVisible: true); var factory = _serviceProvider.GetService(typeof(SVsInfoBarUIFactory)) as IVsInfoBarUIFactory; Assumes.Present(factory); IVsInfoBarUIElement element = factory.CreateInfoBar(infoBarModel); element.Advise(this, out _cookie); host.AddInfoBar(element); } }
/* ~ 1.0.40 * public override InfoBarModel getInfoBarModel() { * InfoBarTextSpan text = new InfoBarTextSpan( * "PeasyMotion: New feature has been added! Text selection via jump. Give it a try via Tools.InvokePeasyMotionTextSelect command."); * InfoBarHyperlink dismiss = new InfoBarHyperlink("Dismiss", "dismiss"); * InfoBarHyperlink moreInfo = new InfoBarHyperlink("More info", * "http://github.com/msomeone/PeasyMotion#text-selection-via-toolsinvokepeasymotiontextselect-command"); * InfoBarTextSpan[] spans = new InfoBarTextSpan[] { text }; * InfoBarActionItem[] actions = new InfoBarActionItem[] { moreInfo, dismiss }; * InfoBarModel infoBarModel = new InfoBarModel(spans, actions, KnownMonikers.StatusInformation, isCloseButtonVisible: true); * return infoBarModel; * } */ /* ~ 1.1.42 * public override InfoBarModel getInfoBarModel() { * InfoBarTextSpan text = new InfoBarTextSpan( * "PeasyMotion: New mode has been added! In-Line word jump (begin/end). Give it a try via Tools.PeasyMotionLineJumpToWordBegining or Tools.PeasyMotionLineJumpToWordEnding command."); * InfoBarHyperlink dismiss = new InfoBarHyperlink("Dismiss", "dismiss"); * InfoBarHyperlink moreInfo = new InfoBarHyperlink("More info", * "https://github.com/msomeone/PeasyMotion#jump-to-word-begining-or-ending-in-current-line"); * InfoBarTextSpan[] spans = new InfoBarTextSpan[] { text }; * InfoBarActionItem[] actions = new InfoBarActionItem[] { moreInfo, dismiss }; * InfoBarModel infoBarModel = new InfoBarModel(spans, actions, KnownMonikers.StatusInformation, isCloseButtonVisible: true); * return infoBarModel; * } */ /* ~1.4.60 * public override InfoBarModel getInfoBarModel() { * InfoBarTextSpan text = new InfoBarTextSpan( * "PeasyMotion: New mode has been added! Jump to document tab. Give it a try via Tools.InvokePeasyMotionJumpToDocumentTab. New option: one can set allowed characters to be used in jump labels."); * InfoBarHyperlink dismiss = new InfoBarHyperlink("Dismiss", "dismiss"); * InfoBarHyperlink moreInfo = new InfoBarHyperlink("More info", * "https://github.com/msomeone/PeasyMotion#jump-to-document-tab"); * InfoBarTextSpan[] spans = new InfoBarTextSpan[] { text }; * InfoBarActionItem[] actions = new InfoBarActionItem[] { moreInfo, dismiss }; * InfoBarModel infoBarModel = new InfoBarModel(spans, actions, KnownMonikers.StatusInformation, isCloseButtonVisible: true); * return infoBarModel; * } */ /* * public override InfoBarModel getInfoBarModel() { * InfoBarTextSpan text = new InfoBarTextSpan( * "PeasyMotion: New mode has been added! Jump to line begining. Give it a try via Tools.InvokePeasyMotionJumpToLineBegining. Several bugfixes"); * InfoBarHyperlink dismiss = new InfoBarHyperlink("Dismiss", "dismiss"); * InfoBarHyperlink moreInfo = new InfoBarHyperlink("More info", * "https://github.com/msomeone/PeasyMotion#jump-to-begining-of-line"); * InfoBarTextSpan[] spans = new InfoBarTextSpan[] { text }; * InfoBarActionItem[] actions = new InfoBarActionItem[] { moreInfo, dismiss }; * InfoBarModel infoBarModel = new InfoBarModel(spans, actions, KnownMonikers.StatusInformation, isCloseButtonVisible: true); * return infoBarModel; * } */ public override InfoBarModel getInfoBarModel() { InfoBarTextSpan text = new InfoBarTextSpan("PeasyMotion: Two characted search mode has beed added! Give it a try via Tools.InvokePeasyMotionTwoCharJump. LineBeginingJump bug fix."); InfoBarHyperlink dismiss = new InfoBarHyperlink("Dismiss", "dismiss"); InfoBarHyperlink moreInfo = new InfoBarHyperlink("More info", "https://github.com/msomeone/PeasyMotion#two-char-search"); InfoBarTextSpan[] spans = new InfoBarTextSpan[] { text }; InfoBarActionItem[] actions = new InfoBarActionItem[] { moreInfo, dismiss }; InfoBarModel infoBarModel = new InfoBarModel(spans, actions, KnownMonikers.StatusInformation, isCloseButtonVisible: true); return(infoBarModel); }
public void DisplayInfoBar() { InfoBarTextSpan textSpan1 = new InfoBarTextSpan("This is a sample info bar "); InfoBarHyperlink link1 = new InfoBarHyperlink("sample link1 ", Resources.InfoBarLinkActionContext1); InfoBarHyperlink link2 = new InfoBarHyperlink("sample link2 ", Resources.InfoBarLinkActionContext2); InfoBarButton button1 = new InfoBarButton("sample button1", Resources.InfoBarButtonActionContext1); InfoBarButton button2 = new InfoBarButton("sample button2", Resources.InfoBarButtonActionContext2); InfoBarTextSpan[] textSpanCollection = new InfoBarTextSpan[] { textSpan1, link1, link2 }; InfoBarActionItem[] actionItemCollection = new InfoBarActionItem[] { button1, button2 }; InfoBarModel infoBarModel = new InfoBarModel(textSpanCollection, actionItemCollection, KnownMonikers.StatusInformation, isCloseButtonVisible: true); this.AddInfoBar(infoBarModel); SubscribeToInfoBarEvents(); }
private void CreateInfoBar(IVsInfoBarHost host, string message) { InfoBarTextSpan text = new InfoBarTextSpan(message); InfoBarHyperlink install = new InfoBarHyperlink("Install extension...", "install"); InfoBarHyperlink ignore = new InfoBarHyperlink("Ignore file type", "ignore"); InfoBarTextSpan[] spans = new InfoBarTextSpan[] { text }; InfoBarActionItem[] actions = new InfoBarActionItem[] { install, ignore }; InfoBarModel infoBarModel = new InfoBarModel(spans, actions, KnownMonikers.VisualStudioFeedback, isCloseButtonVisible: true); var factory = _serviceProvider.GetService(typeof(SVsInfoBarUIFactory)) as IVsInfoBarUIFactory; IVsInfoBarUIElement element = factory.CreateInfoBar(infoBarModel); element.Advise(this, out _cookie); host.AddInfoBar(element); }
public void ShowInfoBar(string message, ToolWindowPane toolWindow = null) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); // Construct an InfoBar. InfoBarTextSpan text = new InfoBarTextSpan(message); InfoBarHyperlink yes = new InfoBarHyperlink("Yes", "yes"); InfoBarHyperlink no = new InfoBarHyperlink("No", "no"); InfoBarButton noButton = new InfoBarButton("No", "no"); InfoBarTextSpan[] spans = new InfoBarTextSpan[] { text }; InfoBarActionItem[] actions = new InfoBarActionItem[] { yes, no, noButton }; InfoBarModel infoBarModel = new InfoBarModel(spans, actions, KnownMonikers.StatusInformation, isCloseButtonVisible: true); var factory = serviceProvider.GetService(typeof(SVsInfoBarUIFactory)) as IVsInfoBarUIFactory; Assumes.Present(factory); IVsInfoBarUIElement element = factory.CreateInfoBar(infoBarModel); element.Advise(this, out cookie); if (toolWindow == null) { var shell = serviceProvider.GetService(typeof(SVsShell)) as IVsShell; if (shell != null) { shell.GetProperty((int)__VSSPROPID7.VSSPROPID_MainWindowInfoBarHost, out var obj); var host = (IVsInfoBarHost)obj; if (host == null) { return; } host.AddInfoBar(element); } } else { toolWindow.AddInfoBar(element); } }