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

57
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/WatchPad.cs

@ -75,11 +75,16 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -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 @@ -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 @@ -105,6 +111,17 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
TreeViewAdv watchList;
Process debuggedProcess;
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 {
get { return watches; }
@ -154,16 +171,42 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -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.AllowDrop = true;
watchList.DragEnter += new DragEventHandler(watchList_DragEnter);
watchList.DragDrop += new DragEventHandler(watchList_DragDrop);
watches = new List<TextNode>();
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)

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewVarNode.cs

@ -82,6 +82,7 @@ namespace Debugger.AddIn.TreeModel @@ -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);

7
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs

@ -233,8 +233,13 @@ namespace Debugger.AddIn.TreeModel @@ -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[] {

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

@ -21,9 +21,9 @@ namespace Aga.Controls.Tree @@ -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 @@ -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 @@ -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 @@ -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 @@ -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);
}

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

@ -41,6 +41,14 @@ namespace Aga.Controls.Tree @@ -41,6 +41,14 @@ namespace Aga.Controls.Tree
private IncrementalSearch _search;
private List<TreeNodeAdv> _expandingNodes = new List<TreeNodeAdv>();
private AbortableThreadPool _threadPool = new AbortableThreadPool();
private ContextMenuStrip _cms;
public new ContextMenuStrip ContextMenuStrip {
set {
base.ContextMenuStrip = value;
_cms = value;
}
}
#region Public Events
@ -182,11 +190,11 @@ namespace Aga.Controls.Tree @@ -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 @@ -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);
@ -433,10 +441,10 @@ namespace Aga.Controls.Tree @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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();
@ -1186,10 +1194,10 @@ namespace Aga.Controls.Tree @@ -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 @@ -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;
}
}
}
}

Loading…
Cancel
Save