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.
Unfortunately, activation email could not send to your email. Please try again.

Howto disallow changing a connection

Thread ID:

Created:

Updated:

Platform:

Replies:

46560 Jul 15,2006 07:12 AM Sep 4,2006 03:59 AM Windows Forms 7
loading
Tags: Diagram
Christian Lützenkirchen
Asked On July 15, 2006 07:12 AM

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

Administrator [Syncfusion]
Replied On July 17, 2006 12:15 PM

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.

Christian Lützenkirchen
Replied On July 21, 2006 11:44 AM

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

Administrator [Syncfusion]
Replied On July 24, 2006 08:52 AM


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.

Christian Lützenkirchen
Replied On July 29, 2006 02:14 AM

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

Christian Lützenkirchen
Replied On August 24, 2006 04:32 AM

Hi Ramya,

any ideas?

Regards,
Christian

Administrator [Syncfusion]
Replied On August 28, 2006 09:21 AM

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

Christian Lützenkirchen
Replied On September 4, 2006 03:59 AM

Hi Ramya,

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

Thanks,
Christian

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.

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.

;