This project has moved and is read-only. For the latest updates, please go here.

Programmatically connect a polyline between 2 shapes( rectanglebase)

Sep 20, 2012 at 5:54 PM

How do i programmatically connect a polyline between 2 shapes( rectanglebase).

I want to programatically connect a new polyline and join it to 2 existing shapes(rectangles)

how do i do this?

(i saw something similar in this forum..but it was connecting a label to shape)

Sep 21, 2012 at 8:17 AM

For a connection between shapes you need the ControlPointIds of the shapes (use GetControlPointIds or FindNearestControlPoint), move the line's control point to the target position and call the line shape's Connect method:

// Get the target position for the line's glue point
ControlPointId rectPointId = 2;
Point p = rectShape.GetControlPointPosition(rectPointId);
// Move the line's glue point to the target position and establish the connection
ControlPointId gluePointId = ControlPointId.FirstVertex;
lineShape.MoveControlPointTo(gluePointId, p.X, p.Y, ResizeModifiers.None);
lineShape.Connect(gluePointId, rectShape, rectPointId);