?? title.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 + -