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

SetMargins() private method

private SetMargins ( System.Drawing.Printing.PrintPageEventArgs e ) : void
e System.Drawing.Printing.PrintPageEventArgs
return void
		private void SetMargins(PrintPageEventArgs e)
		{
			int dpiX = (int)e.Graphics.DpiX;
			int dpiY = (int)e.Graphics.DpiY;
			Rectangle margins = e.MarginBounds;
			Rectangle page = e.PageBounds;
			bool landscape = e.PageSettings.Landscape;

			Rectangle printable = new Rectangle(
				(int)e.Graphics.VisibleClipBounds.Left,
				(int)e.Graphics.VisibleClipBounds.Top,
				(int)e.Graphics.VisibleClipBounds.Width,
				(int)e.Graphics.VisibleClipBounds.Height);

			// To be useful, the printable rectangle needs to be offset so it indicates
			// the actual part of the page where we can print.
			printable.Offset((int)(e.PageSettings.HardMarginX), (int)(e.PageSettings.HardMarginY));

			Rectangle relative;
			if (MiscUtils.IsUnix)
			{
				dpiX = 72;
				dpiY = 72;
				if (landscape)
					page = new Rectangle(e.PageBounds.Y, e.PageBounds.X, e.PageBounds.Height, e.PageBounds.Width);
				relative = page;
			}
			else
				relative = printable;

			m_vwPrintContext.SetMargins(
				PixelsFrom100ths(margins.Left - relative.Left, dpiX),
				PixelsFrom100ths(relative.Right - margins.Right, dpiX),
				PixelsFrom100ths((margins.Top - relative.Top) / 2, dpiY),		// heading; get from smarter page setup?
				PixelsFrom100ths(margins.Top - relative.Top, dpiY),				// top
				PixelsFrom100ths(relative.Bottom - margins.Bottom, dpiY),		// bottom
				PixelsFrom100ths((relative.Bottom - margins.Bottom) / 2, dpiY));	// footer; get from smarter page setup?
		}