Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Anchor Point changing style after connecting (Read 1913 times)
solisgsandc
YaBB Newbies
*
Offline



Posts: 40
Joined: Dec 18th, 2009
Anchor Point changing style after connecting
Feb 11th, 2010 at 4:57pm
Print Post  
Is there a property that I can set on the ShapeNode to have the anchor point change style from an X to a O ( circle ) when that particular anchor point is connected to a link?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Anchor Point changing style after connecting
Reply #1 - Feb 11th, 2010 at 7:14pm
Print Post  
There isn't. Try setting the point's MarkStyle to Custom and drawing the X/O in response to the DrawAnchorPoint event depending on whether there is a link connected to the point. In such case you might also have to call the node's Repaint method when a new link is connected to it.
  
Back to top
 
IP Logged
 
solisgsandc
YaBB Newbies
*
Offline



Posts: 40
Joined: Dec 18th, 2009
Re: Anchor Point changing style after connecting
Reply #2 - Feb 11th, 2010 at 7:50pm
Print Post  
Can you please send a sample code if possible?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Anchor Point changing style after connecting
Reply #3 - Feb 14th, 2010 at 10:50am
Print Post  
This seems to work:

Code
Select All
private void OnLinkCreated(object sender, LinkEventArgs e)
{
	UpdateAnchorPoints(e.Link.Origin);
	UpdateAnchorPoints(e.Link.Destination);
}

private void OnLinkModified(object sender, LinkEventArgs e)
{
	UpdateAnchorPoints(e.Link.Origin);
	UpdateAnchorPoints(e.Link.Destination);
}

private void UpdateAnchorPoints(DiagramNode node)
{
	if (node.AnchorPattern == null)
		return;

	var usedPoints = new Dictionary<int, bool>();

	foreach (DiagramLink link in node.IncomingLinks)
	{
		if (link.DestinationAnchor >= 0)
			usedPoints[link.DestinationAnchor] = true;
	}

	foreach (DiagramLink link in node.OutgoingLinks)
	{
		if (link.OriginAnchor >= 0)
			usedPoints[link.OriginAnchor] = true;
	}

	for (int i = 0; i < node.AnchorPattern.Points.Count; ++i)
	{
		AnchorPoint ap = node.AnchorPattern.Points[i];
		ap.MarkStyle = usedPoints.ContainsKey(i) ? MarkStyle.Circle : MarkStyle.X;
		ap.InvalidateVisual();
	}
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint