Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Specify the link to which Click event happens (Read 2146 times)
leo2015
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Nov 13th, 2015
Specify the link to which Click event happens
Nov 13th, 2015 at 2:23am
Print Post  
Dear all,
I am amazed by the typical features provided by Mindfusion framework and currently using the trial version of Diagramming Winform to develop my own business application.
I have one specific technical question on the use of DiagramBase.LinkClicked Event, in which I would like to know if it is possible to specify specific link to which the Click event happens.
In Developer's guide , I see that creating the Linkclicked Event can capture when user clicks on the link in the diagram. But that is valid for all links existing in the diagram. Does everyone know how to specify the Click Event for each created link respectively in the diagram?
Thanks in advance.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Specify the link to which Click event happens
Reply #1 - Nov 13th, 2015 at 5:42am
Print Post  
Hi,

Click events are raised only by the Diagram / DiagramDocument classes. If they were raised by individual links, you would lose the event handler bindings after loading a diagram file and would need to reattach them to newly loaded links. If you'd like separate click methods called for specific type of links, e.g. inherited classes or having specific Id/Tag values, you could use the diagram.LinkClicked handler only as a dispatcher calling them:

Code
Select All
void MyLinkClicked(object sender, LinkEventArgs e)
{
}

void AssociationClicked(object sender, LinkEventArgs e)
{
}

private void diagram_LinkClicked(object sender, LinkEventArgs e)
{
	var link = e.Link;
	if (link is MyLink)
		MyLinkClicked(sender, e);
	if ("Association".Equals(link.Tag))
		AssociationClicked(sender, e);
} 



If you really need per-instance event handler bindings, you could keep them in a Dictionary<DiagramLink, EventHandler<LinkEventArgs>> and call associated handlers for each link from diagram's handler.

Or if you define a custom link class, you could define Click event there and call MyLink.RaiseClick(...) from diagram's handler. In both last two scenarios you will have to take care of rebinding links to handlers after calling LoadFromFile/Xml methods though.

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