Background Image

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.


9 Replies

DM Dinesh M Syncfusion Team September 23, 2009 11:13 AM UTC

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


LA Larssec September 23, 2009 03:16 PM UTC

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


DM Dinesh M Syncfusion Team September 24, 2009 12:22 PM UTC

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


LA Larssec September 25, 2009 07:19 AM UTC

Hi Dinesh,

OK. Thanks for your help.

Regards,
Imax


DM Dinesh M Syncfusion Team September 28, 2009 06:30 PM UTC

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


LA Larssec September 29, 2009 08:29 AM UTC

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


DM Dinesh M Syncfusion Team September 30, 2009 12:59 PM UTC

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


LA Larssec October 1, 2009 09:06 AM UTC

Hi Dinesh,

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

Regards,
Imax


DM Dinesh M Syncfusion Team October 7, 2009 11:35 AM UTC

Hi Imax,

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

Regards,
Dinesh

Loader.
Up arrow icon