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

Print() public method

Prints the given document. Implements interface IPrintRootSite. Caller is responsible to catch any exceptions.
public Print ( System.Drawing.Printing.PrintDocument pd ) : void
pd System.Drawing.Printing.PrintDocument
return void
		public void Print(PrintDocument pd)
		{
#if false
			long x1 = System.DateTime.Now.Ticks;
#endif
			pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
			pd.Print();
			if (m_rootb != null)
				m_rootb.Close();
			// Check whether the printing actually worked (FWNX-759).
			if (pd.PrinterSettings.PrintToFile && !File.Exists(pd.PrinterSettings.PrintFileName))
			{
				var msg = String.Format(Properties.Resources.ksPrintToFileFailed, pd.PrinterSettings.PrintFileName);
				MessageBox.Show(msg, Properties.Resources.kstidPrintErrorCaption);
			}

#if false
			long x2 = System.DateTime.Now.Ticks;
			Debug.WriteLine("PrintRootSite.Print() took " + DeltaTime(x1,x2) + " seconds.");
#endif
		}

Usage Example

Beispiel #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Print method
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public virtual void Print(PrintDocument pd)
		{
			CheckDisposed();
			if (m_rootb == null || DataAccess == null)
				return;
			int hvo;
			IVwViewConstructor vc;
			int frag;
			IVwStylesheet ss;
			this.GetPrintInfo(out hvo, out vc, out frag, out ss);

			PrintRootSite printRootSite = new PrintRootSite(DataAccess, hvo, vc, frag, ss);
			try
			{
				printRootSite.Print(pd);
			}
			catch (Exception e)
			{
				string errorMsg = String.Format(
					ResourceHelper.GetResourceString("kstidPrintingException"), e.Message);

				// TODO: Add the help file and url when we have a help file.
				MessageBox.Show(FindForm(), errorMsg, "", MessageBoxButtons.OK,
					MessageBoxIcon.Error);
			}
		}