From 32b52efff4a4dd99431b62c3a07d608ded5efb85 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 8 Oct 2019 15:10:32 +0200 Subject: [PATCH] Adjust width of the tooltip, so signatures are displayed on one line. --- ILSpy/TextView/DecompilerTextView.cs | 2 +- ILSpy/TextView/XmlDocRenderer.cs | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ILSpy/TextView/DecompilerTextView.cs b/ILSpy/TextView/DecompilerTextView.cs index da19323fc..76915ddec 100644 --- a/ILSpy/TextView/DecompilerTextView.cs +++ b/ILSpy/TextView/DecompilerTextView.cs @@ -394,7 +394,7 @@ namespace ICSharpCode.ILSpy.TextView public FlowDocumentTooltip(FlowDocument document) { TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display); - viewer = new FlowDocumentScrollViewer() { HorizontalScrollBarVisibility = ScrollBarVisibility.Visible }; + viewer = new FlowDocumentScrollViewer() { Width = document.MinPageWidth + 100 }; viewer.Document = document; Border border = new Border { Background = SystemColors.ControlBrush, diff --git a/ILSpy/TextView/XmlDocRenderer.cs b/ILSpy/TextView/XmlDocRenderer.cs index ceacab4fc..f10ea39db 100644 --- a/ILSpy/TextView/XmlDocRenderer.cs +++ b/ILSpy/TextView/XmlDocRenderer.cs @@ -109,6 +109,15 @@ namespace ICSharpCode.ILSpy.TextView var document = new TextDocument(signature); var richText = highlighting ?? DocumentPrinter.ConvertTextDocumentToRichText(document, new DocumentHighlighter(document, highlightingDefinition)).ToRichTextModel(); var block = new Paragraph(); + // HACK: measure width of signature using a TextBlock + // Paragraph sadly does not support TextWrapping.NoWrap + var text = new TextBlock { + FontFamily = GetCodeFont(), + TextAlignment = TextAlignment.Left + }; + text.Inlines.AddRange(richText.CreateRuns(document)); + text.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); + this.document.MinPageWidth = text.DesiredSize.Width; block.Inlines.AddRange(richText.CreateRuns(document)); block.FontFamily = GetCodeFont(); block.TextAlignment = TextAlignment.Left; @@ -262,11 +271,9 @@ namespace ICSharpCode.ILSpy.TextView } } - bool? ParseBool(string input) { - bool result; - if (bool.TryParse(input, out result)) + if (bool.TryParse(input, out bool result)) return result; else return null; @@ -356,8 +363,9 @@ namespace ICSharpCode.ILSpy.TextView if (referencedEntity != null) { if (element.Children.Any()) { Hyperlink link = new Hyperlink(); - // TODO - //link.Click += CreateNavigateOnClickHandler(referencedEntity); + link.Click += (sender, e) => { + MainWindow.Instance.JumpToReference(referencedEntity); + }; AddSpan(link, element.Children); } else { AddInline(ConvertReference(referencedEntity));