We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to determine connected symbols?

Thread ID:

Created:

Updated:

Platform:

Replies:

57324 Mar 1,2007 01:21 PM UTC Mar 2,2007 11:24 PM UTC WinForms 3
loading
Tags: Diagram
Administrator [Syncfusion]
Asked On March 1, 2007 01:21 PM UTC

Hi,

I want to do the following:
when user connects 2 symbols using linktool, I need to check which symbols are connected and allow or deny this link, using some criteria.

I've tried to use ConnectionsChanging event, but
Connection.SourcePort and Connection.TargetPort do not contain the source and target symbols simultaneously in one call...



J.Nagarajan [Syncfusion]
Replied On March 1, 2007 05:59 PM UTC

Hi Ok,

The symbols connected with each other can be obtained using the following code snippet

private void diagram1_NodeDoubleClick(object sender, Syncfusion.Windows.Forms.Diagram.NodeMouseEventArgs evtArgs)
{
// To find which shape is connected to other shape
if (evtArgs.Node is Symbol)
{
Symbol symbol = evtArgs.Node as Symbol;
foreach(IGraphEdge edge in sym.Edges)
{
if(edge is Link)
{
Link link=edge as Link;
Symbol symbol1=link.FromNode as Symbol;
Symbol symbo2=link.ToNode as Symbol;
if(evtArgs.Node==symbo2)
MessageBox.Show(symbo2.Name+ " " + "connected to"+ " "+ symbo1.Name);

if(evtArgs.Node==symbo1)
MessageBox.Show(symbo1.Name +" "+ "connected to" + " "+symbo2.Name);
}
}
}
}

I have attached a sample that demonstrates all these features.

Please do the following to run the sample

1. Execute the attached sample.
2. Click "Add Symbols" button to draw the custom symbols.
3. Click LinkSuppor->Link menu item to activate the link tool.
4.Connect the link between two symbols and when you double click on the connected symbol, a MessageBox will show up, whether the symbol is connected or not.

You can down load the sample from the following html page.

http://websamples.syncfusion.com/samples/Diagram.Windows/F57324/main.htm

Please let me know if you have any questions.

Thanks,
Nagaraj

Administrator [Syncfusion]
Replied On March 2, 2007 09:19 AM UTC

Thanks,
but I do not want ask user to double click symbol in order to check which link he has just added.
What the earliest possible event allows me determine connected nodes?

J.Nagarajan [Syncfusion]
Replied On March 2, 2007 11:24 PM UTC

Hi Ok,

You can use the Diagram's ConnectionsChanging() event to do what you are seeking. Please refer to the following code snippet

Symbol sym1;
Symbol sym2;

private void diagram1_ConnectionsChanging(object sender, Syncfusion.Windows.Forms.Diagram.ConnectionCollectionEventArgs evtArgs)
{
if (evtArgs.Connection.SourcePort.GetType()==typeof(AnchoredPort))
{
this.textBox1.Text = (evtArgs.Connection.SourcePort.Parent.Name);
symbol1=evtArgs.Connection.SourcePort.Parent as Symbol;
}

if (evtArgs.Connection.TargetPort.GetType()==typeof(AnchoredPort))
{
this. textBox2.Text = (evtArgs.Connection.TargetPort.Parent.Name);
symbol2=evtArgs.Connection.TargetPort.Parent as Symbol;
}

if(symbol1.Name=="MySymbol")
{
evtArgs.Cancel=false;

}
else
{
evtArgs.Cancel=true;
MessageBox.Show("Connection Invalid");
}
}

I have attached the sample for your reference. In this sample you can get the source and destination nodes after creating the links. You can see the Name of the connected Nodes in the textbox.

Also you can allow or deny this link if the symbol1.Name is "MySymbol".

You can download this sample from the following link.

http://websamples.syncfusion.com/samples/Diagram.Windows/ConnectedSymbols/main.htm

Please refer to this sample and let me know if you have any questions

Thanks,
Nagaraj

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;