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. 35
      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 @@ @@ -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; @@ -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 @@ -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 @@ -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);
}
}

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

@ -5,35 +5,33 @@ using System; @@ -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
{
/// <summary>
/// Pin layer class. This class handles the pinning and unpinning operations.
/// </summary>
public class PinLayer : Layer
public class PinLayer : Canvas
{
private Canvas pinningSurface;
private double verticalOffset = 0;
private double horizontalOffset = 0;
private TextView textView;
/// <summary>
/// PinLayer constructor.
/// </summary>
/// <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();
this.Children.Add(pinningSurface);
textView.VisualLinesChanged += new EventHandler(textView_VisualLinesChanged);
textView = textArea.TextView;
textView.VisualLinesChanged += textView_VisualLinesChanged;
}
/// <summary>
@ -76,7 +74,7 @@ namespace Debugger.AddIn.Tooltips @@ -76,7 +74,7 @@ namespace Debugger.AddIn.Tooltips
var container = TryFindChild<StackPanel>(currentThumb);
container.Children.Add(element);
pinningSurface.Children.Add(currentThumb);
this.Children.Add(currentThumb);
}
/// <summary>
@ -88,11 +86,11 @@ namespace Debugger.AddIn.Tooltips @@ -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<PinDebuggerControl>((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 @@ -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<PinDebuggerControl>(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 @@ -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 @@ -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
};
}
}

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

@ -73,7 +73,6 @@ namespace Debugger.AddIn.Tooltips @@ -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 @@ -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;

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

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

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

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

Loading…
Cancel
Save