Munich 14.12.2018: Table (fixed column widths), MunichPrintDocument (up to 5 pages, flow calculation, etc), bug fixes, ver. 2.18.1094
This commit is contained in:
parent
1b7dbec443
commit
bb8b4a6fd6
@ -1,11 +1,13 @@
|
||||
///
|
||||
/// Copyright (c) 2016-2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2016-2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Printing;
|
||||
using Config.Entities;
|
||||
using System.IO;
|
||||
using Results.Resources;
|
||||
|
||||
namespace Results.Output.Printers.Munich
|
||||
{
|
||||
@ -38,11 +40,16 @@ namespace Results.Output.Printers.Munich
|
||||
readonly int resultsCount;
|
||||
readonly bool compound; /// true when MetersKind is MetersKind.Combined
|
||||
|
||||
/// Top coordinate of the table
|
||||
int nrPages;
|
||||
int pageNr;
|
||||
int firstTblTop;
|
||||
int secondTblTop;
|
||||
|
||||
int pageNr; /// Current page number
|
||||
int nrPages; /// Total number of pages
|
||||
float tableTop; /// Top coordinate of the table
|
||||
|
||||
int[] firstTblRowsOnPage;
|
||||
int[] secondTblRowsOnPage;
|
||||
|
||||
|
||||
PageOrientation pageOrientation;
|
||||
|
||||
/// <summary>
|
||||
/// Property variable for the Font the user wishes to use
|
||||
@ -51,7 +58,34 @@ namespace Results.Output.Printers.Munich
|
||||
Font boldFont;
|
||||
Font fontTitle;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Table style
|
||||
///
|
||||
static TableStyle tableStyle = new TableStyle
|
||||
{
|
||||
Font = new Font(FontFamilyName, 10, FontStyle.Regular),
|
||||
HeaderFont = new Font(FontFamilyName, 10, FontStyle.Regular),
|
||||
MarginX = 7,
|
||||
MarginY = 5,
|
||||
LineWidth = 1,
|
||||
TopHeadersCount = 1,
|
||||
HorizLines = TableLines.FirstSecondAndLast,
|
||||
VertLines = TableLines.All,
|
||||
ColumnWidths = new float[] { 150, 70, 75, 75, 70, 75, 75 },
|
||||
};
|
||||
static Alignment[] horizontalAlignment = new Alignment[] /// Horizontal alignment of items of one row
|
||||
{
|
||||
Alignment.Left, Alignment.Left, Alignment.Left,
|
||||
Alignment.Left, Alignment.Left, Alignment.Left, Alignment.Left
|
||||
};
|
||||
static VertAlignment[] verticalAlignment = new VertAlignment[] /// Vertical alignment of items of one row
|
||||
{
|
||||
VertAlignment.Middle, VertAlignment.Middle, VertAlignment.Middle,
|
||||
VertAlignment.Middle, VertAlignment.Middle, VertAlignment.Middle, VertAlignment.Middle
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="textToPrint">Text to be printed</param>
|
||||
@ -61,7 +95,8 @@ namespace Results.Output.Printers.Munich
|
||||
{
|
||||
this.docVersion = docVersion;
|
||||
this.wm = wm;
|
||||
compound = wm.Compound();
|
||||
this.compound = wm.Compound();
|
||||
this.pageOrientation = pageOrientation;
|
||||
|
||||
string[] info = wm.ProductName().Split(new char[] { ';' });
|
||||
if (info.Length >= 2)
|
||||
@ -81,13 +116,88 @@ namespace Results.Output.Printers.Munich
|
||||
}
|
||||
|
||||
results = wm.MeterTestRslts;
|
||||
this.resultsCount = compound ? (results.Count / 3) : results.Count;
|
||||
|
||||
int resultsCount = wm.MeterTestRslts.Count;
|
||||
if (compound) resultsCount /= 3;
|
||||
resultsCount = 0;
|
||||
foreach (var mtr in wm.MeterTestRslts)
|
||||
{
|
||||
if (mtr != null && mtr.IsPilotRslt() && mtr.Publish() == Config.Entities.Publish.Always) resultsCount++;
|
||||
}
|
||||
|
||||
pageNr = 1;
|
||||
nrPages = (compound ? (resultsCount > 7) : (resultsCount > 9)) ? 2 : 1;
|
||||
if (compound)
|
||||
{
|
||||
/// Compound meter results
|
||||
const int MaxOnFirstPage = 23;
|
||||
const int MaxOnPage = 45;
|
||||
if (resultsCount <= 7)
|
||||
{
|
||||
nrPages = 1;
|
||||
firstTblRowsOnPage = new int[] { resultsCount };
|
||||
secondTblRowsOnPage = new int[] { resultsCount };
|
||||
}
|
||||
else if (resultsCount <= MaxOnFirstPage)
|
||||
{
|
||||
nrPages = 2;
|
||||
firstTblRowsOnPage = new int[] { resultsCount, 0 };
|
||||
secondTblRowsOnPage = new int[] { 0, int.MaxValue };
|
||||
}
|
||||
else if (resultsCount <= MaxOnPage)
|
||||
{
|
||||
nrPages = 3;
|
||||
firstTblRowsOnPage = new int[] { MaxOnFirstPage, (resultsCount - MaxOnFirstPage), 0 };
|
||||
int secondTblRowsOn2ndPage = Math.Max(0, MaxOnFirstPage + MaxOnPage - 2 - resultsCount);
|
||||
secondTblRowsOnPage = new int[] { 0, secondTblRowsOn2ndPage, resultsCount - secondTblRowsOn2ndPage };
|
||||
}
|
||||
else if (resultsCount <= MaxOnFirstPage + MaxOnPage)
|
||||
{
|
||||
nrPages = 4;
|
||||
firstTblRowsOnPage = new int[] { MaxOnFirstPage, MaxOnPage, 0, 0 };
|
||||
secondTblRowsOnPage = new int[] { 0, 0, MaxOnPage, MaxOnFirstPage };
|
||||
}
|
||||
else
|
||||
{
|
||||
nrPages = 5;
|
||||
firstTblRowsOnPage = new int[] { MaxOnFirstPage, MaxOnPage, (resultsCount - MaxOnFirstPage - MaxOnPage), 0 };
|
||||
secondTblRowsOnPage = new int[] { 0, 0, Math.Max(0, MaxOnFirstPage + 2 * MaxOnPage - 2 - resultsCount), MaxOnPage, MaxOnFirstPage };
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Regular (single) meter results
|
||||
const int MaxOnFirstPage = 27;
|
||||
const int MaxOnPage = 45;
|
||||
if (resultsCount <= 9)
|
||||
{
|
||||
nrPages = 1;
|
||||
firstTblRowsOnPage = new int[] { resultsCount };
|
||||
secondTblRowsOnPage = new int[] { resultsCount };
|
||||
}
|
||||
else if (resultsCount <= MaxOnFirstPage)
|
||||
{
|
||||
nrPages = 2;
|
||||
firstTblRowsOnPage = new int[] { resultsCount, 0 };
|
||||
secondTblRowsOnPage = new int[] { 0, int.MaxValue };
|
||||
}
|
||||
else if (resultsCount <= MaxOnPage)
|
||||
{
|
||||
nrPages = 3;
|
||||
firstTblRowsOnPage = new int[] { MaxOnFirstPage, (resultsCount - MaxOnFirstPage), 0 };
|
||||
int secondTblRowsOn2ndPage = Math.Max(0, MaxOnFirstPage + MaxOnPage - 2 - resultsCount);
|
||||
secondTblRowsOnPage = new int[] { 0, secondTblRowsOn2ndPage, resultsCount - secondTblRowsOn2ndPage };
|
||||
}
|
||||
else if (resultsCount <= MaxOnFirstPage + MaxOnPage)
|
||||
{
|
||||
nrPages = 4;
|
||||
firstTblRowsOnPage = new int[] { MaxOnFirstPage, MaxOnPage, 0, 0 };
|
||||
secondTblRowsOnPage = new int[] { 0, 0, MaxOnPage, MaxOnFirstPage };
|
||||
}
|
||||
else
|
||||
{
|
||||
nrPages = 5;
|
||||
firstTblRowsOnPage = new int[] { MaxOnFirstPage, MaxOnPage, (resultsCount - MaxOnFirstPage - MaxOnPage), 0 };
|
||||
secondTblRowsOnPage = new int[] { 0, 0, Math.Max(0, MaxOnFirstPage + 2 * MaxOnPage - 2 - resultsCount), MaxOnPage, MaxOnFirstPage };
|
||||
}
|
||||
}
|
||||
|
||||
DefaultPageSettings.Landscape = (pageOrientation == PageOrientation.Landscape);
|
||||
}
|
||||
@ -116,8 +226,30 @@ namespace Results.Output.Printers.Munich
|
||||
/// Run base code
|
||||
base.OnPrintPage(e);
|
||||
|
||||
/// Draw 2550 x 3507 'headpic' scaled to A4 at 100 DPI
|
||||
e.Graphics.DrawImage(Results.Properties.Resources.Headpic, new Rectangle(0, 0, 827, 1137));
|
||||
if (pageOrientation == PageOrientation.Portrait)
|
||||
{
|
||||
string[] templatePaths = new string[] { "C:\\TBF\\Templates\\MunichP.jpg", "C:\\TBF\\Templates\\MunichP.png", "C:\\TBF\\Templates\\MunichP.tif" };
|
||||
foreach (var t in templatePaths)
|
||||
{
|
||||
if (File.Exists(t))
|
||||
{
|
||||
e.Graphics.DrawImage(new Bitmap(Image.FromFile(t), 827, 1169), new Rectangle(0, 0, 827, 1169));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] templatePaths = new string[] { "C:\\TBF\\Templates\\MunichL.jpg", "C:\\TBF\\Templates\\MunichL.png", "C:\\TBF\\Templates\\MunichL.tif" };
|
||||
foreach (var t in templatePaths)
|
||||
{
|
||||
if (File.Exists(t))
|
||||
{
|
||||
e.Graphics.DrawImage(new Bitmap(Image.FromFile(t), 1169, 827), new Rectangle(0, 0, 1169, 827));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 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;
|
||||
@ -144,27 +276,21 @@ namespace Results.Output.Printers.Munich
|
||||
|
||||
if (pageNr == 1)
|
||||
{
|
||||
RectangleF printArea = new RectangleF(TitleX, TitleY, 667, 50);
|
||||
/// This is the first page, drad the title, common part and the 1st table
|
||||
|
||||
RectangleF printArea = new RectangleF(TitleX, TitleY, 667, 50);
|
||||
e.Graphics.DrawString(wm.Batch.ProtocolTitle, this.fontTitle, Brushes.Black, printArea);
|
||||
|
||||
///
|
||||
/// Common
|
||||
///
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, docVersion);
|
||||
lineNr++;
|
||||
PrintBoldAt(e, Tab1, lineNr * SpacingOne, "Prüfstand Nr :");
|
||||
PrintBoldAt(e, Tab2, lineNr * SpacingOne, wm.BenchId().ToString());
|
||||
PrintBoldAt(e, Tab3, lineNr * SpacingOne, "Datum :");
|
||||
PrintBoldAt(e, Tab4, lineNr * SpacingOne, wm.Batch.EndTime.Date.ToString("d"));
|
||||
lineNr++;
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Zählertyp :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, zaehlertyp);
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, "Eichjahr :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.YearOfProduction.ToString());
|
||||
lineNr++;
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Prüfvorlage :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, pruefvorlage);
|
||||
DrawCommonTop(e, ref lineNr, wm, pruefvorlage, docVersion);
|
||||
|
||||
lineNr += 2;
|
||||
tableTop = SpacingOne * lineNr;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// This appears on the top of the 2nd and every subsequent page.
|
||||
/// 2nd table starts from the top of the page.
|
||||
lineNr -= 3;
|
||||
|
||||
if (compound)
|
||||
{
|
||||
@ -189,228 +315,294 @@ namespace Results.Output.Printers.Munich
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, "Seriennummer :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.SerialNrAux);
|
||||
}
|
||||
lineNr++;
|
||||
lineNr += ((resultsCount + 2) * SpacingOneAndHalf) / SpacingOne + 2;
|
||||
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, wm.NewQnames() ? "Q3 :" : "Qn :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, wm.Q3_Qn().ToString());
|
||||
if (compound)
|
||||
{
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, wm.NewQnames() ? "Q3 :" : "Qn :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.Q3_Qn_Aux().ToString());
|
||||
}
|
||||
lineNr++;
|
||||
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Zulassungszeichen :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, wm.ApprovalInfo());
|
||||
if (compound)
|
||||
{
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, "Zulassungszeichen :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.ApprovalInfoAux());
|
||||
}
|
||||
lineNr++;
|
||||
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Metr. klasse :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, wm.MetrologicalClass());
|
||||
if (compound)
|
||||
{
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, "Metr. klasse :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.MetrologicalClassAux());
|
||||
}
|
||||
lineNr++;
|
||||
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Stand :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, wm.EndState);
|
||||
if (compound)
|
||||
{
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, "Stand :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.EndStateAux);
|
||||
|
||||
lineNr += 2;
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Umschaltpunkte :");
|
||||
lineNr++;
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Qsteig");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, (1000.0 * wm.QRise).ToString("F1") + " l/h");
|
||||
lineNr++;
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Qfall");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, (1000.0 * wm.QFall).ToString("F1") + " l/h");
|
||||
}
|
||||
|
||||
lineNr += 2;
|
||||
firstTblTop = SpacingOne * lineNr;
|
||||
|
||||
///
|
||||
/// Table 1
|
||||
///
|
||||
PrintTableOne(e, firstTblTop);
|
||||
DrawTableFrame(e, resultsCount + 1, firstTblTop);
|
||||
tableTop = TitleY + (compound ? 5 : 4) * SpacingOne;
|
||||
}
|
||||
|
||||
if (firstTblRowsOnPage[pageNr - 1] > 0)
|
||||
{
|
||||
int from = 0;
|
||||
for (int pN = 0; pN < pageNr - 1; pN++) from += firstTblRowsOnPage[pN];
|
||||
Table table1 = PrepareTableOne(from, from + firstTblRowsOnPage[pageNr - 1] - 1);
|
||||
tableTop = table1.Draw(e, Tab1, tableTop) + SpacingOneAndHalf;
|
||||
}
|
||||
|
||||
if (pageNr == nrPages)
|
||||
{
|
||||
if (pageNr == 1)
|
||||
{
|
||||
secondTblTop = firstTblTop + (resultsCount + 2) * SpacingOneAndHalf;
|
||||
lineNr += ((resultsCount + 2) * SpacingOneAndHalf * 2) / SpacingOne;
|
||||
}
|
||||
else
|
||||
{
|
||||
lineNr -= 3;
|
||||
|
||||
if (compound)
|
||||
{
|
||||
PrintBoldAt(e, Tab1, lineNr * SpacingOne, "Hauptzahler");
|
||||
PrintBoldAt(e, Tab3, lineNr * SpacingOne, "Nebenzahler");
|
||||
lineNr++;
|
||||
}
|
||||
if (secondTblRowsOnPage[pageNr - 1] > 0)
|
||||
{
|
||||
int from = 0;
|
||||
for (int pN = 0; pN < pageNr - 1; pN++) from += secondTblRowsOnPage[pN];
|
||||
Table table2 = PrepareTableTwo(from, from + secondTblRowsOnPage[pageNr - 1] - 1);
|
||||
tableTop = table2.Draw(e, Tab1, tableTop) + SpacingOneAndHalf;
|
||||
}
|
||||
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Hersteller :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, wm.Producer());
|
||||
if (compound)
|
||||
{
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, "Hersteller :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.ProducerAux());
|
||||
}
|
||||
lineNr++;
|
||||
if (pageNr == nrPages)
|
||||
{
|
||||
int top = topMargin + printHeight - 8 * SpacingOne;
|
||||
DrawCommonBottom(e, top, wm);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.HasMorePages = true;
|
||||
}
|
||||
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Seriennummer :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, wm.SerialNr);
|
||||
if (compound)
|
||||
{
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, "Seriennummer :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.SerialNrAux);
|
||||
}
|
||||
lineNr += ((resultsCount + 2) * SpacingOneAndHalf) / SpacingOne + 2;
|
||||
|
||||
secondTblTop = TitleY + (compound ? 5 : 4) * SpacingOne;
|
||||
}
|
||||
|
||||
///
|
||||
/// Table 2
|
||||
///
|
||||
PrintTableTwo(e, secondTblTop);
|
||||
DrawTableFrame(e, resultsCount + 1, secondTblTop);
|
||||
|
||||
///
|
||||
/// Footer
|
||||
///
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Temperatur");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, wm.Batch.AmbTempMean().ToString("F1") + " \x00b0C");
|
||||
lineNr++;
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Feuchtigkeit");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, wm.Batch.AmbHumiMean().ToString("F0") + " %");
|
||||
lineNr++;
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Luftdruck");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, Config.Units.ConvertTo(Config.Unit.mbar, wm.Batch.AmbPressMean()).ToString("F0") + " mbar");
|
||||
|
||||
lineNr++;
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, wm.Batch.EndTime.Date.ToString("d"));
|
||||
lineNr++;
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, "Datum");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, "Unterschrift");
|
||||
}
|
||||
|
||||
e.HasMorePages = (pageNr != nrPages);
|
||||
pageNr++;
|
||||
}
|
||||
///
|
||||
/// Draw a footer and increment the page number
|
||||
///
|
||||
string pageNrText = string.Format("{0} {1}/{2}", Strings.Page, pageNr++, nrPages);
|
||||
int pageNrWidth = (int)e.Graphics.MeasureString(pageNrText, font).Width;
|
||||
PrintAt(e, leftMargin + (printWidth - pageNrWidth) / 2, topMargin + printHeight - SpacingOne, pageNrText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print table texts.
|
||||
/// Prepares content and style of the first table.
|
||||
/// </summary>
|
||||
void PrintTableOne(System.Drawing.Printing.PrintPageEventArgs e, int tblTop)
|
||||
/// <param name="from">0-based index fo the first result to print</param>
|
||||
/// <param name="to">0-based index fo the last result to print</param>
|
||||
/// <returns>Prepared table</returns>
|
||||
Table PrepareTableOne(int from = 0, int to = int.MaxValue)
|
||||
{
|
||||
PrintAt(e, GetTabItemPos(0, 0, tblTop), "Prüflauf");
|
||||
PrintAt(e, GetTabItemPos(0, 1, tblTop), "Q [l/h]");
|
||||
PrintAt(e, GetTabItemPos(0, 2, tblTop), "Prüf-Vol.[l]");
|
||||
PrintAt(e, GetTabItemPos(0, 3, tblTop), compound ? "HZ-Vol.[l]" : "Z-Vol.[l]");
|
||||
PrintAt(e, GetTabItemPos(0, 4, tblTop), compound ? "NZ-Vol.[l]" : "-");
|
||||
PrintAt(e, GetTabItemPos(0, 5, tblTop), "Fehler [%]");
|
||||
PrintAt(e, GetTabItemPos(0, 6, tblTop), "Ergebnis");
|
||||
Table table = new Table(7);
|
||||
table.Style = tableStyle;
|
||||
|
||||
int rowCnt = 1;
|
||||
string[] tableHeader = new string[]
|
||||
{
|
||||
"Prüflauf",
|
||||
"Q [l/h]",
|
||||
"Prüf-Vol.[l]",
|
||||
compound ? "HZ-Vol.[l]" : "Z-Vol.[l]",
|
||||
compound ? "NZ-Vol.[l]" : "-",
|
||||
"Fehler [%]",
|
||||
"Ergebnis",
|
||||
};
|
||||
table.AddRow(tableHeader, horizontalAlignment, verticalAlignment);
|
||||
|
||||
int rowCount = 0;
|
||||
foreach (var mtr in wm.MeterTestRslts)
|
||||
{
|
||||
if (!compound || mtr.CompoundMeterId == (byte)CompoundMeterId.Compound)
|
||||
{
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 0, tblTop), mtr.Name());
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 1, tblTop), mtr.TestRslt.FlowMass.ToString("F1"));
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 2, tblTop), mtr.TestRslt.VolumeCTV.ToString("F2"));
|
||||
if (compound)
|
||||
{
|
||||
Results.Entities.MeterTestRslt mainMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain);
|
||||
Results.Entities.MeterTestRslt auxMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux);
|
||||
if (mtr != null && mtr.IsPilotRslt() && mtr.Publish() == Config.Entities.Publish.Always)
|
||||
{
|
||||
if (from <= rowCount && rowCount <= to)
|
||||
{
|
||||
double flow_ctv = (mtr.TestRslt.TestTime != 0) ? (3.6 * mtr.TestRslt.VolumeCTV / mtr.TestRslt.TestTime) : 0;
|
||||
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 3, tblTop), mainMtr.VolumeMeter.ToString("F2"));
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 4, tblTop), auxMtr.VolumeMeter.ToString("F2"));
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 5, tblTop), mtr.Error.ToString("F2"));
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 6, tblTop), mtr.Passed ? "iO" : "NiO");
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 3, tblTop), mtr.VolumeMeter.ToString("F2"));
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 4, tblTop), "-");
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 5, tblTop), mtr.Error.ToString("F2"));
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 6, tblTop), mtr.Passed ? "iO" : "NiO");
|
||||
}
|
||||
if (compound)
|
||||
{
|
||||
Results.Entities.MeterTestRslt mainMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain);
|
||||
Results.Entities.MeterTestRslt auxMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux);
|
||||
|
||||
rowCnt++;
|
||||
table.AddRow(new string[] { mtr.Name(),
|
||||
Config.Units.ConvertTo(Config.Unit.lph, flow_ctv).ToString("F1"),
|
||||
mtr.TestRslt.VolumeCTV.ToString("F2"),
|
||||
mainMtr.VolumeMeter.ToString("F2"),
|
||||
auxMtr.VolumeMeter.ToString("F2"),
|
||||
mtr.Error.ToString("F2"),
|
||||
mtr.Passed ? "iO" : "NiO" },
|
||||
horizontalAlignment,
|
||||
verticalAlignment);
|
||||
}
|
||||
else
|
||||
{
|
||||
table.AddRow(new string[] { mtr.Name(),
|
||||
Config.Units.ConvertTo(Config.Unit.lph, flow_ctv).ToString("F1"),
|
||||
mtr.TestRslt.VolumeCTV.ToString("F2"),
|
||||
mtr.VolumeMeter.ToString("F2"),
|
||||
"-",
|
||||
mtr.Error.ToString("F2"),
|
||||
mtr.Passed ? "iO" : "NiO" },
|
||||
|
||||
horizontalAlignment,
|
||||
verticalAlignment);
|
||||
}
|
||||
}
|
||||
rowCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
void PrintTableTwo(System.Drawing.Printing.PrintPageEventArgs e, int tblTop)
|
||||
/// <summary>
|
||||
/// Prepares content and style of the second table.
|
||||
/// </summary>
|
||||
/// <param name="from">0-based index fo the first result to print</param>
|
||||
/// <param name="to">0-based index fo the last result to print</param>
|
||||
/// <returns>Prepared table</returns>
|
||||
Table PrepareTableTwo(int from = 0, int to = int.MaxValue)
|
||||
{
|
||||
PrintAt(e, GetTabItemPos(0, 1, tblTop), "Q [l/h]");
|
||||
PrintAt(e, GetTabItemPos(0, 2, tblTop), "Temperatur");
|
||||
PrintAt(e, GetTabItemPos(0, 3, tblTop), "Dichte");
|
||||
PrintAt(e, GetTabItemPos(0, 4, tblTop), "Prüfzeit");
|
||||
PrintAt(e, GetTabItemPos(0, 5, tblTop), "Druck Eing.");
|
||||
PrintAt(e, GetTabItemPos(0, 6, tblTop), "Druck Ausg.");
|
||||
Table table = new Table(7);
|
||||
table.Style = tableStyle;
|
||||
|
||||
int rowCnt = 1;
|
||||
string[] tableHeader = new string[]
|
||||
{
|
||||
"",
|
||||
"Q [l/h]",
|
||||
"Temperatur",
|
||||
"Dichte",
|
||||
"Prüfzeit",
|
||||
"Druck Eing.",
|
||||
"Druck Ausg.",
|
||||
};
|
||||
table.AddRow(tableHeader, horizontalAlignment, verticalAlignment);
|
||||
|
||||
int rowCount = 0;
|
||||
foreach (var mtr in wm.MeterTestRslts)
|
||||
{
|
||||
if (!compound || mtr.CompoundMeterId == (byte)CompoundMeterId.Compound)
|
||||
{
|
||||
Point p = GetTabItemPos(rowCnt, 0, tblTop);
|
||||
PrintAt(e, p.X, p.Y, mtr.Name());
|
||||
if (mtr != null && mtr.IsPilotRslt() && mtr.Publish() == Config.Entities.Publish.Always)
|
||||
{
|
||||
if (from <= rowCount && rowCount <= to)
|
||||
{
|
||||
double flow_ctv = (mtr.TestRslt.TestTime != 0) ? (3.6 * mtr.TestRslt.VolumeCTV / mtr.TestRslt.TestTime) : 0;
|
||||
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 1, tblTop), mtr.TestRslt.FlowMass.ToString("F1"));
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 2, tblTop), mtr.TestRslt.TempDownMean.ToString("F2"));
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 3, tblTop), mtr.TestRslt.DensityDiv.ToString("F2"));
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 4, tblTop), mtr.TestTime.ToString("F1"));
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 5, tblTop), Config.Units.ConvertTo(Config.Unit.bar, mtr.TestRslt.PressUpMean).ToString("F3"));
|
||||
PrintAt(e, GetTabItemPos(rowCnt, 6, tblTop), Config.Units.ConvertTo(Config.Unit.bar, mtr.TestRslt.PressDownMean).ToString("F3"));
|
||||
|
||||
rowCnt++;
|
||||
}
|
||||
table.AddRow(new string[] { mtr.Name(),
|
||||
Config.Units.ConvertTo(Config.Unit.lph, flow_ctv).ToString("F1"),
|
||||
mtr.TestRslt.TempDownMean.ToString("F2"),
|
||||
mtr.TestRslt.DensityDiv.ToString("F2"),
|
||||
mtr.TestTime.ToString("F1"),
|
||||
Config.Units.ConvertTo(Config.Unit.bar, mtr.TestRslt.PressUpMean).ToString("F3"),
|
||||
Config.Units.ConvertTo(Config.Unit.bar, mtr.TestRslt.PressDownMean).ToString("F3") },
|
||||
horizontalAlignment,
|
||||
verticalAlignment);
|
||||
}
|
||||
rowCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draw table lines.
|
||||
/// </summary>
|
||||
void DrawTableFrame(System.Drawing.Printing.PrintPageEventArgs e, int rowsCount, int tblTop)
|
||||
{
|
||||
int t = tblTop;
|
||||
int m = tblTop + SpacingOneAndHalf;
|
||||
int b = tblTop + rowsCount * SpacingOneAndHalf;
|
||||
/// <summary>
|
||||
/// Prints text on the top of the first page (title, common information).
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <param name="lineNr"></param>
|
||||
/// <param name="wm"></param>
|
||||
/// <param name="pruefvorlage"></param>
|
||||
/// <param name="docVersion"></param>
|
||||
void DrawCommonTop(PrintPageEventArgs e, ref int lineNr, Entities.WaterMeter wm, string pruefvorlage, string docVersion)
|
||||
{
|
||||
///
|
||||
///
|
||||
///
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, docVersion);
|
||||
lineNr++;
|
||||
PrintBoldAt(e, Tab1, lineNr * SpacingOne, "Prüfstand Nr :");
|
||||
PrintBoldAt(e, Tab2, lineNr * SpacingOne, wm.BenchId().ToString());
|
||||
PrintBoldAt(e, Tab3, lineNr * SpacingOne, "Datum :");
|
||||
PrintBoldAt(e, Tab4, lineNr * SpacingOne, wm.Batch.EndTime.Date.ToString("d"));
|
||||
lineNr++;
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Zählertyp :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, zaehlertyp);
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, "Eichjahr :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.YearOfProduction.ToString());
|
||||
lineNr++;
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Prüfvorlage :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, pruefvorlage);
|
||||
lineNr += 2;
|
||||
|
||||
// Horizontal lines
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, t), new Point(747, t));
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, m), new Point(747, m));
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, b), new Point(747, b));
|
||||
if (compound)
|
||||
{
|
||||
PrintBoldAt(e, Tab1, lineNr * SpacingOne, "Hauptzahler");
|
||||
PrintBoldAt(e, Tab3, lineNr * SpacingOne, "Nebenzahler");
|
||||
lineNr++;
|
||||
}
|
||||
|
||||
// Vertical lines
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point( 80, t), new Point( 80, b));
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(267, t), new Point(267, b));
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(347, t), new Point(347, b));
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(427, t), new Point(427, b));
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(507, t), new Point(507, b));
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(587, t), new Point(587, b));
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(667, t), new Point(667, b));
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(747, t), new Point(747, b));
|
||||
}
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Hersteller :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, wm.Producer());
|
||||
if (compound)
|
||||
{
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, "Hersteller :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.ProducerAux());
|
||||
}
|
||||
lineNr++;
|
||||
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Seriennummer :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, wm.SerialNr);
|
||||
if (compound)
|
||||
{
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, "Seriennummer :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.SerialNrAux);
|
||||
}
|
||||
lineNr++;
|
||||
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, wm.NewQnames() ? "Q3 :" : "Qn :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, wm.Q3_Qn().ToString());
|
||||
if (compound)
|
||||
{
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, wm.NewQnames() ? "Q3 :" : "Qn :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.Q3_Qn_Aux().ToString());
|
||||
}
|
||||
lineNr++;
|
||||
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Zulassungszeichen :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, wm.ApprovalInfo());
|
||||
if (compound)
|
||||
{
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, "Zulassungszeichen :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.ApprovalInfoAux());
|
||||
}
|
||||
lineNr++;
|
||||
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Metr. klasse :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, wm.MetrologicalClass());
|
||||
if (compound)
|
||||
{
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, "Metr. klasse :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.MetrologicalClassAux());
|
||||
}
|
||||
lineNr++;
|
||||
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Stand :");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, wm.EndState);
|
||||
if (compound)
|
||||
{
|
||||
PrintAt(e, Tab3, lineNr * SpacingOne, "Stand :");
|
||||
PrintAt(e, Tab4, lineNr * SpacingOne, wm.EndStateAux);
|
||||
|
||||
lineNr += 2;
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Umschaltpunkte :");
|
||||
lineNr++;
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Qsteig");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, (1000.0 * wm.QRise).ToString("F1") + " l/h");
|
||||
lineNr++;
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, "Qfall");
|
||||
PrintAt(e, Tab2, lineNr * SpacingOne, (1000.0 * wm.QFall).ToString("F1") + " l/h");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prints text at the bottom of the last page (footer).
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <param name="lineNr"></param>
|
||||
/// <param name="wm"></param>
|
||||
void DrawCommonBottom(PrintPageEventArgs e, float top, Entities.WaterMeter wm)
|
||||
{
|
||||
int iTop = (int)top;
|
||||
|
||||
PrintAt(e, Tab1, iTop, "Temperatur");
|
||||
PrintAt(e, Tab2, iTop, wm.Batch.AmbTempMean().ToString("F1") + " \x00b0C");
|
||||
|
||||
iTop += SpacingOne;
|
||||
|
||||
PrintAt(e, Tab1, iTop, "Feuchtigkeit");
|
||||
PrintAt(e, Tab2, iTop, wm.Batch.AmbHumiMean().ToString("F0") + " %");
|
||||
|
||||
iTop += SpacingOne;
|
||||
|
||||
PrintAt(e, Tab1, iTop, "Luftdruck");
|
||||
PrintAt(e, Tab2, iTop, Config.Units.ConvertTo(Config.Unit.mbar, wm.Batch.AmbPressMean()).ToString("F0") + " mbar");
|
||||
|
||||
iTop += SpacingOne;
|
||||
|
||||
PrintAt(e, Tab3, iTop, wm.Batch.EndTime.Date.ToString("d"));
|
||||
|
||||
iTop += SpacingOne;
|
||||
|
||||
PrintAt(e, Tab3, iTop, "Datum");
|
||||
PrintAt(e, Tab4, iTop, "Unterschrift");
|
||||
}
|
||||
|
||||
|
||||
void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, Point p, string text)
|
||||
@ -434,18 +626,5 @@ namespace Results.Output.Printers.Munich
|
||||
RectangleF printArea = new RectangleF(x, y, 667, SpacingOne);
|
||||
e.Graphics.DrawString(text, this.boldFont, Brushes.Black, printArea);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get text position form a number of the test and a number of the parameter.
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <param name="column">Table column (0-based)</param>
|
||||
/// <returns></returns>
|
||||
Point GetTabItemPos(int row, int column, int tblTop)
|
||||
{
|
||||
int x = MarginLeft + ((column == 0) ? 80 : 187) + column * 80; /// leftmost column is wider
|
||||
int y = MarginTop + tblTop + (row * SpacingOneAndHalf) - 2;
|
||||
return new Point(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Printing;
|
||||
@ -25,6 +28,7 @@ namespace Results.Output.Printers
|
||||
public float LineWidth;
|
||||
public TableLines HorizLines;
|
||||
public TableLines VertLines;
|
||||
public float[] ColumnWidths; /// null = automatic
|
||||
}
|
||||
|
||||
public class Table
|
||||
@ -154,6 +158,10 @@ namespace Results.Output.Printers
|
||||
/// In not a separator line
|
||||
bool isHeader = (colIx < Style.LeftHeadersCount) || (rowIx < Style.TopHeadersCount);
|
||||
SizeF size = PrintersCommon.Measure(e, Rows[rowIx][colIx], isHeader ? Style.HeaderFont : Style.Font);
|
||||
if ((Style.ColumnWidths != null) && (Style.ColumnWidths.Length > colIx))
|
||||
{
|
||||
size.Width = Style.ColumnWidths[colIx]; /// Override measurement if column width is defined
|
||||
}
|
||||
if (size.Width > columnWidth[colIx]) columnWidth[colIx] = size.Width;
|
||||
if (size.Height > rowHeight[rowIx]) rowHeight[rowIx] = size.Height;
|
||||
}
|
||||
|
||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.18.1076.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1076.0")]
|
||||
[assembly: AssemblyVersion("2.18.1093.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1093.0")]
|
||||
|
||||
@ -562,11 +562,11 @@ namespace TBF
|
||||
TBF.LocalSettings ls = Program.LocalSettings;
|
||||
|
||||
historyListViewEx.Columns.Add(Strings.Name, (ls.HistoryColumnCount > 0) ? ls.HistoryColumnWidths[0] : 80);
|
||||
historyListViewEx.Columns.Add(Strings.Revision, (ls.HistoryColumnCount > 0) ? ls.HistoryColumnWidths[0] : 80);
|
||||
historyListViewEx.Columns.Add(Strings.Date_and_time, (ls.HistoryColumnCount > 1) ? ls.HistoryColumnWidths[1] : 120);
|
||||
historyListViewEx.Columns.Add(Strings.User, (ls.HistoryColumnCount > 2) ? ls.HistoryColumnWidths[2] : 55);
|
||||
historyListViewEx.Columns.Add(Strings.DescriptionColHdr, (ls.HistoryColumnCount > 3) ? ls.HistoryColumnWidths[3] : 150);
|
||||
historyListViewEx.Columns.Add(Strings.Other, (ls.HistoryColumnCount > 3) ? ls.HistoryColumnWidths[3] : 150);
|
||||
historyListViewEx.Columns.Add(Strings.Revision, (ls.HistoryColumnCount > 1) ? ls.HistoryColumnWidths[1] : 80);
|
||||
historyListViewEx.Columns.Add(Strings.Date_and_time, (ls.HistoryColumnCount > 2) ? ls.HistoryColumnWidths[2] : 120);
|
||||
historyListViewEx.Columns.Add(Strings.User, (ls.HistoryColumnCount > 3) ? ls.HistoryColumnWidths[3] : 55);
|
||||
historyListViewEx.Columns.Add(Strings.DescriptionColHdr, (ls.HistoryColumnCount > 4) ? ls.HistoryColumnWidths[4] : 150);
|
||||
historyListViewEx.Columns.Add(Strings.Other, (ls.HistoryColumnCount > 5) ? ls.HistoryColumnWidths[5] : 150);
|
||||
|
||||
RefreshHistoryTab();
|
||||
}
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.18.1089.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1089.0")]
|
||||
[assembly: AssemblyVersion("2.18.1094.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1094.0")]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user