Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Constrain anchor points (Read 3548 times)
ChrisGC
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 2nd, 2010
Constrain anchor points
Jul 5th, 2010 at 10:21am
Print Post  
Hi,

I am doing a project based on the OrgChart sample. I programatically create a diagram (with custom shaped nodes) and perform a LayeredLayout:

[IMG]http://img251.imageshack.us/img251/5078/publishvacancy1394.jpg[/IMG]

I wish for the anchor points to be only in the middle (at top and bottom) of the node and use the following code:

[code]
foreach (var node in nodes)
{
var diagramNode = new OrgChartNode();
diagramNode.ImageWebLocation = "ac0026-64.png";
diagramNode.FullName = node.Attribute("FullName").Value;
diagramNode.JobTitle = node.Attribute("JobTitle").Value;
diagramNode.Department = node.Attribute("Department").Value;
diagramNode.RiskStatus = node.Attribute("RiskStatus").Value;
diagramNode.RoleType = node.Attribute("RoleType").Value;
diagramNode.IntSuccessors = node.Attribute("IntSuccessors").Value;
diagramNode.ExtSuccessors = node.Attribute("ExtSuccessors").Value;
diagramNode.MouseRightButtonDown += new MouseButtonEventHandler(diagramNode_MouseRightButtonDown);
diagramNode.MouseRightButtonUp += new MouseButtonEventHandler(diagramNode_MouseRightButtonUp);

// Anchors
AnchorPattern ap = new AnchorPattern(new AnchorPoint[]{new AnchorPoint(50, 0), new AnchorPoint(50, 100)});
diagramNode.AnchorPattern = ap;

diagram.Nodes.Add(diagramNode);
nodeMap[node.Attribute("id").Value] = diagramNode;
}
[/code]

Yet when i call:

[code]
var layout = new LayeredLayout(MindFusion.Diagramming.Silverlight.Layout.Orientation.Vertical, 80, 250, new Size(10, 10));
layout.LinkType = LayeredLayoutLinkType.Cascading;
layout.Arrange(diagram);

[/code]

The result is like in the above picture. Is there a way to constrain the anchor points as i would like (i have probably missed something very basic!)?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Constrain anchor points
Reply #1 - Jul 5th, 2010 at 11:14am
Print Post  
Hi,

Try setting layout.Anchoring = Anchoring.Reassign;

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


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 2nd, 2010
Re: Constrain anchor points
Reply #2 - Jul 5th, 2010 at 12:34pm
Print Post  
I tried that, before and after the Arrange call - no difference I'm afraid.
  
Back to top
 
IP Logged
 
ChrisGC
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 2nd, 2010
Re: Constrain anchor points
Reply #3 - Jul 5th, 2010 at 2:13pm
Print Post  
This code recreates the issue:

Code
Select All
	  public Page()
{
InitializeComponent();

		AnchorPattern ap = new AnchorPattern(new AnchorPoint[] { new AnchorPoint(50, 0, true, false), new AnchorPoint(50, 100, false, true) });

		diagram.DefaultShape = Shapes.RoundRect;

		ShapeNode pb1 = new ShapeNode(diagram);
		pb1.Bounds = new Rect(268.8, 268.8, 96, 69.12);
		pb1.AnchorPattern = ap;
		diagram.Nodes.Add(pb1);

		ShapeNode pb2 = new ShapeNode(diagram);
		pb2.Bounds = new Rect(268.8, 268.8, 96, 69.12);
		pb2.AnchorPattern = ap;
		diagram.Nodes.Add(pb2);

		ShapeNode pb3 = new ShapeNode(diagram);
		pb3.Bounds = new Rect(268.8, 268.8, 96, 69.12);
		pb3.AnchorPattern = ap;
		diagram.Nodes.Add(pb3);

		diagram.Links.Add(new DiagramLink(diagram, pb1, pb2));
		diagram.Links.Add(new DiagramLink(diagram, pb1, pb3));

		var layout = new LayeredLayout(MindFusion.Diagramming.Silverlight.Layout.Orientation.Vertical, 80, 250, new Size(10, 10));
		layout.LinkType = LayeredLayoutLinkType.Cascading;
		layout.Anchoring = Anchoring.Reassign;
		layout.Arrange(diagram);

}
 



If you move one of the nodes then the anchor pattern is honoured. (but not when first arranged).
  
Back to top
 
IP Logged
 
ChrisGC
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 2nd, 2010
Re: Constrain anchor points
Reply #4 - Jul 5th, 2010 at 2:29pm
Print Post  
Actually Anchoring.Keep does make the Arrange call honour the AnchorPoints.....

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Constrain anchor points
Reply #5 - Jul 5th, 2010 at 3:04pm
Print Post  
Reassign was broken indeed, this version should fix it:
https://mindfusion.eu/_beta/diaglite17_llanchoring.zip

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


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 2nd, 2010
Re: Constrain anchor points
Reply #6 - Jul 5th, 2010 at 3:21pm
Print Post  
Thanks - works with Reassign and Keep now.

Cheers
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint