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.
Syncfusion Feedback

Is it possible to add an Image in the same way as a Label on a Connector?

Thread ID:

Created:

Updated:

Platform:

Replies:

97784 Jan 7,2011 01:30 PM Jan 13,2011 12:28 AM Windows Forms 3
loading
Tags: Diagram
Aubyn Crawford
Asked On January 7, 2011 01:30 PM

The label option is very useful, but it appears to only allow text. Is there a way to add an image instead of just text to a connector? (and that is any type of connector Orthoganal, Polyline. etc).

To be honest it would be useful to be able to that to a Node as well (I have implemented this on a node using groups already, but being able to do it by adding to the Labels collection would make life easier!).

Thanks,


Pandi Murugan A [Syncfusion]
Replied On January 10, 2011 12:22 AM

Hi Aubyn Crawford,

Thanks for using Syncfusion products.

Connectors don't have direct support for adding image to their GraphicsPath instead of Label but it can be achievable. We suggest you to customize a connector and override its render method to achieve your requirement and we have customized the LineConnector to meet your requirement as below. Please refer the below code snippet.

[C#]
//Custom LineConnector
class MyConnector: LineConnector
{
public MyConnector(PointF ptStart, PointF ptEnd)
: base(ptStart, ptEnd)
{
this.LineStyle.LineColor = Color.Orange;
this.LineStyle.LineWidth = 2;
}
protected override void Render(Graphics gfx)
{
base.Render(gfx);
Size size = new Size(16, 16);
PointF[] pts = GetPathPoints();
Bitmap Original = new Bitmap(@"..\\..\\Or.png");
Bitmap bmp = new Bitmap(Original, size);
bmp.MakeTransparent();
Graphics g = Graphics.FromImage(bmp);
//Add image to connector
gfx.DrawImage(bmp,new Point((int)((pts[0].X+pts[1].X)/2 - 8),(int)(pts[0].Y+10)));
}
}

For your convenient, we have created a simple sample to demonstrate this and the same can be downloaded from the below link.

ConnectorWithImage-1281406032.zip

Kindly try the above sample and let me know if this helps.

Regards,
Pandi Murugan A




Aubyn Crawford
Replied On January 12, 2011 05:43 PM

Perfect! Worked first time.

Really quick response from yourselves, which makes a big difference.


Pandi Murugan A [Syncfusion]
Replied On January 13, 2011 12:28 AM

Hi Aubyn Crawford,

Thanks for the update.

We are glad to know that the issue is resolved. Please let me know if you have any other concerns and we will be happy to assist you.

Regards,
Pandi Murugan A


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.

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

;