⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 title.cs

📁 用C#编写的一个新的打印程序
💻 CS
字号:
using System;
using System.Drawing;

namespace GoldPrinter
{
	/// <summary>
	/// 主标题,默认最多只打印两行文字,可用MaxRows调整,可以用\n硬换行。在最后一行文字下画强调下划线
	/// 
	/// 程序提供:周方勇;Email:flygoldfish@sina.com。
	/// 请 关 注:WebMIS.Net快速开发工具,不写一行程序开发B/S架构下MIS、OA、CRM、人事管理、档案管理等数据库网页系统。简单、实用、稳定、可靠。
	/// 下    载:
	///			 上海奥联:WWW.AlinkSoft.COM
	///			 用友华表:WWW.CellSoft.CC
	///★★★★★您可以免费使用此程序,但是请您保留此说明,以维护知识产权★★★★★
	/// </summary>
	public class Title:Caption
	{
		public Title()
		{
			this.IsDrawAllPage = true;
			this.Font = new Font("黑体",21,FontStyle.Bold);		//字体
			this.MaxRows = 2;
		}

		/// <summary>
		/// 主标题构造函数
		/// </summary>
		/// <param name="text">默认最多只打印两行文字,可以用\n硬换行。在最后一行文字下画强调下划线</param>
		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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -