Browse Source

Object graph visualizer:

- node UI Control reuse between subsequent graphs for better performance
 - styled "+" buttons

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4690 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Martin Koníček 16 years ago
parent
commit
f076e218ef
  1. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.addin
  2. 10
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  3. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/GridVisualizerCommand.cs
  4. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/GridVisualizerMenuCommand.cs
  5. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ObjectGraphVisualizerCommand.cs
  6. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ObjectGraphVisualizerMenuCommand.cs
  7. 26
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/NodeControl.xaml
  8. 154
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/NodeControl.xaml.cs
  9. 52
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/PlusToggleButton.xaml
  10. 14
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/PositionedGraphNodeControl.xaml
  11. 11
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/PositionedGraphNodeControl.xaml.cs
  12. 8
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/ContentNode.cs
  13. 3
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/ContentPropertyNode.cs
  14. 6
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedGraphNode.cs
  15. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/TreeLayouter.cs
  16. 50
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/NodeControlCache.cs
  17. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraph/ObjectGraphBuilder.cs
  18. 51
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWPFWindow.xaml.cs
  19. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/GridVisualizer/GridVisualizerWindow.xaml

4
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.addin

@ -154,7 +154,7 @@ @@ -154,7 +154,7 @@
<Condition name="SolutionOpen" action="disable">
<MenuItem id = "DebuggerObjectGraphVisualizerShowCommand"
label = "Object graph visualizer"
class = "Debugger.AddIn.Visualizers.Graph.ShowObjectGraphVisualizerCommand"/>
class = "Debugger.AddIn.Visualizers.ObjectGraphVisualizerMenuCommand"/>
</Condition>
</Path>
@ -162,7 +162,7 @@ @@ -162,7 +162,7 @@
<Condition name="SolutionOpen" action="disable">
<MenuItem id = "DebuggerGridVisualizerShowCommand"
label = "Grid visualizer"
class = "Debugger.AddIn.Visualizers.GridVisualizer.ShowGridVisualizerCommand"/>
class = "Debugger.AddIn.Visualizers.GridVisualizerMenuCommand"/>
</Condition>
</Path>

10
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj

@ -124,8 +124,8 @@ @@ -124,8 +124,8 @@
<Compile Include="Src\Visualizers\Commands\ExpressionNodeVisualizerCommand.cs" />
<Compile Include="Src\Visualizers\Commands\GridVisualizerCommand.cs" />
<Compile Include="Src\Visualizers\Commands\ObjectGraphVisualizerCommand.cs" />
<Compile Include="Src\Visualizers\Commands\ShowGridVisualizerCommand.cs" />
<Compile Include="Src\Visualizers\Commands\ShowObjectGraphVisualizerCommand.cs" />
<Compile Include="Src\Visualizers\Commands\GridVisualizerMenuCommand.cs" />
<Compile Include="Src\Visualizers\Commands\ObjectGraphVisualizerMenuCommand.cs" />
<Compile Include="Src\Visualizers\Common\DebuggerVisualizerException.cs" />
<Compile Include="Src\Visualizers\Common\IEvaluate.cs" />
<Compile Include="Src\Visualizers\Common\IListValuesProvider.cs" />
@ -143,6 +143,7 @@ @@ -143,6 +143,7 @@
<Compile Include="Src\Visualizers\Graph\Layout\ContentNodeEventArgs.cs" />
<Compile Include="Src\Visualizers\Graph\Layout\ContentPropertyNode.cs" />
<Compile Include="Src\Visualizers\Graph\Layout\ContentNode.cs" />
<Compile Include="Src\Visualizers\Graph\NodeControlCache.cs" />
<Compile Include="Src\Visualizers\Graph\ObjectGraph\NamedEdge.cs" />
<Compile Include="Src\Visualizers\Graph\TreeModel\AbstractNode.cs" />
<Compile Include="Src\Visualizers\Graph\TreeModel\BaseClassNode.cs" />
@ -208,9 +209,6 @@ @@ -208,9 +209,6 @@
<Compile Include="Src\TreeModel\Utils.cs" />
<Compile Include="Src\Visualizers\Graph\Drawing\CanvasLocationAdapter.cs" />
<Compile Include="Src\Visualizers\Graph\Drawing\GraphDrawer.cs" />
<Compile Include="Src\Visualizers\Graph\Drawing\NodeControl.xaml.cs">
<DependentUpon>NodeControl.xaml</DependentUpon>
</Compile>
<Compile Include="Src\Visualizers\Graph\ExpandedPaths.cs" />
<Compile Include="Src\Visualizers\Graph\Layout\GraphDiff.cs" />
<Compile Include="Src\Visualizers\Graph\Layout\GraphMatcher.cs" />
@ -323,6 +321,7 @@ @@ -323,6 +321,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="Src\Visualizers\Graph\Drawing\PlusToggleButton.xaml" />
<Page Include="Src\Visualizers\Graph\Drawing\PositionedGraphNodeControl.xaml" />
<Page Include="Src\Visualizers\GridVisualizer\GridVisualizerWindow.xaml" />
<ProjectReference Include="..\..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
@ -354,7 +353,6 @@ @@ -354,7 +353,6 @@
<Folder Include="Src\Visualizers\Utils" />
<Folder Include="Src\Visualizers\GridVisualizer" />
<Folder Include="Src\Visualizers\PresentationBindings" />
<Page Include="Src\Visualizers\Graph\Drawing\NodeControl.xaml" />
<Page Include="Src\Visualizers\Graph\VisualizerWPFWindow.xaml" />
</ItemGroup>
<ItemGroup>

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/GridVisualizerCommand.cs

@ -12,7 +12,7 @@ using System.Linq; @@ -12,7 +12,7 @@ using System.Linq;
namespace Debugger.AddIn.Visualizers
{
/// <summary>
/// Executes grid visualizer for a node.
/// Shows grid visualizer for a node.
/// </summary>
public class GridVisualizerCommand : ExpressionNodeVisualizerCommand
{

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ShowGridVisualizerCommand.cs → src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/GridVisualizerMenuCommand.cs

@ -13,7 +13,7 @@ namespace Debugger.AddIn.Visualizers @@ -13,7 +13,7 @@ namespace Debugger.AddIn.Visualizers
/// <summary>
/// Description of ShowGridVisualizerCommand.
/// </summary>
public class ShowGridVisualizerCommand : AbstractMenuCommand
public class GridVisualizerMenuCommand : AbstractMenuCommand
{
public override void Run()
{

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ObjectGraphVisualizerCommand.cs

@ -12,7 +12,7 @@ using System.Linq; @@ -12,7 +12,7 @@ using System.Linq;
namespace Debugger.AddIn.Visualizers
{
/// <summary>
/// Executes object graph visualizer for a node.
/// Shows object graph visualizer for a node.
/// </summary>
public class ObjectGraphVisualizerCommand : ExpressionNodeVisualizerCommand
{

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ShowObjectGraphVisualizerCommand.cs → src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ObjectGraphVisualizerMenuCommand.cs

@ -16,7 +16,7 @@ namespace Debugger.AddIn.Visualizers @@ -16,7 +16,7 @@ namespace Debugger.AddIn.Visualizers
/// <summary>
/// Command in the tools menu for showing the object graph visualizer.
/// </summary>
public class ShowObjectGraphVisualizerCommand : AbstractMenuCommand
public class ObjectGraphVisualizerMenuCommand : AbstractMenuCommand
{
public override void Run()
{

26
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/NodeControl.xaml

@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
<UserControl x:Class="Debugger.AddIn.Visualizers.Graph.Drawing.NodeControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dropShadow="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
<dropShadow:SystemDropShadowChrome>
<Border Name="border1" BorderBrush="Black" BorderThickness="1" Padding="04,04,04,04"
Canvas.Left="20" Canvas.Top="20">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#ddeeff" Offset="0.0" />
<GradientStop Color="White" Offset="0.4" />
<GradientStop Color="White" Offset="0.8" />
</LinearGradientBrush>
</Border.Background>
<Grid Name="propertyGrid">
<Grid.RowDefinitions>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
</Grid>
</Border>
</dropShadow:SystemDropShadowChrome>
</UserControl>

154
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/NodeControl.xaml.cs

@ -1,154 +0,0 @@ @@ -1,154 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Martin Koníček" email="martin.konicek@gmail.com"/>
// <version>$Revision$</version>
// </file>
using Debugger.AddIn.Visualizers.Graph.Layout;
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;
using Debugger.AddIn.Visualizers.Graph;
namespace Debugger.AddIn.Visualizers.Graph.Drawing
{
/// <summary>
/// UserControl used to display Positione.
/// </summary>
public partial class NodeControl : UserControl
{
/// <summary>
/// Creates new NodeControl displaying PositionedNode.
/// </summary>
/*public NodeControl() : this()
{
//this.GraphNode = graphNode;
}*/
/// <summary>
/// Creates new NodeControl displaying PositionedNode.
/// </summary>
public NodeControl()
{
InitializeComponent();
}
public event EventHandler<PositionedPropertyEventArgs> PropertyExpanded;
public event EventHandler<PositionedPropertyEventArgs> PropertyCollapsed;
private PositionedGraphNode node;
/// <summary>
/// ObjectNode that this control displays.
/// </summary>
public PositionedGraphNode 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 && !property.IsNull)
{
Button btnExpandCollapse = new Button();
btnExpandCollapse.Tag = property;
btnExpandCollapse.Content = property.IsPropertyExpanded ? "-" : "+";
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, nRow);
Grid.SetColumn(txtName, 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)
{
nRow++;
}
}*/
void btnExpandCollapse_Click(object sender, RoutedEventArgs e)
{
Button buttonClicked = ((Button)sender);
var property = (PositionedNodeProperty)buttonClicked.Tag;
property.IsPropertyExpanded = !property.IsPropertyExpanded;
buttonClicked.Content = property.IsPropertyExpanded ? "-" : "+";
if (property.IsPropertyExpanded)
{
OnPropertyExpanded(property);
}
else
{
OnPropertyCollapsed(property);
}
}
/// <summary>
/// Creates TextBlock with given text.
/// </summary>
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.PropertyExpanded != null)
{
this.PropertyExpanded(this, new PositionedPropertyEventArgs(property));
}
}
protected virtual void OnPropertyCollapsed(PositionedNodeProperty property)
{
if (this.PropertyCollapsed != null)
{
this.PropertyCollapsed(this, new PositionedPropertyEventArgs(property));
}
}
#endregion
}
}

52
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/PlusToggleButton.xaml

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Focusable"
Value="False"/>
<Setter Property="Width"
Value="19"/>
<Setter Property="Height"
Value="13"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Width="19"
Height="13"
Background="Transparent">
<Border Width="9"
Height="9"
BorderThickness="1"
BorderBrush="#FF7898B5"
CornerRadius="1"
SnapsToDevicePixels="true">
<Border.Background>
<LinearGradientBrush StartPoint="0,0"
EndPoint="1,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="White"
Offset=".2"/>
<GradientStop Color="#FFC0B7A6"
Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<Path x:Name="ExpandPath"
Margin="1,1,1,1"
Fill="Black"
Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z"/>
</Border>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked"
Value="True">
<Setter Property="Data"
TargetName="ExpandPath"
Value="M 0 2 L 0 3 L 5 3 L 5 2 Z"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

14
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/PositionedGraphNodeControl.xaml

@ -5,6 +5,11 @@ @@ -5,6 +5,11 @@
xmlns:local="clr-namespace:Debugger.AddIn.Visualizers"
>
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="PlusToggleButton.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
<local:TooltipVisibilityConverter x:Key="toolVisConverter"></local:TooltipVisibilityConverter>
<DataTemplate x:Key="valueColumnTemplate">
<TextBlock Text="{Binding Text}">
@ -18,6 +23,7 @@ @@ -18,6 +23,7 @@
</TextBlock>
</DataTemplate>
</UserControl.Resources>
<aero:SystemDropShadowChrome>
<Grid>
<ListView Name="listView" AlternationCount="2" ScrollViewer.VerticalScrollBarVisibility="Auto">
@ -65,12 +71,12 @@ @@ -65,12 +71,12 @@
</GridView.ColumnHeaderContainerStyle>
<GridView.Columns>
<!-- Expand button (either property or nested) -->
<GridViewColumn Header="Plus" Width="Auto">
<GridViewColumn Header="Plus" Width="20">
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<ToggleButton x:Name="Expander" Width="20" Margin="-4 -1 -4 -1" IsChecked="{Binding IsExpanded}" Click="NestedExpandButton_Click" Padding="0">+</ToggleButton>
<ToggleButton x:Name="PropertyExpander" Width="20" Margin="-4 -1 -4 -1" IsChecked="{Binding IsPropertyExpanded}" Click="PropertyExpandButton_Click" Padding="0">+</ToggleButton>
<StackPanel Margin="0 2 0 0">
<ToggleButton x:Name="Expander" Margin="-6 0" IsChecked="{Binding IsExpanded}" Click="NestedExpandButton_Click" Padding="0"></ToggleButton>
<ToggleButton x:Name="PropertyExpander" Margin="-6 0" IsChecked="{Binding IsPropertyExpanded}" Click="PropertyExpandButton_Click" Padding="0"></ToggleButton>
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=HasChildren}" Value="False">

11
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/PositionedGraphNodeControl.xaml.cs

@ -70,6 +70,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing @@ -70,6 +70,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
string addedSpaces = StringHelper.Repeat(' ', spaces);
GridView gv = listView.View as GridView;
// hack - autosize Name column
gv.Columns[1].Header = "Name" + addedSpaces;
//AutoSizeColumns();
@ -114,6 +115,16 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing @@ -114,6 +115,16 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
public PositionedGraphNodeControl()
{
InitializeComponent();
Init();
}
public void Init()
{
PropertyExpanded = null;
PropertyCollapsed = null;
ContentNodeExpanded = null;
ContentNodeCollapsed = null;
//this.listView.ItemsSource = null;
}
void TextBlock_MouseDown(object sender, MouseButtonEventArgs e)

8
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/ContentNode.cs

@ -110,7 +110,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -110,7 +110,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
/// </summary>
public IEnumerable<ContentNode> FlattenExpanded()
{
return Utils.TreeFlattener.FlattenSelectChildrenIf(this, (node) => { return node.IsExpanded; });
return Utils.TreeFlattener.FlattenSelectChildrenIf(this, node => node.IsExpanded);
}
/// <summary>
@ -119,7 +119,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -119,7 +119,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
/// <returns></returns>
public IEnumerable<ContentNode> FlattenChildrenExpanded()
{
return Utils.TreeFlattener.FlattenSelectChildrenIf(this.Children, (node) => { return node.IsExpanded; });
return Utils.TreeFlattener.FlattenSelectChildrenIf(this.Children, node => node.IsExpanded);
}
/// <summary>
@ -127,8 +127,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -127,8 +127,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
/// </summary>
public IEnumerable<PositionedNodeProperty> FlattenProperties()
{
return Utils.TreeFlattener.Flatten(this).Where((node) => { return node is ContentPropertyNode; }).
Select( (propertyNode) => { return ((ContentPropertyNode)propertyNode).Property; });
return Utils.TreeFlattener.Flatten(this).Where(node => node is ContentPropertyNode).
Select( propertyNode => ((ContentPropertyNode)propertyNode).Property);
}
#region Utils.ITreeNode implementation

3
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/ContentPropertyNode.cs

@ -51,6 +51,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -51,6 +51,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
{
// show expand button when appropriate
return (!this.positionedProperty.IsAtomic && !this.positionedProperty.IsNull);
//return true;
}
}
@ -62,7 +63,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -62,7 +63,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
PropertyNode sourcePropertyNode = source as PropertyNode;
this.Name = sourcePropertyNode.Property.Name;
this.Text = sourcePropertyNode.Property.Value; // lazy evaluated
this.Text = sourcePropertyNode.Property.Value; // evaluated in Evaluate()
this.IsNested = false;
this.IsExpanded = false; // always false, property content nodes are never expanded
this.positionedProperty = new PositionedNodeProperty(

6
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedGraphNode.cs

@ -18,6 +18,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -18,6 +18,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
/// </summary>
public class PositionedGraphNode
{
public static readonly double MaxHeight = 300;
/// <summary>
/// Creates new PositionedNode.
/// </summary>
@ -72,8 +74,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -72,8 +74,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
private void initVisualControl()
{
this.nodeVisualControl = new PositionedGraphNodeControl();
this.nodeVisualControl.MaxHeight = 300;
this.nodeVisualControl = NodeControlCache.Instance.GetNodeControl();
this.nodeVisualControl.MaxHeight = MaxHeight;
// propagate events from nodeVisualControl
this.nodeVisualControl.PropertyExpanded += new EventHandler<PositionedPropertyEventArgs>(NodeVisualControl_PropertyExpanded);

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/TreeLayouter.cs

@ -40,7 +40,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -40,7 +40,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
treeNodeFor = new Dictionary<ObjectGraphNode, PositionedGraphNode>();
seenNodes = new HashSet<PositionedGraphNode>();
//TreeGraphNode tree = buildTreeRecursive(objectGraph.Root, expandedNodes);
// convert ObjectGraph to PositionedGraph with TreeEdges

50
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/NodeControlCache.cs

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Martin Koníček" email="martin.konicek@gmail.com"/>
// <version>$Revision$</version>
// </file>
using Debugger.AddIn.Visualizers.Graph.Drawing;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Debugger.AddIn.Visualizers.Graph
{
/// <summary>
/// Description of NodeControlCache.
/// </summary>
public class NodeControlCache
{
public static readonly NodeControlCache Instance = new NodeControlCache();
private Stack<PositionedGraphNodeControl> controls;
private int controlsReturned = 0;
private NodeControlCache()
{
Clear();
}
public void ReturnForReuse(PositionedGraphNodeControl controlToReuse)
{
controls.Push(controlToReuse);
}
public PositionedGraphNodeControl GetNodeControl()
{
return new PositionedGraphNodeControl();
var control = controls.Count == 0 ? new PositionedGraphNodeControl() : controls.Pop();
control.Init();
//control.InvalidateVisual();
controlsReturned++;
return control;
}
public void Clear()
{
controls = new Stack<PositionedGraphNodeControl>();
controlsReturned = 0;
}
}
}

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraph/ObjectGraphBuilder.cs

@ -282,6 +282,7 @@ namespace Debugger.AddIn.Visualizers.Graph @@ -282,6 +282,7 @@ namespace Debugger.AddIn.Visualizers.Graph
if (/*!complexProperty.IsNull && we dont know yet if it's null */expandedNodes.IsExpanded(complexProperty.Expression))
{
// if expanded, evaluate this property
// complexProperty.Evaluate(); // consider
Value memberValue = complexProperty.Expression.Evaluate(this.debuggerService.DebuggedProcess);
if (memberValue.IsNull)
{

51
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWPFWindow.xaml.cs

@ -36,6 +36,7 @@ namespace Debugger.AddIn.Visualizers.Graph @@ -36,6 +36,7 @@ namespace Debugger.AddIn.Visualizers.Graph
private PositionedGraph oldPosGraph;
private PositionedGraph currentPosGraph;
private GraphDrawer graphDrawer;
private Layout.TreeLayouter layouter;
/// <summary>
/// Long-lived map telling which graph nodes and content nodes the user expanded.
@ -50,15 +51,35 @@ namespace Debugger.AddIn.Visualizers.Graph @@ -50,15 +51,35 @@ namespace Debugger.AddIn.Visualizers.Graph
if (debuggerService == null)
throw new ApplicationException("Only windows debugger is currently supported");
debuggerService.IsProcessRunningChanged += new EventHandler(debuggerService_IsProcessRunningChanged);
debuggerService.DebugStopped += new EventHandler(_debuggerService_DebugStopped);
this.Closed += new EventHandler(VisualizerWPFWindow_Closed);
registerEvents();
this.layoutViewModel = new EnumViewModel<LayoutDirection>();
this.layoutViewModel.PropertyChanged += new PropertyChangedEventHandler(layoutViewModel_PropertyChanged);
this.DataContext = this.layoutViewModel;
this.layouter = new TreeLayouter();
this.graphDrawer = new GraphDrawer(this.canvas);
}
void VisualizerWPFWindow_Closed(object sender, EventArgs e)
{
unregisterEvents();
NodeControlCache.Instance.Clear();
}
private void registerEvents()
{
debuggerService.IsProcessRunningChanged += new EventHandler(debuggerService_IsProcessRunningChanged);
debuggerService.DebugStopped += new EventHandler(_debuggerService_DebugStopped);
}
private void unregisterEvents()
{
debuggerService.IsProcessRunningChanged -= new EventHandler(debuggerService_IsProcessRunningChanged);
debuggerService.DebugStopped -= new EventHandler(_debuggerService_DebugStopped);
}
public void debuggerService_IsProcessRunningChanged(object sender, EventArgs e)
{
@ -71,14 +92,13 @@ namespace Debugger.AddIn.Visualizers.Graph @@ -71,14 +92,13 @@ namespace Debugger.AddIn.Visualizers.Graph
public void _debuggerService_DebugStopped(object sender, EventArgs e)
{
debuggerService.IsProcessRunningChanged -= new EventHandler(debuggerService_IsProcessRunningChanged);
this.Close();
}
private void Inspect_Button_Click(object sender, RoutedEventArgs e)
{
clearErrorMessage();
if (debuggerService.IsProcessRunning) // TODO will this solve the "Process not paused" exception?
if (debuggerService.IsProcessRunning) // TODO "Process not paused" exception still occurs
{
showErrorMessage("Cannot inspect when the process is running.");
}
@ -90,9 +110,12 @@ namespace Debugger.AddIn.Visualizers.Graph @@ -90,9 +110,12 @@ namespace Debugger.AddIn.Visualizers.Graph
void layoutViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "SelectedEnumValue") // TODO should be special event for enum value change
if (e.PropertyName == "SelectedEnumValue") // TODO special event for enum value change
{
layoutGraph(this.objectGraph);
if (this.objectGraph != null)
{
layoutGraph(this.objectGraph);
}
}
}
@ -129,14 +152,22 @@ namespace Debugger.AddIn.Visualizers.Graph @@ -129,14 +152,22 @@ namespace Debugger.AddIn.Visualizers.Graph
void layoutGraph(ObjectGraph graph)
{
ICSharpCode.Core.LoggingService.Debug("Debugger visualizer: Calculating graph layout");
Layout.TreeLayouter layouter = new Layout.TreeLayouter();
if (this.oldPosGraph != null)
{
foreach (var oldNode in this.oldPosGraph.Nodes)
{
// controls from old graph would be garbage collected, reuse them
NodeControlCache.Instance.ReturnForReuse(oldNode.NodeVisualControl);
}
}
this.oldPosGraph = this.currentPosGraph;
this.currentPosGraph = layouter.CalculateLayout(graph, layoutViewModel.SelectedEnumValue, this.expanded);
ICSharpCode.Core.LoggingService.Debug("Debugger visualizer: Calculating graph layout");
this.currentPosGraph = this.layouter.CalculateLayout(graph, layoutViewModel.SelectedEnumValue, this.expanded);
ICSharpCode.Core.LoggingService.Debug("Debugger visualizer: Graph layout done");
registerExpandCollapseEvents(this.currentPosGraph);
var graphDiff = new GraphMatcher().MatchGraphs(oldPosGraph, currentPosGraph);
ICSharpCode.Core.LoggingService.Debug("Debugger visualizer: starting graph animation");
this.graphDrawer.StartAnimation(oldPosGraph, currentPosGraph, graphDiff);
//this.graphDrawer.Draw(this.currentPosGraph);
}

4
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/GridVisualizer/GridVisualizerWindow.xaml

@ -237,9 +237,5 @@ @@ -237,9 +237,5 @@
</ListView>
</StackPanel>
<Canvas Name="canvas" Margin="4">
</Canvas>
</StackPanel>
</Window>
Loading…
Cancel
Save