Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic family tree without custom nodes (Read 2844 times)
Amit2
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: Apr 3rd, 2015
family tree without custom nodes
Apr 3rd, 2015 at 3:51pm
Print Post  
Hello,

We are very interested in using your diagramming pack libraries to draw family trees as article from your site (seems I'm disallowed to link it from first forum post). But could you show example how to realize same tree layout using grouped nodes as hinted? We are not keen implementing inherited nodes as it seems we have to also write csutom serialization code to show saved diagram in various platforms, while ShapeNode objects load without problems.

With kind regards,
Amit
  
Back to top
 
IP Logged
 
Amit2
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: Apr 3rd, 2015
Re: family tree without custom nodes
Reply #1 - Apr 3rd, 2015 at 3:51pm
Print Post  
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: family tree without custom nodes
Reply #2 - Apr 7th, 2015 at 8:36am
Print Post  
Hi,

You can find modified layout code here:
http://mindfusion.eu/_samples/GenealogyForm.cs

In short, replace all occurrences of custom class with ShapeNode, run layout with KeepRootPosition property enabled, and use these modified AddNode methods:

Code
Select All
ShapeNode AddNode(Person p)
{
	var bounds = new RectangleF(0, 0, 30, 40);

	var node = new ShapeNode();
	node.Bounds = bounds;
	node.Tag = new List<Person> { p };
	node.AnchorPattern = AnchorPattern.TopInBottomOut;
	node.Image = p.Image;
	node.Pen = new MindFusion.Drawing.Pen(
		p.Gender == Gender.Female ? Color.Red : Color.BlueViolet, 0);
	node.Text = p.Name;
	node.TextFormat.Alignment = StringAlignment.Center;
	node.TextFormat.LineAlignment = StringAlignment.Far;

	diagram.Nodes.Add(node);
	return node;
}

ShapeNode AddNode(Person p1, Person p2)
{
	var bounds = new RectangleF(0, 0, 70, 40);

	var pairContainer = new ShapeNode();
	pairContainer.Bounds = bounds;
	pairContainer.Tag = new List<Person> { p1, p2 };
	pairContainer.AnchorPattern = PairPattern;
	pairContainer.Transparent = true;
	diagram.Nodes.Add(pairContainer);

	var p1Node = AddNode(p1);
	var p2Node = AddNode(p2);
	p2Node.Bounds = new RectangleF(40, 0, 30, 40);
	p1Node.AttachTo(pairContainer, AttachToNode.TopLeft);
	p2Node.AttachTo(pairContainer, AttachToNode.TopLeft);

	return pairContainer;
} 



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


I Love MindFusion!

Posts: 5
Joined: Apr 3rd, 2015
Re: family tree without custom nodes
Reply #3 - Apr 7th, 2015 at 10:23am
Print Post  
Hello Stoyo!

Thanks, that was helpful. The pairs you are binding in the tree are naive simplification tho' - If you start showing progeny from multiple marriages and step relatives or more deviant relations in historical families it could get a lot more messy Wink It is a nice base still and we should be able to develop it further from here for more 'extended' families.

With kind regards,
Amit
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint