/// <summary> /// Default constructor /// </summary> public PageSettings() { // Keep track of the base color for designer serialization. This is a workaround that should // last until the PageSettings can be redesigned. baseColor = base.Color; m_oHeader = new HeaderInformation(PageInformationBorder.Bottom, InformationType.DocumentName, InformationType.Nothing, InformationType.PageNumber); m_oFooter = new FooterInformation(PageInformationBorder.Top, InformationType.Nothing, InformationType.Nothing, InformationType.Nothing); m_sFontMagnification = 0; m_eColorMode = PrintColorMode.Normal; // Set default margins to 1/2 inch (50/100ths) base.Margins.Top = 50; base.Margins.Left = 50; base.Margins.Right = 50; base.Margins.Bottom = 50; }
/// <summary> /// Method called when printing a page /// </summary> /// <param name="e">A PrintPageEventArgs that contains the event data</param> 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 = 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 PageSettings) { oPageSettings = (PageSettings)e.PageSettings; oHeader = oPageSettings.Header; oFooter = oPageSettings.Footer; m_oScintillaControl.NativeInterface.SetPrintMagnification(oPageSettings.FontMagnification); m_oScintillaControl.NativeInterface.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 m_iCurrentPage++; e.HasMorePages = (m_iPosition < m_iPrintEnd); }