microsoft / automatic-graph-layout

A set of tools for graph layout and viewing
Other
1.36k stars 305 forks source link

How to go to node in WPF control? #136

Closed vdisasm closed 7 years ago

vdisasm commented 7 years ago

I want to scroll to some node, so that this node will be at top-center part of the WPF viewer.

I found some workaround, but it seems I don't handle scale correctly (it is 1 here):

// entry is my node

var bbox = entry.BoundingBox;
var c = GraphViewer.GraphCanvas;
var vp = new Rectangle(
    new Point(0, 0),
    new Point(c.RenderSize.Width, bbox.Height));
GraphViewer.SetTransformOnViewportWithoutRaisingViewChangeEvent(1, bbox.Center, vp);
levnach commented 7 years ago

Sorry, is your intent to position a node at the view center?

vdisasm commented 7 years ago

I have graph with top-to-bottom layout and I'd like to navigate to node so that it is placed at top vertically and center horizontally in WPF viewer.

Or probably at center of view will be good too.

Graph is like this one:

levnach commented 7 years ago

I have added a function Microsoft.Msagl.WpfGraphControl.GraphViewer.PointToCenter that will do the job. Call it with the node center as the parameter.

vdisasm commented 7 years ago

Thanks a lot.