www.pudn.com > CFPrinterClass_src.rar > SDPE.cs, change:2008-03-13,size:7090b


using System.Runtime.InteropServices; 
 
using System; 
using System.Drawing; 
using System.Collections; 
using System.Windows.Forms; 
using System.Data; 
using CFPrinting; 
 
namespace SDPEdemo 
{ 
	/// <summary> 
	/// SDPE demo 
	/// </summary> 
	public class Form1 : System.Windows.Forms.Form 
	{ 
		private System.Windows.Forms.Button btnPrint; 
		private System.Windows.Forms.Button btnPreview; 
		private System.Windows.Forms.Button btnExit; 
		private System.Windows.Forms.PictureBox Logo; 
        private Label label1; 
 
		// Smart device print engine 
		private SmartDevicePrintEngine SDPE; 
 
		public Form1() 
		{ 
			// 
			// Required for Windows Form Designer support 
			// 
			InitializeComponent();			 
 
			// 
			// TODO: Add any constructor code after InitializeComponent call 
			// 
		} 
		/// <summary> 
		/// Clean up any resources being used. 
		/// </summary> 
		protected override void Dispose( bool disposing ) 
		{ 
			base.Dispose( disposing ); 
		} 
		#region Windows Form Designer generated code 
		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor. 
		/// </summary> 
		private void InitializeComponent() 
		{ 
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); 
            this.btnPrint = new System.Windows.Forms.Button(); 
            this.btnPreview = new System.Windows.Forms.Button(); 
            this.Logo = new System.Windows.Forms.PictureBox(); 
            this.btnExit = new System.Windows.Forms.Button(); 
            this.label1 = new System.Windows.Forms.Label(); 
            //  
            // btnPrint 
            //  
            this.btnPrint.Location = new System.Drawing.Point(16, 216); 
            this.btnPrint.Size = new System.Drawing.Size(56, 24); 
            this.btnPrint.Text = "打印"; 
            this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click); 
            //  
            // btnPreview 
            //  
            this.btnPreview.Location = new System.Drawing.Point(88, 216); 
            this.btnPreview.Size = new System.Drawing.Size(64, 24); 
            this.btnPreview.Text = "预览"; 
            this.btnPreview.Click += new System.EventHandler(this.btnPreview_Click); 
            //  
            // Logo 
            //  
            this.Logo.Image = ((System.Drawing.Image)(resources.GetObject("Logo.Image"))); 
            this.Logo.Location = new System.Drawing.Point(16, 43); 
            this.Logo.Size = new System.Drawing.Size(72, 71); 
            //  
            // btnExit 
            //  
            this.btnExit.Location = new System.Drawing.Point(168, 216); 
            this.btnExit.Size = new System.Drawing.Size(56, 24); 
            this.btnExit.Text = "退出"; 
            this.btnExit.Click += new System.EventHandler(this.btnExit_Click); 
            //  
            // label1 
            //  
            this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(64)))), ((int)(((byte)(192))))); 
            this.label1.Location = new System.Drawing.Point(105, 53); 
            this.label1.Size = new System.Drawing.Size(119, 61); 
            this.label1.Text = "  药品监督管理\r\n现场执法文书打印\r\n (打印机 测试)"; 
            //  
            // Form1 
            //  
            this.ClientSize = new System.Drawing.Size(240, 255); 
            this.ControlBox = false; 
            this.Controls.Add(this.label1); 
            this.Controls.Add(this.btnExit); 
            this.Controls.Add(this.Logo); 
            this.Controls.Add(this.btnPreview); 
            this.Controls.Add(this.btnPrint); 
            this.Text = "药监执法文书打印示例"; 
            this.Load += new System.EventHandler(this.Form1_Load); 
 
		} 
		#endregion 
 
		  
		private void btnPrint_Click(object sender, System.EventArgs e) 
		{ 
			int iPage=0; 
 
			// Loop for each page 
			for(iPage=0;iPage!=1;iPage++) 
			{ 
				// Write text on logical page	 
				SDPE.WriteToLogicalPage(17, 2, "这是一个执法文书打印的示例"); 
				SDPE.WriteToLogicalPage(7, 4, "检查对象:上海永丰餐馆"); 
				SDPE.WriteToLogicalPage(7, 5, "------------------------------------------------------------------------------------"); 
				SDPE.WriteToLogicalPage(7, 7, "检查科目:卫生从业人员健康证齐全情况."); 
				SDPE.WriteToLogicalPage(7, 8, "检查人数:20人"); 
				SDPE.WriteToLogicalPage(7, 9, "有证人员:18人"); 
				SDPE.WriteToLogicalPage(7, 10,"无证人员:2人"); 
				SDPE.WriteToLogicalPage(7, 12, "是否处罚:是"); 
				SDPE.WriteToLogicalPage(7, 13, "------------------------------------------------------------------------------------"); 
                SDPE.WriteToLogicalPage(7, 20, "法人签字:_____________   日期:_______年_____月______日"); 
 
                SDPE.WriteToLogicalPage(7, 21, "____________________________________________________________________________________"); 
 
                SDPE.WriteToLogicalPage(7, 21, "XX市药品监督管理局XX分局"); 
 
 
 
		 
 
 
				SDPE.Print(); 
				// Set and clear page 
				SDPE.NewPage(); 
			} 
		} 
 
		private void btnPreview_Click(object sender, System.EventArgs e) 
		{ 
			int iPage; // Page number 
 
			// Loop for each page 
			for(iPage=0;iPage!=2;iPage++) 
			{ 
                // Write text on logical page	 
                SDPE.WriteToLogicalPage(17, 2, "这是一个执法文书打印的示例"); 
                SDPE.WriteToLogicalPage(7, 4, "检查对象:上海永丰餐馆"); 
                SDPE.WriteToLogicalPage(7, 5, "------------------------------------------------------------------------------------"); 
                SDPE.WriteToLogicalPage(7, 7, "检查科目:卫生从业人员健康证齐全情况."); 
                SDPE.WriteToLogicalPage(7, 8, "检查人数:20人"); 
                SDPE.WriteToLogicalPage(7, 9, "有证人员:18人"); 
                SDPE.WriteToLogicalPage(7, 10, "无证人员:2人"); 
                SDPE.WriteToLogicalPage(7, 12, "是否处罚:是"); 
                SDPE.WriteToLogicalPage(7, 13, "------------------------------------------------------------------------------------"); 
                SDPE.WriteToLogicalPage(7, 20, "法人签字:_____________   日期:_______年_____月______日"); 
 
                SDPE.WriteToLogicalPage(7, 21, "____________________________________________________________________________________"); 
 
                SDPE.WriteToLogicalPage(7, 21, "XX市药品监督管理局XX分局"); 
 
 
 
 
 
 
                SDPE.Print(); 
                // Set and clear page 
                SDPE.NewPage(); 
			} 
			// Preview page 
			SDPE.Preview(); 
		} 
 
		private void btnExit_Click(object sender, System.EventArgs e) 
		{ 
			// Dispose objects from memory 
			SDPE = null; 
			GC.Collect(); 
 
			this.Dispose(); 
		} 
 
		private void Form1_Load(object sender, System.EventArgs e) 
		{ 
			// Create SDPE instance 
			SDPE = new SmartDevicePrintEngine(); 
 
			// Set COM port for SDPE 
			SDPE.Port="COM7:"; 
 
			// Create page with size parameters 
			SDPE.CreatePage(36,42); 
		} 
	} 
}