Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Arrange algorithm similar to stackpanel (Read 1204 times)
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Arrange algorithm similar to stackpanel
Aug 2nd, 2010 at 10:28am
Print Post  
Hi Stoyo

Can you help me is creating my own layouts arrangement for diagram controls -

For eq. I have a container node which contains all child items. I need to arrange them horizontal and vertically with fixed number of nodes in each row.

Is it possible to integrate this type of layout arrangement in mind fusion libarary.

P.S
I think layeredLayout is doing the same thing. Is it possible to specify number of nodes in each row and then it automatically split the layer in another row. ?

-Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrange algorithm similar to stackpanel
Reply #1 - Aug 2nd, 2010 at 11:40am
Print Post  
Hi Rajesh,

Do you mean something like this?
Code
Select All
void ArrangeInRows(ContainerNode container, int nodesPerRow)
{
	double currX = container.Bounds.Left;
	double currY = container.Bounds.Top;
	double rowHeight = 0;
	int n = 0;
	foreach (var node in container.Children)
	{
		var r = node.Bounds;
		r.X = currX;
		r.Y = currY;
		node.Bounds = r;
		rowHeight = Math.Max(rowHeight, node.Bounds.Height);
		currX = r.Right;
		if (++n == nodesPerRow)
		{
			n = 0;
			currX = container.Bounds.Left;
			currY += rowHeight;
			rowHeight = 0;
		}
	}
} 

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint