protected override void OnPrintPage(PrintPageEventArgs e) { base.OnPrintPage(e); ScintillaPageSettings oPageSettings = null; HeaderInformation oHeader = ((ScintillaPageSettings)DefaultPageSettings).Header; FooterInformation oFooter = ((ScintillaPageSettings)DefaultPageSettings).Footer; Rectangle oPrintBounds = e.MarginBounds; bool bIsPreview = this.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 ScintillaPageSettings) { oPageSettings = (ScintillaPageSettings)e.PageSettings; oHeader = oPageSettings.Header; oFooter = oPageSettings.Footer; sci.SetPrintMagnification(oPageSettings.FontMagnification); sci.SetPrintColourMode((int)oPageSettings.ColorMode); } // Draw the header and footer and get remainder of page bounds oPrintBounds = DrawHeader(e.Graphics, oPrintBounds, oHeader); oPrintBounds = 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); } DrawCurrentPage(e.Graphics, oPrintBounds); // Increment the page count and determine if there are more pages to be printed _iCurrentPage++; e.HasMorePages = (_iPosition < _iPrintEnd); }
public ScintillaPrintDocument(ScintillaControl sci, string documentTitle) { this.sci = sci; DocumentName = documentTitle; DefaultPageSettings = new ScintillaPageSettings(); }