Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to use DiagramNode.AttachTo() method? (Read 2664 times)
esri_test
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 44
Joined: Aug 21st, 2013
How to use DiagramNode.AttachTo() method?
Jun 5th, 2015 at 8:47pm
Print Post  
I have a particular question about DiagramNode.AttachTo() method, especially about
DiagramNode.AttachTo (DiagramNode, AttachToNode)

I am trying to attach a child node to a parent node. for example, I want to attach to top right corner of the parent node, when I use diagram.Factory.CreateShapeNode(point, size) to create the child node, I need to calculate the center point for the child point based on the parent node point and size. It seems AttachToNode.TopRight doesn't do much.

I thought this AttachToNode enumerator will move the child node to top right corner to the parent node. And when I create the child node, CreateShapeNode(point, size) point argument can be anything?

What is correct way to use this?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to use DiagramNode.AttachTo() method?
Reply #1 - Jun 6th, 2015 at 9:29am
Print Post  
It should look like this:

Code
Select All
var parent = diagram.Factory.CreateShapeNode(100, 100, 100, 60);
var childSize = new Size(20, 20);
var child = diagram.Factory.CreateShapeNode(
	parent.Bounds.TopRight - (Vector)childSize / 2, childSize);
child.AttachTo(parent, AttachToNode.TopRight); 



The corner parameter of AttachTo only specifies which corner to follow when the parent node is resized, preserving initial distance from child to that corner. AttachTo does not move the node but only records its offset from argument, because the corner alone does not identify desired child position - you might want it centered, inner- or outer- aligned, with padding space added, etc.

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


I Love MindFusion!

Posts: 44
Joined: Aug 21st, 2013
Re: How to use DiagramNode.AttachTo() method?
Reply #2 - Jun 8th, 2015 at 9:04pm
Print Post  
Thanks!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint