diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj index cf641b2b3d..98b28217fe 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj @@ -170,13 +170,17 @@ - + + NodeControl.xaml + + + @@ -190,7 +194,6 @@ - @@ -202,11 +205,6 @@ - - - - VisualizerWPFControl.xaml - VisualizerWPFWindow.xaml @@ -300,7 +298,6 @@ - diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/NodeControl.xaml b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/NodeControl.xaml index e135828cca..47e27957e1 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/NodeControl.xaml +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/NodeControl.xaml @@ -16,6 +16,7 @@ + diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/NodeControl.xaml.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/NodeControl.xaml.cs index 165fafea46..993ef83f94 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/NodeControl.xaml.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/NodeControl.xaml.cs @@ -4,6 +4,7 @@ // // $Revision$ // +using Debugger.AddIn.Visualizers.Graph.Layout; using System; using System.Collections.Generic; using System.Text; @@ -20,59 +21,133 @@ using Debugger.AddIn.Visualizers.Graph; namespace Debugger.AddIn.Visualizers.Graph.Drawing { - /// - /// UserControl used to display ObjectNode. - /// - public partial class NodeControl : UserControl - { - public NodeControl() - { - InitializeComponent(); - } + /// + /// UserControl used to display Positione. + /// + public partial class NodeControl : UserControl + { + /// + /// Creates new NodeControl displaying PositionedNode. + /// + /// PositionedNode displayed by the control. + public NodeControl(PositionedNode graphNode) : this() + { + //this.initializeWithGraphNode(graphNode); + this.GraphNode = graphNode; + } + + public NodeControl() + { + InitializeComponent(); + } + + public event EventHandler Expanded; + public event EventHandler Collapsed; - private ObjectNode node; - /// - /// ObjectNode that this control displays. - /// - public ObjectNode GraphNode - { - get - { - return node; - } - set - { - node = value; - int row = 0; - // dynamically create TextBlocks and insert them to the 2-column propertyGrid - foreach (var property in node.Properties) - { - propertyGrid.RowDefinitions.Add(new RowDefinition()); + private PositionedNode node; + /// + /// ObjectNode that this control displays. + /// + public PositionedNode GraphNode + { + get + { + return node; + } + private set + { + this.node = value; + } + } + + public void AddProperty(PositionedNodeProperty property) + { + int nRow = propertyGrid.RowDefinitions.Count; + + var row = new RowDefinition(); + propertyGrid.RowDefinitions.Add(row); + + if (!property.IsAtomic) + { + Button btnExpandCollapse = new Button(); + btnExpandCollapse.Tag = property; + btnExpandCollapse.Content = property.IsExpanded ? "-" : "+"; + btnExpandCollapse.Width = 20; + propertyGrid.Children.Add(btnExpandCollapse); + Grid.SetRow(btnExpandCollapse, nRow); + Grid.SetColumn(btnExpandCollapse, 0); + btnExpandCollapse.Click += new RoutedEventHandler(btnExpandCollapse_Click); + } - TextBlock txtName = createTextBlock(property.Name); - propertyGrid.Children.Add(txtName); - Grid.SetRow(txtName, row); - Grid.SetColumn(txtName, 0); + TextBlock txtName = createTextBlock(property.Name); + propertyGrid.Children.Add(txtName); + Grid.SetRow(txtName, nRow); + Grid.SetColumn(txtName, 1); - TextBlock txtValue = createTextBlock(property.Value); - propertyGrid.Children.Add(txtValue); - Grid.SetRow(txtValue, row); - Grid.SetColumn(txtValue, 1); + TextBlock txtValue = createTextBlock(property.Value); + propertyGrid.Children.Add(txtValue); + Grid.SetRow(txtValue, nRow); + Grid.SetColumn(txtValue, 2); + } + + /*public void Measure() + { + this.Measure(); + + int nRow = 0; + // dynamically create TextBlocks and insert them to the 2-column propertyGrid + foreach (var property in node.Properties) + { + - row++; - } - } - } - - /// - /// Creates TextBlock with given text. - /// - private TextBlock createTextBlock(string text) - { - TextBlock newTextblock = new TextBlock(); - newTextblock.Text = text; - newTextblock.Padding = new Thickness(4); - return newTextblock; - } - } + nRow++; + } + }*/ + + void btnExpandCollapse_Click(object sender, RoutedEventArgs e) + { + Button buttonClicked = ((Button)sender); + var property = (PositionedNodeProperty)buttonClicked.Tag; + + property.IsExpanded = !property.IsExpanded; + buttonClicked.Content = property.IsExpanded ? "-" : "+"; + if (property.IsExpanded) + { + OnPropertyExpanded(property); + } + else + { + OnPropertyCollapsed(property); + } + } + + /// + /// Creates TextBlock with given text. + /// + private TextBlock createTextBlock(string text) + { + TextBlock newTextblock = new TextBlock(); + newTextblock.Text = text; + newTextblock.Padding = new Thickness(4); + return newTextblock; + } + + #region event helpers + protected virtual void OnPropertyExpanded(PositionedNodeProperty property) + { + if (this.Expanded != null) + { + this.Expanded(this, new PositionedPropertyEventArgs(property)); + } + } + + protected virtual void OnPropertyCollapsed(PositionedNodeProperty property) + { + if (this.Collapsed != null) + { + this.Collapsed(this, new PositionedPropertyEventArgs(property)); + } + } + #endregion + } } diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ExpandedNodes.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ExpandedNodes.cs new file mode 100644 index 0000000000..8f29e49dde --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ExpandedNodes.cs @@ -0,0 +1,38 @@ +// +// +// +// +// $Revision$ +// +using System; +using System.Collections.Generic; + +namespace Debugger.AddIn.Visualizers.Graph +{ + /// + /// Remembers which expressions the user has expanded. + /// + public class ExpandedNodes + { + private Dictionary expandedNodes = new Dictionary(); + + public ExpandedNodes() + { + } + + public bool IsExpanded(string expression) + { + return expandedNodes.ContainsKey(expression) && (expandedNodes[expression] == true); + } + + public void Expand(string expression) + { + expandedNodes[expression] = true; + } + + public void Collapse(string expression) + { + expandedNodes[expression] = false; + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedGraph.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedGraph.cs index f2d17f837e..31fe5e9c28 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedGraph.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedGraph.cs @@ -16,7 +16,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout /// public class PositionedGraph { - internal List nodes = new List(); + private List nodes = new List(); public System.Windows.Rect BoundingRect { @@ -39,6 +39,11 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout get { return nodes; } } + internal void AddNode(PositionedNode node) + { + this.nodes.Add(node); + } + /// /// All edges in the graph. /// diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedNode.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedNode.cs index 923759bad6..0199f60f14 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedNode.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedNode.cs @@ -25,6 +25,9 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout get { return objectNode; } } + public event EventHandler Expanded; + public event EventHandler Collapsed; + private List properties = new List(); public List Properties { @@ -34,10 +37,13 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout } } - public PositionedNodeProperty AddProperty(ObjectProperty objectProperty) + public PositionedNodeProperty AddProperty(ObjectProperty objectProperty, bool isExpanded) { var newProperty = new PositionedNodeProperty(objectProperty, this); + newProperty.IsExpanded = isExpanded; this.Properties.Add(newProperty); + this.nodeVisualControl.AddProperty(newProperty); + return newProperty; } @@ -49,8 +55,25 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout { this.objectNode = objectNode; - this.nodeVisualControl = new NodeControl(); - this.nodeVisualControl.GraphNode = this.objectNode; // display + this.nodeVisualControl = new NodeControl(this); // display + this.nodeVisualControl.Expanded += new EventHandler(NodeVisualControl_Expanded); + this.nodeVisualControl.Collapsed += new EventHandler(NodeVisualControl_Collapsed); + } + + private void NodeVisualControl_Expanded(object sender, PositionedPropertyEventArgs e) + { + // propagage event + OnPropertyExpanded(this, e); + } + + private void NodeVisualControl_Collapsed(object sender, PositionedPropertyEventArgs e) + { + // propagate event + OnPropertyCollapsed(this, e); + } + + public void Measure() + { this.nodeVisualControl.Measure(new Size(500, 500)); } @@ -100,5 +123,23 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout } } } + + #region event helpers + protected virtual void OnPropertyExpanded(object sender, PositionedPropertyEventArgs propertyArgs) + { + if (this.Expanded != null) + { + this.Expanded(sender, propertyArgs); + } + } + + protected virtual void OnPropertyCollapsed(object sender, PositionedPropertyEventArgs propertyArgs) + { + if (this.Collapsed != null) + { + this.Collapsed(sender, propertyArgs); + } + } + #endregion } } diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedNodeProperty.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedNodeProperty.cs index 9e07486fdb..85fc4ac103 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedNodeProperty.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedNodeProperty.cs @@ -23,6 +23,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout this.containingNode = containingNode; } + public bool IsExpanded { get; set; } + private ObjectProperty objectProperty; /// /// Underlying . @@ -45,5 +47,25 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout /// Edge outgoing from this property to another . /// public PositionedEdge Edge { get; set; } + + /// + /// e.g. "Age" + /// + public string Name { get { return this.objectProperty.Name; } } + + /// + /// e.g. "19" + /// + public string Value { get { return this.objectProperty.Value; } } + + /// + /// Full Debugger expression used to obtain value of this property. + /// + public Debugger.Expressions.Expression Expression { get { return this.objectProperty.Expression; } } + + /// + /// Is this property of atomic type? (int, string, etc.) + /// + public bool IsAtomic { get { return this.objectProperty.IsAtomic; } } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedPropertyEventArgs.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedPropertyEventArgs.cs new file mode 100644 index 0000000000..c6d2417e26 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedPropertyEventArgs.cs @@ -0,0 +1,25 @@ +// +// +// +// +// $Revision$ +// +using System; + +namespace Debugger.AddIn.Visualizers.Graph.Layout +{ + /// + /// EventArgs carrying . + /// + public class PositionedPropertyEventArgs : EventArgs + { + private PositionedNodeProperty property; + + public PositionedPropertyEventArgs(PositionedNodeProperty property) + { + this.property = property; + } + + public PositionedNodeProperty Property { get { return this.property; } } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/TreeLayouter.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/TreeLayouter.cs index bc89d000ad..c5f943fc97 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/TreeLayouter.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/TreeLayouter.cs @@ -36,7 +36,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout /// /// /// - public PositionedGraph CalculateLayout(ObjectGraph objectGraph, LayoutDirection direction) + public PositionedGraph CalculateLayout(ObjectGraph objectGraph, LayoutDirection direction, ExpandedNodes expandedNodes) { layoutDirection = direction; @@ -44,7 +44,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout treeNodeFor = new Dictionary(); seenNodes = new Dictionary(); - TreeNode tree = buildTreeRecursive(objectGraph.Root); + TreeNode tree = buildTreeRecursive(objectGraph.Root, expandedNodes); calculateNodePosRecursive(tree, 0, 0); var neatoRouter = new NeatoEdgeRouter(); @@ -53,14 +53,14 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout return resultGraph; } - private TreeNode buildTreeRecursive(ObjectNode objectGraphNode) + private TreeNode buildTreeRecursive(ObjectNode objectGraphNode, ExpandedNodes expandedNodes) { seenNodes.Add(objectGraphNode, null); TreeNode newTreeNode = TreeNode.Create(this.layoutDirection, objectGraphNode); newTreeNode.HorizontalMargin = horizNodeMargin; newTreeNode.VerticalMargin = vertNodeMargin; - resultGraph.nodes.Add(newTreeNode); + resultGraph.AddNode(newTreeNode); treeNodeFor[objectGraphNode] = newTreeNode; double subtreeSize = 0; @@ -78,19 +78,20 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout } else { - targetTreeNode = buildTreeRecursive(neighbor); + targetTreeNode = buildTreeRecursive(neighbor, expandedNodes); newEdgeIsTreeEdge = true; subtreeSize += targetTreeNode.SubtreeSize; } - var posNodeProperty = newTreeNode.AddProperty(property); + var posNodeProperty = newTreeNode.AddProperty(property, expandedNodes.IsExpanded(property.Expression.Code)); posNodeProperty.Edge = new TreeGraphEdge { IsTreeEdge = newEdgeIsTreeEdge, Name = property.Name, Source = posNodeProperty, Target = targetTreeNode }; } else { - // PositionedNodeProperty.Edge is null - newTreeNode.AddProperty(property); + // property.Edge stays null + newTreeNode.AddProperty(property, expandedNodes.IsExpanded(property.Expression.Code)); } } + newTreeNode.Measure(); subtreeSize = Math.Max(newTreeNode.LateralSizeWithMargin, subtreeSize); newTreeNode.SubtreeSize = subtreeSize; diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraph/ObjectGraphBuilder.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraph/ObjectGraphBuilder.cs index d41f1bf718..2984c6db57 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraph/ObjectGraphBuilder.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraph/ObjectGraphBuilder.cs @@ -80,7 +80,7 @@ namespace Debugger.AddIn.Visualizers.Graph /// /// Expression valid in the program being debugged (eg. variable name) /// Object graph - public ObjectGraph BuildGraphForExpression(string expression) + public ObjectGraph BuildGraphForExpression(string expression, ExpandedNodes expandedNodes) { if (string.IsNullOrEmpty(expression)) { @@ -92,7 +92,7 @@ namespace Debugger.AddIn.Visualizers.Graph // empty graph for null expression if (!debuggerService.GetValueFromName(expression).IsNull) { - resultGraph.Root = buildGraphRecursive(debuggerService.GetValueFromName(expression).GetPermanentReference()); + resultGraph.Root = buildGraphRecursive(debuggerService.GetValueFromName(expression).GetPermanentReference(), expandedNodes); } return resultGraph; @@ -103,7 +103,7 @@ namespace Debugger.AddIn.Visualizers.Graph /// /// The Value for which the subgraph will be built. /// ObjectNode representing the value + all recursive members. - private ObjectNode buildGraphRecursive(Value rootValue) + private ObjectNode buildGraphRecursive(Value rootValue, ExpandedNodes expandedNodes) { ObjectNode thisNode = createNewNode(rootValue); @@ -136,7 +136,7 @@ namespace Debugger.AddIn.Visualizers.Graph else { ObjectNode targetNode = null; - if (!isNull(memberExpr)) + if (!isNull(memberExpr) && expandedNodes.IsExpanded(memberExpr.Code)) { // for object members, edges are added Value memberValue = getPermanentReference(memberExpr); @@ -146,7 +146,7 @@ namespace Debugger.AddIn.Visualizers.Graph if (targetNode == null) { // if no node for memberValue exists, build the subgraph for the value - targetNode = buildGraphRecursive(memberValue); + targetNode = buildGraphRecursive(memberValue, expandedNodes); } } else diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraph/ObjectProperty.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraph/ObjectProperty.cs index 8f647d7fb7..52490e4235 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraph/ObjectProperty.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraph/ObjectProperty.cs @@ -19,18 +19,22 @@ namespace Debugger.AddIn.Visualizers.Graph /// e.g. "Age" /// public string Name { get; set; } + /// /// e.g. "19" /// public string Value { get; set; } + /// /// Expression used for obtaining this property /// public Debugger.Expressions.Expression Expression { get; set; } + /// /// Node that this property points to. Can be null. Always null if is true. /// public ObjectNode TargetNode { get; set; } + /// /// Is this property of atomic type? (int, string, etc.) /// diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraphVisualizerViewContent.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraphVisualizerViewContent.cs deleted file mode 100644 index 6a805f10e7..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraphVisualizerViewContent.cs +++ /dev/null @@ -1,39 +0,0 @@ -// -// -// -// -// $Revision$ -// -using System; -using System.Text; -using System.Windows.Forms; -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Gui; - -namespace Debugger.AddIn.Visualizers.Graph -{ - /// - /// ViewContent of the visualizer. - /// - public class ObjectGraphVisualizerViewContent : AbstractViewContent - { - VisualizerWinFormsControl control = new VisualizerWinFormsControl(); - - /// - /// The representing the view. - /// - public override object Control - { - get - { - return control; - } - } - - public ObjectGraphVisualizerViewContent() - { - this.TitleName = "Object graph visualizer"; - } - } -} diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWPFControl.xaml b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWPFControl.xaml deleted file mode 100644 index 8446aed80f..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWPFControl.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Expression: - - - - - - \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWPFControl.xaml.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWPFControl.xaml.cs deleted file mode 100644 index f6b8aa7273..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWPFControl.xaml.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -// -// -// -// $Revision$ -// -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - - -namespace Debugger.AddIn.Visualizers.Graph -{ - /// - /// Interaction logic for VisualizerWPFControl.xaml - /// - public partial class VisualizerWPFControl : UserControl - { - public VisualizerWPFControl() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWPFWindow.xaml.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWPFWindow.xaml.cs index f17911cb25..a8aea03512 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWPFWindow.xaml.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWPFWindow.xaml.cs @@ -35,6 +35,11 @@ namespace Debugger.AddIn.Visualizers.Graph private PositionedGraph oldGraph; private PositionedGraph currentGraph; private GraphDrawer graphDrawer; + + /// + /// Long-lived map telling which nodes the user expanded. + /// + private ExpandedNodes expandedNodes; public VisualizerWPFWindow() { @@ -52,6 +57,8 @@ namespace Debugger.AddIn.Visualizers.Graph this.DataContext = this.layoutViewModel; this.graphDrawer = new GraphDrawer(this.canvas); + + this.expandedNodes = new ExpandedNodes(); } public void debuggerService_IsProcessRunningChanged(object sender, EventArgs e) @@ -90,7 +97,7 @@ namespace Debugger.AddIn.Visualizers.Graph try { ICSharpCode.Core.LoggingService.Debug("Debugger visualizer: Building graph for expression: " + txtExpression.Text); - this.objectGraph = graphBuilder.BuildGraphForExpression(txtExpression.Text); + this.objectGraph = graphBuilder.BuildGraphForExpression(txtExpression.Text, expandedNodes); } catch(DebuggerVisualizerException ex) { @@ -115,7 +122,8 @@ namespace Debugger.AddIn.Visualizers.Graph Layout.TreeLayouter layouter = new Layout.TreeLayouter(); this.oldGraph = this.currentGraph; - this.currentGraph = layouter.CalculateLayout(graph, layoutViewModel.SelectedEnumValue); + this.currentGraph = layouter.CalculateLayout(graph, layoutViewModel.SelectedEnumValue, this.expandedNodes); + registerExpandCollapseEvents(this.currentGraph); var graphDiff = new GraphMatcher().MatchGraphs(oldGraph, currentGraph); this.graphDrawer.StartAnimation(oldGraph, currentGraph, graphDiff); @@ -126,5 +134,26 @@ namespace Debugger.AddIn.Visualizers.Graph { MessageBox.Show(ex.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error); } + + void registerExpandCollapseEvents(PositionedGraph posGraph) + { + foreach (var node in posGraph.Nodes) + { + node.Expanded += new EventHandler(node_Expanded); + node.Collapsed += new EventHandler(node_Collapsed); + } + } + + void node_Expanded(object sender, PositionedPropertyEventArgs e) + { + expandedNodes.Expand(e.Property.Expression.Code); + refreshGraph(); + } + + void node_Collapsed(object sender, PositionedPropertyEventArgs e) + { + expandedNodes.Collapse(e.Property.Expression.Code); + refreshGraph(); + } } } \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWinFormsControl.Designer.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWinFormsControl.Designer.cs deleted file mode 100644 index 929ca9b041..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWinFormsControl.Designer.cs +++ /dev/null @@ -1,92 +0,0 @@ -namespace Debugger.AddIn.Visualizers.Graph -{ - partial class VisualizerWinFormsControl - { - /// - /// Designer variable used to keep track of non-visual components. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Disposes resources used by the control. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing) { - if (components != null) { - components.Dispose(); - } - } - base.Dispose(disposing); - } - - /// - /// This method is required for Windows Forms designer support. - /// Do not change the method contents inside the source code editor. The Forms designer might - /// not be able to load this method if it was changed manually. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.txtExpression = new System.Windows.Forms.TextBox(); - this.btnInspect = new System.Windows.Forms.Button(); - this.lblInfo = new System.Windows.Forms.Label(); - this.lblExpression = new System.Windows.Forms.Label(); - this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.SuspendLayout(); - // - // txtExpression - // - this.txtExpression.Location = new System.Drawing.Point(88, 13); - this.txtExpression.Name = "txtExpression"; - this.txtExpression.Size = new System.Drawing.Size(131, 20); - this.txtExpression.TabIndex = 0; - this.toolTip1.SetToolTip(this.txtExpression, "Expression (e.g. variable name) to be inspected"); - // - // btnInspect - // - this.btnInspect.Location = new System.Drawing.Point(225, 10); - this.btnInspect.Name = "btnInspect"; - this.btnInspect.Size = new System.Drawing.Size(75, 23); - this.btnInspect.TabIndex = 1; - this.btnInspect.Text = "Inspect"; - this.btnInspect.UseVisualStyleBackColor = true; - this.btnInspect.Click += new System.EventHandler(this.BtnInspectClick); - // - // lblInfo - // - this.lblInfo.Location = new System.Drawing.Point(11, 58); - this.lblInfo.Name = "lblInfo"; - this.lblInfo.Size = new System.Drawing.Size(349, 23); - this.lblInfo.TabIndex = 2; - this.lblInfo.Text = "< Result >"; - // - // lblExpression - // - this.lblExpression.Location = new System.Drawing.Point(11, 14); - this.lblExpression.Name = "lblExpression"; - this.lblExpression.Size = new System.Drawing.Size(71, 23); - this.lblExpression.TabIndex = 4; - this.lblExpression.Text = "Expression:"; - // - // VisualizerWinFormsControl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.lblExpression); - this.Controls.Add(this.lblInfo); - this.Controls.Add(this.btnInspect); - this.Controls.Add(this.txtExpression); - this.Name = "VisualizerWinFormsControl"; - this.Size = new System.Drawing.Size(525, 426); - this.ResumeLayout(false); - this.PerformLayout(); - } - private System.Windows.Forms.Button btnInspect; - private System.Windows.Forms.ToolTip toolTip1; - private System.Windows.Forms.Label lblExpression; - private System.Windows.Forms.Label lblInfo; - private System.Windows.Forms.TextBox txtExpression; - } -} diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWinFormsControl.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWinFormsControl.cs deleted file mode 100644 index 09621ecf01..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWinFormsControl.cs +++ /dev/null @@ -1,84 +0,0 @@ -// -// -// -// -// $Revision$ -// -using System; -using System.ComponentModel; -using System.Drawing; -using System.Windows.Forms; -using System.Linq; - -using ICSharpCode.SharpDevelop.Debugging; -using ICSharpCode.SharpDevelop.Services; - -namespace Debugger.AddIn.Visualizers.Graph -{ - /// - /// Windows forms control making up the object graph visualizer user interface/ - /// - public partial class VisualizerWinFormsControl : UserControl - { - WindowsDebugger _debuggerService = null; - - public VisualizerWinFormsControl() - { - // - // The InitializeComponent() call is required for Windows Forms designer support. - // - InitializeComponent(); - - _debuggerService = DebuggerService.CurrentDebugger as WindowsDebugger; - if (_debuggerService == null) - throw new ApplicationException("Only windows debugger is currently supported"); - - _debuggerService.IsProcessRunningChanged += new EventHandler(debuggerService_IsProcessRunningChanged); - } - - public void debuggerService_IsProcessRunningChanged(object sender, EventArgs e) - { - // on step, breakpoint hit - if (!_debuggerService.IsProcessRunning) - { - refreshGraph(); - } - } - - void BtnInspectClick(object sender, EventArgs e) - { - refreshGraph(); - } - - void refreshGraph() - { - ObjectGraphBuilder graphBuilder = new ObjectGraphBuilder(_debuggerService); - ObjectGraph graph = null; - - try - { - graph = graphBuilder.BuildGraphForExpression(txtExpression.Text); - } - catch(DebuggerVisualizerException ex) - { - guiHandleException(ex); - return; - } - catch(Debugger.GetValueException ex) - { - guiHandleException(ex); - - return; - } - - // just a simple message for checking the graph is build ok, will be replaced by graph drawing of course - //lblInfo.Text = string.Format("Done. Number of graph nodes: {0}, number of edges: {1}", graph.Nodes.Count(), graph.Edges.Count()); - } - - void guiHandleException(System.Exception ex) - { - lblInfo.Text = "< Result >"; - MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } -}