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


C# PaperSize.SetKind方法代码示例

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


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

示例1: LoadPrinterPaperSizes

		/// <summary>
		/// Loads a printer's paper sizes. Returns the default PaperSize, and fills a list of paper_names for use in dialogues
		/// </summary>
		/// <param name="ppd_handle">PPD printer file handle</param>
		/// <param name="settings">PrinterSettings object to fill</param>
		/// <param name="def_size">Default paper size, from the global options of the printer</param>
		/// <param name="paper_names">List of available paper sizes that gets filled</param>
		private PaperSize LoadPrinterPaperSizes(IntPtr ppd_handle, PrinterSettings settings, 
												string def_size, NameValueCollection paper_names)
		{
			IntPtr ptr;
			string real_name;
			PPD_FILE ppd;
			PPD_SIZE size;
			PaperSize ps;

			PaperSize defsize = new PaperSize ("A4", 827, 1169, GetPaperKind (827, 1169), true);
			ppd = (PPD_FILE) Marshal.PtrToStructure (ppd_handle, typeof (PPD_FILE));
			ptr = ppd.sizes;
			float w, h;
			for (int i = 0; i < ppd.num_sizes; i++) {
				size = (PPD_SIZE) Marshal.PtrToStructure (ptr, typeof (PPD_SIZE));
				real_name = paper_names[size.name];
				w = size.width * 100 / 72;
				h = size.length * 100 / 72;
				PaperKind kind = GetPaperKind ((int) w, (int) h);
				ps = new PaperSize (real_name, (int) w, (int) h, kind, def_size == kind.ToString ());
				ps.SetKind (kind);
				if (def_size == ps.Kind.ToString ())
					defsize = ps;
				settings.paper_sizes.Add (ps);
				ptr = (IntPtr) ((long)ptr + Marshal.SizeOf (size));
			}
			
			return defsize;

		}
开发者ID:Profit0004,项目名称:mono,代码行数:37,代码来源:PrintingServicesUnix.cs

示例2: Clone

		public object Clone ()
		{
			// We do a deep copy
			PrinterResolution pres = new PrinterResolution (this.printerResolution.X, this.printerResolution.Y, this.printerResolution.Kind);
			PaperSource psource = new PaperSource (this.paperSource.SourceName, this.paperSource.Kind);
			PaperSize psize = new PaperSize (this.paperSize.PaperName, this.paperSize.Width, this.paperSize.Height);
			psize.SetKind (this.paperSize.Kind);

			PageSettings ps = new PageSettings (this.printerSettings, this.color, this.landscape,
					psize, psource, pres);
			ps.Margins = (Margins) this.margins.Clone ();
			return ps;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:13,代码来源:PageSettings.cs

示例3: LoadPrinterPaperSizes

		void LoadPrinterPaperSizes (string printer, PrinterSettings settings)
		{
			int items, ret;
			IntPtr ptr_names, buff_names = IntPtr.Zero;
			IntPtr ptr_sizes, buff_sizes = IntPtr.Zero;
			IntPtr ptr_sizes_enum, buff_sizes_enum = IntPtr.Zero;
			string name;

			if (settings.PaperSizes == null)
				settings.paper_sizes = new PrinterSettings.PaperSizeCollection (new PaperSize [0]);
			else
				settings.PaperSizes.Clear ();

			items = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_PAPERSIZE, IntPtr.Zero, IntPtr.Zero);

			if (items == -1)
				return;

			try {
				ptr_sizes = buff_sizes = Marshal.AllocHGlobal (items * 2 * 4);
				ptr_names = buff_names = Marshal.AllocHGlobal (items * 64 * 2);
				ptr_sizes_enum = buff_sizes_enum = Marshal.AllocHGlobal (items * 2);
				ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_PAPERSIZE, buff_sizes, IntPtr.Zero);

				if (ret == -1) {
					// the finally clause will free the unmanaged memory before returning
					return;
				}

				ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_PAPERS, buff_sizes_enum, IntPtr.Zero);
				ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_PAPERNAMES, buff_names, IntPtr.Zero);

				int x, y;
				PaperSize ps;
				PaperKind kind;
				for (int i = 0; i < ret; i++) {
					x = Marshal.ReadInt32 (ptr_sizes, i * 8);
					y = Marshal.ReadInt32 (ptr_sizes, (i * 8) + 4);

					x = PrinterUnitConvert.Convert (x, PrinterUnit.TenthsOfAMillimeter,
					      PrinterUnit.Display);

					y = PrinterUnitConvert.Convert (y, PrinterUnit.TenthsOfAMillimeter,
					      PrinterUnit.Display);

					name  = Marshal.PtrToStringUni (ptr_names);
					ptr_names = new IntPtr (ptr_names.ToInt64 () + 64 * 2);

					kind = (PaperKind) Marshal.ReadInt16 (ptr_sizes_enum);
					ptr_sizes_enum = new IntPtr (ptr_sizes_enum.ToInt64 () + 2);

					ps = new PaperSize (name, x,y);
					ps.SetKind (kind);
					settings.PaperSizes.Add (ps);
				}
			}
			finally {
				if (buff_names != IntPtr.Zero)
					Marshal.FreeHGlobal (buff_names);
				if (buff_sizes != IntPtr.Zero)
					Marshal.FreeHGlobal (buff_sizes);
				if (buff_sizes_enum != IntPtr.Zero)
					Marshal.FreeHGlobal (buff_sizes_enum);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:65,代码来源:PrintingServicesWin32.cs


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