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 override async Task CheckAsync() { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var activeInterpreter = _getActiveInterpreterFunc(); if (IsCreated || !Site.GetPythonToolsService().GeneralOptions.PromptForPythonVersionNotSupported || _interpreterTriggeredInfoBar != null || activeInterpreter == null || activeInterpreter.Configuration.Version >= _pythonMinVersionSupported ) { return; } _interpreterTriggeredInfoBar = activeInterpreter; var infoBarTextSpanMessage = new InfoBarTextSpan(Strings.PythonVersionNotSupportedInfoBarText.FormatUI(_interpreterTriggeredInfoBar.Configuration.Version)); var infoBarMessage = new List <IVsInfoBarTextSpan> { infoBarTextSpanMessage }; var actionItems = new List <InfoBarActionItem> { // TODO (Dev17) - link to Python 2.7 support deprecation page. new InfoBarHyperlink(Strings.PythonVersionNotSupportMoreInfo /*, (Action)MoreInformationAction*/), new InfoBarHyperlink(Strings.PythonVersionNotSupportedDontShowMessageAgain, (Action)DoNotShowAgainAction) }; LogEvent(PythonVersionNotSupportedInfoBarAction.Prompt); Create(new InfoBarModel(infoBarMessage, actionItems, KnownMonikers.StatusInformation)); }
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); } }
public InfoBarModel CreateMetadataInfoBar() { var text = new InfoBarTextSpan(Resource.Infobar_RetrievingMetadata); InfoBarTextSpan[] spans = { text }; var infoBarModel = new InfoBarModel(spans); return(infoBarModel); }
/* ~ 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); } }
/// <summary> /// Shows system InfoBar. /// </summary> /// <param name="message">Text message to show.</param> /// <param name="actionText">Action button text.</param> /// <param name="action">Action to execute.</param> /// <param name="showOption">Whether to show Options dialog access button.</param> public void ShowInfoBar(string message, string actionText, Action action, bool showOption) { ThreadHelper.ThrowIfNotOnUIThread(); if (string.IsNullOrEmpty(message)) { throw new ArgumentNullException(nameof(message)); } if (string.IsNullOrEmpty(actionText)) { throw new ArgumentNullException(nameof(actionText)); } if (action == null) { throw new ArgumentNullException(nameof(action)); } if (_cookie > 0) { _log.LogMessage($"InfoBar is already in use: {_cookie}", LOG_CATEGORY); return; } var shell = _serviceProvider.GetService <SVsShell, IVsShell>(); shell.GetProperty((int)__VSSPROPID7.VSSPROPID_MainWindowInfoBarHost, out var obj); var host = obj as IVsInfoBarHost; if (host == null) { _log.LogMessage("InfoBar host is not available", LOG_CATEGORY); return; } var actionLink = new InfoBarHyperlink(actionText, CONTEXT_ACTION); var actions = new List <InfoBarActionItem> { actionLink }; if (showOption) { var showOptionsLink = new InfoBarHyperlink("Options", CONTEXT_OPTIONS); actions.Add(showOptionsLink); } var textSpan = new InfoBarTextSpan(message); var textSpans = new List <InfoBarTextSpan> { textSpan }; var infoBarModel = new InfoBarModel(textSpans, actions, KnownMonikers.StatusInformation, true); var factory = _serviceProvider.GetService <SVsInfoBarUIFactory, IVsInfoBarUIFactory>(); var element = factory.CreateInfoBar(infoBarModel); element.Advise(this, out _cookie); host.AddInfoBar(element); _action = action; _log.LogMessage($"InfoBar is set: {_cookie}", LOG_CATEGORY); }