Browse Source

fix pinning

fix updating the pin in debugger tooltip
pull/11/head
eusebiu 15 years ago
parent
commit
bfefd4ed9a
  1. 11
      src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs
  2. 39
      src/Main/Base/Project/Src/Editor/AvalonEdit/PinLayer.cs
  3. 6
      src/Main/Base/Project/Src/Editor/ITooltip.cs
  4. 2
      src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerPopup.cs
  5. 70
      src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerTooltipControl.xaml.cs
  6. 8
      src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinBookmark.cs
  7. 3
      src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinDebuggerControl.xaml.cs
  8. 4
      src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinningBinding.cs

11
src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs

@ -56,12 +56,11 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -56,12 +56,11 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
case "PinBookmark":
var pin = new PinBookmark(fileName, new Location(columnNumber, lineNumber));
pin.Comment = v[4];
// pop-up position
pin.PopupPosition =
pin.PinPosition =
new Point
{
X = int.Parse(v[5], culture),
Y = int.Parse(v[6], culture)
X = double.Parse(v[5], culture),
Y = double.Parse(v[6], culture)
};
// pop-up nodes
@ -121,9 +120,9 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -121,9 +120,9 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
// popup position
b.Append('|');
b.Append(pin.PopupPosition.X);
b.Append(pin.PinPosition.Value.X);
b.Append('|');
b.Append(pin.PopupPosition.Y);
b.Append(pin.PinPosition.Value.Y);
//popup nodes
foreach(var node in pin.Nodes) {

39
src/Main/Base/Project/Src/Editor/AvalonEdit/PinLayer.cs

@ -46,8 +46,28 @@ namespace Editor.AvalonEdit @@ -46,8 +46,28 @@ namespace Editor.AvalonEdit
throw new NullReferenceException("Element is null!");
Thumb currentThumb = new Thumb();
Canvas.SetTop(currentThumb, element.Location.Y);
Canvas.SetLeft(currentThumb, element.Location.X);
// check for saved position
if (!element.Mark.PinPosition.HasValue) {
// this is satisfied when pinning the first time
element.Mark.PinPosition = new Point {
X = element.Location.X + textView.HorizontalOffset,
Y = element.Location.Y + textView.VerticalOffset
};
Canvas.SetTop(currentThumb, element.Location.Y);
Canvas.SetLeft(currentThumb, element.Location.X);
}
else {
// this is satisfied when loading the pins - so we might have hidden pins
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;
@ -85,6 +105,7 @@ namespace Editor.AvalonEdit @@ -85,6 +105,7 @@ namespace Editor.AvalonEdit
PinDebuggerControl pinControl = TryFindChild<PinDebuggerControl>(currentThumb);
if (pinControl != null)
{
// update relative location
Point location = pinControl.Location;
location.X -= textView.HorizontalOffset;
location.Y += verticalOffset - textView.VerticalOffset;
@ -93,7 +114,10 @@ namespace Editor.AvalonEdit @@ -93,7 +114,10 @@ namespace Editor.AvalonEdit
Canvas.SetTop(currentThumb, location.Y);
pinControl.Location = location;
pinControl.Mark.PopupPosition = location;
pinControl.Mark.PinPosition = new Point {
X = location.X + textView.HorizontalOffset,
Y = location.Y + textView.VerticalOffset,
};
}
}
@ -124,7 +148,14 @@ namespace Editor.AvalonEdit @@ -124,7 +148,14 @@ namespace Editor.AvalonEdit
double top = Canvas.GetTop(currnetThumb);
pinControl.Opacity = 1d;
pinControl.Location = new Point { X = left, Y = top };
pinControl.Mark.PopupPosition = pinControl.Location;
// pin's position is with respect to the layer.
pinControl.Mark.PinPosition =
new Point
{
X = textView.HorizontalOffset + left,
Y = textView.VerticalOffset + top
};
}
}

6
src/Main/Base/Project/Src/Editor/ITooltip.cs

@ -36,12 +36,6 @@ namespace ICSharpCode.SharpDevelop.Editor @@ -36,12 +36,6 @@ namespace ICSharpCode.SharpDevelop.Editor
/// <returns>True if Close succeeded (that is, can close). False otherwise.</returns>
bool Close(bool mouseClick);
/// <summary>
/// Sets the source.
/// </summary>
/// <param name="source">The source.</param>
void SetItemsSource(IEnumerable<ITreeNode> source);
/// <summary>
/// Occurs when this tooltip decides to close.
/// </summary>

2
src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerPopup.cs

@ -63,7 +63,7 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -63,7 +63,7 @@ namespace ICSharpCode.SharpDevelop.Debugging
public IEnumerable<ITreeNode> ItemsSource
{
get { return this.contentControl.ItemsSource; }
set { this.contentControl.SetItemsSource(value); }
set { this.contentControl.ItemsSource = value; }
}
private bool isLeaf;

70
src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerTooltipControl.xaml.cs

@ -4,11 +4,9 @@ @@ -4,11 +4,9 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
@ -54,7 +52,7 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -54,7 +52,7 @@ namespace ICSharpCode.SharpDevelop.Debugging
public DebuggerTooltipControl(IEnumerable<ITreeNode> nodes)
: this()
{
this.itemsSource = nodes;
this.ItemsSource = nodes;
}
public DebuggerTooltipControl(DebuggerTooltipControl parentControl, bool showPins = true)
@ -66,28 +64,9 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -66,28 +64,9 @@ namespace ICSharpCode.SharpDevelop.Debugging
private void OnLoaded(object sender, RoutedEventArgs e)
{
if (showPins) {
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
var editor = provider.TextEditor;
if (editor == null) return;
// verify if at the line of the root there's a pin bookmark
var pin = BookmarkManager.Bookmarks.Find(
b => b is PinBookmark &&
b.Location.Line == LogicalPosition.Line &&
b.FileName == editor.FileName) as PinBookmark;
if (pin != null) {
foreach (var node in this.itemsSource) {
if (pin.ContainsNode(node))
node.IsPinned = true;
}
}
}
else {
if (!showPins) {
dataGrid.Columns[5].Visibility = Visibility.Collapsed;
}
SetItemsSource(this.itemsSource);
}
public event RoutedEventHandler Closed;
@ -100,19 +79,40 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -100,19 +79,40 @@ namespace ICSharpCode.SharpDevelop.Debugging
public IEnumerable<ITreeNode> ItemsSource {
get { return this.itemsSource; }
}
public void SetItemsSource(IEnumerable<ITreeNode> source)
{
this.itemsSource = source;
this.lazyGrid = new LazyItemsControl<ITreeNode>(this.dataGrid, InitialItemsCount);
lazyGrid.ItemsSource = new VirtualizingIEnumerable<ITreeNode>(source);
this.dataGrid.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(handleScroll));
set{
this.itemsSource = value;
this.lazyGrid = new LazyItemsControl<ITreeNode>(this.dataGrid, InitialItemsCount);
// HACK for updating the pinns in tooltip
var observable = new List<ITreeNode>();
this.itemsSource.ForEach(item => observable.Add(item));
// verify if at the line of the root there's a pin bookmark
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
var editor = provider.TextEditor;
if (editor != null) {
var pin = BookmarkManager.Bookmarks.Find(
b => b is PinBookmark &&
b.Location.Line == LogicalPosition.Line &&
b.FileName == editor.FileName) as PinBookmark;
if (pin != null) {
observable.ForEach(item => { // TODO: find a way not to use "observable"
if (pin.ContainsNode(item))
item.IsPinned = true;
});
}
}
var source = new VirtualizingIEnumerable<ITreeNode>(observable);
lazyGrid.ItemsSource = source;
this.dataGrid.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(handleScroll));
if (this.lazyGrid.ItemsSourceTotalCount != null) {
// hide up/down buttons if too few items
btnUp.Visibility = btnDown.Visibility =
this.lazyGrid.ItemsSourceTotalCount.Value <= VisibleItemsCount ? Visibility.Collapsed : Visibility.Visible;
if (this.lazyGrid.ItemsSourceTotalCount != null) {
// hide up/down buttons if too few items
btnUp.Visibility = btnDown.Visibility =
this.lazyGrid.ItemsSourceTotalCount.Value <= VisibleItemsCount ? Visibility.Collapsed : Visibility.Visible;
}
}
}

8
src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinBookmark.cs

@ -29,8 +29,14 @@ namespace Services.Debugger.Tooltips @@ -29,8 +29,14 @@ namespace Services.Debugger.Tooltips
IsVisibleInBookmarkPad = false;
}
public Point PopupPosition { get; set; }
/// <summary>
/// Pin's position relative to the layer BUT ABSOLUTE TO THE SCREEN.
/// </summary>
public Nullable<Point> PinPosition { get; set; }
/// <summary>
/// Nodes inside the pin control.
/// </summary>
public ObservableCollection<ITreeNode> Nodes { get; set; }
/// <summary>

3
src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinDebuggerControl.xaml.cs

@ -71,6 +71,9 @@ namespace Services.Debugger.Tooltips @@ -71,6 +71,9 @@ namespace Services.Debugger.Tooltips
}
}
/// <summary>
/// Relative position of the pin with respect to the screen.
/// </summary>
public Point Location { get; set; }
#endregion

4
src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinningBinding.cs

@ -58,7 +58,6 @@ namespace Services.Debugger.Tooltips @@ -58,7 +58,6 @@ namespace Services.Debugger.Tooltips
var pin = (PinBookmark)bookmark;
pin.Popup = new PinDebuggerControl();
pin.Popup.Mark = pin;
pin.Popup.Location = pin.PopupPosition;
var nodes = new ObservableCollection<ITreeNode>();
foreach (var tuple in pin.SavedNodes) {
@ -88,7 +87,8 @@ namespace Services.Debugger.Tooltips @@ -88,7 +87,8 @@ namespace Services.Debugger.Tooltips
foreach (var bookmark in pins) {
var pin = (PinBookmark)bookmark;
pin.PopupPosition = pin.Popup.Location;
if (!pin.PinPosition.HasValue)
pin.PinPosition = pin.Popup.Location;
// nodes
if (pin.SavedNodes == null)

Loading…
Cancel
Save