StiImage does not "center-align" image
Posted: Thu Jul 12, 2012 11:14 pm
Hey guys,
We are using the Stimulsoft control for displaying a "report preview" to the user in WPF. The user has the ability to upload a unique logo that is displayed in the header of the report as well as the cover page. The logic behind the cover page image is as follows:
Here is my code for doing this:
What's peculiar is that when I have the EXACT SAME settings in the designer for the image control it alligns the image perfectly in the center both horizontally and vertically.
I've also tried setting the "CanGrow" and "CanShrink" properties but to no avail. Any ideas on what could be causing the smaller images to appear in the top-left corner?
Thanks
We are using the Stimulsoft control for displaying a "report preview" to the user in WPF. The user has the ability to upload a unique logo that is displayed in the header of the report as well as the cover page. The logic behind the cover page image is as follows:
- - If the logo is larger than the bounds of the image box (StiImage) then it should be shrunk to fit
- If the logo is smaller than the bounds of the image box (StiImage) then it should keep its size and aspect ratio but appear in the center of the control both horizontally and vertically
Here is my code for doing this:
Code: Select all
var coverTitleBand = (StiBand)coverPage.Components["ReportCoverPageTitleBand"];
var coverImage = (StiImage)coverTitleBand.Components["CoverPageImage"];
coverImage.Image = System.Drawing.Image.FromStream(logo);
var imageControlSize = coverImage.GetActualSize();
if (coverImage.Image.Height > (imageControlSize.Height * 96) || coverImage.Image.Width > (imageControlSize.Width * 96))
coverImage.Stretch = true;
else
{
coverImage.Stretch = false;
coverImage.HorAlignment = StiHorAlignment.Center;
coverImage.VertAlignment = StiVertAlignment.Center;
}
I've also tried setting the "CanGrow" and "CanShrink" properties but to no avail. Any ideas on what could be causing the smaller images to appear in the top-left corner?
Thanks