www.pudn.com > Cnewprint.rar > Title.cs


using System; 
using System.Drawing; 
 
namespace GoldPrinter 
{ 
	///  
	/// 主标题,默认最多只打印两行文字,可用MaxRows调整,可以用\n硬换行。在最后一行文字下画强调下划线 
	///  
	/// 程序提供:周方勇;Email:flygoldfish@sina.com。 
	/// 请 关 注:WebMIS.Net快速开发工具,不写一行程序开发B/S架构下MIS、OA、CRM、人事管理、档案管理等数据库网页系统。简单、实用、稳定、可靠。 
	/// 下    载: 
	///			 上海奥联:WWW.AlinkSoft.COM 
	///			 用友华表:WWW.CellSoft.CC 
	///★★★★★您可以免费使用此程序,但是请您保留此说明,以维护知识产权★★★★★ 
	///  
	public class Title:Caption 
	{ 
		public Title() 
		{ 
			this.IsDrawAllPage = true; 
			this.Font = new Font("黑体",21,FontStyle.Bold);		//字体 
			this.MaxRows = 2; 
		} 
 
		///  
		/// 主标题构造函数 
		///  
		/// 默认最多只打印两行文字,可以用\n硬换行。在最后一行文字下画强调下划线 
		public Title(string text):this() 
		{		 
			this.Text = text; 
		} 
 
		public override bool IsDrawAllPage 
		{ 
			get 
			{ 
				return base.IsDrawAllPage; 
			} 
		} 
 
 
		public override void Draw() 
		{ 
			base.Draw(); 
			//在最后一行文本下画两根下划线 
 
			float x1,x2,y,lineWidth; 
 
			lineWidth = this.RectangleF.Width; 
 
			//仅找最后一个 
			int index = this.Text.LastIndexOf("\n"); 
			 
			//有硬换行 
			if (index > 0) 
			{ 
				string txt = this.Text.Substring(index+1); 
				lineWidth = this.TextWidth(txt); 
			} 
			 
			x1 = (this.PrinterMargins.Width - lineWidth)/2 + this.PrinterMargins.Left + this.MoveX; 
			y = this.RectangleF.Y + this.RectangleF.Height; 
			x2 = x1 + lineWidth;	 
 
			this.Graphics.DrawLine(Pens.Black,x1,y-4,x2,y-4); 
			this.Graphics.DrawLine(Pens.Black,x1,y-2,x2,y-2); 
 
//			//高再相应的加下划线的高 
//			this.RectangleF.Height += 2; 
		} 
 
	}//End Class 
}//End NameSpace