Browse Source

Iamges can be set/changed at runtime

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1622 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 19 years ago
parent
commit
6736850384
  1. 55
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseImageItem.cs

55
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseImageItem.cs

@ -49,6 +49,7 @@ namespace SharpReportCore { @@ -49,6 +49,7 @@ namespace SharpReportCore {
"Unable to Load {0}",fileName);
throw new SharpReportException(str);
}
} catch (System.OutOfMemoryException) {
throw;
} catch (System.IO.FileNotFoundException) {
@ -56,6 +57,26 @@ namespace SharpReportCore { @@ -56,6 +57,26 @@ namespace SharpReportCore {
}
}
/// <summary>
/// ToolboxIcon for ReportRectangle
/// </summary>
/// <returns>Bitmap</returns>
private static Bitmap ErrorBitmap(Rectangle rect) {
Bitmap b = new Bitmap (rect.Width,rect.Height);
using (Graphics g = Graphics.FromImage (b)){
g.DrawRectangle (new Pen(Color.Black, 1),
1,1,rect.Width -2,rect.Height -2);
g.DrawString("Image",new Font("Microsoft Sans Serif",
8),
new SolidBrush(Color.Gray),
new RectangleF(1,1,rect.Width,rect.Height) );
}
return b;
}
#region overrides
public override void Render(ReportPageEventArgs rpea) {
@ -64,19 +85,18 @@ namespace SharpReportCore { @@ -64,19 +85,18 @@ namespace SharpReportCore {
}
base.Render(rpea);
Graphics g = rpea.PrintPageEventArgs.Graphics;
if (this.image != null) {
if (this.scaleImageToSize) {
g.DrawImageUnscaled(image,0,0);
rpea.LocationAfterDraw = new Point (this.Location.X + this.image.Width,
this.Location.Y + this.image.Height);
} else {
SizeF measureSize = base.MeasureReportItem (rpea,this);
RectangleF rect = base.DrawingRectangle (measureSize);
g.DrawImage(image,
rect);
rpea.LocationAfterDraw = new Point (this.Location.X + (int)rect.Width,
this.Location.Y + (int)rect.Height);
}
if (this.scaleImageToSize) {
g.DrawImageUnscaled(this.Image,0,0);
rpea.LocationAfterDraw = new Point (this.Location.X + this.Image.Width,
this.Location.Y + this.Image.Height);
} else {
SizeF measureSize = base.MeasureReportItem (rpea,this);
RectangleF rect = base.DrawingRectangle (measureSize);
g.DrawImage(this.Image,
rect);
rpea.LocationAfterDraw = new Point (this.Location.X + (int)rect.Width,
this.Location.Y + (int)rect.Height);
}
}
@ -108,11 +128,16 @@ namespace SharpReportCore { @@ -108,11 +128,16 @@ namespace SharpReportCore {
}
/// <summary>
/// The Image
/// The Image
/// </summary>
public virtual Image Image {
get {
return image;
if (this.image != null) {
return image;
} else {
return BaseImageItem.ErrorBitmap(new Rectangle(0,0,this.Size.Width,this.Size.Height));
}
}
set {
this.fileName = String.Empty;

Loading…
Cancel
Save