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
|
Hi, Can I limit the quantity of connections for a ConnectionPoint of a Shapenode ? Exemple with a node sn, if I want only one connection for the ConnectionPoints[0] : sn.ConnectionPoints[0] shouldn't have more than 1 connection. So sn.ConnectionPoints[0].Connections[1] could never exist. Can I do this? Thank you |
|
|
Hello Leon Yes, we provide multiple places where you can provide connectivity constraints. - nodes, connection-points, and connection builders/relocators. It sounds like you want to put your logic within a connection point. In order to do this, you will need to create a custom connection point implementation which you could do simply by extending DiagramConnectionPoint. Then in this custom class, override either the CanOriginateNewConnections or CanRecieveNewConnections properties (or both if necessary). These properties will always be checked when the user starts to create a connection from a node (CanOriginate), or tries to drop the end of a new connection onto a node (CanRecieve). Here is a quick example:
This logic only allows a connection to be created if there currently are no connections. Once the connection point is connected, it will then be effectively locked and not allow any more connections to be created - until the connection is deleted. Make sure to always call the base property in your logic which will check that the node that the point is on also allows a new connection. Also, make sure to now use instances of your custom connection point when setting up the connection points in the constructor of your nodes. If you are using ShapeNode instead of your own custom node implementation, you'll need to either extend ShapeNode or DiagramNode so that you can tell it to use instances of your custom connection point. If you extend ShapeNode, you'll first need to empty the ShapeNode.ConnectionPoints collection which the ShapeNode base constructor will populate. Nodes also have the CanOriginateNewConnections and CanRecieveNewConnections properties which you can override if you need to write connectivity logic that effects a whole node. For example, only allowing a node to have 1 input to any point, but multiple outputs. Let me know if you have any questions. Connectivity logic can get quite complicated. -Jason Fauchelle |
|
|
Thank you, it works |
|