www.pudn.com > CFPrinterClass_src.rar > Preview.cs, change:2004-04-05,size:4286b


using System; 
using System.Drawing; 
using System.Collections; 
using System.ComponentModel; 
using System.Windows.Forms; 
 
namespace CFPrinterClass 
{ 
	/// <summary> 
	/// Summary description for Form2. 
	/// </summary> 
	public class frmPreview : System.Windows.Forms.Form 
	{ 
		private System.Windows.Forms.VScrollBar vScrollBar; 
		private System.Windows.Forms.HScrollBar hScrollBar; 
		private System.Windows.Forms.Button btnBack; 
		private System.Windows.Forms.NumericUpDown Page; 
		private System.Windows.Forms.Panel MainPanel; 
	 
		// Local variables 
		private int iPageWidth; 
		private System.Windows.Forms.Label lblPage; 
		private System.Windows.Forms.Panel PreviewPanel; 
		private System.Collections.ArrayList m_array; 
		private int iPageHeight; 
		private const int CHAR_WIDTH=6; 
		private const int CHAR_HEIGHT=12; 
 
		public frmPreview(int PageWidth, int PageHeight, ArrayList Fields) 
		{ 
			// 
			// Required for Windows Form Designer support 
			// 
			InitializeComponent(); 
 
			iPageHeight = PageHeight; 
			iPageWidth = PageWidth; 
			m_array = Fields; 
		} 
 
		/// <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() 
		{ 
			this.vScrollBar = new System.Windows.Forms.VScrollBar(); 
			this.hScrollBar = new System.Windows.Forms.HScrollBar(); 
			this.btnBack = new System.Windows.Forms.Button(); 
			this.Page = new System.Windows.Forms.NumericUpDown(); 
			this.lblPage = new System.Windows.Forms.Label(); 
			this.MainPanel = new System.Windows.Forms.Panel(); 
			this.PreviewPanel = new System.Windows.Forms.Panel(); 
			//  
			// vScrollBar 
			//  
			this.vScrollBar.Location = new System.Drawing.Point(224, 0); 
			this.vScrollBar.Maximum = 91; 
			this.vScrollBar.Size = new System.Drawing.Size(16, 240); 
			//  
			// hScrollBar 
			//  
			this.hScrollBar.Location = new System.Drawing.Point(0, 240); 
			this.hScrollBar.Maximum = 91; 
			this.hScrollBar.Size = new System.Drawing.Size(224, 16); 
			//  
			// btnBack 
			//  
			this.btnBack.Location = new System.Drawing.Point(8, 262); 
			this.btnBack.Size = new System.Drawing.Size(48, 24); 
			this.btnBack.Text = "Back"; 
			//  
			// Page 
			//  
			this.Page.Location = new System.Drawing.Point(184, 265); 
			this.Page.Size = new System.Drawing.Size(40, 20); 
			//  
			// lblPage 
			//  
			this.lblPage.Location = new System.Drawing.Point(137, 269); 
			this.lblPage.Size = new System.Drawing.Size(47, 16); 
			this.lblPage.Text = "Page #"; 
			//  
			// MainPanel 
			//  
			this.MainPanel.Controls.Add(this.PreviewPanel); 
			this.MainPanel.Size = new System.Drawing.Size(224, 240); 
			//  
			// PreviewPanel 
			//  
			this.PreviewPanel.Size = new System.Drawing.Size(16, 16); 
			//  
			// frmPreview 
			//  
			this.ClientSize = new System.Drawing.Size(240, 295); 
			this.ControlBox = false; 
			this.Controls.Add(this.MainPanel); 
			this.Controls.Add(this.lblPage); 
			this.Controls.Add(this.Page); 
			this.Controls.Add(this.btnBack); 
			this.Controls.Add(this.hScrollBar); 
			this.Controls.Add(this.vScrollBar); 
			this.Text = "Preview"; 
			this.Load += new System.EventHandler(this.frmPreview_Load); 
 
		} 
		#endregion 
 
		// Write to screen 
		private void SetText(int X, int Y, string Value) 
		{ 
			Label m_field = new Label(); 
			PreviewPanel.Controls.Add(m_field); 
			m_field.Text = Value; 
			m_field.Left = X; 
			m_field.Height = Y; 
			m_field.Width = 100; 
			m_field.Height = 20; 
			m_field.BackColor = System.Drawing.Color.Black; 
			m_field.Show(); 
		} 
		// Form load event 
		private void frmPreview_Load(object sender, System.EventArgs e) 
		{ 
			// Set main pane size 
			PreviewPanel.Width = iPageWidth * CHAR_WIDTH; 
			PreviewPanel.Height = iPageHeight * CHAR_HEIGHT;	 
			int i; 
			for(i=0;i!=2;i++) 
			{ 
				if(i==0) 
					SetText(10, 10, "oged"); 
				if(i==1) 
					SetText(10, 20, "oged"); 
				if(i==2) 
					SetText(10, 30, "oged"); 
			} 
		} 
	} 
}