Browse Source

Object graph - added node headers with type name.

pull/15/head
mkonicek 15 years ago
parent
commit
1e30f4dd2a
  1. 17
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Drawing/PositionedGraphNodeControl.xaml
  2. 21
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Drawing/PositionedGraphNodeControl.xaml.cs
  3. 22
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/PositionedNode.cs
  4. 3
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/TreeLayout.cs
  5. 1
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraph/ObjectGraphBuilder.cs
  6. 15
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraph/ObjectGraphNode.cs

17
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Drawing/PositionedGraphNodeControl.xaml

@ -14,10 +14,11 @@
<aero:SystemDropShadowChrome> <aero:SystemDropShadowChrome>
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<!--
<Border Background="#ddeeff" BorderThickness="1,1,1,0" BorderBrush="DarkGray" HorizontalAlignment="Stretch" Padding="1"> <Border x:Name="typeNameHeaderBorder" Background="#ddeeff" Height="20" Margin="1,0" BorderThickness="1,1,1,0" BorderBrush="DarkGray" HorizontalAlignment="Stretch" Padding="1">
<TextBlock>Hello</TextBlock> <TextBlock Text="{Binding TypeName}"></TextBlock>
</Border> --> </Border>
<ListView Name="listView" ScrollViewer.VerticalScrollBarVisibility="Auto" Width="200" Height="300"> <ListView Name="listView" ScrollViewer.VerticalScrollBarVisibility="Auto" Width="200" Height="300">
<ListView.Background> <ListView.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
@ -33,14 +34,6 @@
<Setter Property="BorderThickness" Value="1" /> <Setter Property="BorderThickness" Value="1" />
<Setter Property="Focusable" Value="false" /> <Setter Property="Focusable" Value="false" />
<Style.Triggers> <Style.Triggers>
<!--
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="Transparent"></Setter>
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="Transparent"></Setter>
</Trigger>
-->
<DataTrigger Binding="{Binding IsNested}" Value="True"> <DataTrigger Binding="{Binding IsNested}" Value="True">
<Setter Property="Foreground" Value="#666666"></Setter> <Setter Property="Foreground" Value="#666666"></Setter>
<Setter Property="FontStyle" Value="Italic"></Setter> <Setter Property="FontStyle" Value="Italic"></Setter>

21
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Drawing/PositionedGraphNodeControl.xaml.cs

@ -48,20 +48,23 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
// shown in the ListView // shown in the ListView
private ObservableCollection<ContentNode> items = new ObservableCollection<ContentNode>(); private ObservableCollection<ContentNode> items = new ObservableCollection<ContentNode>();
private ContentNode root;
/// <summary> /// <summary>
/// The tree to be displayed in this Control. /// The tree to be displayed in this Control.
/// </summary> /// </summary>
public ContentNode Root public ContentNode Root { get; set; }
/// <summary>
/// Sets the node to be displayed by this control.
/// </summary>
/// <param name="node"></param>
public void SetDataContext(PositionedNode node)
{ {
get { return this.root; } this.DataContext = node;
set { this.Root = node.Content;
this.root = value; this.items = GetInitialItems(this.Root);
this.items = GetInitialItems(this.root);
// data virtualization, ContentPropertyNode implements IEvaluate // data virtualization, ContentPropertyNode implements IEvaluate
this.listView.ItemsSource = new VirtualizingObservableCollection<ContentNode>(this.items); this.listView.ItemsSource = new VirtualizingObservableCollection<ContentNode>(this.items);
} }
}
public void CalculateWidthHeight() public void CalculateWidthHeight()
{ {
@ -72,13 +75,13 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
listView.Width = gv.Columns[0].Width + gv.Columns[1].Width + gv.Columns[2].Width + 10; listView.Width = gv.Columns[0].Width + gv.Columns[1].Width + gv.Columns[2].Width + 10;
int maxItems = 10; int maxItems = 10;
listView.Height = Math.Min(this.items.Count, maxItems) * 20; listView.Height = 4 + Math.Min(this.items.Count, maxItems) * 20;
if (this.items.Count > maxItems) { if (this.items.Count > maxItems) {
listView.Width += 30; // for scrollbar listView.Width += 30; // for scrollbar
} }
this.Width = listView.Width + 2; this.Width = listView.Width + 2;
this.Height = listView.Height + 2; this.Height = listView.Height + this.typeNameHeaderBorder.Height + 2;
} }
public PositionedGraphNodeControl() public PositionedGraphNodeControl()

22
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/PositionedNode.cs

@ -19,10 +19,11 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
/// Creates new PositionedNode. /// Creates new PositionedNode.
/// </summary> /// </summary>
/// <param name="objectNode">Underlying ObjectNode.</param> /// <param name="objectNode">Underlying ObjectNode.</param>
public PositionedNode(ObjectGraphNode objectNode) public PositionedNode(ObjectGraphNode objectNode, Expanded expanded)
{ {
this.objectNode = objectNode; this.ObjectNode = objectNode;
InitVisualControl(); InitVisualControl();
InitContentFromObjectNode(expanded);
} }
public event EventHandler<PositionedPropertyEventArgs> PropertyExpanded; public event EventHandler<PositionedPropertyEventArgs> PropertyExpanded;
@ -30,20 +31,21 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
public event EventHandler<ContentNodeEventArgs> ContentNodeExpanded; public event EventHandler<ContentNodeEventArgs> ContentNodeExpanded;
public event EventHandler<ContentNodeEventArgs> ContentNodeCollapsed; public event EventHandler<ContentNodeEventArgs> ContentNodeCollapsed;
private ObjectGraphNode objectNode;
/// <summary> /// <summary>
/// Underlying ObjectNode. /// Underlying ObjectNode.
/// </summary> /// </summary>
public ObjectGraphNode ObjectNode public ObjectGraphNode ObjectNode { get; private set; }
{
get { return objectNode; }
}
/// <summary> /// <summary>
/// Tree-of-properties content of this node. /// Tree-of-properties content of this node.
/// </summary> /// </summary>
public ContentNode Content { get; set; } public ContentNode Content { get; set; }
/// <summary>
/// Name of the Type in the debuggee.
/// </summary>
public string TypeName { get { return this.ObjectNode.TypeName; } }
/// <summary> /// <summary>
/// The size of the subtree of this node in the layout. /// The size of the subtree of this node in the layout.
/// </summary> /// </summary>
@ -54,14 +56,14 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
/// </summary> /// </summary>
public PositionedGraphNodeControl NodeVisualControl { get; private set; } public PositionedGraphNodeControl NodeVisualControl { get; private set; }
public void InitContentFromObjectNode(Expanded expanded) void InitContentFromObjectNode(Expanded expanded)
{ {
this.Content = new ContentNode(this, null); this.Content = new ContentNode(this, null);
this.Content.InitOverride(this.ObjectNode.Content, expanded); this.Content.InitOverride(this.ObjectNode.Content, expanded);
this.NodeVisualControl.Root = this.Content; this.NodeVisualControl.SetDataContext(this);
} }
private void InitVisualControl() void InitVisualControl()
{ {
this.NodeVisualControl = NodeControlCache.Instance.GetNodeControl(); this.NodeVisualControl = NodeControlCache.Instance.GetNodeControl();
// propagate events from nodeVisualControl // propagate events from nodeVisualControl

3
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/TreeLayout.cs

@ -53,8 +53,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
// create empty PositionedNodes // create empty PositionedNodes
foreach (ObjectGraphNode objectNode in objectGraph.ReachableNodes) { foreach (ObjectGraphNode objectNode in objectGraph.ReachableNodes) {
var posNode = new PositionedNode(objectNode); var posNode = new PositionedNode(objectNode, expanded);
posNode.InitContentFromObjectNode(expanded);
posNode.MeasureVisualControl(); posNode.MeasureVisualControl();
positionedGraph.AddNode(posNode); positionedGraph.AddNode(posNode);
positionedNodeFor[objectNode] = posNode; positionedNodeFor[objectNode] = posNode;

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

@ -303,6 +303,7 @@ namespace Debugger.AddIn.Visualizers.Graph
private ObjectGraphNode createNewNode(Value permanentReference, Expression expression) private ObjectGraphNode createNewNode(Value permanentReference, Expression expression)
{ {
ObjectGraphNode newNode = new ObjectGraphNode(); ObjectGraphNode newNode = new ObjectGraphNode();
newNode.TypeName = permanentReference.Type.Name;
newNode.HashCode = permanentReference.InvokeDefaultGetHashCode(); newNode.HashCode = permanentReference.InvokeDefaultGetHashCode();
resultGraph.AddNode(newNode); resultGraph.AddNode(newNode);

15
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraph/ObjectGraphNode.cs

@ -32,17 +32,16 @@ namespace Debugger.AddIn.Visualizers.Graph
/// <summary> /// <summary>
/// Property tree of this node. /// Property tree of this node.
/// </summary> /// </summary>
public ThisNode Content public ThisNode Content { get; set; }
{
get; set; /// <summary>
} /// Name of the Type in the debuggee.
/// </summary>
public string TypeName { get; set; }
public IEnumerable<ObjectGraphProperty> Properties public IEnumerable<ObjectGraphProperty> Properties
{ {
get get { return this.Content.FlattenPropertyNodes().Select(node => {return node.Property; }); }
{
return this.Content.FlattenPropertyNodes().Select(node => {return node.Property; });
}
} }
} }
} }

Loading…
Cancel
Save