diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs index 1433f3880e..a617c244b7 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Threading; @@ -13,7 +14,6 @@ using Debugger.AddIn.Pads.Controls; using Debugger.AddIn.TreeModel; using ICSharpCode.Core; using ICSharpCode.Core.Presentation; -using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Services; using ICSharpCode.SharpDevelop.Workbench; using ICSharpCode.TreeView; @@ -42,7 +42,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads res.InitializeComponent(); tree = new SharpTreeView(); - tree.Root = new SharpTreeNode(); + tree.Root = new WatchRootNode(); tree.ShowRoot = false; tree.View = (GridView)res["variableGridView"]; tree.SetValue(GridViewColumnAutoSize.AutoWidthProperty, "50%;25%;25%"); @@ -128,4 +128,32 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads } } } + + class WatchRootNode : SharpTreeNode + { + public override bool CanDrop(DragEventArgs e, int index) + { + e.Effects = DragDropEffects.None; + if (e.Data.GetDataPresent(DataFormats.StringFormat)) { + e.Effects = DragDropEffects.Copy; + return true; + } + return false; + } + + public override void Drop(DragEventArgs e, int index) + { + if (e.Data == null) return; + if (!e.Data.GetDataPresent(DataFormats.StringFormat)) return; + + var watchValue = e.Data.GetData(DataFormats.StringFormat).ToString(); + if (string.IsNullOrEmpty(watchValue)) return; + + var pad = SD.Workbench.GetPad(typeof(WatchPad)).PadContent as WatchPad; + if (pad == null) return; + + pad.AddWatch(watchValue); + WindowsDebugger.RefreshPads(); + } + } } diff --git a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/SharpTreeNodeAdapter.cs b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/SharpTreeNodeAdapter.cs index 2aed8dd6e5..b1e7431cf5 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/SharpTreeNodeAdapter.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/SharpTreeNodeAdapter.cs @@ -52,35 +52,5 @@ namespace Debugger.AddIn.Pads.Controls process.EnqueueWork(Dispatcher.CurrentDispatcher, () => Children.AddRange(this.Node.GetChildren().Select(node => node.ToSharpTreeNode()))); } } - - /* - public override bool CanDrop(System.Windows.DragEventArgs e, int index) - { - e.Effects = DragDropEffects.None; - if (e.Data.GetDataPresent(DataFormats.StringFormat)) { - e.Effects = DragDropEffects.Copy; - return true; - } - return false; - } - - public override void Drop(DragEventArgs e, int index) - { - if (ProjectService.CurrentProject == null) return; - if (e.Data == null) return; - if (!e.Data.GetDataPresent(DataFormats.StringFormat)) return; - if (string.IsNullOrEmpty(e.Data.GetData(DataFormats.StringFormat).ToString())) return; - - string language = ProjectService.CurrentProject.Language; - - var text = new TreeNode(e.Data.GetData(DataFormats.StringFormat).ToString(), null); - - var node = text.ToSharpTreeNode(); - if (!WatchPad.Instance.WatchList.WatchItems.Any(n => text.Name == ((SharpTreeNodeAdapter)n).Node.Name)) - WatchPad.Instance.WatchList.WatchItems.Add(node); - - WindowsDebugger.RefreshPads(); - } - */ } }