Browse Source

reimplement drag&drop of watches from the editor

pull/59/merge
Siegfried Pammer 12 years ago
parent
commit
59efcb8964
  1. 32
      src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs
  2. 30
      src/AddIns/Debugger/Debugger.AddIn/TreeModel/SharpTreeNodeAdapter.cs

32
src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs

@ -3,6 +3,7 @@ @@ -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; @@ -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 @@ -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 @@ -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();
}
}
}

30
src/AddIns/Debugger/Debugger.AddIn/TreeModel/SharpTreeNodeAdapter.cs

@ -52,35 +52,5 @@ namespace Debugger.AddIn.Pads.Controls @@ -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();
}
*/
}
}

Loading…
Cancel
Save