Can two linear shapes be connected?

Jan 24, 2013 at 6:26 AM


Can two linear shapes be connected?

In other words, can method <ILinearShape instance>.GetConnectionInfos(FirstVertex or LastVertex) return ShapeConnectionInfo object having .OtherShape also of ILinearShape type?

Jan 24, 2013 at 7:06 AM

Yes, you can connect the first/last vertex (Glue Point) of a linear shape with a connection point of a line.

Connection points of a line can be vertices (ControlPointCapabilities.Resize and ControlPointCapabilities.Connect) or pure connection points (ControlPointCapabilities.Connect only). Connection points can be inserted/removed with
    ControlPointId AddConnectionPoint(int x, int y)
    ILinearShape.RemoveConnectionPoint(ControlPointId id)
or by right-clicking any part of the line (not a vertex) and choosing "Insert Connection Point" from the context menu.

Jan 24, 2013 at 8:46 AM

Thank you for the answer.

Another question: imagine the following sequence of actions:

  • Manually created and connected two Linear Shapes.
  • Saved all vertices of both to some "storage" (doesn't matter which one exactly - any storage capable to store triples { ShapeID; X; Y } will be OK).
  • Deleted both shapes.
  • Manually (or programmatically) created them again - but not connected.
  • Loaded and applied all their vertices from the "storage".

Question: will the shapes get automatically connected in the end?

When we manually drag a glue point of first shape to match some connection point of second shape - this is enough for NShape's core to make these shapes connected. So I just wonder if the same vertex "match" - but made from code and not by dragging - will also make shapes connected.

Jan 25, 2013 at 7:00 AM
Edited Jan 25, 2013 at 7:00 AM

The ShapeConnectionInfos are managed/stored/loaded seperately in the repository/store. Loading diagrams (from a storage that does not support partial loading) performs the following actions in this sequence:

  1. Load diagram object
  2. Load all shapes of this diagram
  3. Load all ShapeConnections
  4. Connect the shapes according to the loaded shape connections

Moving a line's active connection point (GluePoint) over a connection point will not trigger a "connect" action.