This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello, I tried to prevent a Connection creation (I look at my conditions and then I try to remove the Connection) in a ConnectionsCollectionChange event, but it doesn't work. I know it's because I can't edit the Collection when I am in his Change event. It's OK for me. But can I do this implementation somewhere else? I want to prevent a Connection creation depending on the FromConnectionPoint and the ToConnectionPoint. The final aim is to prevent a 'loop' in the connections, there mustn't be any loop of Nodes/Connections on the Diagram. Thank you ! Leon |
|
|
Hello Leon Yes we provide a convenient place for this logic to be placed. What you'll want to do is create a class that implements the IDiagramConnectionBuilder interface. In the CanCreateConnection method, you get the fromConnectionPoint as a parameter, and dropTarget.ConnectionPoint provides the destination connection point. If the dropTarget or dropTarget.ConnectionPoint is null, just return true. Otherwise, if the two connection points exist on the same node (i.e. they have the same Connectable property value) then return false. In the CreateConnection method, simply create an instance of whatever type of connection you want - using the two given connection points, and then add that connection instance to the diagram.Connections collection. Let me know if you have any questions about this. -Jason Fauchelle |
|
|
Hi Jason, Thank you for your answer, I understood what you explained to me, but how can I tell to the diagram to use my ConnectionBuilder class instead of the default ConnectionBuilder class? Thank you. |
|
|
Hello Leon Ah yes, I'd forgotten to mention. This can be done by setting the DefaultConnectionBuilder property of the IDiagramModel. (Your diagram model is probably an instance of the Diagram class). Let me know if you have questions about this. -Jason Fauchelle |
|
|
Ok nice, thank you Jason. I wrote this code :
And I had to create a new Diagram instance (I didn't succeed in change DefaultConnectionBuilder of default ds.Diagram (readonly)) :
And now it works. |
|
|
Hello Leon Great to hear you've got it all working. -Jason Fauchelle |
|