diff --git a/src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinDebuggerControl.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinDebuggerControl.xaml.cs index 40ddb22bf3..913e16df66 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinDebuggerControl.xaml.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinDebuggerControl.xaml.cs @@ -2,7 +2,6 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using System.ComponentModel; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows; @@ -12,7 +11,6 @@ using System.Windows.Input; using System.Windows.Media.Animation; using System.Windows.Shapes; -using Debugger.AddIn.TreeModel; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Bookmarks; using ICSharpCode.SharpDevelop.Debugging; @@ -113,7 +111,9 @@ namespace Debugger.AddIn.Tooltips { var provider = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorProvider; if(provider != null) { - PinningBinding.GetPinlayer(provider.TextEditor).Pin(this); + var pinLayer = PinningBinding.GetPinlayer(provider.TextEditor); + if (pinLayer != null) + pinLayer.Pin(this); } } @@ -121,7 +121,9 @@ namespace Debugger.AddIn.Tooltips { var provider = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorProvider; if(provider != null) { - PinningBinding.GetPinlayer(provider.TextEditor).Unpin(this); + var pinLayer = PinningBinding.GetPinlayer(provider.TextEditor); + if (pinLayer != null) + pinLayer.Unpin(this); } } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinLayer.cs b/src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinLayer.cs index 40f98f2ed7..f0a3e2a22e 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinLayer.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinLayer.cs @@ -5,35 +5,33 @@ using System; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; -using System.Windows.Data; using System.Windows.Input; using System.Windows.Media; using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.SharpDevelop.Refactoring; -using Services.Debugger.Tooltips; namespace Debugger.AddIn.Tooltips { /// /// Pin layer class. This class handles the pinning and unpinning operations. /// - public class PinLayer : Layer + public class PinLayer : Canvas { - private Canvas pinningSurface; - private double verticalOffset = 0; + private double horizontalOffset = 0; + + private TextView textView; /// /// PinLayer constructor. /// /// Text area for this layer. - public PinLayer(TextArea textArea) : base(textArea.TextView, KnownLayer.DataPins) + public PinLayer(TextArea textArea) { - pinningSurface = new Canvas(); - this.Children.Add(pinningSurface); - textView.VisualLinesChanged += new EventHandler(textView_VisualLinesChanged); + textView = textArea.TextView; + textView.VisualLinesChanged += textView_VisualLinesChanged; } /// @@ -62,12 +60,12 @@ namespace Debugger.AddIn.Tooltips element.Location = new Point { X = element.Mark.PinPosition.Value.X - textView.HorizontalOffset, Y = element.Mark.PinPosition.Value.Y - textView.VerticalOffset - }; + }; Canvas.SetTop(currentThumb, element.Mark.PinPosition.Value.Y); Canvas.SetLeft(currentThumb, element.Mark.PinPosition.Value.X); } - + currentThumb.Style = element.TryFindResource("PinThumbStyle") as Style; currentThumb.ApplyTemplate(); currentThumb.DragDelta += onDragDelta; @@ -76,7 +74,7 @@ namespace Debugger.AddIn.Tooltips var container = TryFindChild(currentThumb); container.Children.Add(element); - pinningSurface.Children.Add(currentThumb); + this.Children.Add(currentThumb); } /// @@ -88,11 +86,11 @@ namespace Debugger.AddIn.Tooltips if (element == null) throw new NullReferenceException("Element is null!"); - foreach (var thumb in this.pinningSurface.Children) { + foreach (var thumb in this.Children) { PinDebuggerControl pinControl = TryFindChild((DependencyObject)thumb); if (pinControl != null && pinControl == element) { - pinningSurface.Children.Remove((UIElement)thumb); + this.Children.Remove((UIElement)thumb); element.Close(); break; } @@ -101,14 +99,14 @@ namespace Debugger.AddIn.Tooltips void textView_VisualLinesChanged(object sender, EventArgs e) { - foreach (var ctrl in this.pinningSurface.Children) { + foreach (var ctrl in this.Children) { var currentThumb = ctrl as Thumb; PinDebuggerControl pinControl = TryFindChild(currentThumb); if (pinControl != null) { // update relative location Point location = pinControl.Location; - location.X -= textView.HorizontalOffset; + location.X += horizontalOffset - textView.HorizontalOffset; location.Y += verticalOffset - textView.VerticalOffset; Canvas.SetLeft(currentThumb, location.X); @@ -123,6 +121,7 @@ namespace Debugger.AddIn.Tooltips } verticalOffset = textView.VerticalOffset; + horizontalOffset = textView.HorizontalOffset; } #region Mouse move @@ -153,10 +152,10 @@ namespace Debugger.AddIn.Tooltips // pin's position is with respect to the layer. pinControl.Mark.PinPosition = new Point - { - X = textView.HorizontalOffset + left, - Y = textView.VerticalOffset + top - }; + { + X = textView.HorizontalOffset + left, + Y = textView.VerticalOffset + top + }; } } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinningBinding.cs b/src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinningBinding.cs index 7ad7f372ad..fb5e0d5e47 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinningBinding.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinningBinding.cs @@ -73,7 +73,6 @@ namespace Debugger.AddIn.Tooltips pin.SavedNodes.Clear(); pin.Popup.ItemsSource = nodes; pin.Nodes = nodes; - pin.Popup.Open(); pinLayer.Pin((PinDebuggerControl)pin.Popup); } @@ -110,9 +109,7 @@ namespace Debugger.AddIn.Tooltips public static PinLayer GetPinlayer(ITextEditor editor) { var textEditor = editor.GetService(typeof(TextEditor)) as TextEditor; if (textEditor != null) { - foreach(var layer in textEditor.TextArea.TextView.Layers) - if(((Layer)layer).LayerType == KnownLayer.DataPins) - return (PinLayer)layer; + return textEditor.TextArea.TextView.Layers[3] as PinLayer; } return null; diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/Layer.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/Layer.cs index 141adcc02e..19ee214066 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/Layer.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/Layer.cs @@ -11,7 +11,7 @@ namespace ICSharpCode.AvalonEdit.Rendering /// /// Base class for known layers. /// - public class Layer : Canvas + class Layer : Canvas { /// /// Text view. diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LayerPosition.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LayerPosition.cs index 9603c372db..a41857bf84 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LayerPosition.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LayerPosition.cs @@ -32,11 +32,7 @@ namespace ICSharpCode.AvalonEdit.Rendering /// This layer contains the blinking caret. /// /// This layer is above the Text layer. All items on this layer will blink with the same frequency as the caret. - Caret, - /// - /// This layer contains the data pins - /// - DataPins + Caret } ///