Browse Source

add pin layer as a canvas

pull/11/head
Eusebiu Marcu 15 years ago
parent
commit
6b18951b01
  1. 10
      src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinDebuggerControl.xaml.cs
  2. 39
      src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinLayer.cs
  3. 5
      src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinningBinding.cs
  4. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/Layer.cs
  5. 6
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LayerPosition.cs

10
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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Windows; using System.Windows;
@ -12,7 +11,6 @@ using System.Windows.Input;
using System.Windows.Media.Animation; using System.Windows.Media.Animation;
using System.Windows.Shapes; using System.Windows.Shapes;
using Debugger.AddIn.TreeModel;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Bookmarks; using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Debugging; using ICSharpCode.SharpDevelop.Debugging;
@ -113,7 +111,9 @@ namespace Debugger.AddIn.Tooltips
{ {
var provider = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorProvider; var provider = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorProvider;
if(provider != null) { 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; var provider = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorProvider;
if(provider != null) { if(provider != null) {
PinningBinding.GetPinlayer(provider.TextEditor).Unpin(this); var pinLayer = PinningBinding.GetPinlayer(provider.TextEditor);
if (pinLayer != null)
pinLayer.Unpin(this);
} }
} }

39
src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinLayer.cs

@ -5,35 +5,33 @@ using System;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.SharpDevelop.Refactoring; using ICSharpCode.SharpDevelop.Refactoring;
using Services.Debugger.Tooltips;
namespace Debugger.AddIn.Tooltips namespace Debugger.AddIn.Tooltips
{ {
/// <summary> /// <summary>
/// Pin layer class. This class handles the pinning and unpinning operations. /// Pin layer class. This class handles the pinning and unpinning operations.
/// </summary> /// </summary>
public class PinLayer : Layer public class PinLayer : Canvas
{ {
private Canvas pinningSurface;
private double verticalOffset = 0; private double verticalOffset = 0;
private double horizontalOffset = 0;
private TextView textView;
/// <summary> /// <summary>
/// PinLayer constructor. /// PinLayer constructor.
/// </summary> /// </summary>
/// <param name="textArea">Text area for this layer.</param> /// <param name="textArea">Text area for this layer.</param>
public PinLayer(TextArea textArea) : base(textArea.TextView, KnownLayer.DataPins) public PinLayer(TextArea textArea)
{ {
pinningSurface = new Canvas(); textView = textArea.TextView;
this.Children.Add(pinningSurface); textView.VisualLinesChanged += textView_VisualLinesChanged;
textView.VisualLinesChanged += new EventHandler(textView_VisualLinesChanged);
} }
/// <summary> /// <summary>
@ -62,12 +60,12 @@ namespace Debugger.AddIn.Tooltips
element.Location = new Point { element.Location = new Point {
X = element.Mark.PinPosition.Value.X - textView.HorizontalOffset, X = element.Mark.PinPosition.Value.X - textView.HorizontalOffset,
Y = element.Mark.PinPosition.Value.Y - textView.VerticalOffset Y = element.Mark.PinPosition.Value.Y - textView.VerticalOffset
}; };
Canvas.SetTop(currentThumb, element.Mark.PinPosition.Value.Y); Canvas.SetTop(currentThumb, element.Mark.PinPosition.Value.Y);
Canvas.SetLeft(currentThumb, element.Mark.PinPosition.Value.X); Canvas.SetLeft(currentThumb, element.Mark.PinPosition.Value.X);
} }
currentThumb.Style = element.TryFindResource("PinThumbStyle") as Style; currentThumb.Style = element.TryFindResource("PinThumbStyle") as Style;
currentThumb.ApplyTemplate(); currentThumb.ApplyTemplate();
currentThumb.DragDelta += onDragDelta; currentThumb.DragDelta += onDragDelta;
@ -76,7 +74,7 @@ namespace Debugger.AddIn.Tooltips
var container = TryFindChild<StackPanel>(currentThumb); var container = TryFindChild<StackPanel>(currentThumb);
container.Children.Add(element); container.Children.Add(element);
pinningSurface.Children.Add(currentThumb); this.Children.Add(currentThumb);
} }
/// <summary> /// <summary>
@ -88,11 +86,11 @@ namespace Debugger.AddIn.Tooltips
if (element == null) if (element == null)
throw new NullReferenceException("Element is null!"); throw new NullReferenceException("Element is null!");
foreach (var thumb in this.pinningSurface.Children) { foreach (var thumb in this.Children) {
PinDebuggerControl pinControl = TryFindChild<PinDebuggerControl>((DependencyObject)thumb); PinDebuggerControl pinControl = TryFindChild<PinDebuggerControl>((DependencyObject)thumb);
if (pinControl != null && pinControl == element) if (pinControl != null && pinControl == element)
{ {
pinningSurface.Children.Remove((UIElement)thumb); this.Children.Remove((UIElement)thumb);
element.Close(); element.Close();
break; break;
} }
@ -101,14 +99,14 @@ namespace Debugger.AddIn.Tooltips
void textView_VisualLinesChanged(object sender, EventArgs e) 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; var currentThumb = ctrl as Thumb;
PinDebuggerControl pinControl = TryFindChild<PinDebuggerControl>(currentThumb); PinDebuggerControl pinControl = TryFindChild<PinDebuggerControl>(currentThumb);
if (pinControl != null) if (pinControl != null)
{ {
// update relative location // update relative location
Point location = pinControl.Location; Point location = pinControl.Location;
location.X -= textView.HorizontalOffset; location.X += horizontalOffset - textView.HorizontalOffset;
location.Y += verticalOffset - textView.VerticalOffset; location.Y += verticalOffset - textView.VerticalOffset;
Canvas.SetLeft(currentThumb, location.X); Canvas.SetLeft(currentThumb, location.X);
@ -123,6 +121,7 @@ namespace Debugger.AddIn.Tooltips
} }
verticalOffset = textView.VerticalOffset; verticalOffset = textView.VerticalOffset;
horizontalOffset = textView.HorizontalOffset;
} }
#region Mouse move #region Mouse move
@ -153,10 +152,10 @@ namespace Debugger.AddIn.Tooltips
// pin's position is with respect to the layer. // pin's position is with respect to the layer.
pinControl.Mark.PinPosition = pinControl.Mark.PinPosition =
new Point new Point
{ {
X = textView.HorizontalOffset + left, X = textView.HorizontalOffset + left,
Y = textView.VerticalOffset + top Y = textView.VerticalOffset + top
}; };
} }
} }

5
src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinningBinding.cs

@ -73,7 +73,6 @@ namespace Debugger.AddIn.Tooltips
pin.SavedNodes.Clear(); pin.SavedNodes.Clear();
pin.Popup.ItemsSource = nodes; pin.Popup.ItemsSource = nodes;
pin.Nodes = nodes; pin.Nodes = nodes;
pin.Popup.Open();
pinLayer.Pin((PinDebuggerControl)pin.Popup); pinLayer.Pin((PinDebuggerControl)pin.Popup);
} }
@ -110,9 +109,7 @@ namespace Debugger.AddIn.Tooltips
public static PinLayer GetPinlayer(ITextEditor editor) { public static PinLayer GetPinlayer(ITextEditor editor) {
var textEditor = editor.GetService(typeof(TextEditor)) as TextEditor; var textEditor = editor.GetService(typeof(TextEditor)) as TextEditor;
if (textEditor != null) { if (textEditor != null) {
foreach(var layer in textEditor.TextArea.TextView.Layers) return textEditor.TextArea.TextView.Layers[3] as PinLayer;
if(((Layer)layer).LayerType == KnownLayer.DataPins)
return (PinLayer)layer;
} }
return null; return null;

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/Layer.cs

@ -11,7 +11,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
/// <summary> /// <summary>
/// Base class for known layers. /// Base class for known layers.
/// </summary> /// </summary>
public class Layer : Canvas class Layer : Canvas
{ {
/// <summary> /// <summary>
/// Text view. /// Text view.

6
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LayerPosition.cs

@ -32,11 +32,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
/// This layer contains the blinking caret. /// This layer contains the blinking caret.
/// </summary> /// </summary>
/// <remarks>This layer is above the Text layer. All items on this layer will blink with the same frequency as the caret.</remarks> /// <remarks>This layer is above the Text layer. All items on this layer will blink with the same frequency as the caret.</remarks>
Caret, Caret
/// <summary>
/// This layer contains the data pins
/// </summary>
DataPins
} }
/// <summary> /// <summary>

Loading…
Cancel
Save