Connection point with both Connect and Glue capabilities

Mar 20, 2013 at 3:21 PM
Why can't we have a connection point with both Connect and Glue capabilities?
This gives us an exception because of the following code in the ShapeBase.Connect() method:
// 2. The target shape's control point must not be a glue point
if (otherShape.HasControlPointCapability(otherPointId, ControlPointCapabilities.Glue))
    throw new NShapeException(string.Format("{0}'s point {1} and {2}'s point {3} are both glue points. At least one connection point is required for a connection between shapes.", Type.Name, ownPointId, otherShape.Type.Name, otherPointId));
The statement "At least one connection point is required for a connection between shapes" is not correct because both points do have the Connect capability! Yes, they both also have the Glue capability - but this shouldn't be a problem. Or I'm wrong?
Mar 20, 2013 at 3:59 PM
One connection point cannot be glue point and connection point at the same time:
A GluePoint is an "Active connection point" that attaches to a "passive connection point". The active point follows the passive point when it is moved.
So if you were able to connect a glue point with another glue point, both of them would follow their partner... ending in an endless loop.

Create a connection point (not a vertex) at the position of the glue point using
ILinearShape.AddConnectionPoint(int x, int y)
or right-clicking the line and selecting "Insert Connection Point" from the context menu.
You can attach other lines to this passive connection point and as it is not a vertex, it will move with the line.
Mar 20, 2013 at 4:06 PM
Thank you for explanation.
I just wanted to have a rectangle-based shape with 8 connection points which all are also glue points, so that there's a great freedom in connecting two shapes of this kind.
Mar 22, 2013 at 3:42 PM
Maybe I was not very clear.
I do not want to say that one and the same (physically) control point (of the same shape instance) must be glue and connection point at the same time.
I want to say that if I have two shapes on my Diagram both derived from PreparationSymbol type, I want the TopRight point of the first shape to serve as a glue point, and the TopRight point of the second shape - to serve as a connection point. And the problem is that I do not understand how should I override the HasControlPointCapability() method to achieve this result.
Mar 25, 2013 at 1:36 PM
Take a look at shape class LabelBase. This is a rectangle shape with a glue point that is used to pin it to other shapes.
In addition to give the control point the "Glue" capability, you have to implement FollowConnectionPointWithGluePoint() which defines how the shape behaves when its partner shape moves away.