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.
Unfortunately, activation email could not send to your email. Please try again.

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

 

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;

}

Article ID: Published Date: Last Revised Date: Platform: Control:
183 04/30/2011 07/10/2014 Windows Forms Diagram
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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.