Zapiska and WaterMeterPL added, BenchInfo.Polska added, IBenchInfo infroduced, Version 1.5.74
This commit is contained in:
@@ -31,7 +31,7 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
|
||||
///
|
||||
/// Data to print
|
||||
///
|
||||
readonly BenchControl.BenchId.Component benchId;
|
||||
readonly GenericDevices.IBenchInfo benchId;
|
||||
readonly Entities.Procedure procedure;
|
||||
readonly IList<Entities.TestResult> unsortedResults;
|
||||
readonly bool combined;
|
||||
@@ -47,7 +47,7 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="textToPrint">Text to be printed</param>
|
||||
public BasicPrintDocument(BenchControl.BenchId.Component benchId,
|
||||
public BasicPrintDocument(GenericDevices.IBenchInfo benchId,
|
||||
Entities.Procedure procedure,
|
||||
IList<Entities.TestResult> unsortedResults)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
|
||||
/// <summary>
|
||||
/// Data to print
|
||||
/// </summary>
|
||||
BenchControl.BenchId.Component benchId;
|
||||
GenericDevices.IBenchInfo benchId;
|
||||
Entities.Procedure procedure;
|
||||
IList<Entities.TestResult> unsortedResults;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
|
||||
/// <param name="unsortedResults">Results to print</param>
|
||||
/// <param name="title">This parameter is unused</param>
|
||||
/// <returns>Reference to the operation</returns>
|
||||
public IOperation PrintResultsOp(BenchControl.BenchId.Component benchId,
|
||||
public IOperation PrintResultsOp(GenericDevices.IBenchInfo benchId,
|
||||
IList<GenericDevices.IWaterMeter> waterMeters,
|
||||
Entities.Procedure procedure,
|
||||
IList<Entities.TestResult> unsortedResults,
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace TBF.BenchControl.ResultsPrinters.Munich
|
||||
PrintAt(e, Tab1, lineNr * SpacingOne, prn.Version);
|
||||
lineNr++;
|
||||
PrintBoldAt(e, Tab1, lineNr * SpacingOne, "Prüfstand Nr :");
|
||||
PrintBoldAt(e, Tab2, lineNr * SpacingOne, (prn.BenchId != null) ? prn.BenchId.TestBenchNr.ToString() : "");
|
||||
PrintBoldAt(e, Tab2, lineNr * SpacingOne, (prn.BenchId != null) ? prn.BenchId.TestBenchId : "");
|
||||
PrintBoldAt(e, Tab3, lineNr * SpacingOne, "Datum :");
|
||||
PrintBoldAt(e, Tab4, lineNr * SpacingOne, DateTime.Now.Date.ToString("d"));
|
||||
lineNr++;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace TBF.BenchControl.ResultsPrinters.Munich
|
||||
/// <summary>
|
||||
/// Data to print
|
||||
/// </summary>
|
||||
public BenchControl.BenchId.Component BenchId;
|
||||
public GenericDevices.IBenchInfo BenchId;
|
||||
public IList<GenericDevices.IWaterMeter> WaterMeters;
|
||||
public IList<Entities.TestResult> Results;
|
||||
public string Title;
|
||||
@@ -47,7 +47,7 @@ namespace TBF.BenchControl.ResultsPrinters.Munich
|
||||
/// <param name="benchId">Procedure to print the results of</param>
|
||||
/// <param name="results">Results to print</param>
|
||||
/// <returns>Reference to the operation</returns>
|
||||
public IOperation PrintResultsOp(BenchControl.BenchId.Component benchId,
|
||||
public IOperation PrintResultsOp(GenericDevices.IBenchInfo benchId,
|
||||
IList<GenericDevices.IWaterMeter> waterMeters,
|
||||
Entities.Procedure procedure,
|
||||
IList<Entities.TestResult> results,
|
||||
|
||||
@@ -0,0 +1,448 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Printing;
|
||||
using System.IO;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.BenchControl.ResultsPrinters.Zapiska
|
||||
{
|
||||
public class MyPrintDocument : PrintDocument
|
||||
{
|
||||
const string FontFamilyName = "Arial"; //"Times New Roman";
|
||||
|
||||
const int SpacingOne = 18;
|
||||
const int Padding = 10;
|
||||
const int TitleX = 100;
|
||||
const int TitleY = 160;
|
||||
int HdrTop = 220; /// Depends on the size of the title
|
||||
int TableTopFirstPage = 390; /// Depends on the size of the header
|
||||
int TableTopNextPage = TitleY;
|
||||
|
||||
const int SpacingOneAndHalf = (3 * SpacingOne) / 2;
|
||||
|
||||
/// <summary>
|
||||
/// Property variable for the Font the user wishes to use
|
||||
/// </summary>
|
||||
Font font;
|
||||
Font boldFont;
|
||||
Font titleFont;
|
||||
|
||||
///
|
||||
/// Data to print
|
||||
///
|
||||
readonly Entities.Procedure procedure;
|
||||
readonly IList<Entities.TestResult> allResults;
|
||||
readonly string tester;
|
||||
readonly DateTime dateTime;
|
||||
readonly int batchMin;
|
||||
readonly int batchMax;
|
||||
|
||||
///
|
||||
/// Items to print
|
||||
///
|
||||
readonly IList<string> testNames;
|
||||
readonly int testsPerMeter;
|
||||
readonly IList<TBF.Forms.ResultItemSpec> resultItems;
|
||||
|
||||
///
|
||||
/// Data to print
|
||||
///
|
||||
readonly int maxNrRows;
|
||||
readonly int nrRows;
|
||||
readonly int nrColumns;
|
||||
string[,] dataToPrint;
|
||||
|
||||
///
|
||||
/// Layout and status
|
||||
///
|
||||
int nrTabLinesOnFirstPage;
|
||||
int nrTabLinesOnNextPage;
|
||||
int nextTableRow; /// nr. of table row to be printed as the first one on the next page
|
||||
int nrPages;
|
||||
int pageNr; /// Page number to be printed at the bottom of the page
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// Precalculates some values and dimensions and stores strings for the table
|
||||
/// to be printed into a 2-dimensional array of strings 'dataToprint'.
|
||||
/// </summary>
|
||||
/// <param name="procedure">Procedure belonging to the results</param>
|
||||
/// <param name="allResults">Results to be printed (multiple batches)</param>
|
||||
public MyPrintDocument(Entities.Procedure procedure,
|
||||
IList<Entities.TestResult> allResults,
|
||||
string tester)
|
||||
{
|
||||
this.procedure = procedure;
|
||||
this.allResults = allResults;
|
||||
this.tester = tester;
|
||||
|
||||
dateTime = DateTime.Now;
|
||||
|
||||
batchMin = int.MaxValue;
|
||||
batchMax = int.MinValue;
|
||||
foreach (var tr in allResults)
|
||||
{
|
||||
if (tr.BatchNr < batchMin) batchMin = tr.BatchNr;
|
||||
if (tr.BatchNr > batchMax) batchMax = tr.BatchNr;
|
||||
}
|
||||
|
||||
resultItems = Forms.ResultItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_SingleWM);
|
||||
|
||||
testNames = Utils.GetDecoratedTestNames(procedure, 1);
|
||||
testsPerMeter = testNames.Count;
|
||||
|
||||
maxNrRows = (batchMax - batchMin + 1) * Program.WMsCount;
|
||||
nrColumns = testsPerMeter * resultItems.Count + 2;
|
||||
|
||||
///
|
||||
/// Prepare raw data to print
|
||||
///
|
||||
dataToPrint = new string[maxNrRows, nrColumns];
|
||||
nrRows = 0;
|
||||
for (int i = batchMin; i <= batchMax; i++)
|
||||
{
|
||||
/// Collect all results belonging to one batch
|
||||
IList<Entities.TestResult> unsortedResults = new List<Entities.TestResult>();
|
||||
foreach (var tr in allResults) if (tr.BatchNr == i) unsortedResults.Add(tr);
|
||||
|
||||
if (unsortedResults.Count == 0) continue;
|
||||
|
||||
for (int wmNr = 0; wmNr < Program.WMsCount; wmNr++) /// wmNr is 0-based
|
||||
{
|
||||
if (!unsortedResults[0].Meters[wmNr].Disabled)
|
||||
{
|
||||
dataToPrint[nrRows, 0] = (nrRows + 1).ToString();
|
||||
dataToPrint[nrRows, 1] = unsortedResults[0].Meters[wmNr].SerialNr;
|
||||
|
||||
IList<Entities.TestResult> results =
|
||||
Utils.GetSortedTestResults(procedure, unsortedResults, Utils.PartNr(wmNr + 1, false));
|
||||
|
||||
for (int j = 0; j < testsPerMeter; j++)
|
||||
{
|
||||
if (results[j] != null)
|
||||
{
|
||||
int k = 2 + j * resultItems.Count;
|
||||
foreach (var item in resultItems)
|
||||
{
|
||||
string str = item.Print(results[j].Meters[wmNr]);
|
||||
int pos = str.IndexOf('|');
|
||||
dataToPrint[nrRows, k++] = (pos < 0) ? str : str.Substring(0, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nrRows++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pageNr = 1;
|
||||
nextTableRow = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override the default onbeginPrint method of the PrintDocument Object
|
||||
/// </summary>
|
||||
/// <param name=e></param>
|
||||
/// <remarks></remarks>
|
||||
protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e)
|
||||
{
|
||||
base.OnBeginPrint(e);
|
||||
|
||||
if (font == null) { font = new Font(FontFamilyName, 10, FontStyle.Regular); }
|
||||
if (boldFont == null) { boldFont = new Font(FontFamilyName, 10, FontStyle.Bold); }
|
||||
if (titleFont == null) { titleFont = new Font(FontFamilyName, 18, FontStyle.Bold); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override the default OnPrintPage method of the PrintDocument.
|
||||
/// </summary>
|
||||
/// <param name=e></param>
|
||||
/// <remarks>This provides the print logic for our document</remarks>
|
||||
protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
|
||||
{
|
||||
/// Run base code
|
||||
base.OnPrintPage(e);
|
||||
|
||||
/// 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
|
||||
|
||||
if (base.DefaultPageSettings.Landscape)
|
||||
{
|
||||
/// Landscape mode: we need to swap height/width parameters
|
||||
int tmp = printHeight;
|
||||
printHeight = printWidth;
|
||||
printWidth = tmp;
|
||||
|
||||
if (File.Exists("C:\\TBF\\header-landscape.png"))
|
||||
{
|
||||
Image img = Image.FromFile("C:\\TBF\\header-landscape.png");
|
||||
e.Graphics.DrawImage(new Bitmap(img), new Rectangle(0, 0, 1169, 827));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (File.Exists("C:\\TBF\\header-portrait.png"))
|
||||
{
|
||||
Image img = Image.FromFile("C:\\TBF\\header-portrait.png");
|
||||
e.Graphics.DrawImage(new Bitmap(img), new Rectangle(0, 0, 827, 1169));
|
||||
}
|
||||
}
|
||||
|
||||
///---------------
|
||||
/// Common info
|
||||
///---------------
|
||||
if (pageNr == 1)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(allResults[0].ProtocolTitle))
|
||||
{
|
||||
RectangleF printArea = new RectangleF(TitleX, TitleY, 667, 40);
|
||||
e.Graphics.DrawString(allResults[0].ProtocolTitle, titleFont, Brushes.Black, printArea);
|
||||
}
|
||||
else
|
||||
{
|
||||
TableTopFirstPage -= (HdrTop - TitleY);
|
||||
HdrTop = TitleY;
|
||||
}
|
||||
|
||||
string[] leftColumn = new string[]
|
||||
{
|
||||
Strings.Purchase_order_,
|
||||
Strings.Date_and_time_,
|
||||
Strings.Procedure_,
|
||||
Strings.Tester_,
|
||||
Strings.Approval_,
|
||||
Strings.Ambient_temperature_,
|
||||
Strings.Ambient_pressure_,
|
||||
Strings.Ambient_humidity_,
|
||||
};
|
||||
|
||||
string[] rightColumn = new string[]
|
||||
{
|
||||
allResults[0].PurchaseOrder,
|
||||
//dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString(),
|
||||
string.Format("{0}.{1}.{2} {3}:{4}", dateTime.Year.ToString("D4"),
|
||||
dateTime.Month.ToString("D2"),
|
||||
dateTime.Day.ToString("D2"),
|
||||
dateTime.Hour.ToString("D2"),
|
||||
dateTime.Minute.ToString("D2")),
|
||||
procedure.Name,
|
||||
tester,
|
||||
string.Empty,
|
||||
allResults[0].AmbientTempAve.ToString("F1") + " °C",
|
||||
allResults[0].AmbientPressAve.ToString("F0") + " mbar",
|
||||
allResults[0].AmbientHumiAve.ToString("F0") + " %",
|
||||
};
|
||||
|
||||
/// Determine max. left column width in characters
|
||||
float maxWdth = 0;
|
||||
foreach (var s in leftColumn)
|
||||
{
|
||||
float wdth = e.Graphics.MeasureString(s, font).Width;
|
||||
if (wdth > maxWdth) maxWdth = wdth;
|
||||
}
|
||||
|
||||
/// 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, 100 + (int)maxWdth + 20, HdrTop + SpacingOne * i, rightColumn[i]);
|
||||
}
|
||||
}
|
||||
|
||||
///----------------
|
||||
/// More pages ?
|
||||
///----------------
|
||||
if (pageNr == 1)
|
||||
{
|
||||
/// Determine the number of pages once
|
||||
nrTabLinesOnNextPage = (topMargin + printHeight - TableTopNextPage - 70) / SpacingOne;
|
||||
nrTabLinesOnFirstPage = (topMargin + printHeight - TableTopFirstPage - 70) / SpacingOne;
|
||||
|
||||
if (nrRows <= nrTabLinesOnFirstPage)
|
||||
{
|
||||
nrPages = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
nrPages = 1 + ((nrRows - nrTabLinesOnFirstPage) + nrTabLinesOnNextPage - 1) / nrTabLinesOnNextPage;
|
||||
}
|
||||
}
|
||||
int nrTabLinesOnThisPage = (pageNr == 1) ? nrTabLinesOnFirstPage : nrTabLinesOnNextPage;
|
||||
int rowFrom = nextTableRow;
|
||||
int rowTo;
|
||||
if (nrRows <= nextTableRow + nrTabLinesOnThisPage)
|
||||
{
|
||||
rowTo = nrRows - 1;
|
||||
e.HasMorePages = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
rowTo = rowFrom + nrTabLinesOnThisPage - 1;
|
||||
nextTableRow = rowFrom + nrTabLinesOnThisPage;
|
||||
e.HasMorePages = true;
|
||||
}
|
||||
|
||||
///--------
|
||||
/// Body
|
||||
///--------
|
||||
int[] columnPos = GetColumnPositions(e, dataToPrint, rowFrom, rowTo, leftMargin + Padding, 2 * Padding);
|
||||
int tableLeft = leftMargin;
|
||||
int tableRight = columnPos[nrColumns] - Padding;
|
||||
|
||||
int currentTableTop = (pageNr == 1) ? TableTopFirstPage : TableTopNextPage;
|
||||
int yyy = currentTableTop;
|
||||
|
||||
/// Horizontal line
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeft, yyy), new Point(tableRight, yyy));
|
||||
yyy += 2;
|
||||
|
||||
/// Line with test names (larger columns, names centered)
|
||||
for (int bigcol = 0; bigcol < testsPerMeter; bigcol++)
|
||||
{
|
||||
float width = e.Graphics.MeasureString(testNames[bigcol], font).Width;
|
||||
int bc = 2 + bigcol * resultItems.Count;
|
||||
int xxx = (columnPos[bc] + columnPos[bc + resultItems.Count]) / 2 - Padding - (int)(width / 2 + 0.5f);
|
||||
PrintAt(e, xxx, yyy, testNames[bigcol]);
|
||||
}
|
||||
yyy += SpacingOne;
|
||||
|
||||
int tableTop2 = yyy;
|
||||
|
||||
/// Indented horizontal line
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(columnPos[2] - Padding, yyy), new Point(tableRight, yyy));
|
||||
yyy += 2;
|
||||
|
||||
/// Line with header texts
|
||||
PrintAt(e, columnPos[0], yyy - SpacingOne / 2, GetHeaderItem(0));
|
||||
PrintAt(e, columnPos[1], yyy - SpacingOne / 2, GetHeaderItem(1));
|
||||
for (int col = 2; col < nrColumns; col++)
|
||||
{
|
||||
PrintAt(e, columnPos[col], yyy, GetHeaderItem(col));
|
||||
}
|
||||
yyy += SpacingOne;
|
||||
|
||||
/// Horizontal line
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeft, yyy), new Point(tableRight, yyy));
|
||||
yyy += 2;
|
||||
|
||||
/// Table with results
|
||||
for (int row = rowFrom; row <= rowTo; row++)
|
||||
{
|
||||
for (int col = 0; col < nrColumns; col++)
|
||||
{
|
||||
PrintAt(e, columnPos[col], yyy, dataToPrint[row, col]);
|
||||
}
|
||||
yyy += SpacingOne;
|
||||
}
|
||||
|
||||
/// Horizontal line
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeft, yyy), new Point(tableRight, yyy));
|
||||
int tableBottom = yyy;
|
||||
|
||||
/// Vertical lines
|
||||
for (int col = 0; col <= nrColumns; col++)
|
||||
{
|
||||
if (col < 2 || ((col-2) % resultItems.Count) == 0)
|
||||
{
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(columnPos[col] - Padding, currentTableTop),
|
||||
new Point(columnPos[col] - Padding, tableBottom));
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(columnPos[col] - Padding, tableTop2),
|
||||
new Point(columnPos[col] - Padding, tableBottom));
|
||||
}
|
||||
}
|
||||
|
||||
///----------
|
||||
/// Footer
|
||||
///----------
|
||||
PrintAt(e, leftMargin, topMargin + printHeight - SpacingOne, string.Format("{0} {1}/{2}", Strings.Page, pageNr++, nrPages));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns header text for each column of the table.
|
||||
/// </summary>
|
||||
/// <param name="column">COlumn nymber (0-based)</param>
|
||||
/// <returns>Header text</returns>
|
||||
string GetHeaderItem(int column)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case 0: return "Nr.";
|
||||
case 1: return "S/N";
|
||||
default: return resultItems[(column - 2) % resultItems.Count].ClmnHeaderText;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine column widths and return column left positions for a subset of table rows
|
||||
/// </summary>
|
||||
/// <param name="dataToPrint">string[nrRows, nrColumns]</param>
|
||||
/// <param name="rowFrom">First row to consider</param>
|
||||
/// <param name="rowTo">Last row to consider</param>
|
||||
/// <returns>Left column positions and right side float[nrColumns + 1]</returns>
|
||||
int[] GetColumnPositions(System.Drawing.Printing.PrintPageEventArgs e,
|
||||
string[,] dataToPrint, int rowFrom, int rowTo,
|
||||
int leftMargin, int padding)
|
||||
{
|
||||
int nrColumns = dataToPrint.GetLength(1);
|
||||
int[] columnPos = new int[nrColumns + 1];
|
||||
columnPos[0] = leftMargin;
|
||||
|
||||
for (int column = 0; column < nrColumns; column++)
|
||||
{
|
||||
float columnWidth = e.Graphics.MeasureString(GetHeaderItem(column), font).Width;
|
||||
|
||||
for (int row = rowFrom; row <= rowTo; row++)
|
||||
{
|
||||
float itemWidth = e.Graphics
|
||||
.MeasureString(dataToPrint[row, column] == null ? string.Empty : dataToPrint[row, column], font)
|
||||
.Width;
|
||||
if (itemWidth > columnWidth) columnWidth = itemWidth;
|
||||
}
|
||||
|
||||
columnPos[column + 1] = columnPos[column] + (int)(columnWidth + 0.5f) + padding;
|
||||
}
|
||||
|
||||
return columnPos;
|
||||
}
|
||||
|
||||
|
||||
void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, Point p, string text)
|
||||
{
|
||||
PrintAt(e, p.X, p.Y, text);
|
||||
}
|
||||
|
||||
void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string text)
|
||||
{
|
||||
RectangleF printArea = new RectangleF(x, y, 667, SpacingOne);
|
||||
e.Graphics.DrawString(text, this.font, Brushes.Black, printArea);
|
||||
}
|
||||
|
||||
void PrintBoldAt(System.Drawing.Printing.PrintPageEventArgs e, Point p, string text)
|
||||
{
|
||||
PrintBoldAt(e, p.X, p.Y, text);
|
||||
}
|
||||
|
||||
void PrintBoldAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string text)
|
||||
{
|
||||
RectangleF printArea = new RectangleF(x, y, 667, SpacingOne);
|
||||
e.Graphics.DrawString(text, this.boldFont, Brushes.Black, printArea);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Printing;
|
||||
using log4net;
|
||||
using TBF.BenchControl;
|
||||
|
||||
namespace TBF.BenchControl.ResultsPrinters.Zapiska
|
||||
{
|
||||
public class Printer : ComponentBase, IOperation, GenericDevices.IResultsPrinter
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Printer));
|
||||
public override string ToString() { return string.Format("ResultsPrinters.Basic({0})", Cfg.ToString(1)); }
|
||||
|
||||
readonly PrinterCfg printerCfg;
|
||||
|
||||
public bool SupressPrinting { get { return printerCfg.SupressPrinting; } }
|
||||
|
||||
/// <summary>
|
||||
/// Data to print
|
||||
/// </summary>
|
||||
GenericDevices.IBenchInfo benchId;
|
||||
Entities.Procedure procedure;
|
||||
IList<Entities.TestResult> unsortedResults;
|
||||
|
||||
public Printer()
|
||||
{
|
||||
}
|
||||
|
||||
public Printer(PrinterCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
printerCfg = cfg;
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prints the test cycle results, Events: Event.ResultsPrinted
|
||||
/// </summary>
|
||||
/// <param name="benchId">Bench ID</param>
|
||||
/// <param name="waterMeters">This parameter is unused</param>
|
||||
/// <param name="procedure">Procedure to print the results of</param>
|
||||
/// <param name="unsortedResults">Results to print</param>
|
||||
/// <param name="title">This parameter is unused</param>
|
||||
/// <returns>Reference to the operation</returns>
|
||||
public IOperation PrintResultsOp(GenericDevices.IBenchInfo benchId,
|
||||
IList<GenericDevices.IWaterMeter> waterMeters,
|
||||
Entities.Procedure procedure,
|
||||
IList<Entities.TestResult> unsortedResults,
|
||||
string title)
|
||||
{
|
||||
if ((procedure == null) || (unsortedResults == null) || (unsortedResults.Count < 1))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
this.benchId = benchId;
|
||||
this.procedure = procedure;
|
||||
this.unsortedResults = unsortedResults;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
new MyPrintDocument(procedure, unsortedResults, Entities.User.CurrentUser.Name).Print();
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>Event.ResultsPrinted</returns>
|
||||
public Event Run()
|
||||
{
|
||||
return Event.ResultsPrinted;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.ResultsPrinters.Zapiska
|
||||
{
|
||||
public class PrinterCfg : ComponentCfgBase, Generic.IComponentCfg
|
||||
{
|
||||
public IComponent GetComponent(IList<IComponent> components) { return new Printer(this); }
|
||||
public IComponentCfgCtrl GetControl() { return new PrinterCfgCtrl(); }
|
||||
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public bool SupressPrinting; /// Bypass printing when true
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
PrinterCfg()
|
||||
{
|
||||
Name = "Zapiska";
|
||||
ParentName = string.Empty;
|
||||
SupressPrinting = false;
|
||||
}
|
||||
|
||||
public PrinterCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, SupressPrinting={1}",
|
||||
Name,
|
||||
SupressPrinting ? "yes" : "no"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
namespace TBF.BenchControl.ResultsPrinters.Zapiska
|
||||
{
|
||||
partial class PrinterCfgCtrl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.classNameLabel = new System.Windows.Forms.Label();
|
||||
this.supressPrintingCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(106, 57);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
|
||||
this.nameTextBox.TabIndex = 5;
|
||||
//
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(34, 60);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 4;
|
||||
this.nameLabel.Text = "Name";
|
||||
//
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(103, 33);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
|
||||
this.classNameLabel.TabIndex = 3;
|
||||
this.classNameLabel.Text = "ComonentName";
|
||||
//
|
||||
// supressPrintingCheckBox
|
||||
//
|
||||
this.supressPrintingCheckBox.AutoSize = true;
|
||||
this.supressPrintingCheckBox.Enabled = false;
|
||||
this.supressPrintingCheckBox.Location = new System.Drawing.Point(106, 87);
|
||||
this.supressPrintingCheckBox.Name = "supressPrintingCheckBox";
|
||||
this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17);
|
||||
this.supressPrintingCheckBox.TabIndex = 12;
|
||||
this.supressPrintingCheckBox.Text = "Supress printing";
|
||||
this.supressPrintingCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// PrinterCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.supressPrintingCheckBox);
|
||||
this.Controls.Add(this.nameTextBox);
|
||||
this.Controls.Add(this.nameLabel);
|
||||
this.Controls.Add(this.classNameLabel);
|
||||
this.Name = "PrinterCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 200);
|
||||
this.Load += new System.EventHandler(this.PrinterCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
private System.Windows.Forms.Label classNameLabel;
|
||||
private System.Windows.Forms.CheckBox supressPrintingCheckBox;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.ResultsPrinters.Zapiska
|
||||
{
|
||||
public partial class PrinterCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(PrinterCfgCtrl));
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
PrinterCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
get { return config as IComponentCfg; }
|
||||
set
|
||||
{
|
||||
config = value as PrinterCfg;
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
public PrinterCfgCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void PrinterCfgCtrl_Load(object sender, EventArgs e)
|
||||
{
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
classNameLabel.Text = config.Factory.ClassName;
|
||||
nameTextBox.Text = config.Name;
|
||||
supressPrintingCheckBox.Checked = config.SupressPrinting;
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
supressPrintingCheckBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
return flags;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
|
||||
|
||||
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
||||
|
||||
config.Name = nameTextBox.Text;
|
||||
config.SupressPrinting = supressPrintingCheckBox.Checked;
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,23 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.ResultsPrinters.Zapiska
|
||||
{
|
||||
public class PrinterFactory : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return "Zapiska"; } }
|
||||
|
||||
public void ResetStaticProperties() { Printer.ResetStaticProperties(); }
|
||||
|
||||
public IComponent DummyComponent() { return new Printer(); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new PrinterCfg(this); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(PrinterCfg), component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user