AddConnector

AddConnector(ShapeType, float, float, float, float)

Creates a new connector shape with default template styling and adds it to the end of the shape collection.

public IConnector AddConnector(ShapeType shapeType, float x, float y, float width, float height)
ParameterTypeDescription
shapeTypeShapeTypeThe ShapeType of the connector shape to add.
xSingleThe x-coordinate of the connector’s frame, in points.
ySingleThe y-coordinate of the connector’s frame, in points.
widthSingleThe width of the connector’s frame, in points.
heightSingleThe height of the connector’s frame, in points.

Return Value

The newly created IConnector.

Examples

The following example shows how to add a connector (a bent connector) between two shapes (an ellipse and rectangle) in PowerPoint Presentation.

[C#]
// Instantiates a presentation class that represents a PPTX file
using (Presentation input = new Presentation())
{
    // Accesses the shapes collection for a specific slide
    IShapeCollection shapes = input.Slides[0].Shapes;
    // Adds an Ellipse autoshape
    IAutoShape ellipse = shapes.AddAutoShape(ShapeType.Ellipse, 0, 100, 100, 100);
    // Adds a Rectangle autoshape
    IAutoShape rectangle = shapes.AddAutoShape(ShapeType.Rectangle, 100, 300, 100, 100);
    // Adds a connector shape to the slide shape collection
    IConnector connector = shapes.AddConnector(ShapeType.BentConnector2, 0, 0, 10, 10);
    // Connects the shapes using the connector
    connector.StartShapeConnectedTo = ellipse;
    connector.EndShapeConnectedTo = rectangle;
    // Calls reroute that sets the automatic shortest path between shapes
    connector.Reroute();
    // Saves the presentation
    input.Save("Shapes-connector.pptx", SaveFormat.Pptx);
}

See Also


AddConnector(ShapeType, float, float, float, float, bool)

Creates a new connector shape and adds it to the end of the shape collection, optionally applying default template styling.

public IConnector AddConnector(ShapeType shapeType, float x, float y, float width, float height, 
    bool createFromTemplate)
ParameterTypeDescription
shapeTypeShapeTypeThe ShapeType of the connector shape to create.
xSingleThe x-coordinate of the connector’s frame, in points.
ySingleThe y-coordinate of the connector’s frame, in points.
widthSingleThe width of the connector’s frame, in points.
heightSingleThe height of the connector’s frame, in points.
createFromTemplateBooleanTrue to apply default template styling (non-empty name, simple style); false to create the connector with default property values.

Return Value

The newly created IConnector.

See Also