当前位置: 首页>>代码示例>>C#>>正文


C# IVwRootBox.GetTotalPrintPages方法代码示例

本文整理汇总了C#中IVwRootBox.GetTotalPrintPages方法的典型用法代码示例。如果您正苦于以下问题:C# IVwRootBox.GetTotalPrintPages方法的具体用法?C# IVwRootBox.GetTotalPrintPages怎么用?C# IVwRootBox.GetTotalPrintPages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IVwRootBox的用法示例。


在下文中一共展示了IVwRootBox.GetTotalPrintPages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

		private void Init(PrintPageEventArgs e)
		{
#if false
			long x1 = System.DateTime.Now.Ticks;
#endif
			// Set these now because the Graphics object will be locked below.
			m_rcDst = m_rcSrc = new Rect(0, 0, (int)e.Graphics.DpiX, (int)e.Graphics.DpiY);

			int dpix;
			if (MiscUtils.IsUnix)
				dpix = 72;
			else
				dpix = (int)e.Graphics.DpiX;

			m_dxpAvailWidth = PixelsFrom100ths(e.MarginBounds.Width, dpix);

			// Create and initialize a print context.
			m_vwPrintContext = VwPrintContextWin32Class.Create();

			// TODO: When we provide a way for the user to specify the nFirstPageNo (i.e. the
			// first argument to SetPagePrintInfo), then change the arguments to
			// SetPagePrintInfo.
			m_vwPrintContext.SetPagePrintInfo(1, 1, 65535, 1, false);
			SetMargins(e);

			IVwGraphics vwGraphics = VwGraphicsWin32Class.Create();
			IntPtr hdc = IntPtr.Zero;
			try
			{
				// Get the printer's hdc and use it to initialize other stuff.
				hdc = e.Graphics.GetHdc();
				((IVwGraphicsWin32)vwGraphics).Initialize(hdc);
				m_vwPrintContext.SetGraphics(vwGraphics);

				// Make a rootbox for printing and initialize it.
				m_rootb = VwRootBoxClass.Create();
				m_rootb.SetSite(this);
				m_rootb.DataAccess = m_sda;
				m_rootb.SetRootObject(m_hvo, m_vc, m_frags, m_styleSheet);
				m_rootb.InitializePrinting(m_vwPrintContext);
				m_totalNumberOfPages = m_rootb.GetTotalPrintPages(m_vwPrintContext);
				m_psettings = e.PageSettings.PrinterSettings;
				SetPrintRange();
			}
			catch (Exception ex)
			{
				m_rootb = null;

				throw new ContinuableErrorException("An error has occurred during the setup required for printing.", ex);
			}
			finally
			{
				if (hdc != IntPtr.Zero)
				{
					vwGraphics.ReleaseDC();
					e.Graphics.ReleaseHdc(hdc);
				}
			}
#if false
			long x2 = System.DateTime.Now.Ticks;
			Debug.WriteLine("PrintRootSite.Init() took " + DeltaTime(x1,x2) + " seconds.");
#endif
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:63,代码来源:PrintRootSite.cs

示例2: Init

		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="e"></param>
		/// ------------------------------------------------------------------------------------
		private void Init(PrintPageEventArgs e)
		{
#if false
			long x1 = System.DateTime.Now.Ticks;
#endif
			// Set these now because the Graphics object will be locked below.
			m_rcDst = m_rcSrc = new Rect(0, 0, (int)e.Graphics.DpiX, (int)e.Graphics.DpiY);
			m_dxpAvailWidth = PixelsFrom100ths(e.MarginBounds.Width, (int)e.Graphics.DpiX);

			// Create and initialize a print context.
			m_vwPrintContext = VwPrintContextWin32Class.Create();

			// TODO: When we provide a way for the user to specify the nFirstPageNo (i.e. the
			// first argument to SetPagePrintInfo), then change the arguments to
			// SetPagePrintInfo.
			m_vwPrintContext.SetPagePrintInfo(1, 1, 65535, 1, false);
			SetMargins(e);

			IVwGraphics vwGraphics = VwGraphicsWin32Class.Create();
			IntPtr hdc = IntPtr.Zero;
			try
			{
				// Get the printer's hdc and use it to initialize other stuff.
				hdc = e.Graphics.GetHdc();
				((IVwGraphicsWin32)vwGraphics).Initialize(hdc);
				m_vwPrintContext.SetGraphics(vwGraphics);

				// Make a rootbox for printing and initialize it.
				m_rootb = VwRootBoxClass.Create();
				m_rootb.SetSite(this);
				m_rootb.DataAccess = m_sda;
				m_rootb.SetRootObject(m_hvo, m_vc, m_frags, m_styleSheet);
				m_rootb.InitializePrinting(m_vwPrintContext);
				m_totalNumberOfPages = m_rootb.GetTotalPrintPages(m_vwPrintContext, null);
				m_psettings = e.PageSettings.PrinterSettings;
				SetPrintRange();
			}
			catch
			{
				m_rootb = null;
				string errorMsg =
					ResourceHelper.GetResourceString("kstidErrorCreatingPrintRootSite");

				// TODO: Add the help file and url when we have a help file.
				MessageBox.Show(errorMsg, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
			finally
			{
				if (hdc != IntPtr.Zero)
				{
					vwGraphics.ReleaseDC();
					e.Graphics.ReleaseHdc(hdc);
				}
			}
#if false
			long x2 = System.DateTime.Now.Ticks;
			Debug.WriteLine("PrintRootSite.Init() took " + DeltaTime(x1,x2) + " seconds.");
#endif
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:65,代码来源:PrintRootSite.cs


注:本文中的IVwRootBox.GetTotalPrintPages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。