Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Align nodes via top, bottom, left, etc.? (Read 3096 times)
Chris M
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 17
Joined: Oct 7th, 2014
Align nodes via top, bottom, left, etc.?
Oct 7th, 2014 at 3:34pm
Print Post  
Hello,

I have been looking through the documentation and haven't been able to find if this functionality exists.

What I would like is to select multiple nodes and then choose whether to align them via their tops, bottom left, or right.  What steps would I need to take to achieve this?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Align nodes via top, bottom, left, etc.?
Reply #1 - Oct 7th, 2014 at 4:08pm
Print Post  
Hi,

Try the following methods:

Code
Select All
void Align(
	Func<RectangleF, float> getter,
	Func<RectangleF, float, RectangleF> setter)
{
	var target = diagram.ActiveItem as DiagramNode;
	if (target != null)
	{
		var alignedCoord = getter(target.Bounds);
		foreach (var node in diagram.Selection.Nodes)
		{
			if (node == target)
				continue;
			node.Bounds = setter(node.Bounds, alignedCoord);
		}
	}
}

void AlignLeft()
{
	Align(
		r => r.Left,
		(r, coord) => new RectangleF(coord, r.Y, r.Width, r.Height));
}

void AlignTop()
{
	Align(
		r => r.Top,
		(r, coord) => new RectangleF(r.X, coord, r.Width, r.Height));
}

void AlignRight()
{
	Align(
		r => r.Right,
		(r, coord) => new RectangleF(coord - r.Width, r.Y, r.Width, r.Height));
}

void AlignBottom()
{
	Align(
		r => r.Bottom,
		(r, coord) => new RectangleF(r.X, coord - r.Height, r.Width, r.Height));
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Chris M
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 17
Joined: Oct 7th, 2014
Re: Align nodes via top, bottom, left, etc.?
Reply #2 - Oct 8th, 2014 at 4:11pm
Print Post  
Stoyo, thank you for your assistance with this question and the other I had posted. We are currently doing some prototyping with the trial to see if it meets our needs.

We are pleased with the documentation, functionality and the response for support so I believe we will be purchasing soon.

I do have another question but will post a new topic.

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