Page 1 of 1

How to add image from code?

Posted: Sun Apr 10, 2011 1:52 am
by Jalal
Hello,

I am trying to add new variable ( type of image ) from code behind. So i can use that variable in silverlight designer. But it doesn't work until now. I am using the following code :

StiDesignecontrol = new StiSLDesignerControl();
StiReport report = new StiReport();

if (byteArray != null)
{
report.Load(byteArray);
}
if (logodata != null)
{
BitmapImage bitmap = new BitmapImage();
bitmap.SetSource(new MemoryStream(logodata));

StiImage image = new StiImage();
image.Image = bitmap;

StiVariable logo = new StiVariable("My Variables", "Logo", "Logo", typeof(System.Drawing.Bitmap),"",false);//new StiVariable("My variables", "Logo", "Logo", "", typeof(System.Drawing.Bitmap), "", false, false, false);
logo.ValueObject = image;
report.Dictionary.Variables.Add(logo);
report.Dictionary.Synchronize();
}


report.Render();
StiDesignecontrol.Report = report;

Regards,
Jalal

How to add image from code?

Posted: Mon Apr 11, 2011 6:46 am
by Andrew
Hello,

Your code is correct. Variables for the Image type did not work correctly. We have made changes that will be available tomorrow in prerelease build.

Thank you.

How to add image from code?

Posted: Mon Apr 11, 2011 6:49 am
by Jalal
Thanks for you reply,

I will wait the coming prerelease.

Regards,
Jalal

How to add image from code?

Posted: Mon Apr 11, 2011 8:57 am
by Alex K.
Hello,

Let us know if you need any additional help.

Thank you.

How to add image from code?

Posted: Wed Apr 13, 2011 7:11 am
by Jalal
Hello,

when i added an image in silverlight using the last prerelease (Stimulsoft Reports.Silverlight 2011.04.12 Trial), I notice that it doesn't work in the preview( i cant see the image, but just this "System.window.media.imaging.bitmapimage". ( preview here means 'StiSLDesignerControl' preview ).

However, it works good when i save mrt and open it using the designer. As a result i think that the image is loaded in the variable but there is something wrong when try to preview it in silverlight viewer!

Regards,
Jalal

How to add image from code?

Posted: Thu Apr 14, 2011 3:49 am
by Anton Lozovskiy
Hello,

The problem is fixed. The patch is available in prerelease build of on 19.04.2011.
Let us know if you need any additional help.

Thank you.

How to add image from code?

Posted: Tue Apr 19, 2011 4:06 am
by Jalal
Hello,

I create a variable in code behind like this :

BitmapImage bitmap = new BitmapImage();
bitmap.SetSource(new MemoryStream(logodata));
StiVariable logo = new StiVariable("My variables", "Logo", "Logo", "", typeof(System.Drawing.Bitmap), "", false, false, false);
logo.ValueObject = bitmap;
report.Dictionary.Variables.Add(logo);

But when i drag this variable to report area ( in designer), it doesn't appear same as when add new sti image !!
I mean it doesn't work in preview!

But,
If i add new sti image in designer, and assign imagedata = {Logo}, then it will work!

My question, how i can add sti variable of type image, then user can drag and drop it, so image will be shown in preview ??

I hope if you send me a sample.


Regards,
Jalal

How to add image from code?

Posted: Wed Apr 20, 2011 3:03 am
by Anton Lozovskiy
Hello,

We create an example for you, please see.

Thank you.