AddConnector()

ShapeCollection::AddConnector(ShapeType, float, float, float, float) method

Creates a new Connector, tunes it from default template and adds it to the end of the collection.

System::SharedPtr<IConnector> Aspose::Slides::ShapeCollection::AddConnector(ShapeType shapeType, float x, float y, float width, float height) override

Arguments

ParameterTypeDescription
shapeTypeShapeTypeThe ShapeType of shape.
xfloatThe X-coordinate for a left side of shape’s frame.
yfloatThe Y-coordinate for a top side of shape’s frame.
widthfloatThe width of shape’s frame.
heightfloatThe height of shape’s frame.

Return Value

The zero-based index of the created shape.

Created Connector object.

Remarks

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

// Instantiates a presentation class that represents a PPTX file
auto input = System::MakeObject<Presentation>();

// Accesses the shapes collection for a specific slide
auto shapes = input->get_Slides()->idx_get(0)->get_Shapes();
// Adds an Ellipse autoshape
System::SharedPtr<IAutoShape> ellipse = shapes->AddAutoShape(ShapeType::Ellipse, 0.0f, 100.0f, 100.0f, 100.0f);
// Adds a Rectangle autoshape
System::SharedPtr<IAutoShape> rectangle = shapes->AddAutoShape(ShapeType::Rectangle, 100.0f, 300.0f, 100.0f, 100.0f);

// Adds a connector shape to the slide shape collection
System::SharedPtr<IConnector> connector = shapes->AddConnector(ShapeType::BentConnector2, 0.0f, 0.0f, 10.0f, 10.0f);
// Connects the shapes using the connector
connector->set_StartShapeConnectedTo(ellipse);
connector->set_EndShapeConnectedTo(rectangle);
// Calls reroute that sets the automatic shortest path between shapes
connector->Reroute();

// Saves the presentation
input->Save(u"Shapes-connector.pptx", SaveFormat::Pptx);

ShapeCollection::AddConnector(ShapeType, float, float, float, float, bool) method

Creates a new Connector and adds it to the end of the collection.

System::SharedPtr<IConnector> Aspose::Slides::ShapeCollection::AddConnector(ShapeType shapeType, float x, float y, float width, float height, bool createFromTemplate) override

Arguments

ParameterTypeDescription
shapeTypeShapeTypeThe ShapeType of shape.
xfloatThe X-coordinate for a left side of shape’s frame.
yfloatThe Y-coordinate for a top side of shape’s frame.
widthfloatThe width of shape’s frame.
heightfloatThe height of shape’s frame.
createFromTemplateboolIf true then new shape will be tuned from default template. Not empty name, simple style, text centered will be assined to the new shape. If false then all values of the properties of the new shape will have default values.

Return Value

The zero-based index of the created shape.

Created Connector object.

See Also