From 986adf1754f7dbd08821e69236792bbdea9e6f39 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 9 Mar 2009 20:18:54 +0000 Subject: [PATCH] Fixed two bugs introduced by Layers. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3844 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../ICSharpCode.AvalonEdit/Gui/CaretLayer.cs | 2 ++ .../ICSharpCode.AvalonEdit/Gui/Layer.cs | 2 -- .../Gui/SelectionLayer.cs | 7 ++++++- .../ICSharpCode.AvalonEdit/Gui/TextView.cs | 1 + .../Gui/TextViewWeakEventManager.cs | 19 +++++++++++++++++++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/CaretLayer.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/CaretLayer.cs index eb8a699be6..2417824559 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/CaretLayer.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/CaretLayer.cs @@ -23,6 +23,8 @@ namespace ICSharpCode.AvalonEdit.Gui public CaretLayer(TextView textView) : base(textView, KnownLayer.Caret) { + this.IsHitTestVisible = false; + blinkAnimation = new DoubleAnimationUsingKeyFrames(); blinkAnimation.KeyFrames.Add(new DiscreteDoubleKeyFrame(1, KeyTime.FromPercent(0))); blinkAnimation.KeyFrames.Add(new DiscreteDoubleKeyFrame(0, KeyTime.FromPercent(0.5))); diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/Layer.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/Layer.cs index 2d493e978d..9896cb3db0 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/Layer.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/Layer.cs @@ -25,8 +25,6 @@ namespace ICSharpCode.AvalonEdit.Gui Debug.Assert(textView != null); this.textView = textView; this.knownLayer = knownLayer; - - this.IsHitTestVisible = false; } protected override GeometryHitTestResult HitTestCore(GeometryHitTestParameters hitTestParameters) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/SelectionLayer.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/SelectionLayer.cs index 9f65102c69..e9ac6a89b0 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/SelectionLayer.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/SelectionLayer.cs @@ -17,13 +17,18 @@ namespace ICSharpCode.AvalonEdit.Gui public SelectionLayer(TextArea textArea) : base(textArea.TextView, KnownLayer.Selection) { + this.IsHitTestVisible = false; + this.textArea = textArea; TextViewWeakEventManager.VisualLinesChanged.AddListener(textView, this); + TextViewWeakEventManager.ScrollOffsetChanged.AddListener(textView, this); } public bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e) { - if (managerType == typeof(TextViewWeakEventManager.VisualLinesChanged)) { + if (managerType == typeof(TextViewWeakEventManager.VisualLinesChanged) + || managerType == typeof(TextViewWeakEventManager.ScrollOffsetChanged)) + { InvalidateVisual(); return true; } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextView.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextView.cs index ce1f7da8ce..427f1f8d55 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextView.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextView.cs @@ -935,6 +935,7 @@ namespace ICSharpCode.AvalonEdit.Gui if (!scrollOffset.X.IsClose(offset)) { SetScrollOffset(new Vector(offset, scrollOffset.Y)); InvalidateVisual(); + textLayer.InvalidateVisual(); } } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextViewWeakEventManager.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextViewWeakEventManager.cs index 62128c5eee..40920c69bd 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextViewWeakEventManager.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextViewWeakEventManager.cs @@ -52,5 +52,24 @@ namespace ICSharpCode.AvalonEdit.Gui source.VisualLinesChanged -= DeliverEvent; } } + + /// + /// Weak event manager for the event. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] + public sealed class ScrollOffsetChanged : WeakEventManagerBase + { + /// + protected override void StartListening(TextView source) + { + source.ScrollOffsetChanged += DeliverEvent; + } + + /// + protected override void StopListening(TextView source) + { + source.ScrollOffsetChanged -= DeliverEvent; + } + } } }