Hi,
I'd like to add a small image, like EndPointDecorator (for example, DiamondDecorator), but at the middle of the link line( i'm using my own link tool class based on DirectedLineLinkTool).
What is the simplest way to add such image ?
J.
J.Nagarajan
Syncfusion Team
March 13, 2007 05:56 PM UTC
Hi Ok,
You can add a small image (DiamondDecorator) at the middle of the link line. You can use the following code snippet to achieve this.
this.diagram1.Model.LineRoutingEnabled=true;
LinkCmd newlink= new LinkCmd();
Link link= new Link(Link.Shapes.Line);
newlink.SourcePort = symbol.CenterPort;
newlink.TargetPort = rrect.CenterPort;
newlink.Link=link;
diagram1.Controller.ExecuteCommand(newlink);
InsertNodesCmd cmd=new InsertNodesCmd();
BitmapNode bitmap=new BitmapNode("..\\..\\Image.gif");
bitmap.X= link.X+link.Width/2;
bitmap.Y=link.Y+link.Height/2;
bitmap.Rotate(135);
cmd.Nodes.Add(bitmap);
this.diagram1.Controller.ExecuteCommand(cmd);
I have attached the sample for your reference. In this sample you can add symbols by clicking on the "Add Symbols" button. When you click on the Link button a link should be created and you can see the image at the middle of this link.
You can download this sample from the following page.
Please refer to it and let me know if you have any questions.
http://websamples.syncfusion.com/samples/Diagram.Windows/F57874/main.htm
Thanks for using Syncfusion product.
Regards,
Nagaraj
AD
Administrator
Syncfusion Team
March 14, 2007 07:01 AM UTC
Thanks for your sample, though it has one disadvatage: when link is moved during symbol moving the bitmap remained in old place.
J.
J.Nagarajan
Syncfusion Team
March 15, 2007 11:24 PM UTC
Hi Ok,
Thanks for you for being patience.
The bitmap gets placed in the middle of the link when link is moved. But we have a minar problem in bitmap alignment. We will resolve this issue and I will get back to you with more details at the earliest.
Thanks,
Nagaraj
J.
J.Nagarajan
Syncfusion Team
March 20, 2007 06:11 PM UTC
Hi Ok,
Sorry for the delay in getting back to you.
You can handle NodeMoved and Bounds changed events to position the bitmap at the center of the link.
BitmapNode bitmap;
Link link;
private void diagram1_NodeMoved(object sender, Syncfusion.Windows.Forms.Diagram.MoveEventArgs evtArgs)
{
bitmap.X= link.X+link.Width/2-bitmap.Width/2;
bitmap.Y=link.Y+link.Height/2-bitmap.Height/2;
}
private void diagram1_BoundsChanged(object sender, Syncfusion.Windows.Forms.Diagram.BoundsEventArgs evtArgs)
{
bitmap.X= link.X+link.Width/2-bitmap.Width/2;
bitmap.Y=link.Y+link.Height/2-bitmap.Height/2;
}
I have attached the sample for your reference. Please download the sample from the following page.
http://websamples.syncfusion.com/samples/Diagram.Windows/Image On Link/main.htm
Let me know if you have any questions.
Thanks,
Nagaraj