131 lines
2.0 KiB
C#
131 lines
2.0 KiB
C#
using System;
|
|
using System.Drawing.Printing;
|
|
|
|
namespace GoldPrinter
|
|
{
|
|
public abstract class PrinterBase : DrawBase
|
|
{
|
|
private PrintDocument _printDocument;
|
|
|
|
private PrinterMargins _printerMargins;
|
|
|
|
private int _pageWidth;
|
|
|
|
private int _pageHeight;
|
|
|
|
private int _leftMargin;
|
|
|
|
private int _rightMargin;
|
|
|
|
private int _topMargin;
|
|
|
|
private int _bottomMargin;
|
|
|
|
public PrintDocument PrintDocument
|
|
{
|
|
get
|
|
{
|
|
return this._printDocument;
|
|
}
|
|
set
|
|
{
|
|
if (value != null)
|
|
{
|
|
this._printDocument = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public PrinterMargins PrinterMargins
|
|
{
|
|
get
|
|
{
|
|
return this._printerMargins;
|
|
}
|
|
set
|
|
{
|
|
if (value != null)
|
|
{
|
|
this._printerMargins = value;
|
|
this.SetPageInfo();
|
|
}
|
|
}
|
|
}
|
|
|
|
public int PageWidth
|
|
{
|
|
get
|
|
{
|
|
return this._pageWidth;
|
|
}
|
|
}
|
|
|
|
public int PageHeight
|
|
{
|
|
get
|
|
{
|
|
return this._pageHeight;
|
|
}
|
|
}
|
|
|
|
public int LeftMargin
|
|
{
|
|
get
|
|
{
|
|
return this._leftMargin;
|
|
}
|
|
}
|
|
|
|
public int RightMargin
|
|
{
|
|
get
|
|
{
|
|
return this._rightMargin;
|
|
}
|
|
}
|
|
|
|
public int TopMargin
|
|
{
|
|
get
|
|
{
|
|
return this._topMargin;
|
|
}
|
|
}
|
|
|
|
public int BottomMargin
|
|
{
|
|
get
|
|
{
|
|
return this._bottomMargin;
|
|
}
|
|
}
|
|
|
|
public PrinterBase()
|
|
{
|
|
this._printDocument = PrinterSingleton.PrintDocument;
|
|
this._printerMargins = PrinterSingleton.PrinterMargins;
|
|
this.SetPageInfo();
|
|
}
|
|
|
|
public void CalculatePageInfo()
|
|
{
|
|
this.PrinterMargins = new PrinterMargins(this.PrintDocument);
|
|
this.SetPageInfo();
|
|
}
|
|
|
|
private void SetPageInfo()
|
|
{
|
|
this._leftMargin = this.PrinterMargins.Left;
|
|
this._topMargin = this.PrinterMargins.Top;
|
|
this._rightMargin = this.PrinterMargins.Right;
|
|
this._bottomMargin = this.PrinterMargins.Bottom;
|
|
this._pageWidth = this.PrinterMargins.Width + this._leftMargin + this._rightMargin;
|
|
this._pageHeight = this.PrinterMargins.Height + this._topMargin + this._bottomMargin;
|
|
}
|
|
|
|
private void AddNonePrintArea()
|
|
{
|
|
}
|
|
}
|
|
}
|