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
|
Jason, Is there anyway that I can associate a Node (with a small circle shape) with a connection, and this Node can only move along the connection. When the connection moves, the node should also follow. Thank you! Xiaochu |
|
|
Hello Xiaochu This is functionality you will need to implement at your end. In the node implementation, you could listen to when it's bounds property changes, and as a result, adjust the bounds to ensure that it is snapped to closest point on it's associated connection. Similarly, listen to when the Segments collection of a connection is changed and again adjust the position of the node. DiagramConnectionSegment has a method called GetClosestPointTo which gives you the closest point on the segments line to the given Point. The buffer value lets you limit how close to either end of the segment the point can be. Use a buffer of 0 if you want the node to be moved all the way to the ends of each segment. Let me know if you have further questions about this. -Jason Fauchelle |
|
|
Jason, I tried what you suggested and it works for the most part. There is only one small thing as shown in pic3, it seems that the method GetClosestPointTo does not consider the rounded curve of the corner. Thank you! Xiaochu |
|
|
Hello Xiaochu Unfortunately this is somewhat expected. The GetClosestPointTo method works purely with the model objects of the diagram. But the rounded corners are provided by a path-builder which takes the model objects (that don't have any notion of rounded corners) and then adds the rounded corners to the connection visual. There are 2 ways to work around this: You could use that buffer parameter I mentioned to limit how far the circle can get to the end of each segment. That way it can not appear off the connection at the corner. Or, you will need to implement your own GetClosestPointTo method which assumes the visual appearance of the connections, and incorporates the rounded corners into the calculation. Here is the code for GetClosestPointTo to help you get started:
The GeometryUtils.Distance method simply calculates and returns the distance between 2 points. -Jason Fauchele |
|