/// <summary> /// Initializes a new instance of the <see cref="InfoBar"/> class. /// </summary> /// <param name="content"> /// The content to dislay. /// </param> /// <param name="clickAction"> /// An action to take when a user clicks on an <see cref="IVsInfoBarActionItem"/> (e.g. button) in the info bar. /// </param> /// <param name="closeAction"> /// An action to take when the info bar is closed. /// </param> /// <param name="imageMoniker">The moniker of the image.</param> public InfoBar(IVsInfoBarTextSpan[] content, Action <IVsInfoBarActionItem> clickAction = null, Action closeAction = null, ImageMoniker imageMoniker = default) { this.content = content; this.clickAction = clickAction; this.closeAction = closeAction; this.imageMoniker = imageMoniker.Equals(default(ImageMoniker)) ? KnownMonikers.StatusError : imageMoniker; }
private void EnsureWindowFrameInfoBarUpdated() { AssertIsForeground(); if (_windowFrameMessageToShow == null || _windowFrame == null || _currentWindowFrameMessage == _windowFrameMessageToShow && !_currentWindowFrameImageMoniker.Equals(_windowFrameImageMonikerToShow)) { // We don't have anything to do, or anything to do yet. return; } var infoBarFactory = (IVsInfoBarUIFactory)_fileManager._serviceProvider.GetService(typeof(SVsInfoBarUIFactory)); Assumes.Present(infoBarFactory); if (ErrorHandler.Failed(_windowFrame.GetProperty((int)__VSFPROPID7.VSFPROPID_InfoBarHost, out var infoBarHostObject)) || infoBarHostObject is not IVsInfoBarHost infoBarHost) { return; } // Remove the existing bar if (_currentWindowFrameInfoBarElement != null) { infoBarHost.RemoveInfoBar(_currentWindowFrameInfoBarElement); } var infoBar = new InfoBarModel(_windowFrameMessageToShow, _windowFrameImageMonikerToShow, isCloseButtonVisible: false); var infoBarUI = infoBarFactory.CreateInfoBar(infoBar); infoBarHost.AddInfoBar(infoBarUI); _currentWindowFrameMessage = _windowFrameMessageToShow; _currentWindowFrameImageMoniker = _windowFrameImageMonikerToShow; _currentWindowFrameInfoBarElement = infoBarUI; }