How to add image from code?

Stimulsoft Reports.Silverlight discussion
Locked
Jalal
Posts: 66
Joined: Sat Oct 09, 2010 4:10 am
Location: Palestine

How to add image from code?

Post 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
Andrew
Posts: 4107
Joined: Fri Jun 09, 2006 3:58 am

How to add image from code?

Post 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.
Jalal
Posts: 66
Joined: Sat Oct 09, 2010 4:10 am
Location: Palestine

How to add image from code?

Post by Jalal »

Thanks for you reply,

I will wait the coming prerelease.

Regards,
Jalal
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How to add image from code?

Post by Alex K. »

Hello,

Let us know if you need any additional help.

Thank you.
Jalal
Posts: 66
Joined: Sat Oct 09, 2010 4:10 am
Location: Palestine

How to add image from code?

Post 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
Anton Lozovskiy
Posts: 135
Joined: Tue Aug 11, 2009 9:38 am

How to add image from code?

Post 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.
Jalal
Posts: 66
Joined: Sat Oct 09, 2010 4:10 am
Location: Palestine

How to add image from code?

Post 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
Anton Lozovskiy
Posts: 135
Joined: Tue Aug 11, 2009 9:38 am

How to add image from code?

Post by Anton Lozovskiy »

Hello,

We create an example for you, please see.

Thank you.
Attachments
930.SilverlightApplication4.zip
(6.5 KiB) Downloaded 487 times
Locked