Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How can I Restrict to link once for one anchor? (Read 3826 times)
khstar
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Apr 23rd, 2009
How can I Restrict to link once for one anchor?
May 6th, 2009 at 6:46am
Print Post  
Hello~
As I wrote as title,..
How can I Restrict to link just once for one anchor?

For now, I can link several times for one anchor. However It will make errors for my application...
Where can I fix this problem?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How can I Restrict to link once for one anchor
Reply #1 - May 6th, 2009 at 8:03am
Print Post  
Hi,

The control does not provide built-in support for this. Try to handle the ValidateAnchorPoint event, and set e.Cancel = true if any of the links that are already connected to the node has its OriginAnchor / DestinationAnchor set to the one for which the event is raised.

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


I love YaBB 1G - SP1!

Posts: 19
Joined: Apr 23rd, 2009
Re: How can I Restrict to link once for one anchor
Reply #2 - May 6th, 2009 at 8:52am
Print Post  
Thank you for a reply~

However,.. Could you Show me an Example code shortly?
I cannot find out the way.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How can I Restrict to link once for one anchor
Reply #3 - May 6th, 2009 at 10:02am
Print Post  
Code
Select All
private void diagram_ValidateAnchorPoint(object sender, LinkValidationEventArgs e)
{
	if (CountLinks(e.Node, e.AnchorIndex, e.Link) > 0)
		e.Cancel = true;
}

private int CountLinks(DiagramNode node, int anchorIndex, DiagramLink skipThisLink)
{
	int c = 0;
	foreach (DiagramLink link in node.IncomingLinks)
	{
		if (link == skipThisLink)
			continue;
		if (link.DestinationAnchor == anchorIndex)
			c++;
	}
	foreach (DiagramLink link in node.OutgoingLinks)
	{
		if (link == skipThisLink)
			continue;
		if (link.OriginAnchor == anchorIndex)
			c++;
	}
return c;
}
 



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


I love YaBB 1G - SP1!

Posts: 19
Joined: Apr 23rd, 2009
Re: How can I Restrict to link once for one anchor
Reply #4 - May 6th, 2009 at 11:17pm
Print Post  
Thank you so much!!



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