From 6d36627647723e2b8250091da745b475e44dbb76 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 26 Oct 2019 12:16:03 +0200 Subject: [PATCH] Limit size of tooltips to MainWindow size. --- ILSpy/TextView/DecompilerTextView.cs | 8 ++++++-- ILSpy/TextView/XmlDocRenderer.cs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ILSpy/TextView/DecompilerTextView.cs b/ILSpy/TextView/DecompilerTextView.cs index 76915ddec..f7771d9c6 100644 --- a/ILSpy/TextView/DecompilerTextView.cs +++ b/ILSpy/TextView/DecompilerTextView.cs @@ -394,7 +394,11 @@ namespace ICSharpCode.ILSpy.TextView public FlowDocumentTooltip(FlowDocument document) { TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display); - viewer = new FlowDocumentScrollViewer() { Width = document.MinPageWidth + 100 }; + double fontSize = DisplaySettingsPanel.CurrentDisplaySettings.SelectedFontSize; + viewer = new FlowDocumentScrollViewer() { + Width = document.MinPageWidth + fontSize * 5, + MaxWidth = MainWindow.Instance.ActualWidth + }; viewer.Document = document; Border border = new Border { Background = SystemColors.ControlBrush, @@ -405,7 +409,7 @@ namespace ICSharpCode.ILSpy.TextView }; this.Child = border; viewer.Foreground = SystemColors.InfoTextBrush; - document.FontSize = DisplaySettingsPanel.CurrentDisplaySettings.SelectedFontSize; + document.FontSize = fontSize; } public bool CloseWhenMouseMovesAway { diff --git a/ILSpy/TextView/XmlDocRenderer.cs b/ILSpy/TextView/XmlDocRenderer.cs index ac4ae7d18..14cd8c421 100644 --- a/ILSpy/TextView/XmlDocRenderer.cs +++ b/ILSpy/TextView/XmlDocRenderer.cs @@ -119,7 +119,7 @@ namespace ICSharpCode.ILSpy.TextView }; text.Inlines.AddRange(richText.CreateRuns(document)); text.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); - this.document.MinPageWidth = text.DesiredSize.Width; + this.document.MinPageWidth = Math.Min(text.DesiredSize.Width, MainWindow.Instance.ActualWidth); block.Inlines.AddRange(richText.CreateRuns(document)); block.FontFamily = GetCodeFont(); block.TextAlignment = TextAlignment.Left;