From af9798ef457bf4a39a00cd8e2e1bf0d13c8a7e5c Mon Sep 17 00:00:00 2001 From: eusebiu Date: Sat, 6 Nov 2010 16:10:00 +0200 Subject: [PATCH 01/20] Edit Pin control v0.1 --- data/resources/StringResources.resx | 3 + .../image/BitmapResources/BitmapResources.res | 2 + .../image/BitmapResources/Bookmarks/Pin.png | Bin 0 -> 671 bytes .../Debugger.AddIn/Pads/WatchPadModel.cs | 4 +- .../TreeModel/ExpressionNode.cs | 76 ++++--- .../Debugger.AddIn/TreeModel/TreeNode.cs | 13 +- .../AvalonEdit.AddIn/Src/CodeEditorView.cs | 6 +- .../Project/ICSharpCode.SharpDevelop.csproj | 6 + .../Src/Bookmarks/BookmarkConverter.cs | 31 ++- src/Main/Base/Project/Src/Editor/ITooltip.cs | 6 + .../Debugger/Tooltips/DebuggerPopup.cs | 8 +- .../Tooltips/DebuggerTooltipControl.xaml | 72 +++++- .../Tooltips/DebuggerTooltipControl.xaml.cs | 209 +++++++++++++++++- .../Services/Debugger/Tooltips/ITreeNode.cs | 4 + .../Services/Debugger/Tooltips/PinBookmark.cs | 57 +++++ .../Debugger/Tooltips/PinCloseControl.xaml | 29 +++ .../Debugger/Tooltips/PinCloseControl.xaml.cs | 89 ++++++++ .../Tooltips/PinControlsDictionary.xaml | 151 +++++++++++++ .../Resources/BitmapResources.resources | Bin 654336 -> 655209 bytes 19 files changed, 718 insertions(+), 48 deletions(-) create mode 100644 data/resources/image/BitmapResources/Bookmarks/Pin.png create mode 100644 src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinBookmark.cs create mode 100644 src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinCloseControl.xaml create mode 100644 src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinCloseControl.xaml.cs create mode 100644 src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinControlsDictionary.xaml diff --git a/data/resources/StringResources.resx b/data/resources/StringResources.resx index 1b0e5e1330..637730eff5 100644 --- a/data/resources/StringResources.resx +++ b/data/resources/StringResources.resx @@ -4500,6 +4500,9 @@ has been changed externally do you want to reload it? Unhandled exception has occured + + Saved + Can't deserialize form. Possible reason: Initialize component method was changed manually. diff --git a/data/resources/image/BitmapResources/BitmapResources.res b/data/resources/image/BitmapResources/BitmapResources.res index 76615e2224..71c1744c7a 100644 --- a/data/resources/image/BitmapResources/BitmapResources.res +++ b/data/resources/image/BitmapResources/BitmapResources.res @@ -343,6 +343,8 @@ Bookmarks.UnhealthyBreakpoint = Bookmarks\UnhealthyBreakpoin Bookmarks.UnhealthyBreakpointConditional = Bookmarks\UnhealthyBreakpointConditional.png Bookmarks.CurrentLine = Bookmarks\CurrentLine.png +Bookmarks.Pin = Bookmarks\Pin.png + #backend icons C#.ProjectIcon = backendicons\CSharp\SmallProject.png C#.FileIcon = backendicons\CSharp\SmallFile.png diff --git a/data/resources/image/BitmapResources/Bookmarks/Pin.png b/data/resources/image/BitmapResources/Bookmarks/Pin.png new file mode 100644 index 0000000000000000000000000000000000000000..a93b751c8bbddb0c3364047f363b525c9a40483b GIT binary patch literal 671 zcmV;Q0$}}#P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vH0TL1tzTLGDa0>%IU02y>eSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+$tiu~XJ00Iw5L_t(IPh(&p0x-Ex=4N#5Wg*lm9ZfPwgby5UJpaG9vDE zPeOW*|F^C__@CKp#($szf0?|d8xb_bu<<&tUfI#J`h`3HsU|J{ub#fz>E|RdaUy7xr%d$z_$NjoW7Tsf_$#i_Qf0o&TRa z|Nj5_T|fVOPk;Vjv*gHsv7pKSxNHh067;uH^2(CD#kc?EFMIeuc*djude!IuOGM89 z&t+Tuiq$Adh@b(C7M*NPb^G_E&cE|NWZIqoN?F_gbGtPDXLs#*&*V9km!JV41$z!0 zFAr~A_t&!K$UjivNoVf)&mXnwAG6Oa6M_ajdGf^g@WF%MySut3^90TJ<_cM~k1J&H z7goQy=NUbxbKx~$?wq;Yw{G0LHf`$EOP*d{V8x7H(-|3@C$KQMOk^Zz``45AHySO#kL-o!NULm002ovPDHLk FV1l;lLxunV literal 0 HcmV?d00001 diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadModel.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadModel.cs index 4b6fac8574..38d93e1407 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadModel.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadModel.cs @@ -19,13 +19,13 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads this.Language = language; } - public bool CanSetText { + public new bool CanSetText { get { return true; } } - public bool SetText(string text) + public new bool SetText(string text) { this.Text = text; return true; diff --git a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ExpressionNode.cs b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ExpressionNode.cs index a1ee943a84..7a09ab96f2 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ExpressionNode.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ExpressionNode.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Drawing; using System.Globalization; using System.Reflection; @@ -26,7 +27,7 @@ namespace Debugger.AddIn.TreeModel /// Node in the tree which can be defined by a debugger expression. /// The expression will be lazily evaluated when needed. /// - public class ExpressionNode: TreeNode, ISetText, IContextMenu + public class ExpressionNode: TreeNode, ISetText, INotifyPropertyChanged { bool evaluated; @@ -36,11 +37,16 @@ namespace Debugger.AddIn.TreeModel string fullText; + public bool Evaluated { + get { return evaluated; } + set { evaluated = value; } + } + public Expression Expression { get { return expression; } } - public bool CanSetText { + public override bool CanSetText { get { if (!evaluated) EvaluateExpression(); return canSetText; @@ -54,11 +60,21 @@ namespace Debugger.AddIn.TreeModel } } + public string FullText { + get { return fullText; } + } + public override string Text { get { if (!evaluated) EvaluateExpression(); return base.Text; } + set { + if (value != base.Text) { + base.Text = value; + NotifyPropertyChanged("Text"); + } + } } public override string Type { @@ -80,7 +96,7 @@ namespace Debugger.AddIn.TreeModel if (!evaluated) EvaluateExpression(); return base.HasChildNodes; } - } + } /// Used to determine available VisualizerCommands private DebugType expressionType; @@ -269,7 +285,7 @@ namespace Debugger.AddIn.TreeModel return size >= 7 && runs <= (size + 7) / 8; } - public bool SetText(string newText) + public override bool SetText(string newText) { Value val = null; try { @@ -343,19 +359,19 @@ namespace Debugger.AddIn.TreeModel return DebuggerResourceService.GetImage("Icons.16x16." + name); } - public ContextMenuStrip GetContextMenu() - { - if (this.Error != null) return GetErrorContextMenu(); - - ContextMenuStrip menu = new ContextMenuStrip(); - - ToolStripMenuItem copyItem; - copyItem = new ToolStripMenuItem(); - copyItem.Text = ResourceService.GetString("MainWindow.Windows.Debug.LocalVariables.CopyToClipboard"); - copyItem.Checked = false; - copyItem.Click += delegate { - ClipboardWrapper.SetText(fullText); - }; +// public ContextMenuStrip GetContextMenu() +// { +// if (this.Error != null) return GetErrorContextMenu(); +// +// ContextMenuStrip menu = new ContextMenuStrip(); +// +// ToolStripMenuItem copyItem; +// copyItem = new ToolStripMenuItem(); +// copyItem.Text = ResourceService.GetString("MainWindow.Windows.Debug.LocalVariables.CopyToClipboard"); +// copyItem.Checked = false; +// copyItem.Click += delegate { +// ClipboardWrapper.SetText(fullText); +// }; // ToolStripMenuItem hexView; // hexView = new ToolStripMenuItem(); @@ -371,13 +387,13 @@ namespace Debugger.AddIn.TreeModel // WatchPad.Instance.RefreshPad(); // }; - menu.Items.AddRange(new ToolStripItem[] { - copyItem, - //hexView - }); - - return menu; - } +// menu.Items.AddRange(new ToolStripItem[] { +// copyItem, +// //hexView +// }); +// +// return menu; +// } public ContextMenuStrip GetErrorContextMenu() { @@ -403,5 +419,15 @@ namespace Debugger.AddIn.TreeModel return (WindowsDebugger)DebuggerService.CurrentDebugger; } } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + private void NotifyPropertyChanged(string info) + { + if (PropertyChanged != null) + { + PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(info)); + } + } } -} +} \ No newline at end of file diff --git a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/TreeNode.cs b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/TreeNode.cs index 956410e91f..ca328cd1ae 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/TreeNode.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/TreeNode.cs @@ -3,9 +3,10 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Drawing; -using System.Windows.Media; using System.Linq; +using System.Windows.Media; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Debugging; @@ -58,7 +59,7 @@ namespace Debugger.AddIn.TreeModel public virtual string Text { get { return text; } - protected set { text = value; } + set { text = value; } } public virtual string Type { @@ -79,6 +80,10 @@ namespace Debugger.AddIn.TreeModel get { return childNodes != null; } } + public virtual bool CanSetText { + get { return false; } + } + public virtual IEnumerable VisualizerCommands { get { return null; @@ -108,5 +113,9 @@ namespace Debugger.AddIn.TreeModel { return this.Name.CompareTo(other.Name); } + + public virtual bool SetText(string newValue) { + return false; + } } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs index 5304aa6b7a..9005a8e65e 100755 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs @@ -13,6 +13,8 @@ using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Documents; using System.Windows.Input; +using System.Windows.Media; + using ICSharpCode.AvalonEdit.AddIn.Options; using ICSharpCode.AvalonEdit.AddIn.Snippets; using ICSharpCode.AvalonEdit.Editing; @@ -234,6 +236,7 @@ namespace ICSharpCode.AvalonEdit.AddIn if (!(args.ContentToShow is UIElement)) { throw new NotSupportedException("Content to show in Popup must be UIElement: " + args.ContentToShow); } + contentToShowITooltip.LogicalPosition = args.LogicalPosition; if (popup == null) { popup = CreatePopup(); } @@ -321,6 +324,7 @@ namespace ICSharpCode.AvalonEdit.AddIn { popup = new Popup(); popup.Closed += PopupClosed; + popup.AllowsTransparency = true; popup.PlacementTarget = this; // required for property inheritance popup.Placement = PlacementMode.Absolute; popup.StaysOpen = true; @@ -499,4 +503,4 @@ namespace ICSharpCode.AvalonEdit.AddIn } } } -} +} \ No newline at end of file diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index f127f7ead4..a5de9b36f8 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -317,6 +317,10 @@ + + + PinCloseControl.xaml + @@ -817,6 +821,8 @@ + + diff --git a/src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs b/src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs index 05b3332645..c910200964 100644 --- a/src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs +++ b/src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs @@ -1,12 +1,14 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -using ICSharpCode.NRefactory; using System; using System.ComponentModel; using System.Globalization; using System.Text; + using ICSharpCode.Core; +using ICSharpCode.NRefactory; +using Services.Debugger.Tooltips; namespace ICSharpCode.SharpDevelop.Bookmarks { @@ -25,8 +27,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks { if (value is string) { string[] v = ((string)value).Split('|'); - if (v.Length != 8) - return null; + FileName fileName = FileName.Create(v[1]); int lineNumber = int.Parse(v[2], culture); int columnNumber = int.Parse(v[3], culture); @@ -49,6 +50,14 @@ namespace ICSharpCode.SharpDevelop.Bookmarks bbm.IsEnabled = bool.Parse(v[4]); bookmark = bbm; break; + case "PinBookmark": + var pin = new PinBookmark(fileName, new Location(columnNumber, lineNumber)); + for (int i = 4; i < v.Length; i+=2) { + pin.SavedNodes.Add(new Tuple(v[i], v[i+1])); + } + + bookmark = pin; + break; default: bookmark = new SDBookmark(fileName, new Location(columnNumber, lineNumber)); break; @@ -67,7 +76,10 @@ namespace ICSharpCode.SharpDevelop.Bookmarks if (bookmark is Debugging.BreakpointBookmark) { b.Append("Breakpoint"); } else { - b.Append("Bookmark"); + if (bookmark is PinBookmark) + b.Append("PinBookmark"); + else + b.Append("Bookmark"); } b.Append('|'); b.Append(bookmark.FileName); @@ -75,6 +87,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks b.Append(bookmark.LineNumber); b.Append('|'); b.Append(bookmark.ColumnNumber); + if (bookmark is Debugging.BreakpointBookmark) { Debugging.BreakpointBookmark bbm = (Debugging.BreakpointBookmark)bookmark; b.Append('|'); @@ -86,6 +99,16 @@ namespace ICSharpCode.SharpDevelop.Bookmarks b.Append('|'); b.Append(bbm.Condition); } + + if (bookmark is PinBookmark) { + var pin = (PinBookmark)bookmark; + b.Append(pin.Comment); + foreach(var node in pin.Nodes) { + b.Append(node.Name); + b.Append('|'); + b.Append(node.Text); + } + } return b.ToString(); } else { return base.ConvertTo(context, culture, value, destinationType); diff --git a/src/Main/Base/Project/Src/Editor/ITooltip.cs b/src/Main/Base/Project/Src/Editor/ITooltip.cs index def96396f1..48063054a4 100644 --- a/src/Main/Base/Project/Src/Editor/ITooltip.cs +++ b/src/Main/Base/Project/Src/Editor/ITooltip.cs @@ -3,6 +3,7 @@ using System; using System.Windows; +using ICSharpCode.NRefactory; namespace ICSharpCode.SharpDevelop.Editor { @@ -12,6 +13,11 @@ namespace ICSharpCode.SharpDevelop.Editor /// public interface ITooltip { + /// + /// Gets or sets the logical location within the document. + /// + Location LogicalPosition { get; set; } + /// /// If true, this ITooltip will be displayed in a WPF Popup. /// Otherwise it will be displayed in a WPF Tooltip. diff --git a/src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerPopup.cs b/src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerPopup.cs index 2f045b5450..6f422cf640 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerPopup.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerPopup.cs @@ -17,11 +17,11 @@ namespace ICSharpCode.SharpDevelop.Debugging /// public class DebuggerPopup : Popup { - private DebuggerTooltipControl contentControl; + internal DebuggerTooltipControl contentControl; - public DebuggerPopup(DebuggerTooltipControl parentControl) + public DebuggerPopup(DebuggerTooltipControl parentControl, bool showPinControl) { - this.contentControl = new DebuggerTooltipControl(parentControl); + this.contentControl = new DebuggerTooltipControl(parentControl, showPinControl); this.contentControl.containingPopup = this; this.Child = this.contentControl; this.IsLeaf = false; @@ -30,7 +30,7 @@ namespace ICSharpCode.SharpDevelop.Debugging //this.contentControl.Focusable = true; //Keyboard.Focus(this.contentControl); - //this.AllowsTransparency = true; + this.AllowsTransparency = true; //this.PopupAnimation = PopupAnimation.Slide; } diff --git a/src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerTooltipControl.xaml b/src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerTooltipControl.xaml index f9af4fca25..04d7a99ca6 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerTooltipControl.xaml +++ b/src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerTooltipControl.xaml @@ -3,13 +3,17 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:aero="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" xmlns:debugging="clr-namespace:ICSharpCode.SharpDevelop.Debugging" + xmlns:core="http://icsharpcode.net/sharpdevelop/core" + xmlns:localControls="clr-namespace:Services.Debugger.Tooltips" + Background="Transparent" > + - + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerTooltipControl.xaml.cs b/src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerTooltipControl.xaml.cs index 7fe7c0ee6d..2340fa1bb9 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerTooltipControl.xaml.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/Tooltips/DebuggerTooltipControl.xaml.cs @@ -3,15 +3,22 @@ using System; using System.Collections.Generic; -using System.Text; +using System.Globalization; 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; +using System.Windows.Media.Animation; +using System.Windows.Shapes; + +using ICSharpCode.Core; +using ICSharpCode.NRefactory; +using ICSharpCode.SharpDevelop.Bookmarks; using ICSharpCode.SharpDevelop.Editor; +using ICSharpCode.SharpDevelop.Gui; +using Services.Debugger.Tooltips; namespace ICSharpCode.SharpDevelop.Debugging { @@ -24,10 +31,28 @@ namespace ICSharpCode.SharpDevelop.Debugging private readonly double ChildPopupOpenYOffet = 15; private readonly int InitialItemsCount = 12; private readonly int VisibleItemsCount = 11; + + bool showPinControl; + PinCloseControl pinCloseControl; - public DebuggerTooltipControl() + public DebuggerTooltipControl(bool showPinControl = false) { InitializeComponent(); + + this.showPinControl = showPinControl; + + // show pin close control + if (this.showPinControl) { + dataGrid.Columns[5].Visibility = Visibility.Collapsed; + + pinCloseControl = new PinCloseControl(this); + pinCloseControl.Visibility = Visibility.Visible; + PinControlCanvas.Visibility = Visibility.Visible; + PinControlCanvas.Children.Add(pinCloseControl); + } + else { + PinControlCanvas.Visibility = Visibility.Collapsed; + } } public DebuggerTooltipControl(ITreeNode node) @@ -41,8 +66,8 @@ namespace ICSharpCode.SharpDevelop.Debugging this.ItemsSource = nodes; } - public DebuggerTooltipControl(DebuggerTooltipControl parentControl) - : this() + public DebuggerTooltipControl(DebuggerTooltipControl parentControl, bool showPinControl = false) + : this(showPinControl) { this.parentControl = parentControl; } @@ -74,7 +99,6 @@ namespace ICSharpCode.SharpDevelop.Debugging this.lazyGrid.ItemsSourceTotalCount.Value <= VisibleItemsCount ? Visibility.Collapsed : Visibility.Visible; } } - } /// @@ -85,7 +109,17 @@ namespace ICSharpCode.SharpDevelop.Debugging return true; } } + + public string Comment { + get { return CommentTextBox.Text; } + set { CommentTextBox.Text = value; } + } + /// + /// Position within the document + /// + public Location LogicalPosition { get; set; } + /// public bool Close(bool mouseClick) { @@ -161,7 +195,7 @@ namespace ICSharpCode.SharpDevelop.Debugging // open child Popup if (this.childPopup == null) { - this.childPopup = new DebuggerPopup(this); + this.childPopup = new DebuggerPopup(this, showPinControl); this.childPopup.Placement = PlacementMode.Absolute; } if (this.containingPopup != null) { @@ -192,5 +226,164 @@ namespace ICSharpCode.SharpDevelop.Debugging { this.lazyGrid.ScrollViewer.ScrollDown(1); } + + void TextBox_KeyUp(object sender, KeyEventArgs e) + { + if (e.Key == Key.Escape) { + dataGrid.Focus(); + return; + } + + if (e.Key == Key.Enter) { + dataGrid.Focus(); + // set new value + var textBox = (TextBox)sender; + var newValue = textBox.Text; + var node = ((FrameworkElement)sender).DataContext as ITreeNode; + SaveNewValue(node, textBox.Text); + } + } + + void TextBox_LostFocus(object sender, RoutedEventArgs e) + { + // set new value + var textBox = (TextBox)sender; + var node = ((FrameworkElement)sender).DataContext as ITreeNode; + SaveNewValue(node, textBox.Text); + } + + void SaveNewValue(ITreeNode node, string newValue) + { + if(node != null && node.SetText(newValue)) { + // show adorner + var adornerLayer = AdornerLayer.GetAdornerLayer(dataGrid); + var adorners = adornerLayer.GetAdorners(dataGrid); + if (adorners != null && adorners.Length != 0) + adornerLayer.Remove(adorners[0]); + SavedAdorner adorner = new SavedAdorner(dataGrid); + adornerLayer.Add(adorner); + } + } + + void PinButton_Checked(object sender, RoutedEventArgs e) + { + ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorProvider; + ToggleButton button = (ToggleButton)sender; + + if (provider != null) { + ITextEditor editor = provider.TextEditor; + if (!string.IsNullOrEmpty(editor.FileName)) { + + var pin = new PinBookmark(editor.FileName, LogicalPosition); + if (!BookmarkManager.Bookmarks.Contains(pin)) { + // show pinned DebuggerPopup + if (pin.Popup == null) { + pin.Popup = new DebuggerPopup(this, true); + pin.Popup.Placement = PlacementMode.Absolute; + Rect rect = new Rect(this.DesiredSize); + var point = this.PointToScreen(rect.TopRight); + pin.Popup.HorizontalOffset = point.X + 150; + pin.Popup.VerticalOffset = point.Y - 20; + pin.Popup.Open(); + } + pin.Nodes.Add(button.DataContext as ITreeNode); + + BookmarkManager.ToggleBookmark( + editor, + LogicalPosition.Line, + b => b.CanToggle && b is PinBookmark, + location => pin); + } + else + { + pin.Nodes.Add(button.DataContext as ITreeNode); + } + } + } + } + + void PinButton_Unchecked(object sender, RoutedEventArgs e) + { + if (!showPinControl) + return; + + ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorProvider; + if (provider != null) { + ITextEditor editor = provider.TextEditor; + if (!string.IsNullOrEmpty(editor.FileName)) { + // remove from pinned DebuggerPopup + var pin = new PinBookmark(editor.FileName, LogicalPosition); + if (!BookmarkManager.Bookmarks.Contains(pin)) + return; + ToggleButton button = (ToggleButton)sender; + pin.Nodes.Remove(button.DataContext as ITreeNode); + } + } + } + + public void ShowComment(bool show) + { + if(show && BorderComment.Height != 0) + return; + if(!show && BorderComment.Height != 40) + return; + + DoubleAnimation animation = new DoubleAnimation(); + animation.From = show ? 0 : 40; + animation.To = show ? 40 : 0; + + animation.Duration = new Duration(TimeSpan.FromMilliseconds(300)); + animation.SetValue(Storyboard.TargetProperty, BorderComment); + animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Border.HeightProperty)); + + Storyboard board = new Storyboard(); + board.Children.Add(animation); + board.Begin(this); + } + + class SavedAdorner : Adorner + { + public SavedAdorner(UIElement adornedElement) : base(adornedElement) + { + Loaded += delegate { Show(); }; + } + + protected override void OnRender(DrawingContext drawingContext) + { + Rect adornedElementRect = new Rect(this.AdornedElement.DesiredSize); + + // Some arbitrary drawing implements. + var formatedText = new FormattedText(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Debugging.SavedString}"), + CultureInfo.CurrentCulture, + FlowDirection.LeftToRight, + new Typeface(new FontFamily("Arial"), + FontStyles.Normal, + FontWeights.Black, + FontStretches.Expanded), + 8d, + Brushes.Black); + + + drawingContext.DrawText(formatedText, + new Point(adornedElementRect.TopRight.X - formatedText.Width - 2, + adornedElementRect.TopRight.Y)); + } + + private void Show() + { + DoubleAnimation animation = new DoubleAnimation(); + animation.From = 1; + animation.To = 0; + + animation.Duration = new Duration(TimeSpan.FromSeconds(2)); + animation.SetValue(Storyboard.TargetProperty, this); + animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Rectangle.OpacityProperty)); + + Storyboard board = new Storyboard(); + board.Children.Add(animation); + + board.Begin(this); + } + } } -} +} \ No newline at end of file diff --git a/src/Main/Base/Project/Src/Services/Debugger/Tooltips/ITreeNode.cs b/src/Main/Base/Project/Src/Services/Debugger/Tooltips/ITreeNode.cs index abc88cdd3b..a96fc17f45 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/Tooltips/ITreeNode.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/Tooltips/ITreeNode.cs @@ -16,6 +16,8 @@ namespace ICSharpCode.SharpDevelop.Debugging string Text { get; } + bool CanSetText { get; } + string Type { get; } ImageSource ImageSource { get; } @@ -27,5 +29,7 @@ namespace ICSharpCode.SharpDevelop.Debugging IEnumerable VisualizerCommands { get; } bool HasVisualizerCommands { get; } + + bool SetText(string newValue); } } diff --git a/src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinBookmark.cs b/src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinBookmark.cs new file mode 100644 index 0000000000..50e05496e5 --- /dev/null +++ b/src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinBookmark.cs @@ -0,0 +1,57 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Collections.Specialized; + +using ICSharpCode.Core; +using ICSharpCode.NRefactory; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Bookmarks; +using ICSharpCode.SharpDevelop.Debugging; +using ICSharpCode.SharpDevelop.Editor; + +namespace Services.Debugger.Tooltips +{ + public class PinBookmark : SDBookmark + { + string tooltip; + + public DebuggerPopup Popup { get; set; } + + public static readonly IImage PinImage = new ResourceServiceImage("Bookmarks.Pin"); + + public PinBookmark(FileName fileName, Location location) : base(fileName, location) + { + Nodes = new ObservableCollection(); + Nodes.CollectionChanged += new NotifyCollectionChangedEventHandler(Nodes_CollectionChanged); + IsVisibleInBookmarkPad = false; + } + + void Nodes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + if (e.Action == NotifyCollectionChangedAction.Add || + e.Action == NotifyCollectionChangedAction.Remove) + Popup.contentControl.ItemsSource = Nodes; + } + + public ObservableCollection Nodes { get; set; } + + public List> SavedNodes { get; set; } + + public string Comment { get; set; } + + public override IImage Image { + get { + return PinImage; + } + } + + public string Tooltip { + get { return tooltip; } + set { tooltip = value; } + } + } +} diff --git a/src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinCloseControl.xaml b/src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinCloseControl.xaml new file mode 100644 index 0000000000..9b97989108 --- /dev/null +++ b/src/Main/Base/Project/Src/Services/Debugger/Tooltips/PinCloseControl.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + +