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.

Background Image

Thread ID:

Created:

Updated:

Platform:

Replies:

90226 Sep 22,2009 11:24 AM Oct 7,2009 07:35 AM ASP.NET Web Forms (Classic) 9
loading
Tags: DiagramWebControl
Larssec
Asked On September 22, 2009 11:24 AM

Hi,

I'd appreciate some help with the following question. I'm trying to set the background for the diagrams like this:

string url = Server.MapPath(string.Empty) + @"\image.png";
System.Drawing.Bitmap background = new System.Drawing.Bitmap(url);
this.DiagramWebControl1.Model.BackgroundImage = background;
this.DiagramWebControl1.Model.BackgroundImageLayout = ImageLayout.Center;

no exception is thrown, but no background is showed. What am I doing wrong?


Thanks for your time,
Imax.


Dinesh M [Syncfusion]
Replied On September 23, 2009 07:13 AM

Hi Imax,

Thank you for your interest in Syncfusion products.

The issue mentioned here is suspected to be a defect and we have sent this to our development team for more analysis. We will update you once we get back from our development team.

In the meantime please make use of the following code that sets the background image using the BackgroundStyle property.

string url = Server.MapPath(string.Empty) + @"\Sunset.jpg";
System.Drawing.Bitmap background = new System.Drawing.Bitmap(url);

this.DiagramWebControl1.Model.BackgroundStyle.PathBrushStyle = Syncfusion.Windows.Forms.Diagram.PathGradientBrushStyle.RectangleCenter;
this.DiagramWebControl1.Model.BackgroundStyle.Texture = background; this.DiagramWebControl1.Model.BackgroundStyle.TextureWrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
this.DiagramWebControl1.Model.BackgroundStyle.Type = Syncfusion.Windows.Forms.Diagram.FillStyleType.Texture;

Regards,
Dinesh

Larssec
Replied On September 23, 2009 11:16 AM

Hi Dinesh,

Thanks for your help. In that case, is there a way I can make the background fit the size of the DiagramWebControl.Model without having to do some image processing? Thanks.

Regards,
Imax

Dinesh M [Syncfusion]
Replied On September 24, 2009 08:22 AM

Hi Imax,

It is not possible to fit the Image in the case of "BackgroundStyle" property and it could be done only through "BackgroundImage" property of the Model, in which an issue exists. We will analyze this issue and provide you further details in 2 business days.

Regards,
Dinesh

Larssec
Replied On September 25, 2009 03:19 AM

Hi Dinesh,

OK. Thanks for your help.

Regards,
Imax

Dinesh M [Syncfusion]
Replied On September 28, 2009 02:30 PM

Hi Imax,

The issue 'BackgroundImage not working for DiagramWebControl' has been confirmed as a defect and we have logged a defect report. The fix for this issue will be available on our forth coming refresh release as this requires implementation of codes that makes DiagramWebControl to support this property.

Thank you for your interest in Syncfusion products.

Regards,
Dinesh

Larssec
Replied On September 29, 2009 04:29 AM

Hi Dinesh,

Tnanks for your time. Then I'm trying to find a workaround, as I need to precisely set the position and size of the nodes in a A4 document according to different document backgrounds.

(1) As you said, if you set:

this.DiagramWebControl1.Model.DocumentSize = new PageSize(210, MeasureUnits.Millimeter, 297, MeasureUnits.Millimeter);

and the then set a background,

string url = Server.MapPath(string.Empty) + @"\Sunset.jpg";
System.Drawing.Bitmap background = new System.Drawing.Bitmap(url);
this.DiagramWebControl1.Model.BackgroundStyle.PathBrushStyle = Syncfusion.Windows.Forms.Diagram.PathGradientBrushStyle.RectangleCenter;
this.DiagramWebControl1.Model.BackgroundStyle.Texture = background; this.DiagramWebControl1.Model.BackgroundStyle.TextureWrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
this.DiagramWebControl1.Model.BackgroundStyle.Type = Syncfusion.Windows.Forms.Diagram.FillStyleType.Texture;

it doesn't fit the document size. What resolution (and/or other parameters) does the image have to have in order to fit the 210x297 DiagramWebControl.Model?

(2)The other way around,if you set a background without forcing the document size, the model seems to become 827x1169 pixels regardless of the image resolution.

Does that mean that you can't tinker with the image resolution to make it fit the document?

Any suggestion is welcome. Thanks for your help.

Regards,
Imax

Dinesh M [Syncfusion]
Replied On September 30, 2009 08:59 AM

Hi Imax,

I have modified the code such that with some manual calculation of document size it is possible to set the Background image that fit with the DiagramWebControl's view area. Please make use of the following code and let me know if it helps.

this.DiagramWebControl1.Model.DocumentSize = new PageSize(500, 400);
string url = Server.MapPath(string.Empty) + @"\Sunset.jpg";
System.Drawing.Bitmap background = new System.Drawing.Bitmap(url);
this.DiagramWebControl1.Model.BackgroundStyle.PathBrushStyle = Syncfusion.Windows.Forms.Diagram.PathGradientBrushStyle.RectangleCenter;
this.DiagramWebControl1.Model.BackgroundStyle.Texture = new System.Drawing.Bitmap(background, DiagramWebControl1.View.Width, DiagramWebControl1.View.Height);
this.DiagramWebControl1.Model.BackgroundStyle.TextureWrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
this.DiagramWebControl1.Model.BackgroundStyle.Type = Syncfusion.Windows.Forms.Diagram.FillStyleType.Texture;

Regards,
Dinesh

Larssec
Replied On October 1, 2009 05:06 AM

Hi Dinesh,

It works perfectly. Thanks for helping us. Much appreciated.

Regards,
Imax

Dinesh M [Syncfusion]
Replied On October 7, 2009 07:35 AM

Hi Imax,

Thank you for your update. We are glad to hear that you problem was solved.

Regards,
Dinesh

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.

;