116 lines
2.4 KiB
C#
116 lines
2.4 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Drawing.Drawing2D;
|
|
|
|
namespace GoldPrinter
|
|
{
|
|
public class Sewing : IDisposable
|
|
{
|
|
private SewingDirectionFlag _sewingDirection;
|
|
|
|
private int _margin;
|
|
|
|
private int _lineLength;
|
|
|
|
public SewingDirectionFlag SewingDirection
|
|
{
|
|
get
|
|
{
|
|
return this._sewingDirection;
|
|
}
|
|
set
|
|
{
|
|
this._sewingDirection = value;
|
|
}
|
|
}
|
|
|
|
public int Margin
|
|
{
|
|
get
|
|
{
|
|
return this._margin;
|
|
}
|
|
set
|
|
{
|
|
this._margin = value;
|
|
}
|
|
}
|
|
|
|
public int LineLen
|
|
{
|
|
get
|
|
{
|
|
return this._lineLength;
|
|
}
|
|
set
|
|
{
|
|
this._lineLength = value;
|
|
}
|
|
}
|
|
|
|
public Sewing()
|
|
{
|
|
this._margin = 0;
|
|
this._sewingDirection = SewingDirectionFlag.Left;
|
|
this._lineLength = 0;
|
|
}
|
|
|
|
public Sewing(int margin) : this(margin, SewingDirectionFlag.Left, 0)
|
|
{
|
|
}
|
|
|
|
public Sewing(int margin, int lineLength) : this(margin, SewingDirectionFlag.Left, lineLength)
|
|
{
|
|
}
|
|
|
|
public Sewing(int margin, SewingDirectionFlag sewingDirection) : this(margin, sewingDirection, 0)
|
|
{
|
|
}
|
|
|
|
public Sewing(int margin, SewingDirectionFlag sewingDirection, int lineLength)
|
|
{
|
|
this._margin = margin;
|
|
this._sewingDirection = sewingDirection;
|
|
this._lineLength = lineLength;
|
|
}
|
|
|
|
public virtual void Dispose()
|
|
{
|
|
}
|
|
|
|
public void Draw(Graphics g)
|
|
{
|
|
Font font = new Font("宋体", 8f);
|
|
string s = "装 订 线";
|
|
StringFormat stringFormat = new StringFormat();
|
|
stringFormat.Alignment = StringAlignment.Center;
|
|
int margin;
|
|
int num = margin = this._margin;
|
|
int lineLength;
|
|
int num2 = lineLength = this._lineLength;
|
|
Pen pen = new Pen(Color.Red);
|
|
pen.DashStyle = DashStyle.Dot;
|
|
if (this._sewingDirection == SewingDirectionFlag.Left)
|
|
{
|
|
g.DrawLine(pen, margin, 0, margin, lineLength);
|
|
stringFormat.FormatFlags = StringFormatFlags.DirectionVertical;
|
|
int num3 = (int)g.MeasureString("装", font).Width;
|
|
num3 /= 2;
|
|
Rectangle r = new Rectangle(margin - num3, 0, margin - num3, lineLength);
|
|
g.DrawString(s, font, Brushes.DodgerBlue, r, stringFormat);
|
|
}
|
|
else if (this._sewingDirection == SewingDirectionFlag.Top)
|
|
{
|
|
g.DrawLine(pen, 0, num, num2, num);
|
|
int num4 = (int)g.MeasureString("装", font).Height;
|
|
num4 /= 2;
|
|
Rectangle r = new Rectangle(0, num - num4, num2, num - num4);
|
|
g.DrawString(s, font, Brushes.DodgerBlue, r, stringFormat);
|
|
}
|
|
pen.Dispose();
|
|
font.Dispose();
|
|
stringFormat.Dispose();
|
|
}
|
|
}
|
|
}
|