Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Centre align tree layout (Read 2073 times)
binuvc
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 46
Joined: Nov 7th, 2011
Centre align tree layout
Feb 3rd, 2012 at 11:50am
Print Post  
Hi,

We were looking in to the possibility of aligning a treelayout diagram to the center.

Now after applying the layout it is aligning to the left of the diagramlite control.
We are setting the width and height of the base control to some value.

The center aligning is required espicially when there are very few nodes in the diagram.

We are applying the layout as follows


            TreeLayout layout = new TreeLayout();
            layout.Balance = TreeLayoutBalance.Original;             
            layout.Type = TreeLayoutType.Centered;
            layout.Direction = TreeLayoutDirections.TopToBottom;
            layout.LinkStyle = TreeLayoutLinkType.Cascading3;
            layout.LevelDistance = 25;
            layout.NodeDistance = 10;
            layout.Arrange(diagramLite);


Please advice.

Thanks
BinuVC
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Centre align tree layout
Reply #1 - Feb 6th, 2012 at 7:46am
Print Post  
Hi,

Try the following if you need to center the tree relatively to the visible area of the diagram:

Code
Select All
private void OnCenterLayout(object sender, RoutedEventArgs e)
{
      if (diagram.Nodes.Count == 0)
            return;

      var root = diagram.Nodes[0];
      var r = root.Bounds;

      var view = diagram.Viewport;
      var centerX = view.X + view.Width / 2 - r.Width / 2;
      root.Bounds = new Rect(
            centerX, diagram.Bounds.Y + 5, r.Width, r.Height);

      var layout = new TreeLayout(root);
      layout.KeepRootPosition = true;
      // other layout settings ...
      layout.Arrange(diagram);
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint