2022-12-27 17:33:33 +08:00

38 lines
900 B
C#

using System;
using System.Drawing;
namespace GoldPrinter
{
public class Title : Caption
{
public Title()
{
this.IsDrawAllPage = true;
this.Font = new Font("黑体", 21f, FontStyle.Bold);
base.MaxRows = 2;
}
public Title(string text) : this()
{
base.Text = text;
}
public override void Draw()
{
base.Draw();
float num = (float)base.Rectangle.Width;
int num2 = base.Text.LastIndexOf("\n");
if (num2 > 0)
{
string text = base.Text.Substring(num2 + 1);
num = (float)base.TextWidth(text);
}
float num3 = ((float)base.PrinterMargins.Width - num) / 2f + (float)base.PrinterMargins.Left + (float)base.MoveX;
float num4 = (float)(base.Rectangle.Y + base.Rectangle.Height);
float x = num3 + num;
base.Graphics.DrawLine(base.Pen, num3, num4 - 4f, x, num4 - 4f);
base.Graphics.DrawLine(base.Pen, num3, num4 - 2f, x, num4 - 2f);
}
}
}