public void Draw(Graphics oGraphics, Rectangle oBounds, String strDocumentName, int iPageNumber)
{
var oFormat = new StringFormat(StringFormat.GenericDefault);
Pen oPen = Pens.Black;
Brush oBrush = Brushes.Black;
// Draw border
switch (this._eBorder)
{
case PageInformationBorder.Top:
oGraphics.DrawLine(oPen, oBounds.Left, oBounds.Top, oBounds.Right, oBounds.Top);
break;
case PageInformationBorder.Bottom:
oGraphics.DrawLine(oPen, oBounds.Left, oBounds.Bottom, oBounds.Right, oBounds.Bottom);
break;
case PageInformationBorder.Box:
oGraphics.DrawRectangle(oPen, oBounds);
oBounds = new Rectangle(oBounds.Left + _iBorderSpace, oBounds.Top, oBounds.Width - (2 * _iBorderSpace), oBounds.Height);
break;
case PageInformationBorder.None:
default:
break;
}
// Center vertically
oFormat.LineAlignment = StringAlignment.Center;
// Draw left side
oFormat.Alignment = StringAlignment.Near;
switch (this._eLeft)
{
case InformationType.DocumentName:
oGraphics.DrawString(strDocumentName, this._oFont, oBrush, oBounds, oFormat);
break;
case InformationType.PageNumber:
oGraphics.DrawString("Page " + iPageNumber, this._oFont, oBrush, oBounds, oFormat);
break;
case InformationType.Nothing:
default:
break;
}
// Draw center
oFormat.Alignment = StringAlignment.Center;
switch (this._eCenter)
{
case InformationType.DocumentName:
oGraphics.DrawString(strDocumentName, this._oFont, oBrush, oBounds, oFormat);
break;
case InformationType.PageNumber:
oGraphics.DrawString("Page " + iPageNumber, this._oFont, oBrush, oBounds, oFormat);
break;
case InformationType.Nothing:
default:
break;
}
// Draw right side
oFormat.Alignment = StringAlignment.Far;
switch (this._eRight)
{
case InformationType.DocumentName:
oGraphics.DrawString(strDocumentName, this._oFont, oBrush, oBounds, oFormat);
break;
case InformationType.PageNumber:
oGraphics.DrawString("Page " + iPageNumber, this._oFont, oBrush, oBounds, oFormat);
break;
case InformationType.Nothing:
default:
break;
}
}