Browse Source

- fixed SD2-1523 - Watch pad right click shows two context menus based on patch from http://community.sharpdevelop.net/forums/t/9006.aspx

- applied patch for drag&drop in Watch pad from http://community.sharpdevelop.net/forums/t/9320.aspx
- fixed NullReferenceException in ValueNode if either Watch Pad or LocalVarPad are not opened (added comments)


git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3962 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 17 years ago
parent
commit
b47cf83b0e
  1. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
  2. 63
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/WatchPad.cs
  3. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewVarNode.cs
  4. 7
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs
  5. 17
      src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.Input.cs
  6. 100
      src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.cs

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs

@ -62,6 +62,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
instance = this; instance = this;
} }
/// <remarks>Always check if Instance is null, might be null if pad is not opened!</remarks>
public static LocalVarPad Instance { public static LocalVarPad Instance {
get { return instance; } get { return instance; }
} }

63
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) public override void SetValue(TreeNodeAdv node, object value)
{ {
if (((TreeViewVarNode)node).Content is ValueNode) if (string.IsNullOrEmpty(value as string))
((ValueNode)((TreeViewVarNode)node).Content).SetName(value.ToString()); MessageBox.Show("You can not set name to an empty string!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
else { else
if (((TreeViewVarNode)node).Content is TextNode) {
((TextNode)((TreeViewVarNode)node).Content).SetName(value.ToString()); 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) public override void MouseDown(TreeNodeAdvMouseEventArgs args)
@ -93,6 +98,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
ContextMenuStrip menu = ((IContextMenu)content).GetContextMenu(); ContextMenuStrip menu = ((IContextMenu)content).GetContextMenu();
if (menu != null) { if (menu != null) {
menu.Show(args.Node.Tree, args.Location); menu.Show(args.Node.Tree, args.Location);
args.Handled = true;
} }
} else { } else {
base.MouseDown(args); base.MouseDown(args);
@ -105,6 +111,17 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
TreeViewAdv watchList; TreeViewAdv watchList;
Process debuggedProcess; Process debuggedProcess;
List<TextNode> watches; List<TextNode> watches;
static WatchPad instance;
/// <remarks>Always check if Instance is null, might be null if pad is not opened!</remarks>
public static WatchPad Instance {
get { return instance; }
}
public WatchPad()
{
instance = this;
}
public List<TextNode> Watches { public List<TextNode> Watches {
get { return watches; } get { return watches; }
@ -154,16 +171,42 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
watchList.NodeControls.Add(typeControl); watchList.NodeControls.Add(typeControl);
watchList.AutoRowHeight = true; watchList.AutoRowHeight = true;
watchList.MouseDoubleClick += new MouseEventHandler(watchList_DoubleClick);
watchList.MouseDoubleClick += new MouseEventHandler(watchList_DoubleClick); watchList.ContextMenuStrip = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/WatchPad/ContextMenu");
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<TextNode>(); watches = new List<TextNode>();
RedrawContent(); 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) void watchList_DoubleClick(object sender, MouseEventArgs e)
{ {
if (watchList.SelectedNode == null) if (watchList.SelectedNode == null)

1
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(); ContextMenuStrip menu = ((IContextMenu)content).GetContextMenu();
if (menu != null) { if (menu != null) {
menu.Show(args.Node.Tree, args.Location); menu.Show(args.Node.Tree, args.Location);
args.Handled = true;
} }
} else { } else {
base.MouseDown(args); base.MouseDown(args);

7
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.Text = ResourceService.GetString("MainWindow.Windows.Debug.LocalVariables.ShowInHexadecimal");
hexView.Checked = DebuggingOptions.Instance.ShowValuesInHexadecimal; hexView.Checked = DebuggingOptions.Instance.ShowValuesInHexadecimal;
hexView.Click += delegate { hexView.Click += delegate {
// refresh all pads that use ValueNode for display
DebuggingOptions.Instance.ShowValuesInHexadecimal = !DebuggingOptions.Instance.ShowValuesInHexadecimal; 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[] { menu.Items.AddRange(new ToolStripItem[] {

17
src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.Input.cs

@ -21,9 +21,9 @@ namespace Aga.Controls.Tree
protected override bool IsInputKey(Keys keyData) protected override bool IsInputKey(Keys keyData)
{ {
if (((keyData & Keys.Up) == Keys.Up) if (((keyData & Keys.Up) == Keys.Up)
|| ((keyData & Keys.Down) == Keys.Down) || ((keyData & Keys.Down) == Keys.Down)
|| ((keyData & Keys.Left) == Keys.Left) || ((keyData & Keys.Left) == Keys.Left)
|| ((keyData & Keys.Right) == Keys.Right)) || ((keyData & Keys.Right) == Keys.Right))
return true; return true;
else else
return base.IsInputKey(keyData); return base.IsInputKey(keyData);
@ -102,7 +102,7 @@ namespace Aga.Controls.Tree
{ {
TreeNodeAdvMouseEventArgs args = new TreeNodeAdvMouseEventArgs(e); TreeNodeAdvMouseEventArgs args = new TreeNodeAdvMouseEventArgs(e);
args.ViewLocation = new Point(e.X + OffsetX, 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.ModifierKeys = ModifierKeys;
args.Node = GetNodeAt(e.Location); args.Node = GetNodeAt(e.Location);
NodeControlInfo info = GetNodeControlInfoAt(args.Node, e.Location); NodeControlInfo info = GetNodeControlInfoAt(args.Node, e.Location);
@ -155,8 +155,11 @@ namespace Aga.Controls.Tree
if (args.Node != null && args.Control != null) if (args.Node != null && args.Control != null)
args.Control.MouseDown(args); args.Control.MouseDown(args);
if (!args.Handled) if (!args.Handled) {
Input.MouseDown(args); Input.MouseDown(args);
base.ContextMenuStrip = _cms;
} else
base.ContextMenuStrip = null;
base.OnMouseDown(e); base.OnMouseDown(e);
} }
@ -218,7 +221,7 @@ namespace Aga.Controls.Tree
SetCursor(e); SetCursor(e);
UpdateToolTip(e); UpdateToolTip(e);
if (ItemDragMode && Dist(e.Location, ItemDragStart) > ItemDragSensivity if (ItemDragMode && Dist(e.Location, ItemDragStart) > ItemDragSensivity
&& CurrentNode != null && CurrentNode.IsSelected) && CurrentNode != null && CurrentNode.IsSelected)
{ {
ItemDragMode = false; ItemDragMode = false;
_toolTip.Active = false; _toolTip.Active = false;
@ -380,7 +383,7 @@ namespace Aga.Controls.Tree
{ {
Size ms = btc.GetActualSize(args.Node, _measureContext); Size ms = btc.GetActualSize(args.Node, _measureContext);
if (ms.Width > args.ControlBounds.Size.Width || ms.Height > args.ControlBounds.Size.Height 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); msg = btc.GetLabel(args.Node);
} }

100
src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.cs

@ -41,7 +41,15 @@ namespace Aga.Controls.Tree
private IncrementalSearch _search; private IncrementalSearch _search;
private List<TreeNodeAdv> _expandingNodes = new List<TreeNodeAdv>(); private List<TreeNodeAdv> _expandingNodes = new List<TreeNodeAdv>();
private AbortableThreadPool _threadPool = new AbortableThreadPool(); private AbortableThreadPool _threadPool = new AbortableThreadPool();
private ContextMenuStrip _cms;
public new ContextMenuStrip ContextMenuStrip {
set {
base.ContextMenuStrip = value;
_cms = value;
}
}
#region Public Events #region Public Events
[Category("Action")] [Category("Action")]
@ -182,11 +190,11 @@ namespace Aga.Controls.Tree
{ {
InitializeComponent(); InitializeComponent();
SetStyle(ControlStyles.AllPaintingInWmPaint SetStyle(ControlStyles.AllPaintingInWmPaint
| ControlStyles.UserPaint | ControlStyles.UserPaint
| ControlStyles.OptimizedDoubleBuffer | ControlStyles.OptimizedDoubleBuffer
| ControlStyles.ResizeRedraw | ControlStyles.ResizeRedraw
| ControlStyles.Selectable | ControlStyles.Selectable
, true); , true);
if (Application.RenderWithVisualStyles) if (Application.RenderWithVisualStyles)
@ -308,7 +316,7 @@ namespace Aga.Controls.Tree
point.X += OffsetX; point.X += OffsetX;
foreach (NodeControlInfo info in GetNodeControls(node)) foreach (NodeControlInfo info in GetNodeControls(node))
if (info.Bounds.Contains(point)) if (info.Bounds.Contains(point))
return info; return info;
if (FullRowSelect) if (FullRowSelect)
return new NodeControlInfo(null, Rectangle.Empty, node); return new NodeControlInfo(null, Rectangle.Empty, node);
@ -383,7 +391,7 @@ namespace Aga.Controls.Tree
CreateRowMap(); CreateRowMap();
int row = -1; int row = -1;
if (node.Row < FirstVisibleRow) if (node.Row < FirstVisibleRow)
row = node.Row; row = node.Row;
else else
@ -433,10 +441,10 @@ namespace Aga.Controls.Tree
Rectangle clientRect = ClientRectangle; Rectangle clientRect = ClientRectangle;
_hScrollBar.SetBounds(clientRect.X, clientRect.Bottom - hBarSize, _hScrollBar.SetBounds(clientRect.X, clientRect.Bottom - hBarSize,
clientRect.Width - vBarSize, hBarSize); clientRect.Width - vBarSize, hBarSize);
_vScrollBar.SetBounds(clientRect.Right - vBarSize, clientRect.Y, _vScrollBar.SetBounds(clientRect.Right - vBarSize, clientRect.Y,
vBarSize, clientRect.Height - hBarSize); vBarSize, clientRect.Height - hBarSize);
} }
private void SafeUpdateScrollBars() private void SafeUpdateScrollBars()
@ -483,10 +491,10 @@ namespace Aga.Controls.Tree
switch (BorderStyle) switch (BorderStyle)
{ {
case BorderStyle.FixedSingle: case BorderStyle.FixedSingle:
res.Style |= 0x800000; res.Style |= 0x800000;
break; break;
case BorderStyle.Fixed3D: case BorderStyle.Fixed3D:
res.ExStyle |= 0x200; res.ExStyle |= 0x200;
break; break;
} }
return res; return res;
@ -580,10 +588,10 @@ namespace Aga.Controls.Tree
bool isLastControl = true; bool isLastControl = true;
for (int k = i + 1; k < NodeControls.Count; k++) for (int k = i + 1; k < NodeControls.Count; k++)
if (NodeControls[k].ParentColumn == col) if (NodeControls[k].ParentColumn == col)
{ {
isLastControl = false; isLastControl = false;
break; break;
} }
width = right - x; width = right - x;
if (!isLastControl) if (!isLastControl)
@ -669,26 +677,26 @@ namespace Aga.Controls.Tree
IEnumerable items = Model.GetChildren(GetPath(parentNode)); IEnumerable items = Model.GetChildren(GetPath(parentNode));
if (items != null) if (items != null)
foreach (object obj in items) foreach (object obj in items)
{
bool found = false;
if (obj != null)
{ {
bool found = false; for (int i = 0; i < oldNodes.Count; i++)
if (obj != null) if (object.Equals(obj, oldNodes[i].Tag))
{ {
for (int i = 0; i < oldNodes.Count; i++) oldNodes[i].RightBounds = oldNodes[i].Height = null;
if (object.Equals(obj, oldNodes[i].Tag)) AddNode(parentNode, -1, oldNodes[i]);
{ oldNodes.RemoveAt(i);
oldNodes[i].RightBounds = oldNodes[i].Height = null; found = true;
AddNode(parentNode, -1, oldNodes[i]); break;
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; _contentWidth = 0;
foreach (TreeColumn col in _columns) foreach (TreeColumn col in _columns)
if (col.IsVisible) 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--) for (int i = Selection.Count - 1; i >= 0; i--)
if (!IsMyNode(Selection[i])) if (!IsMyNode(Selection[i]))
{ {
flag = true; flag = true;
Selection.RemoveAt(i); Selection.RemoveAt(i);
} }
if (flag) if (flag)
OnSelectionChanged(); OnSelectionChanged();
@ -1158,7 +1166,7 @@ namespace Aga.Controls.Tree
UpdateSelection(); UpdateSelection();
SmartFullUpdate(); SmartFullUpdate();
} }
//else //else
// throw new ArgumentException("Path not found"); // throw new ArgumentException("Path not found");
} }
@ -1186,10 +1194,10 @@ namespace Aga.Controls.Tree
{ {
for (int n = 0; n < e.Children.Length; n++) for (int n = 0; n < e.Children.Length; n++)
if (parent.Nodes[i].Tag == e.Children[n]) if (parent.Nodes[i].Tag == e.Children[n])
{ {
parent.Nodes.RemoveAt(i); parent.Nodes.RemoveAt(i);
break; break;
} }
} }
} }
} }
@ -1246,9 +1254,9 @@ namespace Aga.Controls.Tree
{ {
foreach (object obj in e.Children) foreach (object obj in e.Children)
if (node.Tag == obj) if (node.Tag == obj)
{ {
node.Height = node.RightBounds = null; node.Height = node.RightBounds = null;
} }
} }
} }
} }

Loading…
Cancel
Save