We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I extend the Link types present in Essential Diagram?

Platform: WinForms |
Control: Diagram |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

To create a new Link class or to customize the drawing for an existing link type, implement a subclass of the Syncfusion.Windows.Forms.Diagram.Link class with an appropriate override of the Link.CreateLinkShape(Link.Shapes shapeType, PointF[] pts) method. The CreateLinkShape method is called by the Link constructor and it is up to your override to suitably interpret the method parameters and returns a valid implementation of the Syncfusion.Windows.Forms.Diagram.IPoints interface. A sample override is shown below:

C#

// A subclass of the Syncfusion.Windows.Forms.Diagram.Link class

public class CustomLink : Syncfusion.Windows.Forms.Diagram.Link

{

// Override the Link.CreateLinkShape method to create a link for the specified type 

// and with the given points

protected override IPoints CreateLinkShape(Link.Shapes shapeType, PointF[] pts)

{

Shape linkShape = null;

  if(shapeType == Link.Shapes.OrthogonalLine)

   {

    OrthogonalLine orthogonalLine = new OrthogonalLine();

    orthogonalLine.AutomaticHeadings = true;

    linkShape = orthogonalLine;

   }

   if(linkShape != null)

   {

    linkShape.SetPoints(pts);

   }

   return linkShape;

}

}

Now all that is required to use this Link type is to provide to the LinkTool a LinkFactory delegate that instantiates this newly defined Link type when the tool is activated. A sample implementation is shown below:

C#

// Create a Link tool for the custom link type

LinkTool customLinkTool = new LinkTool("CustomLinkTool");

customLinkTool.LinkFactory = new LinkFactory(this.CreateCustomLink);

// Register this tool with the Diagram Controller

this.diagram.Controller.RegisterTool(customLinkTool);

// LinkFactory delegate for instantiating the CustomLink

protected Link CreateCustomLink(PointF[] pts)

{

CustomLink mylink = new CustomLink(Link.Shapes.OrthogonalLine, pts);

return mylink;

}

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon