Basic results printer modified as well.
This commit is contained in:
@@ -17,11 +17,19 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
|
||||
|
||||
const int SpacingOne = 18;
|
||||
const int SpacingOneAndHalf = (3 * SpacingOne) / 2;
|
||||
const int TitleX = 100;
|
||||
|
||||
readonly int topMargin;
|
||||
readonly int bottomMargin;
|
||||
readonly int leftMargin;
|
||||
readonly int TitleX;
|
||||
readonly int TitleY; /// Depends on the size of the header
|
||||
readonly int HdrTop; /// = TitleY + 60
|
||||
readonly int BodyTop; /// = HdrTop + 160
|
||||
|
||||
/// Size of the printed area without margins, after taking into account 'pageOrientation'
|
||||
int printHeight;
|
||||
int printWidth;
|
||||
|
||||
/// <summary>
|
||||
/// Property variable for the Font the user wishes to use
|
||||
/// </summary>
|
||||
@@ -55,13 +63,18 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
|
||||
/// <param name="textToPrint">Text to be printed</param>
|
||||
public BasicPrintDocument(Results.Entities.Batch batch,
|
||||
PageOrientation pageOrientation,
|
||||
int topMrgn)
|
||||
int topMargin, int bottomMargin, int leftMargin)
|
||||
{
|
||||
this.batch = batch;
|
||||
|
||||
DefaultPageSettings.Landscape = (pageOrientation == PageOrientation.Landscape);
|
||||
|
||||
TitleY = topMrgn; /// Depends on the size of the header
|
||||
this.topMargin = topMargin;
|
||||
this.bottomMargin = bottomMargin;
|
||||
this.leftMargin = leftMargin;
|
||||
|
||||
TitleX = leftMargin;
|
||||
TitleY = topMargin; /// Depends on the size of the header
|
||||
HdrTop = TitleY + 60;
|
||||
BodyTop = HdrTop + 160;
|
||||
|
||||
@@ -74,19 +87,16 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
|
||||
rsltItems = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_SingleWM);
|
||||
}
|
||||
|
||||
/// Set print area size and margins (in dots using 80 dpi)
|
||||
int printHeight = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom;
|
||||
int printWidth = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right;
|
||||
int leftMargin = base.DefaultPageSettings.Margins.Left; /// X
|
||||
int topMargin = base.DefaultPageSettings.Margins.Top; /// Y
|
||||
|
||||
/// Check if the user selected to print in Landscape mode
|
||||
/// if they did then we need to swap height/width parameters
|
||||
/// Set print area size and margins (in dots using 100 dpi)
|
||||
if (DefaultPageSettings.Landscape)
|
||||
{
|
||||
int tmp = printHeight;
|
||||
printHeight = printWidth;
|
||||
printWidth = tmp;
|
||||
printHeight = base.DefaultPageSettings.PaperSize.Width - topMargin - bottomMargin;
|
||||
printWidth = base.DefaultPageSettings.PaperSize.Height - leftMargin - leftMargin;
|
||||
}
|
||||
else
|
||||
{
|
||||
printHeight = base.DefaultPageSettings.PaperSize.Height - topMargin - bottomMargin;
|
||||
printWidth = base.DefaultPageSettings.PaperSize.Width - leftMargin - leftMargin;
|
||||
}
|
||||
|
||||
int testsCount = batch.WaterMeters[0].MeterTestRslts.Count;
|
||||
@@ -133,24 +143,6 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
|
||||
e.Graphics.DrawImage(new Bitmap(img), new Rectangle(0, 0, 827, 1169));
|
||||
}
|
||||
|
||||
/// Set print area size and margins (in dots using 80 dpi)
|
||||
int printHeight = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom;
|
||||
int printWidth = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right;
|
||||
int leftMargin = base.DefaultPageSettings.Margins.Left; /// X
|
||||
int topMargin = base.DefaultPageSettings.Margins.Top; /// Y
|
||||
|
||||
/// Check if the user selected to print in Landscape mode
|
||||
/// if they did then we need to swap height/width parameters
|
||||
if (base.DefaultPageSettings.Landscape)
|
||||
{
|
||||
int tmp = printHeight;
|
||||
printHeight = printWidth;
|
||||
printWidth = tmp;
|
||||
}
|
||||
|
||||
int x = leftMargin;
|
||||
int y = topMargin;
|
||||
|
||||
/// Use the StringFormat class for the text layout of our document
|
||||
StringFormat format = new StringFormat(StringFormatFlags.LineLimit);
|
||||
|
||||
@@ -159,7 +151,7 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
|
||||
///----------
|
||||
/// Header
|
||||
///----------
|
||||
RectangleF printArea = new RectangleF(TitleX, TitleY, 667, 40);
|
||||
RectangleF printArea = new RectangleF(TitleX, TitleY, printWidth, 40);
|
||||
e.Graphics.DrawString(batch.ProtocolTitle, titleFont, Brushes.Black, printArea);
|
||||
|
||||
string[] leftColumn = new string[]
|
||||
@@ -196,7 +188,7 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
|
||||
/// Write aligned columns
|
||||
for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++)
|
||||
{
|
||||
PrintAt(e, 100, HdrTop + SpacingOne * i, leftColumn[i]);
|
||||
PrintAt(e, leftMargin, HdrTop + SpacingOne * i, leftColumn[i]);
|
||||
PrintAt(e, 300, HdrTop + SpacingOne * i, rightColumn[i]);
|
||||
}
|
||||
}
|
||||
@@ -222,7 +214,10 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
|
||||
///----------
|
||||
/// Footer
|
||||
///----------
|
||||
PrintAt(e, leftMargin, topMargin + printHeight - SpacingOne, string.Format("{0} {1}/{2}", Strings.Page, pageNr++, nrPages));
|
||||
string footerText = string.Format("str. {1}/{2}", Strings.Page, pageNr++, nrPages);
|
||||
int footerWidth = (int)e.Graphics.MeasureString(footerText, font).Width;
|
||||
PrintAt(e, leftMargin + (printWidth - footerWidth) / 2, topMargin + printHeight - SpacingOne, footerText);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -238,7 +233,7 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
|
||||
{
|
||||
/// Determin column widths
|
||||
float[] columnPos = new float[rsltItems.Count + 1];
|
||||
columnPos[0] = 100.0f;
|
||||
columnPos[0] = (float)leftMargin;
|
||||
|
||||
for (int i = 0; i < rsltItems.Count; i++)
|
||||
{
|
||||
@@ -275,10 +270,10 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
|
||||
int tableRightX = (int)columnPos[rsltItems.Count] - 20;
|
||||
|
||||
string wmText = string.Format("Water meter {0}", printedWMNr);
|
||||
PrintAt(e, 100, top, wmText);
|
||||
PrintAt(e, leftMargin, top, wmText);
|
||||
if (!string.IsNullOrEmpty(wm.SerialNr))
|
||||
{
|
||||
PrintAt(e, 100 + (int)e.Graphics.MeasureString(wmText, font).Width, top,
|
||||
PrintAt(e, leftMargin + (int)e.Graphics.MeasureString(wmText, font).Width, top,
|
||||
string.Format(" s/n = {0}", wm.SerialNr));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user