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.

Image in the middle of the link?

Thread ID:

Created:

Updated:

Platform:

Replies:

57874 Mar 13,2007 09:09 AM Mar 20,2007 02:11 PM Windows Forms 4
loading
Tags: Diagram
Administrator [Syncfusion]
Asked On March 13, 2007 09:09 AM

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.Nagarajan [Syncfusion]
Replied On March 13, 2007 01:56 PM

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

Administrator [Syncfusion]
Replied On March 14, 2007 03:01 AM

Thanks for your sample, though it has one disadvatage: when link is moved during symbol moving the bitmap remained in old place.

J.Nagarajan [Syncfusion]
Replied On March 15, 2007 07:24 PM

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.Nagarajan [Syncfusion]
Replied On March 20, 2007 02:11 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;