SIL.FieldWorks.Common.RootSites.PrintRootSite.pd_PrintPage C# (CSharp) Method

pd_PrintPage() private method

private pd_PrintPage ( object sender, System.Drawing.Printing.PrintPageEventArgs e ) : void
sender object
e System.Drawing.Printing.PrintPageEventArgs
return void
		private void pd_PrintPage(object sender, PrintPageEventArgs e)
		{
			// If the print rootsite hasn't been initialized yet, do so now.
			if (m_rootb == null)
			{
				Init(e);

				if (m_rootb == null || !m_morePagesToPrint)
				{
					e.HasMorePages = false;
					return;
				}
			}

			// Initialize the IVwGraphics with the hDC from the .Net graphics object.
			IVwGraphics vwGraphics = VwGraphicsWin32Class.Create();
			IntPtr hdc = e.Graphics.GetHdc();
			((IVwGraphicsWin32)vwGraphics).Initialize(hdc);
			m_vwPrintContext.SetGraphics(vwGraphics);

			// Print the next page
			m_rootb.PrintSinglePage(m_vwPrintContext, m_nextPageToPrint);

			// Release these things here or bad things will happen.
			vwGraphics.ReleaseDC();
			if (hdc != IntPtr.Zero)
				e.Graphics.ReleaseHdc(hdc);

			// If more lines exist, print another page.
			Advance();
			e.HasMorePages = m_morePagesToPrint;
		}