The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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.J.Nagarajan Syncfusion Team 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);
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.
ADAdministrator Syncfusion Team 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.J.Nagarajan Syncfusion Team 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; }
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.