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. Image for the cookie policy date
close icon

Howto disallow changing a connection

Hi, I am creating a diagram programaticaly. It contains custom symbols and custom links from a database. I also want to allow a user to add additional symbols and links like in DiagramBuilder sample. How can I disallow changing the links between symbols created from database (change / remove / add)? The user still has to select these symbols/links or move parts of ortogonal links. All other links should be changed, added or removed. Regards, Christian

7 Replies

AD Administrator Syncfusion Team July 17, 2006 04:15 PM UTC

Hi Christian, Thanks for your interest in Syncfusion products. You can avoid changing links between specific symbols by overriding the AcceptConnection( ) method within the custom symbol class. This is demonstrated in many of the diagram samples. Kindly refer the Samples\InDepth\OrgLayout in particular. And referring to the sample''s EmployeeSymbol(Custom Symbol) class AcceptConnection() method will give you an idea about what you are looking for. Please let us know if you have any queries. Thanks & Regards, Ramya.


CL Christian Lützenkirchen July 21, 2006 03:44 PM UTC

Hi Ramya,

Thank you for your reply. I looked at the OrgLayout sample but it doesn''t help. I want to implement the following rules:

1. Any Syncfusion.Windows.Forms.Diagram.Link can connect to any Shape except my own ObjectSymbol class. This could be achieved by overwriting the AcceptConnection() method.
2. Any type ObjectLink (derived from Syncfusion.Windows.Forms.Diagram.Link) must not be changed. I tried the following:
a.) I included public override void OnConnectionMove(Connection connection) in my ObjectLink class. This member is not called when I change the connection.
b.) I added a Syncfusion.Windows.Forms.Diagram.ConnectionCollectionEventHandler to my ConnectionsChanging Event of the diagram. This event is called but setting the evtArgs.Cancel = true has a strange behaviour. The ObjectLink is placed near the target but not connected when the target symbol is moved. When you move the original symbol, the link is moved too (seems to be a bug).

I cannot override AcceptConnection() because I have other symbols that are not subclassed.

Is there any canceable event when a Link is disconnected from a Symbol?

Regards,
Christian


AD Administrator Syncfusion Team July 24, 2006 12:52 PM UTC


Hi Christian,

You can restrict the links from being edited by the end users by disabling the corresponding edit style of the node . For E.g. if your intension is not to allow the users from being select a link, link''s EditStyle.AllowSelect property should be set to false. Please refer the following sample code snippet for reference.

//add to the coding part of link creation link.EditStyle.AllowSelect=false;

//add to coding part of symbol creation, after the symbol is appended to the diagram symbol.EditStyle.AllowMove=false;

Please let me know if I am wrong in getting your requirement.

Thanks,

Ramya.


CL Christian Lützenkirchen July 29, 2006 06:14 AM UTC

Hi Ramya,

disallowing selection is not possible because the user must be able to select a link to open a dialog to change the style (color etc). Do you have any other ideas?

Thanks & Regards
Christian


CL Christian Lützenkirchen August 24, 2006 08:32 AM UTC

Hi Ramya,

any ideas?

Regards,
Christian


AD Administrator Syncfusion Team August 28, 2006 01:21 PM UTC

Hi Christian,

My apologies for the delay in getting back to you.

1.You can avoid adding link to your ObjectSymbol Class using following code snippet.

private void diagram1_ConnectionsChanging(object sender, ConnectionCollectionEventArgs evtArgs)
{
if(evtArgs.Connection.SourcePort.Container is MySymbol && this.diagram1.Controller.ActiveTool!=CustomLinkTool)
{
evtArgs.Cancel=true;
}
}


2.The links can be avoided from getting edited using Link.EditStyle.Enabled property(i.e avoid links from moving).

3.To avoid changing paths of link the LineSegmentTool has to be deactivated as shown in the code snippet below,

private void diagram_Controller_ToolActivate(object sender, Syncfusion.Windows.Forms.Diagram.DiagramController.ToolEventArgs evtArgs)
{
if(evtArgs.Tool.Name =="LineSegmentTool" &&this.diagram.SelectionList.First is CustomOrthogonalLink)
{
LineSegmentTool tool = (LineSegmentTool)evtArgs.Tool;
this.diagram.Controller.DeactivateTool(tool);

}
}

Kindly look into attached a sample to get the above points in clear.

Let me know if you have any queries.


Thanks,
Ramya.


Links0.zip


CL Christian Lützenkirchen September 4, 2006 07:59 AM UTC

Hi Ramya,

thank you for your sample. Number 2.) is the solution what I was looking for!!! So simple ...

Thanks,
Christian

Loader.
Live Chat Icon For mobile
Up arrow icon