// (c) 2003-2005 Datron, Inc. All rights reserved. http://www.blix.net
using System;
namespace freeBlix
{
public class Graphics: IDisposable
{
#region static FromImage
public static Graphics FromImage(System.Drawing.Image aImage)
{
return new Graphics(System.Drawing.Graphics.FromImage(aImage));
}
#endregion
#region Fields
private System.Drawing.Graphics _WindowsGraphics;
#endregion
#region Graphics(aGraphics)
public Graphics(System.Drawing.Graphics aGraphics)
{
_WindowsGraphics = aGraphics;
}
#endregion
#region Clear
public void Clear(System.Drawing.Color aColor)
{
_WindowsGraphics.Clear(aColor);
}
#endregion
#region DrawImage(aImage, aLocation)
public void DrawImage(System.Drawing.Image aImage, Point aLocation)
{
_WindowsGraphics.DrawImage(aImage, aLocation.X, aLocation.Y);
}
#endregion
#region DrawImage(aImage, aLocation, aRectangle)
public void DrawImage(System.Drawing.Image aImage, Point aLocation, Rectangle aRectangle)
{
System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(aRectangle.Left, aRectangle.Top, aRectangle.Width, aRectangle.Height);
_WindowsGraphics.DrawImage(aImage, aLocation.X, aLocation.Y, rectangle, System.Drawing.GraphicsUnit.Pixel);
}
#endregion
#region DrawImage(aImage, aDestinationRectangle, aSourceRectangle)
public void DrawImage(System.Drawing.Image aImage, Rectangle aDestinationRectangle, Rectangle aSourceRectangle)
{
System.Drawing.Rectangle destRect = new System.Drawing.Rectangle(aDestinationRectangle.Left, aDestinationRectangle.Top, aDestinationRectangle.Width, aDestinationRectangle.Height);
System.Drawing.Rectangle sourceRect = new System.Drawing.Rectangle(aSourceRectangle.Left, aSourceRectangle.Top, aSourceRectangle.Width, aSourceRectangle.Height);
_WindowsGraphics.DrawImage(aImage, destRect, sourceRect, System.Drawing.GraphicsUnit.Pixel);
}
#endregion
#region DrawRectangle
public void DrawRectangle(System.Drawing.Pen aPen, Rectangle aRectangle)
{
_WindowsGraphics.DrawRectangle(aPen, aRectangle.Left, aRectangle.Top, aRectangle.Width - 1, aRectangle.Height - 1);
}
#endregion
#region DrawLine(aPen, aStartPoint, aEndPoint)
public void DrawLine(System.Drawing.Pen aPen, Point aStartPoint, Point aEndPoint)
{
int x1 = aStartPoint.X;
int x2 = aEndPoint.X;
int y1 = aStartPoint.Y;
int y2 = aEndPoint.Y;
_WindowsGraphics.DrawLine(aPen, x1, y1, x2, y2);
}
#endregion
#region DrawLine(aPen, aX1, aY1, aX2, aY2)
public void DrawLine(System.Drawing.Pen aPen, int aX1, int aY1, int aX2, int aY2)
{
_WindowsGraphics.DrawLine(aPen, aX1, aY1, aX2, aY2);
}
#endregion
#region DrawPixel(aPen, aX, aY)
public void DrawPixel(System.Drawing.Pen aPen, int aX, int aY)
{
_WindowsGraphics.DrawLine(aPen, aX, aY, (float)aX + 0.1f, aY);
}
#endregion
#region DrawPixel(aPen, aPoint)
public void DrawPixel(System.Drawing.Pen aPen, Point aPoint)
{
_WindowsGraphics.DrawLine(aPen, aPoint.X, aPoint.Y, (float)aPoint.X + 0.1f, aPoint.Y);
}
#endregion
#region FillRectangle
public void FillRectangle(System.Drawing.Brush aBrush, Rectangle aRectangle)
{
_WindowsGraphics.FillRectangle(aBrush, aRectangle.Left, aRectangle.Top, aRectangle.Width, aRectangle.Height);
}
#endregion
#region Clip
public Rectangle Clip
{
get
{
System.Drawing.Rectangle clipBounds = System.Drawing.Rectangle.Truncate(_WindowsGraphics.ClipBounds);
return new Rectangle(clipBounds.Left, clipBounds.Top, clipBounds.Width, clipBounds.Height);
}
set
{
System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(value.Left, value.Top, value.Width, value.Height);
_WindowsGraphics.Clip = new System.Drawing.Region(rectangle);
}
}
#endregion
#region WindowsGraphics
public System.Drawing.Graphics WindowsGraphics
{
get
{
return _WindowsGraphics;
}
}
#endregion
#region IDisposable
void IDisposable.Dispose()
{
((IDisposable)_WindowsGraphics).Dispose();
}
#endregion
}
}