/// <summary> /// Creates a link shape matching the type specified by the /// <see cref="Syncfusion.Windows.Forms.Diagram.Link.Shapes"/> /// enumeration and load its with the given array of points. /// </summary> /// <param name="shapeType">Type of shape to create</param> /// <param name="pts">Points to initialize shape with</param> /// <returns>IPoints interface to the link shape object created</returns> /// <remarks> /// <para> /// A link shape can be any type of node that supports the /// <see cref="Syncfusion.Windows.Forms.Diagram.IPoints"/> /// interface. This method supports creating one of the following /// types of link shapes: /// <see cref="Syncfusion.Windows.Forms.Diagram.Line"/>, /// <see cref="Syncfusion.Windows.Forms.Diagram.OrthogonalLine"/>, /// <see cref="Syncfusion.Windows.Forms.Diagram.PolyLine"/>, and /// <see cref="Syncfusion.Windows.Forms.Diagram.Arc"/>. If /// <see cref="Syncfusion.Windows.Forms.Diagram.Link.Shapes.Default"/> /// is specified, then a polyline is created. /// </para> /// <para> /// This method can be overridden in derived classes to support the /// creation of other types of link shapes. /// </para> /// <seealso cref="Syncfusion.Windows.Forms.Diagram.Link.Shapes"/> /// <seealso cref="Syncfusion.Windows.Forms.Diagram.IPoints"/> /// </remarks> protected virtual IPoints CreateLinkShape(Link.Shapes shapeType, PointF[] pts) { Shape linkShape = null; switch (shapeType) { case Link.Shapes.Line: linkShape = new Line(); break; case Link.Shapes.OrthogonalLine: linkShape = new OrthogonalLine(); break; case Link.Shapes.Arc: linkShape = new Arc(); break; default: linkShape = new PolyLine(); break; } if (linkShape != null) { linkShape.SetPoints(pts); } return(linkShape); }
/// <summary> /// Creates a link with a given type of shape and an array of points. /// </summary> /// <param name="shapeType">Type of shape to create</param> /// <param name="pts">Array of points to load the shape with</param> /// <remarks> /// <para> /// Calls the /// <see cref="Syncfusion.Windows.Forms.Diagram.Link.CreateLinkShape"/> /// method passing it the /// <see cref="Syncfusion.Windows.Forms.Diagram.Link.Shapes"/> /// parameter and the array of points. An object supporting the IPoints /// interface is returned by the CreateLinkShape method, which is /// then added as the first child node in the link. /// </para> /// <seealso cref="Syncfusion.Windows.Forms.Diagram.Link.CreateLinkShape"/> /// <seealso cref="Syncfusion.Windows.Forms.Diagram.IPoints"/> /// </remarks> public Link(Link.Shapes shapeType, PointF[] pts) { IPoints linkPoints = this.CreateLinkShape(shapeType, pts); if (linkPoints != null) { INode childNode = linkPoints as INode; if (childNode != null) { this.AppendChild(childNode); } } this.Ports.Add(CreateTailPort()); this.Ports.Add(CreateHeadPort()); }