Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Resize rotated nodes (Read 1719 times)
Kris
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 9
Joined: May 17th, 2017
Resize rotated nodes
May 17th, 2017 at 12:56pm
Print Post  
Hi,

I'm trying to resize rotated node, not via resize handles but just changing the node Size (DiagramAdapterNode.Resize(w,h)

the problem is that when node is rotated the locations is changing not in proper way - i.e when node is rotated 45deg, and when resizing via right bottom handle - the left top position is kept, but when I resize the node via Resize method the location is moved. How to achieve the same behavior when resizing node the same as when resizing via resize handles ?

Regards,
K
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Resize rotated nodes
Reply #1 - May 17th, 2017 at 7:10pm
Print Post  
Hi,

Try this method -
Code
Select All
void Resize(DiagramNode node, double width, double height)
{
	var topLeft = new Point(0, 0);
	topLeft = node.TransformItemToDiagram(topLeft);

	double rad = node.RotationAngle * Math.PI / 180;
	var rightVector = new Vector(
		width * Math.Cos(rad), width * Math.Sin(rad));
	rad += Math.PI / 2;
	var downVector = new Vector(
		height * Math.Cos(rad), height * Math.Sin(rad));

	var bottomRight = topLeft + rightVector + downVector;
	var center = topLeft + rightVector / 2 + downVector / 2;
	var rotate = new RotateTransform(
		-node.RotationAngle, center.X, center.Y);
	topLeft = rotate.Transform(topLeft);
	bottomRight = rotate.Transform(bottomRight);
	node.Bounds = new Rect(topLeft, bottomRight);
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Kris
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 9
Joined: May 17th, 2017
Re: Resize rotated nodes
Reply #2 - May 19th, 2017 at 8:50am
Print Post  
Thanks,

adapted it to work in all expand/shrink directions.
Don't you thought about putting it to the API or if already is hidden make it public ?

Regards
Kris
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Resize rotated nodes
Reply #3 - May 19th, 2017 at 9:02am
Print Post  
I guess we could add a pivot-point argument to usual Resize method, we'll have it in mind for next releases.

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