diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
index f7712df19d..f528a03377 100644
--- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
@@ -62,6 +62,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
instance = this;
}
+ /// Always check if Instance is null, might be null if pad is not opened!
public static LocalVarPad Instance {
get { return instance; }
}
diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/WatchPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/WatchPad.cs
index 4c3bb1d3b4..4f79c5954b 100644
--- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/WatchPad.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/WatchPad.cs
@@ -75,11 +75,16 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
}
public override void SetValue(TreeNodeAdv node, object value)
{
- if (((TreeViewVarNode)node).Content is ValueNode)
- ((ValueNode)((TreeViewVarNode)node).Content).SetName(value.ToString());
- else {
- if (((TreeViewVarNode)node).Content is TextNode)
- ((TextNode)((TreeViewVarNode)node).Content).SetName(value.ToString());
+ if (string.IsNullOrEmpty(value as string))
+ MessageBox.Show("You can not set name to an empty string!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ else
+ {
+ if (((TreeViewVarNode)node).Content is ValueNode)
+ ((ValueNode)((TreeViewVarNode)node).Content).SetName(value.ToString());
+ else {
+ if (((TreeViewVarNode)node).Content is TextNode)
+ ((TextNode)((TreeViewVarNode)node).Content).SetName(value.ToString());
+ }
}
}
public override void MouseDown(TreeNodeAdvMouseEventArgs args)
@@ -93,6 +98,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
ContextMenuStrip menu = ((IContextMenu)content).GetContextMenu();
if (menu != null) {
menu.Show(args.Node.Tree, args.Location);
+ args.Handled = true;
}
} else {
base.MouseDown(args);
@@ -105,6 +111,17 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
TreeViewAdv watchList;
Process debuggedProcess;
List watches;
+ static WatchPad instance;
+
+ /// Always check if Instance is null, might be null if pad is not opened!
+ public static WatchPad Instance {
+ get { return instance; }
+ }
+
+ public WatchPad()
+ {
+ instance = this;
+ }
public List Watches {
get { return watches; }
@@ -154,16 +171,42 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
watchList.NodeControls.Add(typeControl);
watchList.AutoRowHeight = true;
-
- watchList.MouseDoubleClick += new MouseEventHandler(watchList_DoubleClick);
-
- watchList.ContextMenuStrip = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/WatchPad/ContextMenu");
-
+ watchList.MouseDoubleClick += new MouseEventHandler(watchList_DoubleClick);
+ watchList.ContextMenuStrip = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/WatchPad/ContextMenu");
+
+ watchList.AllowDrop = true;
+ watchList.DragEnter += new DragEventHandler(watchList_DragEnter);
+ watchList.DragDrop += new DragEventHandler(watchList_DragDrop);
+
watches = new List();
RedrawContent();
}
+
+ void watchList_DragDrop(object sender, DragEventArgs e)
+ {
+ watchList.BeginUpdate();
+ TextNode text = new TextNode(e.Data.GetData(DataFormats.StringFormat).ToString());
+ TreeViewVarNode node = new TreeViewVarNode(this.debuggedProcess, this.watchList, text);
+ watches.Add(text);
+ watchList.Root.Children.Add(node);
+ watchList.EndUpdate();
+
+ node.IsSelected = true;
+
+ this.RefreshPad();
+ }
+ void watchList_DragEnter(object sender, DragEventArgs e)
+ {
+ if(e.Data.GetDataPresent(DataFormats.StringFormat)) {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
void watchList_DoubleClick(object sender, MouseEventArgs e)
{
if (watchList.SelectedNode == null)
diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewVarNode.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewVarNode.cs
index 56d1a8d2f7..bc840edaaf 100644
--- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewVarNode.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewVarNode.cs
@@ -82,6 +82,7 @@ namespace Debugger.AddIn.TreeModel
ContextMenuStrip menu = ((IContextMenu)content).GetContextMenu();
if (menu != null) {
menu.Show(args.Node.Tree, args.Location);
+ args.Handled = true;
}
} else {
base.MouseDown(args);
diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs
index 646bc1a0f2..4e844a2ea3 100644
--- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs
@@ -233,8 +233,13 @@ namespace Debugger.AddIn.TreeModel
hexView.Text = ResourceService.GetString("MainWindow.Windows.Debug.LocalVariables.ShowInHexadecimal");
hexView.Checked = DebuggingOptions.Instance.ShowValuesInHexadecimal;
hexView.Click += delegate {
+ // refresh all pads that use ValueNode for display
DebuggingOptions.Instance.ShowValuesInHexadecimal = !DebuggingOptions.Instance.ShowValuesInHexadecimal;
- LocalVarPad.Instance.RefreshPad();
+ // always check if instance is null, might be null if pad is not opened
+ if (LocalVarPad.Instance != null)
+ LocalVarPad.Instance.RefreshPad();
+ if (WatchPad.Instance != null)
+ WatchPad.Instance.RefreshPad();
};
menu.Items.AddRange(new ToolStripItem[] {
diff --git a/src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.Input.cs b/src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.Input.cs
index 60e880b31e..dbfda231aa 100644
--- a/src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.Input.cs
+++ b/src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.Input.cs
@@ -21,9 +21,9 @@ namespace Aga.Controls.Tree
protected override bool IsInputKey(Keys keyData)
{
if (((keyData & Keys.Up) == Keys.Up)
- || ((keyData & Keys.Down) == Keys.Down)
- || ((keyData & Keys.Left) == Keys.Left)
- || ((keyData & Keys.Right) == Keys.Right))
+ || ((keyData & Keys.Down) == Keys.Down)
+ || ((keyData & Keys.Left) == Keys.Left)
+ || ((keyData & Keys.Right) == Keys.Right))
return true;
else
return base.IsInputKey(keyData);
@@ -102,7 +102,7 @@ namespace Aga.Controls.Tree
{
TreeNodeAdvMouseEventArgs args = new TreeNodeAdvMouseEventArgs(e);
args.ViewLocation = new Point(e.X + OffsetX,
- e.Y + _rowLayout.GetRowBounds(FirstVisibleRow).Y - ColumnHeaderHeight);
+ e.Y + _rowLayout.GetRowBounds(FirstVisibleRow).Y - ColumnHeaderHeight);
args.ModifierKeys = ModifierKeys;
args.Node = GetNodeAt(e.Location);
NodeControlInfo info = GetNodeControlInfoAt(args.Node, e.Location);
@@ -155,8 +155,11 @@ namespace Aga.Controls.Tree
if (args.Node != null && args.Control != null)
args.Control.MouseDown(args);
- if (!args.Handled)
+ if (!args.Handled) {
Input.MouseDown(args);
+ base.ContextMenuStrip = _cms;
+ } else
+ base.ContextMenuStrip = null;
base.OnMouseDown(e);
}
@@ -218,7 +221,7 @@ namespace Aga.Controls.Tree
SetCursor(e);
UpdateToolTip(e);
if (ItemDragMode && Dist(e.Location, ItemDragStart) > ItemDragSensivity
- && CurrentNode != null && CurrentNode.IsSelected)
+ && CurrentNode != null && CurrentNode.IsSelected)
{
ItemDragMode = false;
_toolTip.Active = false;
@@ -380,7 +383,7 @@ namespace Aga.Controls.Tree
{
Size ms = btc.GetActualSize(args.Node, _measureContext);
if (ms.Width > args.ControlBounds.Size.Width || ms.Height > args.ControlBounds.Size.Height
- || args.ControlBounds.Right - OffsetX > DisplayRectangle.Width)
+ || args.ControlBounds.Right - OffsetX > DisplayRectangle.Width)
msg = btc.GetLabel(args.Node);
}
diff --git a/src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.cs b/src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.cs
index 83a6e31c3a..c01572150e 100644
--- a/src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.cs
+++ b/src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.cs
@@ -41,7 +41,15 @@ namespace Aga.Controls.Tree
private IncrementalSearch _search;
private List _expandingNodes = new List();
private AbortableThreadPool _threadPool = new AbortableThreadPool();
-
+ private ContextMenuStrip _cms;
+
+ public new ContextMenuStrip ContextMenuStrip {
+ set {
+ base.ContextMenuStrip = value;
+ _cms = value;
+ }
+ }
+
#region Public Events
[Category("Action")]
@@ -182,11 +190,11 @@ namespace Aga.Controls.Tree
{
InitializeComponent();
SetStyle(ControlStyles.AllPaintingInWmPaint
- | ControlStyles.UserPaint
- | ControlStyles.OptimizedDoubleBuffer
- | ControlStyles.ResizeRedraw
- | ControlStyles.Selectable
- , true);
+ | ControlStyles.UserPaint
+ | ControlStyles.OptimizedDoubleBuffer
+ | ControlStyles.ResizeRedraw
+ | ControlStyles.Selectable
+ , true);
if (Application.RenderWithVisualStyles)
@@ -308,7 +316,7 @@ namespace Aga.Controls.Tree
point.X += OffsetX;
foreach (NodeControlInfo info in GetNodeControls(node))
if (info.Bounds.Contains(point))
- return info;
+ return info;
if (FullRowSelect)
return new NodeControlInfo(null, Rectangle.Empty, node);
@@ -383,7 +391,7 @@ namespace Aga.Controls.Tree
CreateRowMap();
int row = -1;
-
+
if (node.Row < FirstVisibleRow)
row = node.Row;
else
@@ -433,10 +441,10 @@ namespace Aga.Controls.Tree
Rectangle clientRect = ClientRectangle;
_hScrollBar.SetBounds(clientRect.X, clientRect.Bottom - hBarSize,
- clientRect.Width - vBarSize, hBarSize);
+ clientRect.Width - vBarSize, hBarSize);
_vScrollBar.SetBounds(clientRect.Right - vBarSize, clientRect.Y,
- vBarSize, clientRect.Height - hBarSize);
+ vBarSize, clientRect.Height - hBarSize);
}
private void SafeUpdateScrollBars()
@@ -483,10 +491,10 @@ namespace Aga.Controls.Tree
switch (BorderStyle)
{
case BorderStyle.FixedSingle:
- res.Style |= 0x800000;
- break;
+ res.Style |= 0x800000;
+ break;
case BorderStyle.Fixed3D:
- res.ExStyle |= 0x200;
+ res.ExStyle |= 0x200;
break;
}
return res;
@@ -580,10 +588,10 @@ namespace Aga.Controls.Tree
bool isLastControl = true;
for (int k = i + 1; k < NodeControls.Count; k++)
if (NodeControls[k].ParentColumn == col)
- {
- isLastControl = false;
- break;
- }
+ {
+ isLastControl = false;
+ break;
+ }
width = right - x;
if (!isLastControl)
@@ -669,26 +677,26 @@ namespace Aga.Controls.Tree
IEnumerable items = Model.GetChildren(GetPath(parentNode));
if (items != null)
foreach (object obj in items)
+ {
+ bool found = false;
+ if (obj != null)
{
- bool found = false;
- if (obj != null)
+ for (int i = 0; i < oldNodes.Count; i++)
+ if (object.Equals(obj, oldNodes[i].Tag))
{
- for (int i = 0; i < oldNodes.Count; i++)
- if (object.Equals(obj, oldNodes[i].Tag))
- {
- oldNodes[i].RightBounds = oldNodes[i].Height = null;
- AddNode(parentNode, -1, oldNodes[i]);
- oldNodes.RemoveAt(i);
- found = true;
- break;
- }
+ oldNodes[i].RightBounds = oldNodes[i].Height = null;
+ AddNode(parentNode, -1, oldNodes[i]);
+ oldNodes.RemoveAt(i);
+ found = true;
+ break;
}
- if (!found)
- AddNewNode(parentNode, obj, -1);
-
- if (performFullUpdate)
- FullUpdate();
}
+ if (!found)
+ AddNewNode(parentNode, obj, -1);
+
+ if (performFullUpdate)
+ FullUpdate();
+ }
}
}
@@ -860,7 +868,7 @@ namespace Aga.Controls.Tree
_contentWidth = 0;
foreach (TreeColumn col in _columns)
if (col.IsVisible)
- _contentWidth += col.Width;
+ _contentWidth += col.Width;
}
}
@@ -945,10 +953,10 @@ namespace Aga.Controls.Tree
for (int i = Selection.Count - 1; i >= 0; i--)
if (!IsMyNode(Selection[i]))
- {
- flag = true;
- Selection.RemoveAt(i);
- }
+ {
+ flag = true;
+ Selection.RemoveAt(i);
+ }
if (flag)
OnSelectionChanged();
@@ -1158,7 +1166,7 @@ namespace Aga.Controls.Tree
UpdateSelection();
SmartFullUpdate();
}
- //else
+ //else
// throw new ArgumentException("Path not found");
}
@@ -1186,10 +1194,10 @@ namespace Aga.Controls.Tree
{
for (int n = 0; n < e.Children.Length; n++)
if (parent.Nodes[i].Tag == e.Children[n])
- {
- parent.Nodes.RemoveAt(i);
- break;
- }
+ {
+ parent.Nodes.RemoveAt(i);
+ break;
+ }
}
}
}
@@ -1246,9 +1254,9 @@ namespace Aga.Controls.Tree
{
foreach (object obj in e.Children)
if (node.Tag == obj)
- {
- node.Height = node.RightBounds = null;
- }
+ {
+ node.Height = node.RightBounds = null;
+ }
}
}
}