Browse Source

Object graph - added simple zoom slider.

pull/15/head
mkonicek 15 years ago
parent
commit
acc439575b
  1. 2
      src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj
  2. 55
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Drawing/PositionedGraphNodeControl.xaml.cs
  3. 9
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/RouteGraph/RouteGraph.cs
  4. 4
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/ShortestPath/DijkstraShortestPathFinder.cs
  5. 9
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/TreeLayout.cs
  6. 14
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml

2
src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj

@ -245,7 +245,7 @@ @@ -245,7 +245,7 @@
<Compile Include="Visualizers\Graph\Layout\SplineRouting\RouteGraph\RouteGraph.cs" />
<Compile Include="Visualizers\Graph\Layout\SplineRouting\RouteGraph\RouteGraphEdge.cs" />
<Compile Include="Visualizers\Graph\Layout\SplineRouting\RouteGraph\RouteVertex.cs" />
<Compile Include="Visualizers\Graph\Layout\SplineRouting\ShortestPath\AStarShortestPathFinder.cs" />
<Compile Include="Visualizers\Graph\Layout\SplineRouting\ShortestPath\DijkstraShortestPathFinder.cs" />
<Compile Include="Visualizers\Graph\Layout\TreeModel\ContentNode.cs" />
<Compile Include="Visualizers\Graph\Layout\TreeModel\ContentNodeEventArgs.cs" />
<Compile Include="Visualizers\Graph\Layout\TreeModel\ContentPropertyNode.cs" />

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

@ -60,43 +60,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing @@ -60,43 +60,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
this.items = GetInitialItems(this.root);
// data virtualization, ContentPropertyNode implements IEvaluate
this.listView.ItemsSource = new VirtualizingObservableCollection<ContentNode>(this.items);
//AutoSizeColumns();
/*DispatcherTimer t = new DispatcherTimer();
t.Interval = TimeSpan.FromMilliseconds(1000);
t.Start();
t.Tick += (s, ee) => { AutoSizeColumns(); t.Stop(); };*/
}
}
public void AutoSizeColumns()
{
//listView.UpdateLayout();
//listView.Measure(new Size(800, 800));
//double sum = 0;
GridView gv = listView.View as GridView;
if (gv != null)
{
foreach (var c in gv.Columns)
{
//var header = c.Header as GridViewColumnHeader;
// Code below was found in GridViewColumnHeader.OnGripperDoubleClicked() event handler (using Reflector)
// i.e. it is the same code that is executed when the gripper is double clicked
//var uw = c.GetType().GetMethod("UpdateActualWidth", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic);
//uw.Invoke(c, new object[] { });
//if (double.IsNaN(c.Width))
{
c.Width = c.ActualWidth;
}
c.Width = double.NaN;
/*var dw = c.GetType().GetProperty("DesiredWidth", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic);
double desired = (double)dw.GetValue(c, null);
c.Width = c.ActualWidth; // ActualWidth is not correct until GridViewRowPresenter gets measured
c.Width = double.NaN;
sum += c.Width;*/
}
}
}
@ -154,7 +117,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing @@ -154,7 +117,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
}
PositionedNodeProperty property = clickedNode.Property;
//property.IsPropertyExpanded = !property.IsPropertyExpanded; // done by databinding
clickedButton.Content = property.IsPropertyExpanded ? "-" : "+";
if (property.IsPropertyExpanded)
@ -172,7 +134,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing @@ -172,7 +134,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
var clickedButton = (ToggleButton)e.Source;
var clickedNode = (ContentNode)(clickedButton).DataContext;
int clickedIndex = this.items.IndexOf(clickedNode);
//clickedNode.IsExpanded = !clickedNode.IsExpanded; // done by data binding
clickedButton.Content = clickedNode.IsExpanded ? "-" : "+"; // could be done by a converter
if (clickedNode.IsExpanded)
@ -184,7 +145,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing @@ -184,7 +145,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
this.items.Insert(clickedIndex + i, childNode);
i++;
}
// insertChildren(clickedNode, this.view, clickedIndex); // TODO
OnContentNodeExpanded(clickedNode);
}
else
@ -199,21 +159,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing @@ -199,21 +159,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing
}
CalculateWidthHeight();
//AutoSizeColumns();
// set to Auto again to resize columns
/*var colName = (this.listView.View as GridView).Columns[0];
var colValue = (this.listView.View as GridView).Columns[1];
colName.Width = 300;
colName.Width = double.NaN;
colValue.Width = 300;
colValue.Width = double.NaN;
//this.view.Insert(0, new ContentNode());
//this.view.RemoveAt(0);
this.listView.UpdateLayout();
this.listView.Width = colName.ActualWidth + colValue.ActualWidth + 30;
this.listView.Width = double.NaN;*/
}
ObservableCollection<ContentNode> GetInitialItems(ContentNode root)

9
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/RouteGraph/RouteGraph.cs

@ -15,7 +15,7 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting @@ -15,7 +15,7 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting
{
static readonly double boxPadding = 15;
//static readonly double boxSafetyMargin = 5; // inflate boxes for collision testing
static readonly double multiEdgeGap = 10;
static readonly double multiEdgeGap = 15;
List<IRect> boxes = new List<IRect>();
public List<IRect> Boxes {
@ -27,11 +27,11 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting @@ -27,11 +27,11 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting
get { return vertices; }
}
AStarShortestPathFinder pathFinder;
DijkstraShortestPathFinder pathFinder;
public RouteGraph()
{
pathFinder = new AStarShortestPathFinder(this);
pathFinder = new DijkstraShortestPathFinder(this);
}
public static RouteGraph InitializeVertices(IEnumerable<IRect> nodes, IEnumerable<IEdge> edges)
@ -104,7 +104,8 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting @@ -104,7 +104,8 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting
{
if (edgeStart == null || edgeEnd == null) {
// should not happen
return;
throw new System.Exception("edgeStart is null");
//return;
}
var startPoint = new RouteVertex(edgeStart.Value.X, edgeStart.Value.Y);
startPoint.IsEdgeEndpoint = true;

4
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/ShortestPath/AStarShortestPathFinder.cs → src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/ShortestPath/DijkstraShortestPathFinder.cs

@ -10,11 +10,11 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting @@ -10,11 +10,11 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting
/// <summary>
/// Description of AStarShortestPathFinder.
/// </summary>
public class AStarShortestPathFinder
public class DijkstraShortestPathFinder
{
RouteGraph graph;
public AStarShortestPathFinder(RouteGraph routeGraph)
public DijkstraShortestPathFinder(RouteGraph routeGraph)
{
this.graph = routeGraph;
}

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

@ -14,8 +14,11 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -14,8 +14,11 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
/// </summary>
public class TreeLayout
{
private static readonly double NodeMarginH = 30;
private static readonly double NodeMarginV = 30;
static readonly double NodeMarginH = 30;
static readonly double NodeMarginV = 30;
static readonly double MarginTop = 0;
static readonly double MarginBottom = 0;
GraphEdgeRouter edgeRouter = new GraphEdgeRouter();
/// <summary>
@ -81,7 +84,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -81,7 +84,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
// first layout pass
CalculateSubtreeSizes(positionedGraph.Root, seenNodes, treeEdges);
// second layout pass
CalculateNodePosRecursive(positionedGraph.Root, treeEdges, 0, 0);
CalculateNodePosRecursive(positionedGraph.Root, treeEdges, MarginTop, MarginBottom);
}
// determines which edges are tree edges, and calculates subtree size for each node

14
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml

@ -27,7 +27,9 @@ @@ -27,7 +27,9 @@
<TextBox Name="txtExpression" VerticalAlignment="Center" Width="100"></TextBox>
<Button Click="Inspect_Button_Click">Inspect</Button>
<TextBlock Margin="12 0 6 0" VerticalAlignment="Center">Layout:</TextBlock>
<ComboBox Name="cmbLayoutDirection" Width="150" ItemsSource="{Binding Path=EnumValues}" SelectedValue="{Binding Path=SelectedEnumValue}" SelectedValuePath="EnumValue" DisplayMemberPath="DisplayValue"></ComboBox>
<ComboBox Name="cmbLayoutDirection" Width="120" ItemsSource="{Binding Path=EnumValues}" SelectedValue="{Binding Path=SelectedEnumValue}" SelectedValuePath="EnumValue" DisplayMemberPath="DisplayValue"></ComboBox>
<TextBlock Margin="12 0 6 0" VerticalAlignment="Center">Zoom:</TextBlock>
<Slider x:Name="zoomSlider" Width="100" Minimum="0.5" Maximum="1" Value="1"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Name="pnlError" Visibility="Collapsed" Margin="0 6 0 0">
<TextBlock Margin="0 0 4 0" Name="lblError" FontStyle="Italic">Error: </TextBlock>
@ -35,16 +37,14 @@ @@ -35,16 +37,14 @@
</StackPanel>
</StackPanel>
</Border>
<Border Margin="3" Padding="3">
<StackPanel Orientation="Horizontal">
</StackPanel>
</Border>
</StackPanel>
<controls:DragScrollViewer x:Name="scroller" Margin="0 4 0 0" Grid.Row="1" Grid.Column="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<Canvas HorizontalAlignment="Left" VerticalAlignment="Top" Name="canvas" Margin="4">
<Canvas.LayoutTransform>
<ScaleTransform ScaleX="{Binding Path=Value, ElementName=zoomSlider}"
ScaleY="{Binding Path=Value, ElementName=zoomSlider}"/>
</Canvas.LayoutTransform>
</Canvas>
</controls:DragScrollViewer>
</Grid>

Loading…
Cancel
Save