AD
Administrator
Syncfusion Team
January 11, 2005 09:19 PM UTC
Hi Suwit,
I am assuming you are referring to creating a custom Link type. To customize the Link drawing, 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 that renders the link. A sample override is shown below,
// Override the Link.CreateLinkShape method in a Link subclass
protected override IPoints CreateLinkShape(Link.Shapes shapeType, PointF[] pts)
{
Shape linkShape = null;
if(shapeType == Link.Shapes.Arc)
{
OrthogonalLine orthogonalLine = new OrthogonalLine();
orthogonalLine.AutomaticHeadings = true;
linkShape = orthogonalLine;
}
if(linkShape != null)
{
linkShape.SetPoints(pts);
}
return linkShape;
}
Now to use your Link class all that is required is to provide a suitable LinkFactory delegate to the LinkTool that create the Link type that you have defined. A sample implementation as used in the DiagramBuilder sample is shown below,
// Create and register a tool for arc links
LinkTool arcLinkTool = new LinkTool("ArcLinkTool");
arcLinkTool.LinkFactory = new LinkFactory(this.CreateArcLink);
this.diagram.Controller.RegisterTool(arcLinkTool);
// Implement the LinkFactory delegate
protected Link CreateArcLink(PointF[] pts)
{
Link link = new Link(Link.Shapes.Arc, pts);
return link;
}
I hope this helps.
Regards,
Prakash
SU
suwit
January 12, 2005 02:40 PM UTC
Thanks,
but??? where is middle arrow in the code?
>Hi Suwit,
>
>I am assuming you are referring to creating a custom Link type. To customize the Link drawing, 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 that renders the link. A sample override is shown below,
>
>// Override the Link.CreateLinkShape method in a Link subclass
>protected override IPoints CreateLinkShape(Link.Shapes shapeType, PointF[] pts)
>{
> Shape linkShape = null;
> if(shapeType == Link.Shapes.Arc)
> {
> OrthogonalLine orthogonalLine = new OrthogonalLine();
> orthogonalLine.AutomaticHeadings = true;
> linkShape = orthogonalLine;
> }
>
> if(linkShape != null)
> {
> linkShape.SetPoints(pts);
> }
>
> return linkShape;
>}
>
>Now to use your Link class all that is required is to provide a suitable LinkFactory delegate to the LinkTool that create the Link type that you have defined. A sample implementation as used in the DiagramBuilder sample is shown below,
>
>// Create and register a tool for arc links
>LinkTool arcLinkTool = new LinkTool("ArcLinkTool");
>arcLinkTool.LinkFactory = new LinkFactory(this.CreateArcLink);
>this.diagram.Controller.RegisterTool(arcLinkTool);
>
>// Implement the LinkFactory delegate
>protected Link CreateArcLink(PointF[] pts)
>{
> Link link = new Link(Link.Shapes.Arc, pts);
> return link;
>}
>
>I hope this helps.
>
>Regards,
>Prakash
AD
Administrator
Syncfusion Team
January 12, 2005 05:29 PM UTC
Suwit,
That bit of code was provided just to help you get started with the implementation for custom drawing the ''link middle arrow''. In your custom Link class''s override of the CreateLinkShape() method, you will have to interpret the PointF collection and draw the link(with the middle arrow) as required. Unfortunately, we do not have any code available that shows rendering a Link with such a middle arrow.
Thanks,
Prakash Surendra