private void AddInfoBar(IVsUIElement uiElement) { if (this.TryGetInfoBarHost(out IVsInfoBarHost infoBarHost)) { infoBarHost.AddInfoBar(uiElement); } }
private static bool TryAddInfoBarToFrame(IVsWindowFrame frame, IVsUIElement uiElement) { IVsInfoBarHost infoBarHost; if (TryGetInfoBarHost(frame, out infoBarHost)) { infoBarHost.AddInfoBar(uiElement); return(true); } return(false); }
private void SetNewView(ContentControl contentHost, VsUIElementDescriptor viewDescriptor, object viewModel) { IVsUIElement uiElement = UIFactoryHelper.GetViewFromUIFactory(viewDescriptor); contentHost.Content = (uiElement == null) ? this.EmptyView : UIFactoryHelper.ResolveWpfViewAndSetDataContext(uiElement, viewModel); this.currentViewDescriptor = viewDescriptor; this.currentViewElement = uiElement; }
/// <summary> /// Create an element from a UI factory and bind it to the given data model. /// If an error occurs, then create a suitable view to display the error message. /// </summary> /// <param name="factory">GUID part of the UI Element identifier</param> /// <param name="elementId">DWORD part of the UI Element identifier</param> /// <param name="model">The new view's model</param> /// <returns>A WPF FrameworkElement that is bound to the given model, or view displaying /// an error message.</returns> public static FrameworkElement CreateModelBoundViewOrErrorMessage(Guid factory, uint elementId, object model) { try { IVsUIElement uiElement = UIFactoryHelper.GetViewFromUIFactory(factory, elementId); return(UIFactoryHelper.ResolveWpfViewAndSetDataContext(uiElement, model)); } catch (UIFactoryException ex) { Telemetry.Client.TrackException(ex); return(CreateErrorMessageView(ex.Message)); } }
/// <summary>Creates an instance of the specified element.</summary> /// <param name="guid">The GUID of the command.</param> /// <param name="commandId">The command ID. </param> /// <param name="uiElement">[out] The element that was created.</param> /// <returns>If the method succeeds, it returns <see cref="F:Microsoft.VisualStudio.VSConstants.S_OK" />. If it fails, it returns an error code.</returns> public int CreateUIElement(ref Guid guid, uint commandId, out IVsUIElement uiElement) { if (guid != typeof(GcpMenuBarControlFactory).GUID) { uiElement = null; return(Marshal.GetHRForException( new ArgumentException($"Expected {typeof(GcpMenuBarControlFactory).GUID} but got {guid}", nameof(guid)))); } if (commandId != GcpMenuBarControlCommandId) { uiElement = null; return(Marshal.GetHRForException( new ArgumentException($"Expected {GcpMenuBarControlCommandId} but got {commandId}", nameof(commandId)))); } uiElement = WpfControl; return(VSConstants.S_OK); }
void IVsInfoBarHost.RemoveInfoBar(IVsUIElement uiElement) { this.elements.Contains(uiElement).Should().BeTrue(); this.elements.Remove(uiElement); }
void IVsInfoBarHost.AddInfoBar(IVsUIElement uiElement) { this.elements.Contains(uiElement).Should().BeFalse(); this.elements.Add(uiElement); }
private static bool TryAddInfoBarToFrame(IVsWindowFrame frame, IVsUIElement uiElement) { IVsInfoBarHost infoBarHost; if (TryGetInfoBarHost(frame, out infoBarHost)) { infoBarHost.AddInfoBar(uiElement); return true; } return false; }
void IVsInfoBarHost.RemoveInfoBar(IVsUIElement uiElement) { Assert.IsTrue(this.elements.Contains(uiElement)); this.elements.Remove(uiElement); }
void IVsInfoBarHost.AddInfoBar(IVsUIElement uiElement) { Assert.IsFalse(this.elements.Contains(uiElement)); this.elements.Add(uiElement); }
/// <summary> /// Create a special view to display an error message /// </summary> /// <param name="message">The message to display</param> /// <returns>The error view</returns> public static FrameworkElement CreateErrorMessageView(string message) { IVsUIElement viewElement = UIFactoryHelper.GetViewFromUIFactory(GuidList.UiFactory, UIElementIds.ExceptionView); return(UIFactoryHelper.ResolveWpfViewAndSetDataContext(viewElement, new ErrorDataSource(message))); }
private void HandleViewCreationException(ContentControl contentHost, Exception ex) { Telemetry.Client.TrackException(ex); this.currentViewElement = null; contentHost.Content = ViewHelper.CreateErrorMessageView(ex.Message); }
void IVsInfoBarHost.RemoveInfoBar(IVsUIElement uiElement) { Assert.IsTrue(this.elements.Contains(uiElement)); this.elements.Remove(uiElement); }
void IVsInfoBarHost.AddInfoBar(IVsUIElement uiElement) { Assert.IsFalse(this.elements.Contains(uiElement)); this.elements.Add(uiElement); }