From a467999fbe01ead7e3c745c2f486c15cbe6fea93 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 27 Sep 2010 16:51:44 +0200 Subject: [PATCH] CompletionWindowBase: if window opened upwards, adjust its position when the window gets resized (e.g. due to filtering of code completion items) [based on patch by Eusebiu Marcu] --- .../CodeCompletion/CompletionWindowBase.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs index 94fc38f566..124bf6876c 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs @@ -47,6 +47,11 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion /// public int EndOffset { get; set; } + /// + /// Gets whether the window was opened above the current line. + /// + protected bool IsUp { get; private set; } + /// /// Creates a new CompletionWindowBase. /// @@ -307,6 +312,9 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion } if (bounds.Bottom > workingScreen.Bottom) { bounds.Y = locationTop.Y - bounds.Height; + IsUp = true; + } else { + IsUp = false; } if (bounds.Y < workingScreen.Top) { bounds.Y = workingScreen.Top; @@ -318,6 +326,15 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion this.Top = bounds.Y; } + /// + protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) + { + base.OnRenderSizeChanged(sizeInfo); + if (sizeInfo.HeightChanged && IsUp) { + this.Top += sizeInfo.PreviousSize.Height - sizeInfo.NewSize.Height; + } + } + /// /// Gets/sets whether the completion window should expect text insertion at the start offset, /// which not go into the completion region, but before it.