From dcadd297913a48f01477bfbb1aee70effa774087 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Mon, 1 Aug 2016 15:41:46 +0200 Subject: [PATCH] Label printer modification for Israel PT200. --- .../LabelPrinter/PrintLabelDocument.cs | 48 ++++++------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrintLabelDocument.cs b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrintLabelDocument.cs index 888df0db7..8caf98a73 100644 --- a/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrintLabelDocument.cs +++ b/TestBenchFramework/BenchControl/ResultsPrinters/LabelPrinter/PrintLabelDocument.cs @@ -165,46 +165,32 @@ namespace TBF.BenchControl.ResultsPrinters.LabelPrinter /// Serial number - if (!string.IsNullOrEmpty(wm.SerialNr)) PrintAt(e, 20, 62, wm.SerialNr); + if (!string.IsNullOrEmpty(wm.SerialNr)) PrintAt(e, 20, 62, string.Format("S/N: {0}", wm.SerialNr)); /// Watermeter type PrintAt(e, 20, 74, batch.ProtocolTitle); /// Date - PrintAt(e, 135, 74, DateTimeStr(batch.EndTime)); + PrintAt(e, 135, 74, string.Format("{0:dd/MM/yy", batch.EndTime)); if (rsltItems.Count > 0) { - int printPosition = 1; + Results.WMeterRsltItemSpec item1 = Results.WMeterRsltItemSpec.GetItem(Results.ItemID.Test_name); + + Results.WMeterRsltItemSpec item2 = Results.WMeterRsltItemSpec.GetItem(Results.ItemID.Error); + item2.Units = Config.Unit.Pct; + item2.Precision = "F2"; + item2.Format = "{0}%"; + + int printPosition = 1; foreach (var mtr in wm.MeterTestRslts) { - string itemText; + item1.TestID = mtr.Name(); + item2.TestID = mtr.Name(); - if (!wm.Compound()) - { - itemText = rsltItems[0].Print(mtr); - } - else if (mtr.CompoundMeterId == (byte)CompoundMeterId.Compound) - { - Results.Entities.MeterTestRslt mainMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain); - Results.Entities.MeterTestRslt auxMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain); - itemText = rsltItems[0].PrintCombined(mainMtr, auxMtr, mtr); - } - else - { - continue; - } + PrintAt(e, 20, 6 + 14 * printPosition, item1.Print(wm)); + PrintAt(e, 78, 6 + 14 * printPosition, item2.Print(wm)); - string[] texts = itemText.Split(new char[] { '|' }); - - if (texts.Length == 2) - { - Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White); - itemText = texts[0]; - /// TODO: How to print colors? - } - - PrintAt(e, 78, 6 + 14 * printPosition, string.Format("{0}%", itemText)); printPosition++; } } @@ -222,11 +208,5 @@ namespace TBF.BenchControl.ResultsPrinters.LabelPrinter RectangleF printArea = new RectangleF(x, y, 667, 18); e.Graphics.DrawString(text, this.font, Brushes.Black, printArea); } - - - string DateTimeStr(DateTime dateTime) - { - return string.Format("{0}/{1}/{2}", dateTime.Day.ToString("D2"), dateTime.Month.ToString("D2"), (dateTime.Year % 100).ToString("D2")); - } } }