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

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

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

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

@ -12,7 +12,7 @@ using System.Linq;
namespace Debugger.AddIn.Visualizers namespace Debugger.AddIn.Visualizers
{ {
/// <summary> /// <summary>
/// Executes grid visualizer for a node. /// Shows grid visualizer for a node.
/// </summary> /// </summary>
public class GridVisualizerCommand : ExpressionNodeVisualizerCommand 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
/// <summary> /// <summary>
/// Description of ShowGridVisualizerCommand. /// Description of ShowGridVisualizerCommand.
/// </summary> /// </summary>
public class ShowGridVisualizerCommand : AbstractMenuCommand public class GridVisualizerMenuCommand : AbstractMenuCommand
{ {
public override void Run() public override void Run()
{ {

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

@ -12,7 +12,7 @@ using System.Linq;
namespace Debugger.AddIn.Visualizers namespace Debugger.AddIn.Visualizers
{ {
/// <summary> /// <summary>
/// Executes object graph visualizer for a node. /// Shows object graph visualizer for a node.
/// </summary> /// </summary>
public class ObjectGraphVisualizerCommand : ExpressionNodeVisualizerCommand 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
/// <summary> /// <summary>
/// Command in the tools menu for showing the object graph visualizer. /// Command in the tools menu for showing the object graph visualizer.
/// </summary> /// </summary>
public class ShowObjectGraphVisualizerCommand : AbstractMenuCommand public class ObjectGraphVisualizerMenuCommand : AbstractMenuCommand
{ {
public override void Run() public override void Run()
{ {

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

@ -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 @@
// <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 @@
<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 @@
xmlns:local="clr-namespace:Debugger.AddIn.Visualizers" xmlns:local="clr-namespace:Debugger.AddIn.Visualizers"
> >
<UserControl.Resources> <UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="PlusToggleButton.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
<local:TooltipVisibilityConverter x:Key="toolVisConverter"></local:TooltipVisibilityConverter> <local:TooltipVisibilityConverter x:Key="toolVisConverter"></local:TooltipVisibilityConverter>
<DataTemplate x:Key="valueColumnTemplate"> <DataTemplate x:Key="valueColumnTemplate">
<TextBlock Text="{Binding Text}"> <TextBlock Text="{Binding Text}">
@ -18,6 +23,7 @@
</TextBlock> </TextBlock>
</DataTemplate> </DataTemplate>
</UserControl.Resources> </UserControl.Resources>
<aero:SystemDropShadowChrome> <aero:SystemDropShadowChrome>
<Grid> <Grid>
<ListView Name="listView" AlternationCount="2" ScrollViewer.VerticalScrollBarVisibility="Auto"> <ListView Name="listView" AlternationCount="2" ScrollViewer.VerticalScrollBarVisibility="Auto">
@ -65,12 +71,12 @@
</GridView.ColumnHeaderContainerStyle> </GridView.ColumnHeaderContainerStyle>
<GridView.Columns> <GridView.Columns>
<!-- Expand button (either property or nested) --> <!-- Expand button (either property or nested) -->
<GridViewColumn Header="Plus" Width="Auto"> <GridViewColumn Header="Plus" Width="20">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<StackPanel> <StackPanel Margin="0 2 0 0">
<ToggleButton x:Name="Expander" Width="20" Margin="-4 -1 -4 -1" IsChecked="{Binding IsExpanded}" Click="NestedExpandButton_Click" Padding="0">+</ToggleButton> <ToggleButton x:Name="Expander" Margin="-6 0" 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> <ToggleButton x:Name="PropertyExpander" Margin="-6 0" IsChecked="{Binding IsPropertyExpanded}" Click="PropertyExpandButton_Click" Padding="0"></ToggleButton>
</StackPanel> </StackPanel>
<DataTemplate.Triggers> <DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=HasChildren}" Value="False"> <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
string addedSpaces = StringHelper.Repeat(' ', spaces); string addedSpaces = StringHelper.Repeat(' ', spaces);
GridView gv = listView.View as GridView; GridView gv = listView.View as GridView;
// hack - autosize Name column
gv.Columns[1].Header = "Name" + addedSpaces; gv.Columns[1].Header = "Name" + addedSpaces;
//AutoSizeColumns(); //AutoSizeColumns();
@ -114,6 +115,16 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
public PositionedGraphNodeControl() public PositionedGraphNodeControl()
{ {
InitializeComponent(); InitializeComponent();
Init();
}
public void Init()
{
PropertyExpanded = null;
PropertyCollapsed = null;
ContentNodeExpanded = null;
ContentNodeCollapsed = null;
//this.listView.ItemsSource = null;
} }
void TextBlock_MouseDown(object sender, MouseButtonEventArgs e) 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
/// </summary> /// </summary>
public IEnumerable<ContentNode> FlattenExpanded() public IEnumerable<ContentNode> FlattenExpanded()
{ {
return Utils.TreeFlattener.FlattenSelectChildrenIf(this, (node) => { return node.IsExpanded; }); return Utils.TreeFlattener.FlattenSelectChildrenIf(this, node => node.IsExpanded);
} }
/// <summary> /// <summary>
@ -119,7 +119,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
/// <returns></returns> /// <returns></returns>
public IEnumerable<ContentNode> FlattenChildrenExpanded() public IEnumerable<ContentNode> FlattenChildrenExpanded()
{ {
return Utils.TreeFlattener.FlattenSelectChildrenIf(this.Children, (node) => { return node.IsExpanded; }); return Utils.TreeFlattener.FlattenSelectChildrenIf(this.Children, node => node.IsExpanded);
} }
/// <summary> /// <summary>
@ -127,8 +127,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
/// </summary> /// </summary>
public IEnumerable<PositionedNodeProperty> FlattenProperties() public IEnumerable<PositionedNodeProperty> FlattenProperties()
{ {
return Utils.TreeFlattener.Flatten(this).Where((node) => { return node is ContentPropertyNode; }). return Utils.TreeFlattener.Flatten(this).Where(node => node is ContentPropertyNode).
Select( (propertyNode) => { return ((ContentPropertyNode)propertyNode).Property; }); Select( propertyNode => ((ContentPropertyNode)propertyNode).Property);
} }
#region Utils.ITreeNode implementation #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
{ {
// show expand button when appropriate // show expand button when appropriate
return (!this.positionedProperty.IsAtomic && !this.positionedProperty.IsNull); return (!this.positionedProperty.IsAtomic && !this.positionedProperty.IsNull);
//return true;
} }
} }
@ -62,7 +63,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
PropertyNode sourcePropertyNode = source as PropertyNode; PropertyNode sourcePropertyNode = source as PropertyNode;
this.Name = sourcePropertyNode.Property.Name; this.Name = sourcePropertyNode.Property.Name;
this.Text = sourcePropertyNode.Property.Value; // lazy evaluated this.Text = sourcePropertyNode.Property.Value; // evaluated in Evaluate()
this.IsNested = false; this.IsNested = false;
this.IsExpanded = false; // always false, property content nodes are never expanded this.IsExpanded = false; // always false, property content nodes are never expanded
this.positionedProperty = new PositionedNodeProperty( 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
/// </summary> /// </summary>
public class PositionedGraphNode public class PositionedGraphNode
{ {
public static readonly double MaxHeight = 300;
/// <summary> /// <summary>
/// Creates new PositionedNode. /// Creates new PositionedNode.
/// </summary> /// </summary>
@ -72,8 +74,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
private void initVisualControl() private void initVisualControl()
{ {
this.nodeVisualControl = new PositionedGraphNodeControl(); this.nodeVisualControl = NodeControlCache.Instance.GetNodeControl();
this.nodeVisualControl.MaxHeight = 300; this.nodeVisualControl.MaxHeight = MaxHeight;
// propagate events from nodeVisualControl // propagate events from nodeVisualControl
this.nodeVisualControl.PropertyExpanded += new EventHandler<PositionedPropertyEventArgs>(NodeVisualControl_PropertyExpanded); 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
treeNodeFor = new Dictionary<ObjectGraphNode, PositionedGraphNode>(); treeNodeFor = new Dictionary<ObjectGraphNode, PositionedGraphNode>();
seenNodes = new HashSet<PositionedGraphNode>(); seenNodes = new HashSet<PositionedGraphNode>();
//TreeGraphNode tree = buildTreeRecursive(objectGraph.Root, expandedNodes); //TreeGraphNode tree = buildTreeRecursive(objectGraph.Root, expandedNodes);
// convert ObjectGraph to PositionedGraph with TreeEdges // convert ObjectGraph to PositionedGraph with TreeEdges

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

@ -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
if (/*!complexProperty.IsNull && we dont know yet if it's null */expandedNodes.IsExpanded(complexProperty.Expression)) if (/*!complexProperty.IsNull && we dont know yet if it's null */expandedNodes.IsExpanded(complexProperty.Expression))
{ {
// if expanded, evaluate this property // if expanded, evaluate this property
// complexProperty.Evaluate(); // consider
Value memberValue = complexProperty.Expression.Evaluate(this.debuggerService.DebuggedProcess); Value memberValue = complexProperty.Expression.Evaluate(this.debuggerService.DebuggedProcess);
if (memberValue.IsNull) 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
private PositionedGraph oldPosGraph; private PositionedGraph oldPosGraph;
private PositionedGraph currentPosGraph; private PositionedGraph currentPosGraph;
private GraphDrawer graphDrawer; private GraphDrawer graphDrawer;
private Layout.TreeLayouter layouter;
/// <summary> /// <summary>
/// Long-lived map telling which graph nodes and content nodes the user expanded. /// Long-lived map telling which graph nodes and content nodes the user expanded.
@ -50,15 +51,35 @@ namespace Debugger.AddIn.Visualizers.Graph
if (debuggerService == null) if (debuggerService == null)
throw new ApplicationException("Only windows debugger is currently supported"); throw new ApplicationException("Only windows debugger is currently supported");
debuggerService.IsProcessRunningChanged += new EventHandler(debuggerService_IsProcessRunningChanged); this.Closed += new EventHandler(VisualizerWPFWindow_Closed);
debuggerService.DebugStopped += new EventHandler(_debuggerService_DebugStopped);
registerEvents();
this.layoutViewModel = new EnumViewModel<LayoutDirection>(); this.layoutViewModel = new EnumViewModel<LayoutDirection>();
this.layoutViewModel.PropertyChanged += new PropertyChangedEventHandler(layoutViewModel_PropertyChanged); this.layoutViewModel.PropertyChanged += new PropertyChangedEventHandler(layoutViewModel_PropertyChanged);
this.DataContext = this.layoutViewModel; this.DataContext = this.layoutViewModel;
this.layouter = new TreeLayouter();
this.graphDrawer = new GraphDrawer(this.canvas); 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) public void debuggerService_IsProcessRunningChanged(object sender, EventArgs e)
{ {
@ -71,14 +92,13 @@ namespace Debugger.AddIn.Visualizers.Graph
public void _debuggerService_DebugStopped(object sender, EventArgs e) public void _debuggerService_DebugStopped(object sender, EventArgs e)
{ {
debuggerService.IsProcessRunningChanged -= new EventHandler(debuggerService_IsProcessRunningChanged);
this.Close(); this.Close();
} }
private void Inspect_Button_Click(object sender, RoutedEventArgs e) private void Inspect_Button_Click(object sender, RoutedEventArgs e)
{ {
clearErrorMessage(); 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."); showErrorMessage("Cannot inspect when the process is running.");
} }
@ -90,9 +110,12 @@ namespace Debugger.AddIn.Visualizers.Graph
void layoutViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) 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
void layoutGraph(ObjectGraph graph) void layoutGraph(ObjectGraph graph)
{ {
ICSharpCode.Core.LoggingService.Debug("Debugger visualizer: Calculating graph layout"); if (this.oldPosGraph != null)
{
Layout.TreeLayouter layouter = new Layout.TreeLayouter(); 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.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); registerExpandCollapseEvents(this.currentPosGraph);
var graphDiff = new GraphMatcher().MatchGraphs(oldPosGraph, 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.StartAnimation(oldPosGraph, currentPosGraph, graphDiff);
//this.graphDrawer.Draw(this.currentPosGraph); //this.graphDrawer.Draw(this.currentPosGraph);
} }

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

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