- Welcome, Guest. Please Login or Register
MindFusion  
  Version 2 of our Xamarin Calendar component adds Resource view and support for Universal Windows Platform. Now beta testing spreadsheet component for Java Swing.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Resize rotated nodes
Read 69 times

Kris   Offline
YaBB Newbies
*
Posts: 2
I Love MindFusion!


   
     
 
Resize rotated nodes
May 17th, 2017 at 1:56pm
 
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
 
 
 
IP Logged    
 
     

Slavcho   Online
God Member
*****
Posts: 937
Gender: male
tech.support


   
     
 
Re: Resize rotated nodes
Reply #1 - May 17th, 2017 at 8:10pm
 
Hi,

Try this method -
Code:
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
 
 
 
IP Logged    
 
     

Kris   Offline
YaBB Newbies
*
Posts: 2
I Love MindFusion!


   
     
 
Re: Resize rotated nodes
Reply #2 - May 19th, 2017 at 9:50am
 
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
 
 
 
IP Logged    
 
     

Slavcho   Online
God Member
*****
Posts: 937
Gender: male
tech.support


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

Regards,
Slavcho
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print