protected override void OnPrintPage(PrintPageEventArgs e)
{
base.OnPrintPage(e);
PageSettings oPageSettings = null;
HeaderInformation oHeader = ((PageSettings)DefaultPageSettings).Header;
FooterInformation oFooter = ((PageSettings)DefaultPageSettings).Footer;
Rectangle oPrintBounds = e.MarginBounds;
bool bIsPreview = PrintController.IsPreview;
// When not in preview mode, adjust graphics to account for hard margin of the printer
if (!bIsPreview)
{
e.Graphics.TranslateTransform(-e.PageSettings.HardMarginX, -e.PageSettings.HardMarginY);
}
// Get the header and footer provided if using Scintilla.Printing.PageSettings
if (e.PageSettings is PageSettings)
{
oPageSettings = (PageSettings)e.PageSettings;
oHeader = oPageSettings.Header;
oFooter = oPageSettings.Footer;
this._oScintillaControl.NativeInterface.SetPrintMagnification(oPageSettings.FontMagnification);
this._oScintillaControl.NativeInterface.SetPrintColourMode((int)oPageSettings.ColorMode);
}
// Draw the header and footer and get remainder of page bounds
oPrintBounds = this.DrawHeader(e.Graphics, oPrintBounds, oHeader);
oPrintBounds = this.DrawFooter(e.Graphics, oPrintBounds, oFooter);
// When not in preview mode, adjust page bounds to account for hard margin of the printer
if (!bIsPreview)
{
oPrintBounds.Offset((int)-e.PageSettings.HardMarginX, (int)-e.PageSettings.HardMarginY);
}
this.DrawCurrentPage(e.Graphics, oPrintBounds);
// Increment the page count and determine if there are more pages to be printed
this._iCurrentPage++;
e.HasMorePages = (this._iPosition < this._iPrintEnd);
}