void FixQuickInfo(StackPanel infoPanel) { var doc = infoPanel.GetFirstVisualChild <StackPanel>(); if (doc == null) { return; } var titlePanel = infoPanel.GetFirstVisualChild <WrapPanel>(); if (titlePanel == null) { return; } titlePanel.HorizontalAlignment = HorizontalAlignment.Stretch; doc.HorizontalAlignment = HorizontalAlignment.Stretch; var icon = infoPanel.GetFirstVisualChild <CrispImage>(); var signature = infoPanel.GetFirstVisualChild <TextBlock>(); // beautify the title panel if (Config.Instance.QuickInfoOptions.MatchFlags(QuickInfoOptions.AlternativeStyle)) { var b = doc.GetParent <Border>(); if (b != null && icon != null && signature != null) { b.Margin = __DocPanelBorderMargin; titlePanel.Margin = __TitlePanelMargin; titlePanel.Background = ThemeHelper.ToolWindowBackgroundBrush.Alpha(0.5); doc.Margin = __DocMargin; icon.Margin = __IconMargin; signature.Margin = __SignatureMargin; } } // replace the default XML doc var items = doc.Children; if (DocElement != null) { try { // sequence of items in default XML Doc panel: // 1. summary // 2. type parameter // 3. usage // 4. exception if (items.Count > 1 && items[1] is TextBlock) { items.RemoveAt(1); items.Insert(1, DocElement); } else { items.Add(DocElement); } } catch (InvalidOperationException) { // ignore exception: doc.Children was changed by another thread } } if (ExceptionDoc != null) { try { if (items.Count > 1 && items[items.Count - 1] is TextBlock) { items.RemoveAt(items.Count - 1); } items.Add(ExceptionDoc); } catch (InvalidOperationException) { // ignore exception: doc.Children was changed by another thread } } if (icon != null && signature != null) { // apply click and go feature if (ClickAndGoSymbol != null) { QuickInfoOverrider.ApplyClickAndGo(ClickAndGoSymbol, signature); } // fix the width of the signature part to prevent it from falling down to the next row if (Config.Instance.QuickInfoMaxWidth > 0) { //wrapPanel.MaxWidth = Config.Instance.QuickInfoMaxWidth; //signature.HorizontalAlignment = HorizontalAlignment.Left; signature.MaxWidth = Config.Instance.QuickInfoMaxWidth - icon.Width - 30; } } }
void FixQuickInfo(StackPanel infoPanel) { var titlePanel = infoPanel.GetFirstVisualChild <WrapPanel>(); if (titlePanel == null) { return; } var doc = titlePanel.GetParent <StackPanel>(); if (doc == null) { return; } var v16_1orLater = titlePanel.GetParent <ItemsControl>().GetParent <ItemsControl>() != null; titlePanel.HorizontalAlignment = HorizontalAlignment.Stretch; doc.HorizontalAlignment = HorizontalAlignment.Stretch; var icon = infoPanel.GetFirstVisualChild <CrispImage>(); var signature = infoPanel.GetFirstVisualChild <TextBlock>(); // beautify the title panel if (Config.Instance.QuickInfoOptions.MatchFlags(QuickInfoOptions.AlternativeStyle)) { if (icon != null) { infoPanel.GetParent <Border>().Background = new VisualBrush(CreateEnlargedIcon(icon)) { Opacity = 0.3, AlignmentX = AlignmentX.Right, AlignmentY = AlignmentY.Bottom, TileMode = TileMode.None, Stretch = Stretch.None }; icon.Visibility = Visibility.Collapsed; } if (signature != null) { var list = (IList)signature.Inlines; for (var i = 0; i < list.Count; i++) { if (list[i] is Hyperlink link) { var r = link.Inlines.FirstInline as Run; if (r != null) { list[i] = new Run { Text = r.Text, Foreground = r.Foreground, Background = r.Background }; } } } } var c = infoPanel.GetParent <Border>(); c.Margin = __DocPanelBorderMargin; c.Padding = __DocPanelBorderPadding; c.MinHeight = 50; titlePanel.Margin = __TitlePanelMargin; } #region Override documentation // https://github.com/dotnet/roslyn/blob/version-3.0.0/src/Features/Core/Portable/QuickInfo/CommonSemanticQuickInfoProvider.cs // replace the default XML doc // sequence of items in default XML Doc panel: // 1. summary // 2. generic type parameter // 3. anonymous types // 4. availability warning // 5. usage // 6. exception // 7. captured variables var items = doc.IsItemsHost ? (IList)doc.GetParent <ItemsControl>().Items : doc.Children; if (KeepBuiltInXmlDoc == false) { ClearDefaultDocumentationItems(doc, v16_1orLater, items); } if (DocElement != null) { OverrideDocElement(doc, v16_1orLater, items); } if (ExceptionDoc != null) { OverrideExceptionDocElement(doc, v16_1orLater, items); } #endregion if (icon != null && signature != null) { // apply click and go feature if (ClickAndGoSymbol != null) { QuickInfoOverrider.ApplyClickAndGo(ClickAndGoSymbol, TextBuffer, signature, QuickInfoSession); } // fix the width of the signature part to prevent it from falling down to the next row if (Config.Instance.QuickInfoMaxWidth >= 100) { signature.MaxWidth = Config.Instance.QuickInfoMaxWidth - icon.Width - 30; } } }
void FixQuickInfo(StackPanel infoPanel) { var doc = infoPanel.GetFirstVisualChild <StackPanel>(); if (doc == null) { return; } var wrapPanel = infoPanel.GetFirstVisualChild <WrapPanel>(); if (wrapPanel == null) { return; } var icon = infoPanel.GetFirstVisualChild <Microsoft.VisualStudio.Imaging.CrispImage>(); var signature = infoPanel.GetFirstVisualChild <TextBlock>(); // replace the default XML doc if (DocElement != null) { // todo: apply decoratives lines between doc and other parts with a WPF template //DocElement = new StackPanel { // Children = { // CreateDecorativeLine(doc), // DocElement, // CreateDecorativeLine(doc) // } //}; try { if (doc.Children.Count > 1 && doc.Children[1] is TextBlock) { doc.Children.RemoveAt(1); doc.Children.Insert(1, DocElement); } else { doc.Children.Add(DocElement); } } catch (InvalidOperationException) { // ignore exception: doc.Children was changed by another thread } } if (icon != null && signature != null) { // apply click and go feature if (ClickAndGoSymbol != null) { QuickInfoOverrider.ApplyClickAndGo(ClickAndGoSymbol, signature); } // fix the width of the signature part to prevent it from falling down to the next row if (Config.Instance.QuickInfoMaxWidth > 0) { wrapPanel.MaxWidth = Config.Instance.QuickInfoMaxWidth; signature.MaxWidth = Config.Instance.QuickInfoMaxWidth - icon.Width - 10; } } System.Windows.Shapes.Line CreateDecorativeLine(StackPanel docPanel) { return(new System.Windows.Shapes.Line { Stroke = ThemeHelper.MenuGlyphBackgroundBrush, StrokeThickness = 1, StrokeDashArray = new DoubleCollection { 4, 2 }, X1 = 0, X2 = docPanel.DesiredSize.Width, Y1 = 3, Y2 = 3, Height = 5, MaxWidth = Config.Instance.QuickInfoMaxWidth }); } }
void FixQuickInfo(StackPanel infoPanel) { var titlePanel = infoPanel.GetFirstVisualChild <WrapPanel>(); if (titlePanel == null) { return; } var doc = titlePanel.GetParent <StackPanel>(); if (doc == null) { return; } var v16_1orLater = titlePanel.GetParent <ItemsControl>().GetParent <ItemsControl>() != null; titlePanel.HorizontalAlignment = HorizontalAlignment.Stretch; doc.HorizontalAlignment = HorizontalAlignment.Stretch; var icon = infoPanel.GetFirstVisualChild <CrispImage>(); var signature = infoPanel.GetFirstVisualChild <TextBlock>(); // beautify the title panel if (Config.Instance.QuickInfoOptions.MatchFlags(QuickInfoOptions.AlternativeStyle)) { if (icon != null) { infoPanel.GetParent <Border>().Background = new VisualBrush(CreateEnlargedIcon(icon)) { Opacity = 0.3, AlignmentX = AlignmentX.Right, AlignmentY = AlignmentY.Bottom, TileMode = TileMode.None, Stretch = Stretch.None }; icon.Visibility = Visibility.Collapsed; } var c = infoPanel.GetParent <Border>(); c.Margin = __DocPanelBorderMargin; c.Padding = __DocPanelBorderPadding; c.MinHeight = 50; titlePanel.Margin = __TitlePanelMargin; } // replace the default XML doc // sequence of items in default XML Doc panel: // 1. summary // 2. type parameter // 3. usage // 4. exception var items = doc.IsItemsHost ? (IList)doc.GetParent <ItemsControl>().Items : doc.Children; if (DocElement != null) { OverrideDocElement(doc, v16_1orLater, items); } if (ExceptionDoc != null) { OverrideExceptionDocElement(doc, v16_1orLater, items); } if (icon != null && signature != null) { // apply click and go feature if (ClickAndGoSymbol != null) { QuickInfoOverrider.ApplyClickAndGo(ClickAndGoSymbol, signature, QuickInfoSession); } // fix the width of the signature part to prevent it from falling down to the next row if (Config.Instance.QuickInfoMaxWidth > 0) { signature.MaxWidth = Config.Instance.QuickInfoMaxWidth - icon.Width - 30; } } }
void FixQuickInfo(StackPanel infoPanel) { var titlePanel = infoPanel.GetFirstVisualChild <WrapPanel>(); if (titlePanel == null) { return; } var doc = titlePanel.GetParent <StackPanel>(); if (doc == null) { return; } var v16_1orLater = titlePanel.GetParent <ItemsControl>().GetParent <ItemsControl>() != null; titlePanel.HorizontalAlignment = HorizontalAlignment.Stretch; doc.HorizontalAlignment = HorizontalAlignment.Stretch; var icon = infoPanel.GetFirstVisualChild <CrispImage>(); var signature = infoPanel.GetFirstVisualChild <TextBlock>(); // beautify the title panel if (Config.Instance.QuickInfoOptions.MatchFlags(QuickInfoOptions.AlternativeStyle)) { if (icon != null) { var bgIcon = CreateEnlargedIcon(icon); infoPanel.GetParent <Border>().Background = new VisualBrush(bgIcon) { Opacity = 0.3, AlignmentX = AlignmentX.Right, AlignmentY = AlignmentY.Bottom, TileMode = TileMode.None, Stretch = Stretch.None }; icon.Visibility = Visibility.Collapsed; } var c = infoPanel.GetParent <Border>(); c.Margin = __DocPanelBorderMargin; c.Padding = __DocPanelBorderPadding; c.MinHeight = 50; titlePanel.Margin = __TitlePanelMargin; } // replace the default XML doc // sequence of items in default XML Doc panel: // 1. summary // 2. type parameter // 3. usage // 4. exception var items = doc.IsItemsHost ? (System.Collections.IList)doc.GetParent <ItemsControl>().Items : doc.Children; if (DocElement != null) { try { if (items.Count > 1 && items[1] is TextBlock) { items.RemoveAt(1); items.Insert(1, DocElement); } else { items.Add(DocElement); } var myDoc = DocElement as ThemedTipDocument; if (myDoc != null) { items = doc.GetParent <ItemsControl>()?.Items; if (v16_1orLater && items != null && myDoc.Tag is int) { // used the value from XmlDocRenderer.ParagraphCount to remove builtin paragraphs for (int i = (int)myDoc.Tag - 1; i >= 0; i--) { items.RemoveAt(1); } } myDoc.ApplySizeLimit(); } } catch (InvalidOperationException) { // ignore exception: doc.Children was changed by another thread } } if (ExceptionDoc != null) { if (v16_1orLater) { items = doc.GetParent <ItemsControl>().Items; } try { if (items.Count > 1 && (v16_1orLater && items[items.Count - 1] is StackPanel || items[items.Count - 1] is TextBlock)) { items.RemoveAt(items.Count - 1); } items.Add(ExceptionDoc); //todo move this to ApplySizeLimit (ExceptionDoc as ThemedTipDocument)?.ApplySizeLimit(); } catch (InvalidOperationException) { // ignore exception: doc.Children was changed by another thread } } if (icon != null && signature != null) { // apply click and go feature if (ClickAndGoSymbol != null) { QuickInfoOverrider.ApplyClickAndGo(ClickAndGoSymbol, signature); } // fix the width of the signature part to prevent it from falling down to the next row if (Config.Instance.QuickInfoMaxWidth > 0) { signature.MaxWidth = Config.Instance.QuickInfoMaxWidth - icon.Width - 30; } } }