NShape Programmer Tasks
Connecting Shapes

<< Click to Display Table of Contents >>

Navigation:  Programmer Tasks >

NShape Programmer Tasks
Connecting Shapes

Previous pageReturn to chapter overviewNext page

Two shapes, one of them usually being a line-type one, can be connected in two ways, either point-to-point or point-to-shape (see "Concepts: Shape Connections").

To Connect two shapes point-to-point:

Lets say there are two shapes in the diagram one a line called line and the other one a circle called circle.

1.Use the Shape.Connect method to connect the two shapes. You can call the method on either side, however you want. Let us say you call it on the active, the glue point side, i.e. on the line side.

2.Pass the glue point's control id to define which glue point of the connecting shape you want to use. For a line, you will mostly use either ControlPointId.FirstVertex or ControlPointId.LastVertex.

3.Pass the shape you want to connect to.

4.Pass the control point id of the connection point you want to connect to. You can look-up the control point ids in the template editor as mentioned in "Concepts: Shape Connections":
line.Connect(ControlPointId.FirstVertex, circle, 8).

To Connect two shapes point-to-shape:

Lets say there are two shapes in the diagram one a line called line and the other one a circle called circle.

1.Use the Shape.Connect method to connect the two shapes. You can call the method on either side, however you want. Let us say you call it on the active, the glue point side, i.e. on the line side.

2.Pass the glue point's control id to define which glue point of the connecting shape you want to use. For a line, you will mostly use either ControlPointId.FirstVertex or ControlPointId.LastVertex.

3.Pass the shape you want to connect to.

4.In order to indicate that you want a shape-to-shape connection, use ControlPointId.Reference as the control point id:
line.Connect(ControlPointId.FirstVertex, circle, ControlPointId.Reference).