public class ClassificationReport : PrintDocument
{
private String _fontName = "MS Pゴシック";
public ClassificationReport()
{
}
protected override void OnPrintPage(PrintPageEventArgs e)
{
base.OnPrintPage(e);
SetPrintDate(e);
}
private void SetPrintDate(PrintPageEventArgs e)
{
Graphics g = e.Graphics;
g.PageUnit = GraphicsUnit.Millimeter;
SetText(g, "区分台帳一覧表", 32, Brushes.Black, 0, 0);
SetHorizonLine(g, Brushes.Black, 0, new Font(this._fontName, 30).GetHeight(g), 300, 2, System.Drawing.Drawing2D.DashStyle.Solid);
SetText(g, "|", 12, Brushes.Black, 0,50 );
SetText(g, "|", 12, Brushes.Black, 10, 50);
SetText(g, "|", 12, Brushes.Black, 20, 50);
SetText(g, "|", 12, Brushes.Black, 30, 50);
SetText(g, "|", 12, Brushes.Black, 40, 50);
SetText(g, "|", 12, Brushes.Black, 180, 50);
SetText(g, "|", 12, Brushes.Black, 190, 50);
SetText(g, "|", 12, Brushes.Black, 200, 50);
SetText(g, "キタ━━━━━━(゚∀゚)━━━━━━ !!!!!", 12, Brushes.Black, 0, 250);
//このページで終了
e.HasMorePages = false;
}
protected override void OnEndPrint(PrintEventArgs e)
{
base.OnEndPrint(e);
}
private void SetText(Graphics g, String value, float size, Brush foreColor, float x, float y)
{
Font font = new Font(this._fontName, size);
g.DrawString(value, font, foreColor, x, y);
}
private void SetHorizonLine(Graphics g,Brush lineColor,float x,float y,float width,float lineHeight,System.Drawing.Drawing2D.DashStyle dashStyle)
{
Pen pen = new Pen(lineColor, lineHeight);
pen.DashStyle = dashStyle;
g.DrawLine(pen, x, y + (lineHeight / 2), x + width, y + (lineHeight / 2));
}