From 9e28ca5df3a78506822362f73f6514337d26d614 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 15 Nov 2017 11:49:20 +0100 Subject: [PATCH] Printers.Zapiska, OnePerMeter, etc. changes: flow coordinates, content separated from layout, etc. --- .../OnePagePerMeter/EnhancedPrintDocument.cs | 320 ----------- .../OnePerMeter/OnePerMeterPrintDocument.cs | 461 ++++++++++++++++ .../OnePerMeterPrinterCfg.cs} | 20 +- .../Printers/Zapiska/ZapiskaPrintDocument.cs | 364 +++++++------ Results/Properties/AssemblyInfo.cs | 4 +- Results/Results.csproj | 4 +- Results/WMeterRsltItemSpec.cs | 10 +- .../Output/FileWriters/Basic/Writer.cs | 10 +- .../Output/FileWriters/Enhanced/Writer.cs | 10 +- .../FileWriters/OneFilePerMeter/Writer.cs | 12 +- .../Output/FileWriters/Xml/Writer.cs | 10 +- .../Output/Printers/Enhanced/Printer.cs | 112 ++-- .../PrinterCfgCtrl.Designer.cs | 458 ---------------- .../FactoryCompound.cs | 4 +- .../FactoryHeatMeters.cs | 4 +- .../FactorySingle.cs | 4 +- .../Printer.cs | 58 +- .../PrinterCfg.cs | 15 +- .../OnePerMeter/PrinterCfgCtrl.Designer.cs | 514 ++++++++++++++++++ .../PrinterCfgCtrl.cs | 62 ++- .../PrinterCfgCtrl.resx | 0 .../Output/Printers/Zapiska/Printer.cs | 55 +- .../BenchControl/TbfComponents.cs | 6 +- TestBenchFramework/Properties/AssemblyInfo.cs | 4 +- TestBenchFramework/TBF.csproj | 16 +- 25 files changed, 1400 insertions(+), 1137 deletions(-) delete mode 100644 Results/Output/Printers/OnePagePerMeter/EnhancedPrintDocument.cs create mode 100644 Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs rename Results/Output/Printers/{OnePagePerMeter/EnhancedPrinterCfg.cs => OnePerMeter/OnePerMeterPrinterCfg.cs} (58%) delete mode 100644 TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/PrinterCfgCtrl.Designer.cs rename TestBenchFramework/BenchControl/Output/Printers/{OnePagePerMeter => OnePerMeter}/FactoryCompound.cs (84%) rename TestBenchFramework/BenchControl/Output/Printers/{OnePagePerMeter => OnePerMeter}/FactoryHeatMeters.cs (84%) rename TestBenchFramework/BenchControl/Output/Printers/{OnePagePerMeter => OnePerMeter}/FactorySingle.cs (85%) rename TestBenchFramework/BenchControl/Output/Printers/{OnePagePerMeter => OnePerMeter}/Printer.cs (70%) rename TestBenchFramework/BenchControl/Output/Printers/{OnePagePerMeter => OnePerMeter}/PrinterCfg.cs (81%) create mode 100644 TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs rename TestBenchFramework/BenchControl/Output/Printers/{OnePagePerMeter => OnePerMeter}/PrinterCfgCtrl.cs (85%) rename TestBenchFramework/BenchControl/Output/Printers/{OnePagePerMeter => OnePerMeter}/PrinterCfgCtrl.resx (100%) diff --git a/Results/Output/Printers/OnePagePerMeter/EnhancedPrintDocument.cs b/Results/Output/Printers/OnePagePerMeter/EnhancedPrintDocument.cs deleted file mode 100644 index 2ba444231..000000000 --- a/Results/Output/Printers/OnePagePerMeter/EnhancedPrintDocument.cs +++ /dev/null @@ -1,320 +0,0 @@ -/// -/// Copyright (c) 2017 Sensus Metering Systems -/// -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Printing; -using System.IO; -using Config.Entities; -using Results.Resources; - -namespace Results.Output.Printers.OnePagePerMeter -{ - public class EnhancedPrintDocument : PrintDocument - { - /// Size of the printed area without margins, after taking into account 'pageOrientation' - readonly int printHeight; - readonly int printWidth; - - readonly int topMargin; - readonly int bottomMargin; - readonly int leftMargin; - readonly int TitleX; - readonly int TitleY; /// Depends on the size of the header - - readonly int SpacingOne; - readonly int SpacingOneAndHalf; - readonly int SpacingOne4Header; - readonly int SpacingOneAndHalf4Header; - - int CommonTop; /// = TitleY + 60 - int BodyTop; /// = HdrTop + 160 - /// - int titleHeight; - int commonHeight; - - /// - /// Property variable for the Font the user wishes to use - /// - Font font; - Font headerFont; - Font titleFont; - - /// - /// Data to print - /// - Results.Entities.Batch batch; - EnhancedPrinterCfg cfg; - Results.Entities.WaterMeter wm; - - /// - /// Items to print - /// - string header; - IList commonItems; - IList testItems; - string footer; - - /// - /// Constructor - /// - /// Text to be printed - public EnhancedPrintDocument(Results.Entities.Batch batch, EnhancedPrinterCfg cfg, Results.Entities.WaterMeter wm) - { - this.batch = batch; - this.cfg = cfg; - this.wm = wm; - - topMargin = cfg.TopMargin; - bottomMargin = cfg.BottomMargin; - leftMargin = cfg.LeftMargin; - - header = string.IsNullOrEmpty(cfg.Header) ? string.Empty : cfg.Header.Replace("~", Environment.NewLine); - commonItems = Results.WMeterRsltItemSpec.FromStrArray(cfg.CommonItems); - testItems = Results.WMeterRsltItemSpec.FromStrArray(cfg.TestItems); /// TestID info will be overwritten later on - footer = string.IsNullOrEmpty(cfg.Footer) ? string.Empty : cfg.Footer.Replace("~", Environment.NewLine); - - /// Initialize fonts - titleFont = new Font((cfg.TitFntFml != null ? cfg.TitFntFml : "Arial"), (cfg.TitFntSz > 0 ? cfg.TitFntSz : 10), (FontStyle)cfg.TitFntSty); - headerFont = new Font((cfg.HdrFntFml != null ? cfg.HdrFntFml : "Arial"), (cfg.HdrFntSz > 0 ? cfg.HdrFntSz : 10), (FontStyle)cfg.HdrFntSty); - font = new Font((cfg.BodyFntFml != null ? cfg.BodyFntFml : "Arial"), (cfg.BodyFntSz > 0 ? cfg.BodyFntSz : 10), (FontStyle)cfg.BodyFntSty); - - /// Set print area size and margins (in dots using 100 dpi) - DefaultPageSettings.Landscape = (cfg.PageOrientation == PageOrientation.Landscape); - /// - if (DefaultPageSettings.Landscape) - { - 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; - } - - SpacingOne = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", font).Height; - SpacingOneAndHalf = (3 * SpacingOne) / 2; - SpacingOne4Header = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", headerFont).Height; - SpacingOneAndHalf4Header = (3 * SpacingOne4Header) / 2; - - /// Calculate the tests count - int testsCount = 0; - foreach (var mtr in wm.MeterTestRslts) - { - if (mtr.Publish() == Config.Entities.Publish.Always && mtr.IsPilotRslt()) testsCount++; - } - - /// Prepare document outline - TitleX = cfg.LeftMargin; - TitleY = cfg.TopMargin; - - titleHeight = System.Windows.Forms.TextRenderer.MeasureText(header, titleFont).Height; - CommonTop = TitleY + titleHeight + SpacingOne4Header; - - commonHeight = commonItems.Count * SpacingOne; - BodyTop = CommonTop + commonHeight + SpacingOne4Header; - - int wmSectionHeight = (testsCount + 1) * SpacingOne + 3 * SpacingOne4Header; - } - - /// - /// Override the default onbeginPrint method of the PrintDocument Object - /// - /// - /// - protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e) - { - base.OnBeginPrint(e); - } - - /// - /// Override the default OnPrintPage method of the PrintDocument. - /// - /// - /// This provides the print logic for our document - protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e) - { - /// Run base code - base.OnPrintPage(e); - - if (File.Exists("C:\\TBF\\header.png")) - { - Image img = Image.FromFile("C:\\TBF\\header.png"); - e.Graphics.DrawImage(new Bitmap(img), new Rectangle(0, 0, 827, 1169)); - } - - /// Use the StringFormat class for the text layout of our document - StringFormat format = new StringFormat(StringFormatFlags.LineLimit); - - ///---------- - /// Title - ///---------- - RectangleF printArea = new RectangleF(TitleX, TitleY, printWidth, titleHeight); - e.Graphics.DrawString(header, titleFont, Brushes.Black, printArea); - - ///---------------- - /// Common items - ///---------------- - string[] leftColumn = new string[commonItems.Count]; - string[] rightColumn = new string[commonItems.Count]; - - int cnt = 0; - foreach (var v in commonItems) - { - leftColumn[cnt] = v.Caption; - rightColumn[cnt] = (batch.WaterMeters.Count > 0) ? v.Print(batch.WaterMeters[0]) : string.Empty; - cnt++; - } - - /// Determine max. left column width in characters - int maxLen = 0; - foreach (var s in leftColumn) if (s.Length > maxLen) maxLen = s.Length; - - /// Write aligned columns - for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++) - { - PrintAt(e, leftMargin, CommonTop + SpacingOne * i, leftColumn[i]); - PrintAt(e, 300, CommonTop + SpacingOne * i, rightColumn[i]); - } - - ///-------- - /// Body - ///-------- - - /// This variable represents the top coordinate of the area where WM results are printed - /// and it is updated (increased by) the value returned by PrintXyzWM() - the section size. - int nextWmTop = BodyTop; - int wmPosition = wm.WMPosition; - nextWmTop += PrintWM(e, wm, wmPosition, nextWmTop); - - e.HasMorePages = false; - - ///---------- - /// Footer - ///---------- - int footerWidth = (int)e.Graphics.MeasureString(footer, font).Width; - PrintAt(e, leftMargin, topMargin + printHeight - 2 * SpacingOne, footer); - - //string pageNrText = string.Format("{0} {1}/{2}", Strings.Page, 1, 1); - //int pageNrWidth = (int)e.Graphics.MeasureString(pageNrText, font).Width; - //PrintAt(e, leftMargin + (printWidth - pageNrWidth) / 2, topMargin + printHeight - SpacingOne, pageNrText); - } - - - /// - /// Print one water meter results - /// - /// Water meter - /// Number of the water meter printed - /// Top coordinate of watermeter data - /// The height of the printed section - int PrintWM(System.Drawing.Printing.PrintPageEventArgs e, - Results.Entities.WaterMeter wm, int printedWMNr, int top) - { - /// Determin column widths - float[] columnPos = new float[testItems.Count + 1]; - columnPos[0] = (float)leftMargin; - - for (int i = 0; i < testItems.Count; i++) - { - float columnWidth = e.Graphics.MeasureString(testItems[i].Caption, headerFont).Width; - foreach (var mtr in wm.MeterTestRslts) - { - if (mtr != null && mtr.IsPilotRslt() && mtr.Publish() == Config.Entities.Publish.Always) - { - string itemText = testItems[i].Print(wm, mtr.Name()); - - /// Strip color information - string[] texts = itemText.Split(new char[] { '|' }); - if (texts.Length == 2) { itemText = texts[0]; } - - float width = e.Graphics.MeasureString(itemText, font).Width; - if (width > columnWidth) columnWidth = width; - } - } - columnPos[i + 1] = columnPos[i] + columnWidth + 20.0f; - } - int tableLeftX = (int)columnPos[0]; - int tableRightX = (int)columnPos[testItems.Count] - 20; - - string wmText = string.Format("{0} {1}", Strings.Water_Meter, printedWMNr); - PrintHeaderAt(e, leftMargin, top, wmText); - if (!string.IsNullOrEmpty(wm.SerialNr)) - { - PrintHeaderAt(e, leftMargin + (int)e.Graphics.MeasureString(wmText, headerFont).Width, top, - string.Format(" {0} = {1}", Strings.sn, wm.SerialNr)); - } - - /// Horizontal line - int horY = top + SpacingOneAndHalf4Header; - e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeftX, horY), new Point(tableRightX, horY)); - - for (int i = 0; i < testItems.Count; i++) - { - PrintHeaderAt(e, (int)columnPos[i], top + (int)(1.6 * SpacingOne4Header), testItems[i].Caption); - } - - /// Horizontal line - horY = top + (int)(2.8 * SpacingOne4Header); - e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeftX, horY), new Point(tableRightX, horY)); - - int testsCount = 0; - foreach (var mtr in wm.MeterTestRslts) - { - if ((mtr != null) && (mtr.Publish() == Config.Entities.Publish.Always)) - { - testsCount++; - for (int i = 0; i < testItems.Count; i++) - { - string itemText = testItems[i].Print(wm, mtr.Name()); - - /// Strip color information - string[] texts = itemText.Split(new char[] { '|' }); - if (texts.Length == 2) - { - itemText = texts[0]; - Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White); - /// TODO: How to print colors? - } - - PrintAt(e, (int)columnPos[i], top + 2 * SpacingOne4Header + SpacingOne * testsCount, itemText); - } - } - } - - /// Horizontal line - horY = top + 2 * SpacingOneAndHalf4Header + SpacingOne * testsCount; - e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeftX, horY), new Point(tableRightX, horY)); - - return (testsCount + 1) * SpacingOne + 3 * SpacingOne4Header; - } - - - 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, 2000, SpacingOne); - e.Graphics.DrawString(text, this.font, Brushes.Black, printArea); - } - - - void PrintHeaderAt(System.Drawing.Printing.PrintPageEventArgs e, Point p, string text) - { - PrintHeaderAt(e, p.X, p.Y, text); - } - - - void PrintHeaderAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string text) - { - RectangleF printArea = new RectangleF(x, y, 2000, SpacingOne4Header); - e.Graphics.DrawString(text, this.headerFont, Brushes.Black, printArea); - } - } -} diff --git a/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs b/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs new file mode 100644 index 000000000..996ed9397 --- /dev/null +++ b/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs @@ -0,0 +1,461 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Printing; +using System.IO; +using Config.Entities; +using Results.Resources; + +namespace Results.Output.Printers.OnePerMeter +{ + public class OnePerMeterPrintDocument : PrintDocument + { + const float GapBetweenTableColumns = 10; + const float GapBetweenCommonColumns = 10; + + /// Size of the printed area without margins, after taking into account 'pageOrientation' + readonly int printHeight; + readonly int printWidth; + + readonly int topMargin; + readonly int bottomMargin; + readonly int leftMargin; + readonly int TitleX; + readonly int TitleY; /// Depends on the size of the header + + readonly int spacingOne; + readonly int spacingOne4Header; + + float commonTop; /// = TitleY + 60 + float bodyTop; /// = HdrTop + 160 + /// + float titleHeight; + float commonHeight; + + /// + /// Property variable for the Font the user wishes to use + /// + Font font; + Font headerFont; + Font titleFont; + + /// + /// Data to print + /// + Results.Entities.Batch batch; + OnePerMeterPrinterCfg cfg; + Results.Entities.WaterMeter wm; + + /// + /// Items to print + /// + string header; + IList commonItems; + IList testItems; + IList testItems2; + string footer; + + int nrPages; + int pageNr; /// Page number to be printed at the bottom of the page + + /// + /// Constructor + /// + /// Text to be printed + public OnePerMeterPrintDocument(Results.Entities.Batch batch, OnePerMeterPrinterCfg cfg, Results.Entities.WaterMeter wm) + { + this.batch = batch; + this.cfg = cfg; + this.wm = wm; + + topMargin = cfg.TopMargin; + bottomMargin = cfg.BottomMargin; + leftMargin = cfg.LeftMargin; + + header = string.IsNullOrEmpty(cfg.Header) ? string.Empty : cfg.Header.Replace("~", Environment.NewLine); + commonItems = Results.WMeterRsltItemSpec.FromStrArray(cfg.CommonItems); + testItems = Results.WMeterRsltItemSpec.FromStrArray(cfg.TestItems); /// TestID info will be overwritten later on + testItems2 = Results.WMeterRsltItemSpec.FromStrArray(cfg.TestItems2); /// TestID info will be overwritten later on + footer = string.IsNullOrEmpty(cfg.Footer) ? string.Empty : cfg.Footer.Replace("~", Environment.NewLine); + + /// Initialize fonts + titleFont = new Font((cfg.TitFntFml != null ? cfg.TitFntFml : "Arial"), (cfg.TitFntSz > 0 ? cfg.TitFntSz : 10), (FontStyle)cfg.TitFntSty); + headerFont = new Font((cfg.HdrFntFml != null ? cfg.HdrFntFml : "Arial"), (cfg.HdrFntSz > 0 ? cfg.HdrFntSz : 10), (FontStyle)cfg.HdrFntSty); + font = new Font((cfg.BodyFntFml != null ? cfg.BodyFntFml : "Arial"), (cfg.BodyFntSz > 0 ? cfg.BodyFntSz : 10), (FontStyle)cfg.BodyFntSty); + + /// Set print area size and margins (in dots using 100 dpi) + DefaultPageSettings.Landscape = (cfg.PageOrientation == PageOrientation.Landscape); + /// + if (DefaultPageSettings.Landscape) + { + 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; + } + + spacingOne = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", font).Height; + spacingOne4Header = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", headerFont).Height; + + /// Prepare document outline + TitleX = cfg.LeftMargin; + TitleY = cfg.TopMargin; + + pageNr = 1; + nrPages = (testItems2.Count != 0) ? 2 : 1; + } + + /// + /// Override the default onbeginPrint method of the PrintDocument Object + /// + /// + /// + protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e) + { + base.OnBeginPrint(e); + } + + /// + /// Override the default OnPrintPage method of the PrintDocument. + /// + /// + /// This provides the print logic for our document + protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e) + { + /// Run base code + base.OnPrintPage(e); + + if (pageNr == 1) + { + titleHeight = System.Windows.Forms.TextRenderer.MeasureText(header, titleFont).Height; + commonTop = TitleY + titleHeight + spacingOne4Header; + + commonHeight = commonItems.Count * spacingOne; + bodyTop = commonTop + commonHeight + spacingOne4Header; + } + + if (File.Exists("C:\\TBF\\header.png")) + { + Image img = Image.FromFile("C:\\TBF\\header.png"); + e.Graphics.DrawImage(new Bitmap(img), new Rectangle(0, 0, 827, 1169)); + } + + /// Use the StringFormat class for the text layout of our document + StringFormat format = new StringFormat(StringFormatFlags.LineLimit); + + if (pageNr == 1) + { + /// + /// Title + /// + RectangleF printArea = new RectangleF(TitleX, TitleY, printWidth, titleHeight); + e.Graphics.DrawString(header, titleFont, Brushes.Black, printArea); + + /// + /// Common items + /// + string[] leftColumn = new string[commonItems.Count]; + string[] rightColumn = new string[commonItems.Count]; + + int cnt = 0; + foreach (var v in commonItems) + { + leftColumn[cnt] = v.Caption; + rightColumn[cnt] = (batch.WaterMeters.Count > 0) ? v.Print(batch.WaterMeters[0]) : string.Empty; + cnt++; + } + + /// Determine left column width + float maxWidth = 0; + foreach (var str in leftColumn) + { + float width = e.Graphics.MeasureString(str, font).Width; + if (width > maxWidth) maxWidth = width; + } + + /// Write aligned columns + for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++) + { + PrintAt(e, leftMargin, commonTop + spacingOne * i, maxWidth, leftColumn[i], font, Alignment.Left); + PrintAt(e, leftMargin + maxWidth + GapBetweenCommonColumns, commonTop + spacingOne * i, 0, rightColumn[i], font, Alignment.Left); + } + } + + /// + /// Body + /// + if (pageNr == 1) + { + string[] tableHeader; + IList tableRows; + Alignment[] itemAlignment; + + /// + /// Prepare table content: tableHeader + tableRows + itemAlignment + /// + if (cfg.TestsAreRows) + { + GetContentTestsAreRows(wm, testItems, out tableHeader, out tableRows, out itemAlignment); + } + else + { + GetContentTestsAreColumns(wm, testItems, out tableHeader, out tableRows, out itemAlignment); + } + + DrawTable(e, (float)leftMargin, bodyTop, tableHeader, tableRows, itemAlignment); + } + else + { + string[] tableHeader; + IList tableRows; + Alignment[] itemAlignment; + + /// + /// Prepare table content: tableHeader + tableRows + itemAlignment + /// + if (cfg.TestsAreRows2) + { + GetContentTestsAreRows(wm, testItems2, out tableHeader, out tableRows, out itemAlignment); + } + else + { + GetContentTestsAreColumns(wm, testItems2, out tableHeader, out tableRows, out itemAlignment); + } + + DrawTable(e, (float)leftMargin, (float)topMargin, tableHeader, tableRows, itemAlignment); + } + + if (pageNr == nrPages) + { + /// + /// Footer on the last page + /// + float footerWidth = e.Graphics.MeasureString(footer, font).Width; + PrintAt(e, leftMargin, topMargin + printHeight - 2 * spacingOne, 0, footer, font, Alignment.Left); + } + + /// + /// Page number on each page + /// + string pageNrText = string.Format("{0} {1}/{2}", Strings.Page, pageNr, nrPages); + float pageNrWidth = e.Graphics.MeasureString(pageNrText, font).Width; + PrintAt(e, leftMargin + (printWidth - pageNrWidth) / 2, topMargin + printHeight - spacingOne, 0, pageNrText, font, Alignment.Left); + + e.HasMorePages = !(pageNr == nrPages); + + pageNr++; + } + + + void GetContentTestsAreRows(Results.Entities.WaterMeter wm, IList items, out string[] tableHeader, out IList tableRows, out Alignment[] itemAlignment) + { + int tableColumnsCount = items.Count; + + tableRows = new List(); + tableHeader = new string[tableColumnsCount]; + itemAlignment = new Alignment[tableColumnsCount]; + + for (int i = 0; i < tableColumnsCount; i++) + { + tableHeader[i] = items[i].Caption; + itemAlignment[i] = items[i].Alignment; + } + + WMeterRsltItemSpec.TableRowNr = 0; + foreach (var mtr in wm.MeterTestRslts) + { + if (mtr != null && mtr.IsPilotRslt() && mtr.Publish() == Config.Entities.Publish.Always) + { + string[] oneTableRow = new string[tableColumnsCount]; + WMeterRsltItemSpec.TableRowNr++; + + for (int i = 0; i < tableColumnsCount; i++) + { + WMeterRsltItemSpec.TableColumnNr = i + 1; + oneTableRow[i] = items[i].Print(wm, mtr.Name()).Split(new char[] { '|' })[0]; + } + + tableRows.Add(oneTableRow); + } + } + } + + + void GetContentTestsAreColumns(Results.Entities.WaterMeter wm, IList items, out string[] tableHeader, out IList tableRows, out Alignment[] itemAlignment) + { + int tableColumnsCount = 1; + foreach (var mtr in wm.MeterTestRslts) + { + if (mtr != null && mtr.IsPilotRslt() && mtr.Publish() == Config.Entities.Publish.Always) + { + tableColumnsCount++; + } + } + + tableRows = new List(); + tableHeader = new string[tableColumnsCount]; + itemAlignment = new Alignment[tableColumnsCount]; + + tableHeader[0] = string.Empty; + itemAlignment[0] = Alignment.Left; + int columnsCount = 1; + foreach (var mtr in wm.MeterTestRslts) + { + if (mtr != null && mtr.IsPilotRslt() && mtr.Publish() == Config.Entities.Publish.Always) + { + tableHeader[columnsCount] = mtr.Name(); + itemAlignment[columnsCount] = Alignment.Left; + columnsCount++; + } + } + + WMeterRsltItemSpec.TableRowNr = 0; + for (int i = 0; i < items.Count; i++) + { + string[] oneTableRow = new string[tableColumnsCount]; + WMeterRsltItemSpec.TableRowNr++; + + oneTableRow[0] = items[i].Caption; + + WMeterRsltItemSpec.TableColumnNr = 1; + foreach (var mtr in wm.MeterTestRslts) + { + if (mtr != null && mtr.IsPilotRslt() && mtr.Publish() == Config.Entities.Publish.Always) + { + /// Strip color information + oneTableRow[WMeterRsltItemSpec.TableColumnNr] = + items[i].Print(wm, mtr.Name()).Split(new char[] { '|' })[0]; + WMeterRsltItemSpec.TableColumnNr++; + } + } + + tableRows.Add(oneTableRow); + } + } + + + float DrawTable(System.Drawing.Printing.PrintPageEventArgs e, float left, float top, string[] header, IList rows, Alignment[] alignment) + { + int tblColumnsCount = header.Length; + + float[] columnWidth = new float[tblColumnsCount]; + float[] columnPos = new float[tblColumnsCount + 1]; + columnPos[0] = left; + + /// + /// Measure table column widths and header height + /// + float headerHeight = 0; + for (int i = 0; i < tblColumnsCount; i++) + { + SizeF size = e.Graphics.MeasureString(header[i], headerFont); + columnWidth[i] = (int)(size.Width + 0.99f); + if (size.Height > headerHeight) headerHeight = (int)(size.Height + 0.99f); + + foreach (var tableRow in rows) + { + int width = (int)(e.Graphics.MeasureString(tableRow[i], font).Width + 0.99f); + if (width > columnWidth[i]) columnWidth[i] = width; + } + columnPos[i + 1] = columnPos[i] + columnWidth[i] + GapBetweenTableColumns; + } + + float tableLeftX = columnPos[0]; + float tableRightX = columnPos[tblColumnsCount] - GapBetweenTableColumns; + + /// Horizontal line + float horY = top + 1.5f * spacingOne4Header; + e.Graphics.DrawLine(new Pen(Color.Black, 2), new PointF(tableLeftX, horY), new PointF(tableRightX, horY)); + + /// + /// Draw table header + /// + for (int i = 0; i < tblColumnsCount; i++) + { + PrintAt(e, columnPos[i], + top + 1.7f * spacingOne4Header, + columnWidth[i], + header[i], + headerFont, + Alignment.Center); + } + /// Horizontal line + horY = top + 2.1f * spacingOne4Header + headerHeight; + e.Graphics.DrawLine(new Pen(Color.Black, 2), new PointF(tableLeftX, horY), new PointF(tableRightX, horY)); + + /// + /// Draw table body + /// + int rowsCount = 0; + foreach (var oneTableRow in rows) + { + for (int i = 0; i < tblColumnsCount; i++) + { + PrintAt(e, columnPos[i], + horY + 0.2f * spacingOne4Header + spacingOne * rowsCount, + columnWidth[i], + oneTableRow[i], + font, + alignment[i]); + } + rowsCount++; + } + + /// Horizontal line + horY = horY + spacingOne * rowsCount + (3 * spacingOne4Header / 10); + e.Graphics.DrawLine(new Pen(Color.Black, 2), new PointF(tableLeftX, horY), new PointF(tableRightX, horY)); + + return horY - top + spacingOne; + } + + + static Font lastFont = null; + static float lastSpacing = 0; + + SizeF Measure(System.Drawing.Printing.PrintPageEventArgs e, string paragraph, Font font) + { + if (font != lastFont) + { + lastFont = font; + lastSpacing = e.Graphics.MeasureString("Abcgq", font).Height; + } + + string[] lines = paragraph.Split(new char[] { '~' }); + float width = 0; + foreach (var line in lines) + { + float lineWid = e.Graphics.MeasureString(line, font).Width; + if (lineWid > width) width = lineWid; + } + + return new SizeF(width, 0.8f * lines.Length * lastSpacing + 0.2f); + } + + + void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, float x, float y, float width, string paragraph, Font font, Alignment alignment) + { + SizeF size = Measure(e, paragraph, font); + + string[] lines = paragraph.Split(new char[] { '~' }); + foreach (var line in lines) + { + float xx; + switch (alignment) + { + default: + case Alignment.Left: xx = x; break; + case Alignment.Center: xx = x + (width - e.Graphics.MeasureString(line, font).Width) / 2; break; + case Alignment.Right: xx = x + width - e.Graphics.MeasureString(line, font).Width; break; + } + e.Graphics.DrawString(line, font, Brushes.Black, new PointF(xx, y)); + y += 0.8f * lastSpacing; + } + } + } +} diff --git a/Results/Output/Printers/OnePagePerMeter/EnhancedPrinterCfg.cs b/Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs similarity index 58% rename from Results/Output/Printers/OnePagePerMeter/EnhancedPrinterCfg.cs rename to Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs index 615f2d48f..bca6e68ff 100644 --- a/Results/Output/Printers/OnePagePerMeter/EnhancedPrinterCfg.cs +++ b/Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs @@ -1,14 +1,10 @@ /// /// Copyright (c) 2017 Sensus Metering Systems /// -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -namespace Results.Output.Printers.OnePagePerMeter +namespace Results.Output.Printers.OnePerMeter { - public class EnhancedPrinterCfg + public class OnePerMeterPrinterCfg { public Config.Entities.PageOrientation PageOrientation; public int TopMargin; @@ -23,11 +19,15 @@ namespace Results.Output.Printers.OnePagePerMeter public string BodyFntFml; public int BodyFntSz; public int BodyFntSty; - public bool SupressPrinting; /// Bypass printing when true + public bool GoodOnly; + public bool SupressPrinting; /// Bypass printing when true public System.Globalization.CultureInfo CultureInfo; - public string[] CommonItems; + public string Header; /// =Title + public string[] CommonItems; public string[] TestItems; - public string Header; /// =Title + public string[] TestItems2; public string Footer; - } + public bool TestsAreRows; + public bool TestsAreRows2; + } } diff --git a/Results/Output/Printers/Zapiska/ZapiskaPrintDocument.cs b/Results/Output/Printers/Zapiska/ZapiskaPrintDocument.cs index 4cb3a096a..5282318d1 100644 --- a/Results/Output/Printers/Zapiska/ZapiskaPrintDocument.cs +++ b/Results/Output/Printers/Zapiska/ZapiskaPrintDocument.cs @@ -14,33 +14,32 @@ namespace Results.Output.Printers.Zapiska { public class ZapiskaPrintDocument : PrintDocument { - const int GapBetweenTableColumns = 10; - const int GapBetweenCommonColumns = 10; + const float GapBetweenTableColumns = 10.0f; + const float GapBetweenCommonColumns = 10.0f; /// Size of the printed area without margins, after taking into account 'pageOrientation' - readonly int printHeight; - readonly int printWidth; + readonly int printHeight; /// in 0.254 mm = 0.01 in + readonly int printWidth; /// in 0.254 mm = 0.01 in - readonly int topMargin; - readonly int bottomMargin; - readonly int leftMargin; - readonly int leftMarginCommon1; - readonly int leftMarginCommon2; - readonly int leftMarginCommon3; - readonly int leftMarginBelow1; - readonly int leftMarginBelow2; - readonly int leftMarginBelow3; + readonly int topMargin; /// in 0.254 mm = 0.01 in + readonly int bottomMargin; /// in 0.254 mm = 0.01 in + readonly int leftMargin; /// in 0.254 mm = 0.01 in - readonly int SpacingOne; - readonly int SpacingOneAndHalf; - readonly int SpacingOne4Header; - readonly int SpacingOneAndHalf4Header; - - int CommonTop; /// = TitleY + 60 - int BodyTop; /// = HdrTop + 160 + readonly float leftMarginCommon1; + readonly float leftMarginCommon2; + readonly float leftMarginCommon3; + readonly float leftMarginBelow1; + readonly float leftMarginBelow2; + readonly float leftMarginBelow3; + + readonly float spacingOne; + readonly float spacingOne4Header; + + float commonTop; /// = TitleY + 60 + float bodyTop; /// = HdrTop + 160 /// - int titleHeight; - int commonHeight; + float titleHeight; + float commonHeight; /// /// Property variable for the Font the user wishes to use @@ -120,50 +119,16 @@ namespace Results.Output.Printers.Zapiska printWidth = base.DefaultPageSettings.PaperSize.Width - leftMargin - leftMargin; } - leftMarginCommon1 = leftMargin + (int)(printWidth * cfg.ColW0Pct / 100.0f); - leftMarginCommon2 = leftMargin + (int)(printWidth * (cfg.ColW0Pct + cfg.ColW1Pct) / 100.0f); - leftMarginCommon3 = leftMargin + (int)(printWidth * (cfg.ColW0Pct + cfg.ColW1Pct + cfg.ColW2Pct) / 100.0f); + leftMarginCommon1 = leftMargin + printWidth * 0.01f * cfg.ColW0Pct; + leftMarginCommon2 = leftMargin + printWidth * 0.01f * (cfg.ColW0Pct + cfg.ColW1Pct); + leftMarginCommon3 = leftMargin + printWidth * 0.01f * (cfg.ColW0Pct + cfg.ColW1Pct + cfg.ColW2Pct); - leftMarginBelow1 = leftMargin + (int)(printWidth * cfg.BelowW0Pct / 100.0f); - leftMarginBelow2 = leftMargin + (int)(printWidth * (cfg.BelowW0Pct + cfg.BelowW1Pct) / 100.0f); - leftMarginBelow3 = leftMargin + (int)(printWidth * (cfg.BelowW0Pct + cfg.BelowW1Pct + cfg.BelowW2Pct) / 100.0f); + leftMarginBelow1 = leftMargin + printWidth * 0.01f * cfg.BelowW0Pct; + leftMarginBelow2 = leftMargin + printWidth * 0.01f * (cfg.BelowW0Pct + cfg.BelowW1Pct); + leftMarginBelow3 = leftMargin + printWidth * 0.01f * (cfg.BelowW0Pct + cfg.BelowW1Pct + cfg.BelowW2Pct); - SpacingOne = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", font).Height; - SpacingOneAndHalf = (3 * SpacingOne) / 2; - SpacingOne4Header = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", headerFont).Height; - SpacingOneAndHalf4Header = (3 * SpacingOne4Header) / 2; - - /// Calculate the table rows count - int tableRowsCount = 0; - if (cfg.GoodOnly) - { - foreach (var wm in batch.WaterMeters) - { - if (!cfg.GoodOnly || wm.Passed) tableRowsCount++; - } - } - - /// Prepare document outline - titleHeight = System.Windows.Forms.TextRenderer.MeasureText(header, titleFont).Height; - CommonTop = cfg.TopMargin + titleHeight + SpacingOne4Header; - - int commonCount = Math.Max(commonItems1.Count, Math.Max(commonItems2.Count, commonItems3.Count)); - commonHeight = commonCount * SpacingOne; - BodyTop = CommonTop + commonHeight + SpacingOne4Header; - - int wmSectionHeight = (tableRowsCount + 1) * SpacingOne + 3 * SpacingOne4Header; - - tablesOnFirstPage = (printHeight - BodyTop + cfg.TopMargin - 2 * SpacingOne) / wmSectionHeight; - tablesOnNextPage = Math.Max((printHeight - 2 * SpacingOne) / wmSectionHeight, 1); /// Min. 1, prevent division by zero - - if (tablesOnFirstPage >= 1) - { - nrPages = 1; - } - else - { - nrPages = 2; - } + spacingOne = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", font).Height; + spacingOne4Header = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", headerFont).Height; pageNr = 1; } @@ -185,6 +150,34 @@ namespace Results.Output.Printers.Zapiska /// This provides the print logic for our document protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e) { + if (pageNr == 1) + { + /// Calculate the table rows count + int tableRowsCount = 0; + foreach (var wm in batch.WaterMeters) + { + if (!cfg.GoodOnly || wm.Passed) tableRowsCount++; + } + + /// Prepare document outline + titleHeight = System.Windows.Forms.TextRenderer.MeasureText(header, titleFont).Height; + commonTop = cfg.TopMargin + titleHeight + spacingOne4Header; + + int commonCount = Math.Max(commonItems1.Count, Math.Max(commonItems2.Count, commonItems3.Count)); + commonHeight = commonCount * spacingOne; + bodyTop = commonTop + commonHeight + spacingOne4Header; + + float wmSectionHeight = (tableRowsCount + 1) * spacingOne + 3 * spacingOne4Header; + + tablesOnFirstPage = (int)Math.Floor((printHeight - bodyTop + (float)cfg.TopMargin - 2 * spacingOne) / wmSectionHeight); + tablesOnNextPage = Math.Max(1, (int)Math.Floor((printHeight - 2 * spacingOne) / wmSectionHeight)); /// Min. 1, prevent division by zero + + if (tablesOnFirstPage >= 1) + nrPages = 1; + else + nrPages = 2; + } + /// Run base code base.OnPrintPage(e); @@ -202,7 +195,7 @@ namespace Results.Output.Printers.Zapiska ///---------- /// Title ///---------- - int titleWid = System.Windows.Forms.TextRenderer.MeasureText(header, titleFont).Width + 1; + float titleWid = e.Graphics.MeasureString(header, titleFont).Width; RectangleF printArea = new RectangleF(cfg.LeftMargin + Math.Max(0, (printWidth - titleWid)) / 2, cfg.TopMargin, titleWid, titleHeight); e.Graphics.DrawString(header, titleFont, Brushes.Black, printArea); @@ -213,7 +206,7 @@ namespace Results.Output.Printers.Zapiska for (int n = 1; n <= 3; n++) { IList commonItems; - int lMargin; + float lMargin; switch (n) { default: @@ -236,22 +229,25 @@ namespace Results.Output.Printers.Zapiska } /// Determine left column width - int leftColWidth = 0; + float leftColWidth = 0; foreach (var paragraph in leftColumn) { string[] lines = paragraph.Split(new char[] { '~' }); foreach (var line in lines) { - int itemWidth = Measure(paragraph, this.font).Width + 1; - if (itemWidth > leftColWidth) leftColWidth = itemWidth; + float itemWidth = Measure(e, paragraph, this.font).Width; + if (itemWidth > leftColWidth) + { + leftColWidth = itemWidth; + } } } /// Write aligned columns for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++) { - PrintAt(e, lMargin, CommonTop + SpacingOne * i, leftColWidth, leftColumn[i], this.font, commonItems[i].Alignment); - PrintAt(e, lMargin + leftColWidth + GapBetweenCommonColumns, CommonTop + SpacingOne * i, 0, rightColumn[i], this.font, Alignment.Left); + PrintAt(e, lMargin, commonTop + spacingOne * i, leftColWidth, leftColumn[i], this.font, commonItems[i].Alignment); + PrintAt(e, lMargin + leftColWidth + GapBetweenCommonColumns, commonTop + spacingOne * i, 0, rightColumn[i], this.font, Alignment.Left); } } } @@ -262,7 +258,7 @@ namespace Results.Output.Printers.Zapiska /// This variable represents the top coordinate of the area where WM results are printed /// and it is updated (increased by) the value returned by PrintXyzWM() - the section size. - int nextTableTop = (pageNr == 1) ? BodyTop : cfg.TopMargin; + float nextTableTop = (pageNr == 1) ? bodyTop : cfg.TopMargin; if (tablesOnFirstPage > 0 || pageNr == 2) { @@ -277,7 +273,7 @@ namespace Results.Output.Printers.Zapiska for (int n = 1; n <= 3; n++) { IList belowItems; - int lMargin; + float lMargin; switch (n) { default: @@ -300,13 +296,13 @@ namespace Results.Output.Printers.Zapiska } /// Determine left column width - int leftColWidth = 0; + float leftColWidth = 0; foreach (var paragraph in leftColumn) { string[] lines = paragraph.Split(new char[] { '~' }); foreach (var line in lines) { - int itemWidth = System.Windows.Forms.TextRenderer.MeasureText(paragraph, font).Width + 1; + float itemWidth = e.Graphics.MeasureString(paragraph, font).Width + 1; if (itemWidth > leftColWidth) leftColWidth = itemWidth; } } @@ -314,20 +310,20 @@ namespace Results.Output.Printers.Zapiska /// Write aligned columns for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++) { - PrintAt(e, lMargin, nextTableTop + SpacingOne * i, leftColWidth, leftColumn[i], this.font, belowItems[i].Alignment); - PrintAt(e, lMargin + leftColWidth + GapBetweenCommonColumns, nextTableTop + SpacingOne * i, 0, rightColumn[i], this.font, Alignment.Left); + PrintAt(e, lMargin, nextTableTop + spacingOne * i, leftColWidth, leftColumn[i], this.font, belowItems[i].Alignment); + PrintAt(e, lMargin + leftColWidth + GapBetweenCommonColumns, nextTableTop + spacingOne * i, 0, rightColumn[i], this.font, Alignment.Left); } } ///---------- /// Footer ///---------- - int footerWidth = Measure(footer, font).Width; - PrintAt(e, leftMargin + (printWidth - footerWidth) / 2, topMargin + printHeight - 2 * SpacingOne, 0, footer, font, Alignment.Left); + float footerWidth = Measure(e, footer, font).Width; + PrintAt(e, leftMargin + (printWidth - footerWidth) / 2, topMargin + printHeight - 2 * spacingOne, 0, footer, font, Alignment.Left); string pageNrText = string.Format("{0} {1}/{2}", Strings.Page, pageNr++, nrPages); - int pageNrWidth = System.Windows.Forms.TextRenderer.MeasureText(pageNrText, font).Width; - PrintAt(e, leftMargin + (printWidth - pageNrWidth) / 2, topMargin + printHeight - SpacingOne, 0, pageNrText, font, Alignment.Left); + float pageNrWidth = e.Graphics.MeasureString(pageNrText, font).Width; + PrintAt(e, leftMargin + (printWidth - pageNrWidth) / 2, topMargin + printHeight - spacingOne, 0, pageNrText, font, Alignment.Left); } @@ -338,137 +334,161 @@ namespace Results.Output.Printers.Zapiska /// Number of the water meter printed /// Top coordinate of watermeter data /// The height of the printed section - int PrintWMs(System.Drawing.Printing.PrintPageEventArgs e, - IList wms, int top) + float PrintWMs(System.Drawing.Printing.PrintPageEventArgs e, + IList wms, float top) { - /// Determine column widths - WMeterRsltItemSpec.TableRowNr = 99; - WMeterRsltItemSpec.TableColumnNr = 99; - int[] columnWidth = new int[selectedItems.Count]; - int[] columnPos = new int[selectedItems.Count + 1]; - int headerHeight = 0; - columnPos[0] = leftMargin; - - for (int i = 0; i < selectedItems.Count; i++) - { - Size size = Measure(selectedItems[i].Caption, headerFont); - columnWidth[i] = size.Width + 1; - if (size.Height > headerHeight) headerHeight = size.Height; - - foreach (var wm in wms) - { - if (!cfg.GoodOnly || wm.Passed) - { - string itemText = selectedItems[i].Print(wm); - - /// Strip color information - string[] texts = itemText.Split(new char[] { '|' }); - if (texts.Length == 2) { itemText = texts[0]; } - - int width = Measure(itemText, font).Width + 1; - if (width > columnWidth[i]) columnWidth[i] = width; - } - } - columnPos[i + 1] = columnPos[i] + columnWidth[i] + GapBetweenTableColumns; - } - int tableLeftX = (int)columnPos[0]; - int tableRightX = (int)columnPos[selectedItems.Count] - GapBetweenTableColumns; - - /// Horizontal line - int horY = top + SpacingOneAndHalf4Header; - e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeftX, horY), new Point(tableRightX, horY)); - - for (int i = 0; i < selectedItems.Count; i++) - { - PrintAt(e, (int)columnPos[i], top + (int)(1.7 * SpacingOne4Header), columnWidth[i], selectedItems[i].Caption, this.headerFont, Alignment.Center); - } - /// Horizontal line - horY = top + 21 * SpacingOne4Header / 10 + headerHeight; - e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeftX, horY), new Point(tableRightX, horY)); - - int rowsCount = 0; + /// + /// Prepare table content + /// + int tableColumnsCount = selectedItems.Count; + /// + string[] tableHeader = new string[tableColumnsCount]; + IList tableRows = new List(); + Alignment[] itemAlignment = new Alignment[tableColumnsCount]; + /// + for (int i = 0; i < tableColumnsCount; i++) + { + tableHeader[i] = selectedItems[i].Caption; + itemAlignment[i] = selectedItems[i].Alignment; + } + /// + WMeterRsltItemSpec.TableRowNr = 0; foreach (var wm in wms) { - rowsCount++; if (!cfg.GoodOnly || wm.Passed) { - WMeterRsltItemSpec.TableRowNr = rowsCount; + string[] oneTableRow = new string[tableColumnsCount]; + WMeterRsltItemSpec.TableRowNr++; - for (int i = 0; i < selectedItems.Count; i++) + for (int i = 0; i < tableColumnsCount; i++) { WMeterRsltItemSpec.TableColumnNr = i + 1; - - string itemText = selectedItems[i].Print(wm); - - /// Strip color information - string[] texts = itemText.Split(new char[] { '|' }); - if (texts.Length == 2) - { - itemText = texts[0]; - Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White); - /// TODO: How to print colors? - } - - PrintAt(e, (int)columnPos[i], horY + (3 * SpacingOne4Header / 10) + SpacingOne * (rowsCount - 1), columnWidth[i], itemText, this.font, selectedItems[i].Alignment); + oneTableRow[i] = selectedItems[i].Print(wm).Split(new char[] { '|' })[0]; /// Strip color information } + + tableRows.Add(oneTableRow); } - } + } - /// Horizontal line - horY = horY + SpacingOne * rowsCount + (3 * SpacingOne4Header / 10); - e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeftX, horY), new Point(tableRightX, horY)); - - return horY - top + SpacingOne; + return DrawTable(e, leftMargin, top, tableHeader, tableRows, itemAlignment); } - static Font lastFont = null; - static int lastSpacing = 0; + float DrawTable(System.Drawing.Printing.PrintPageEventArgs e, float left, float top, string[] header, IList rows, Alignment[] alignment) + { + int tblColumnsCount = header.Length; - Size Measure(string paragraph, Font font) + float[] columnWidth = new float[tblColumnsCount]; + float[] columnPos = new float[tblColumnsCount + 1]; + columnPos[0] = left; + + /// + /// Measure table column widths and header height + /// + float headerHeight = 0; + for (int i = 0; i < tblColumnsCount; i++) + { + SizeF size = Measure(e, header[i], headerFont); + columnWidth[i] = size.Width; + if (size.Height > headerHeight) headerHeight = size.Height; + + foreach (var tableRow in rows) + { + float width = Measure(e, tableRow[i], font).Width + 1; + if (width > columnWidth[i]) columnWidth[i] = width; + } + columnPos[i + 1] = columnPos[i] + columnWidth[i] + GapBetweenTableColumns; + } + + float tableLeftX = columnPos[0]; + float tableRightX = columnPos[tblColumnsCount] - GapBetweenTableColumns; + + /// Horizontal line + float horY = top + 1.5f * spacingOne4Header; + e.Graphics.DrawLine(new Pen(Color.Black, 2), new PointF(tableLeftX, horY), new PointF(tableRightX, horY)); + + /// + /// Draw table header + /// + for (int i = 0; i < tblColumnsCount; i++) + { + PrintAt(e, columnPos[i], + top + 1.7f * spacingOne4Header, + columnWidth[i], + header[i], + headerFont, + Alignment.Center); + } + /// Horizontal line + horY = top + 2.1f * spacingOne4Header + headerHeight; + e.Graphics.DrawLine(new Pen(Color.Black, 2), new PointF(tableLeftX, horY), new PointF(tableRightX, horY)); + + /// + /// Draw table body + /// + int rowsCount = 0; + foreach (var oneTableRow in rows) + { + for (int i = 0; i < tblColumnsCount; i++) + { + PrintAt(e, columnPos[i], + horY + 0.2f * spacingOne4Header + spacingOne * rowsCount, + columnWidth[i], + oneTableRow[i], + font, + alignment[i]); + } + rowsCount++; + } + + /// Horizontal line + horY = horY + spacingOne * rowsCount + (3 * spacingOne4Header / 10); + e.Graphics.DrawLine(new Pen(Color.Black, 2), new PointF(tableLeftX, horY), new PointF(tableRightX, horY)); + + return horY - top + spacingOne; + } + + + static Font lastFont = null; + static float lastSpacing = 0; + + SizeF Measure(System.Drawing.Printing.PrintPageEventArgs e, string paragraph, Font font) { if (font != lastFont) { lastFont = font; - lastSpacing = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", font).Height; + lastSpacing = e.Graphics.MeasureString("Abcgq", font).Height; } string[] lines = paragraph.Split(new char[] { '~' }); - int width = 0; + float width = 0; foreach (var line in lines) { - int lineWid = System.Windows.Forms.TextRenderer.MeasureText(line, font).Width; + float lineWid = e.Graphics.MeasureString(line, font).Width; if (lineWid > width) width = lineWid; } - return new Size(width, (8 * lines.Length * lastSpacing + 2) / 10); + return new SizeF(width, 0.8f * lines.Length * lastSpacing + 0.2f); } - void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, int width, string paragraph, Font font, Alignment alignment) + void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, float x, float y, float width, string paragraph, Font font, Alignment alignment) { - Size size = Measure(paragraph, font); - - if (font != lastFont) - { - lastFont = font; - lastSpacing = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", font).Height; - } + SizeF size = Measure(e, paragraph, font); string[] lines = paragraph.Split(new char[] { '~' }); foreach (var line in lines) { - int xx; + float xx; switch (alignment) { default: case Alignment.Left: xx = x; break; - case Alignment.Center: xx = x + (width - System.Windows.Forms.TextRenderer.MeasureText(line, font).Width) / 2; break; - case Alignment.Right: xx = x + width - System.Windows.Forms.TextRenderer.MeasureText(line, font).Width; break; + case Alignment.Center: xx = x + (width - e.Graphics.MeasureString(line, font).Width) / 2; break; + case Alignment.Right: xx = x + width - e.Graphics.MeasureString(line, font).Width; break; } - RectangleF printArea = new RectangleF(xx, y, 2000, lastSpacing); - e.Graphics.DrawString(line, font, Brushes.Black, printArea); - y += 8 * lastSpacing / 10; + e.Graphics.DrawString(line, font, Brushes.Black, new PointF(xx, y)); + y += 0.8f * lastSpacing; } } } diff --git a/Results/Properties/AssemblyInfo.cs b/Results/Properties/AssemblyInfo.cs index a15287e32..4c1c78388 100644 --- a/Results/Properties/AssemblyInfo.cs +++ b/Results/Properties/AssemblyInfo.cs @@ -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.17.731.0")] -[assembly: AssemblyFileVersion("2.17.731.0")] +[assembly: AssemblyVersion("2.17.735.0")] +[assembly: AssemblyFileVersion("2.17.735.0")] diff --git a/Results/Results.csproj b/Results/Results.csproj index 061082460..cc89a2beb 100644 --- a/Results/Results.csproj +++ b/Results/Results.csproj @@ -107,10 +107,10 @@ Component - + Component - + Component diff --git a/Results/WMeterRsltItemSpec.cs b/Results/WMeterRsltItemSpec.cs index 8d8268a0a..7f3be9bdd 100644 --- a/Results/WMeterRsltItemSpec.cs +++ b/Results/WMeterRsltItemSpec.cs @@ -99,6 +99,10 @@ namespace Results Quantity = quantity; Category = category; this.printDlgt = printDlgt; + + Format = string.Empty; + Precision = string.Empty; + TestID = string.Empty; } /// @@ -113,7 +117,11 @@ namespace Results Quantity = quantity; Category = category; this.printDlgt = printDlgt; - } + + Format = string.Empty; + Precision = string.Empty; + TestID = string.Empty; + } /// Static list of all available items diff --git a/TestBenchFramework/BenchControl/Output/FileWriters/Basic/Writer.cs b/TestBenchFramework/BenchControl/Output/FileWriters/Basic/Writer.cs index 19b22d4f5..0eb3f5640 100644 --- a/TestBenchFramework/BenchControl/Output/FileWriters/Basic/Writer.cs +++ b/TestBenchFramework/BenchControl/Output/FileWriters/Basic/Writer.cs @@ -213,15 +213,17 @@ namespace TBF.BenchControl.Output.FileWriters.Basic { CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture; - try { Thread.CurrentThread.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString()); } - catch { } + if (writerCfg.Culture != Culture.system) + { + Thread.CurrentThread.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString()); + } abort = false; WriteRslts(batch, writerCfg.DestinationPath); WriteRslts(batch, writerCfg.DestinationPath2); - Thread.CurrentThread.CurrentCulture = oriCulture; - } + Thread.CurrentThread.CurrentCulture = oriCulture; + } /// Run this operation /// Event.ResultsWritten diff --git a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/Writer.cs b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/Writer.cs index 8912de6bb..fd377f430 100644 --- a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/Writer.cs +++ b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/Writer.cs @@ -213,14 +213,16 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced { CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture; - try { Thread.CurrentThread.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString()); } - catch { } + if (writerCfg.Culture != Culture.system) + { + Thread.CurrentThread.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString()); + } abort = false; WriteRslts(batch, writerCfg.DestinationPath); WriteRslts(batch, writerCfg.DestinationPath2); - Thread.CurrentThread.CurrentCulture = oriCulture; + Thread.CurrentThread.CurrentCulture = oriCulture; } /// Run this operation @@ -323,7 +325,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced #if BADGER_MALA_TRAT || BADGER_STREDNA_TRAT || BADGER_VELKA_TRAT wr.Write(string.Format("Water meter {0} s/n: {1}", wm.WMPosition, wm.SerialNr)); #else - wr.Write(string.Format(Strings.Water_Meter_nr, wm.WMPosition)); + wr.Write(string.Format("{0} {1}", Strings.Water_Meter, wm.WMPosition)); if (!wm.Compound()) { if (!string.IsNullOrEmpty(wm.SerialNr)) diff --git a/TestBenchFramework/BenchControl/Output/FileWriters/OneFilePerMeter/Writer.cs b/TestBenchFramework/BenchControl/Output/FileWriters/OneFilePerMeter/Writer.cs index a56d1878e..9de42600b 100644 --- a/TestBenchFramework/BenchControl/Output/FileWriters/OneFilePerMeter/Writer.cs +++ b/TestBenchFramework/BenchControl/Output/FileWriters/OneFilePerMeter/Writer.cs @@ -213,15 +213,17 @@ namespace TBF.BenchControl.Output.FileWriters.OneFilePerMeter /// Start this operation public void Start() { - CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture; + CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture; - try { Thread.CurrentThread.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString()); } - catch { } + if (writerCfg.Culture != Culture.system) + { + Thread.CurrentThread.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString()); + } WriteRslts(batch, writerCfg.DestinationPath); WriteRslts(batch, writerCfg.DestinationPath2); - Thread.CurrentThread.CurrentCulture = oriCulture; + Thread.CurrentThread.CurrentCulture = oriCulture; } /// Run this operation @@ -319,7 +321,7 @@ namespace TBF.BenchControl.Output.FileWriters.OneFilePerMeter #if BADGER_MALA_TRAT || BADGER_STREDNA_TRAT || BADGER_VELKA_TRAT wr.Write(string.Format("Water meter {0} s/n: {1}", wm.WMPosition, wm.SerialNr)); #else - wr.Write(string.Format(Strings.Water_Meter_nr, wm.WMPosition)); + wr.Write(string.Format("{0} {1}", Strings.Water_Meter, wm.WMPosition)); if (!wm.Compound()) { if (!string.IsNullOrEmpty(wm.SerialNr)) diff --git a/TestBenchFramework/BenchControl/Output/FileWriters/Xml/Writer.cs b/TestBenchFramework/BenchControl/Output/FileWriters/Xml/Writer.cs index c50faa4ec..b01e43a4a 100644 --- a/TestBenchFramework/BenchControl/Output/FileWriters/Xml/Writer.cs +++ b/TestBenchFramework/BenchControl/Output/FileWriters/Xml/Writer.cs @@ -192,15 +192,17 @@ namespace TBF.BenchControl.Output.FileWriters.Xml /// Start this operation public void Start() { - CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture; + CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture; - try { Thread.CurrentThread.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString()); } - catch { } + if (writerCfg.Culture != Culture.system) + { + Thread.CurrentThread.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString()); + } WriteRslts(batch, writerCfg.DestinationPath); WriteRslts(batch, writerCfg.DestinationPath2); - Thread.CurrentThread.CurrentCulture = oriCulture; + Thread.CurrentThread.CurrentCulture = oriCulture; } /// Run this operation diff --git a/TestBenchFramework/BenchControl/Output/Printers/Enhanced/Printer.cs b/TestBenchFramework/BenchControl/Output/Printers/Enhanced/Printer.cs index c841fb900..a9ab699ec 100644 --- a/TestBenchFramework/BenchControl/Output/Printers/Enhanced/Printer.cs +++ b/TestBenchFramework/BenchControl/Output/Printers/Enhanced/Printer.cs @@ -19,6 +19,9 @@ namespace TBF.BenchControl.Output.Printers.Enhanced public bool SupressPrinting { get { return printerCfg.SupressPrinting; } } + /// Data to print + Results.Entities.Batch batch; + /// /// Items to print /// @@ -28,14 +31,8 @@ namespace TBF.BenchControl.Output.Printers.Enhanced string footer; - Thread thread; /// Thread where results are printed - bool completed; /// Set to 'true' by the thread when printing results is completed - bool abort; /// Set to 'true' by Stop() operation to abort printing results - - public Printer() { } - public Printer(Generic.IComponentCfg cfg) : base(cfg) { @@ -112,80 +109,67 @@ namespace TBF.BenchControl.Output.Printers.Enhanced /// Reference to the operation public IOperation PrintResultsOp(Results.Entities.Batch batch) { - thread = new Thread(() => - { - PrintResults(batch); - completed = true; - }); - - thread.CurrentCulture = Thread.CurrentThread.CurrentCulture; - thread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture; - - if (printerCfg.Culture > Culture.system && printerCfg.Culture < Culture.Count) - { - thread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString()); - } - - return this; - } + this.batch = batch; + return this; + } /// Start this operation public void Start() { - completed = false; - abort = false; - thread.Start(); - } + CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture; + + if (printerCfg.Culture != Culture.system) + { + Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString()); + } + + PrintResults(batch); + + Thread.CurrentThread.CurrentCulture = oriCulture; + } /// Run this operation /// Event.ResultsPrinted public Event Run() { - if (completed) - return Event.ResultsPrinted; - else - return Event.Busy; + return Event.ResultsPrinted; } /// Stop this operation public void Stop() { - if (!completed) abort = true; } - void PrintResults(Results.Entities.Batch batch) - { - CultureInfo culture = Thread.CurrentThread.CurrentCulture; - try { culture = new System.Globalization.CultureInfo(printerCfg.Culture.ToString()); } - catch { } + void PrintResults(Results.Entities.Batch batch) + { + if (batch.WaterMeters.Count > 0) + { + EnhancedPrinterCfg cfg = new EnhancedPrinterCfg + { + PageOrientation = printerCfg.PageOrientation, + TopMargin = printerCfg.TopMargin, + BottomMargin = printerCfg.BottomMargin, + LeftMargin = printerCfg.LeftMargin, + TitFntFml = printerCfg.TitFntFml, + HdrFntFml = printerCfg.HdrFntFml, + BodyFntFml = printerCfg.BodyFntFml, + TitFntSz = printerCfg.TitFntSz, + HdrFntSz = printerCfg.HdrFntSz, + BodyFntSz = printerCfg.BodyFntSz, + TitFntSty = printerCfg.TitFntSty, + HdrFntSty = printerCfg.HdrFntSty, + BodyFntSty = printerCfg.BodyFntSty, + SupressPrinting = printerCfg.SupressPrinting, + CultureInfo = (printerCfg.Culture == Culture.system) ? Thread.CurrentThread.CurrentCulture : new CultureInfo(printerCfg.Culture.ToString()), + Header = printerCfg.Header, + CommonItems = printerCfg.CommonItems, + TestItems = printerCfg.SelectedItems, + Footer = printerCfg.Footer, + }; - if (batch.WaterMeters.Count > 0) - { - EnhancedPrinterCfg cfg = new EnhancedPrinterCfg { - PageOrientation = printerCfg.PageOrientation, - TopMargin = printerCfg.TopMargin, - BottomMargin = printerCfg.BottomMargin, - LeftMargin = printerCfg.LeftMargin, - TitFntFml = printerCfg.TitFntFml, - HdrFntFml = printerCfg.HdrFntFml, - BodyFntFml = printerCfg.BodyFntFml, - TitFntSz = printerCfg.TitFntSz, - HdrFntSz = printerCfg.HdrFntSz, - BodyFntSz = printerCfg.BodyFntSz, - TitFntSty = printerCfg.TitFntSty, - HdrFntSty = printerCfg.HdrFntSty, - BodyFntSty = printerCfg.BodyFntSty, - SupressPrinting = printerCfg.SupressPrinting, - CultureInfo = culture, - Header = printerCfg.Header, - CommonItems = printerCfg.CommonItems, - TestItems = printerCfg.SelectedItems, - Footer = printerCfg.Footer, - }; - - new Results.Output.Printers.Enhanced.EnhancedPrintDocument(batch, cfg).Print(); - } - } - } + new Results.Output.Printers.Enhanced.EnhancedPrintDocument(batch, cfg).Print(); + } + } + } } diff --git a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/PrinterCfgCtrl.Designer.cs b/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/PrinterCfgCtrl.Designer.cs deleted file mode 100644 index e8727f91a..000000000 --- a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/PrinterCfgCtrl.Designer.cs +++ /dev/null @@ -1,458 +0,0 @@ -/// -/// Copyright (c) 2017 Sensus Metering Systems -/// -namespace TBF.BenchControl.Output.Printers.OnePagePerMeter -{ - partial class PrinterCfgCtrl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - 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.orientationLabel = new System.Windows.Forms.Label(); - this.orientationComboBox = new System.Windows.Forms.ComboBox(); - this.topMarginTextBox = new System.Windows.Forms.TextBox(); - this.topMarginLabel = new System.Windows.Forms.Label(); - this.leftMarginTextBox = new System.Windows.Forms.TextBox(); - this.bottomMarginTextBox = new System.Windows.Forms.TextBox(); - this.cultureComboBox = new System.Windows.Forms.ComboBox(); - this.cultureLabel = new System.Windows.Forms.Label(); - this.commonItemsButton = new System.Windows.Forms.Button(); - this.footerButton = new System.Windows.Forms.Button(); - this.headerButton = new System.Windows.Forms.Button(); - this.testItemsButton = new System.Windows.Forms.Button(); - this.headerFontLabel = new System.Windows.Forms.Label(); - this.titleFontLabel = new System.Windows.Forms.Label(); - this.titleFontFamilyComboBox = new System.Windows.Forms.ComboBox(); - this.headerFontFamilyComboBox = new System.Windows.Forms.ComboBox(); - this.bodyFontFamilyComboBox = new System.Windows.Forms.ComboBox(); - this.bodyFontLabel = new System.Windows.Forms.Label(); - this.titleFontSizeTextBox = new System.Windows.Forms.TextBox(); - this.headerFontSizeTextBox = new System.Windows.Forms.TextBox(); - this.bodyFontSizeTextBox = new System.Windows.Forms.TextBox(); - this.titleBoldCheckBox = new System.Windows.Forms.CheckBox(); - this.titleItalicCheckBox = new System.Windows.Forms.CheckBox(); - this.headerItalicCheckBox = new System.Windows.Forms.CheckBox(); - this.headerBoldCheckBox = new System.Windows.Forms.CheckBox(); - this.bodyItalicCheckBox = new System.Windows.Forms.CheckBox(); - this.bodyBoldCheckBox = new System.Windows.Forms.CheckBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // nameTextBox - // - this.nameTextBox.Enabled = false; - this.nameTextBox.Location = new System.Drawing.Point(142, 40); - this.nameTextBox.Name = "nameTextBox"; - this.nameTextBox.Size = new System.Drawing.Size(218, 20); - this.nameTextBox.TabIndex = 2; - // - // nameLabel - // - this.nameLabel.AutoSize = true; - this.nameLabel.Location = new System.Drawing.Point(16, 43); - this.nameLabel.Name = "nameLabel"; - this.nameLabel.Size = new System.Drawing.Size(35, 13); - this.nameLabel.TabIndex = 1; - this.nameLabel.Text = "Name"; - // - // classNameLabel - // - this.classNameLabel.AutoSize = true; - this.classNameLabel.Location = new System.Drawing.Point(139, 16); - this.classNameLabel.Name = "classNameLabel"; - this.classNameLabel.Size = new System.Drawing.Size(83, 13); - this.classNameLabel.TabIndex = 0; - this.classNameLabel.Text = "ComonentName"; - // - // supressPrintingCheckBox - // - this.supressPrintingCheckBox.AutoSize = true; - this.supressPrintingCheckBox.Enabled = false; - this.supressPrintingCheckBox.Location = new System.Drawing.Point(143, 188); - this.supressPrintingCheckBox.Name = "supressPrintingCheckBox"; - this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17); - this.supressPrintingCheckBox.TabIndex = 24; - this.supressPrintingCheckBox.Text = "Supress printing"; - this.supressPrintingCheckBox.UseVisualStyleBackColor = true; - // - // orientationLabel - // - this.orientationLabel.AutoSize = true; - this.orientationLabel.Location = new System.Drawing.Point(16, 67); - this.orientationLabel.Name = "orientationLabel"; - this.orientationLabel.Size = new System.Drawing.Size(84, 13); - this.orientationLabel.TabIndex = 3; - this.orientationLabel.Text = "Page orientation"; - // - // orientationComboBox - // - this.orientationComboBox.Enabled = false; - this.orientationComboBox.FormattingEnabled = true; - this.orientationComboBox.Location = new System.Drawing.Point(142, 64); - this.orientationComboBox.Name = "orientationComboBox"; - this.orientationComboBox.Size = new System.Drawing.Size(218, 21); - this.orientationComboBox.TabIndex = 4; - // - // topMarginTextBox - // - this.topMarginTextBox.Enabled = false; - this.topMarginTextBox.Location = new System.Drawing.Point(142, 89); - this.topMarginTextBox.Name = "topMarginTextBox"; - this.topMarginTextBox.Size = new System.Drawing.Size(44, 20); - this.topMarginTextBox.TabIndex = 6; - // - // topMarginLabel - // - this.topMarginLabel.AutoSize = true; - this.topMarginLabel.Location = new System.Drawing.Point(16, 92); - this.topMarginLabel.Name = "topMarginLabel"; - this.topMarginLabel.Size = new System.Drawing.Size(116, 13); - this.topMarginLabel.TabIndex = 5; - this.topMarginLabel.Text = "Top/bottom/left margin"; - // - // leftMarginTextBox - // - this.leftMarginTextBox.Enabled = false; - this.leftMarginTextBox.Location = new System.Drawing.Point(244, 89); - this.leftMarginTextBox.Name = "leftMarginTextBox"; - this.leftMarginTextBox.Size = new System.Drawing.Size(44, 20); - this.leftMarginTextBox.TabIndex = 8; - // - // bottomMarginTextBox - // - this.bottomMarginTextBox.Enabled = false; - this.bottomMarginTextBox.Location = new System.Drawing.Point(193, 89); - this.bottomMarginTextBox.Name = "bottomMarginTextBox"; - this.bottomMarginTextBox.Size = new System.Drawing.Size(44, 20); - this.bottomMarginTextBox.TabIndex = 7; - // - // cultureComboBox - // - this.cultureComboBox.Enabled = false; - this.cultureComboBox.FormattingEnabled = true; - this.cultureComboBox.Location = new System.Drawing.Point(142, 209); - this.cultureComboBox.Name = "cultureComboBox"; - this.cultureComboBox.Size = new System.Drawing.Size(218, 21); - this.cultureComboBox.TabIndex = 26; - // - // cultureLabel - // - this.cultureLabel.AutoSize = true; - this.cultureLabel.Location = new System.Drawing.Point(16, 212); - this.cultureLabel.Name = "cultureLabel"; - this.cultureLabel.Size = new System.Drawing.Size(42, 13); - this.cultureLabel.TabIndex = 25; - this.cultureLabel.Text = "Cullture"; - // - // commonItemsButton - // - this.commonItemsButton.Enabled = false; - this.commonItemsButton.Location = new System.Drawing.Point(142, 259); - this.commonItemsButton.Name = "commonItemsButton"; - this.commonItemsButton.Size = new System.Drawing.Size(218, 23); - this.commonItemsButton.TabIndex = 28; - this.commonItemsButton.Text = "Common items"; - this.commonItemsButton.UseVisualStyleBackColor = true; - this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click); - // - // footerButton - // - this.footerButton.Enabled = false; - this.footerButton.Location = new System.Drawing.Point(142, 309); - this.footerButton.Name = "footerButton"; - this.footerButton.Size = new System.Drawing.Size(218, 23); - this.footerButton.TabIndex = 30; - this.footerButton.Text = "Footer"; - this.footerButton.UseVisualStyleBackColor = true; - this.footerButton.Click += new System.EventHandler(this.footerButton_Click); - // - // headerButton - // - this.headerButton.Enabled = false; - this.headerButton.Location = new System.Drawing.Point(142, 234); - this.headerButton.Name = "headerButton"; - this.headerButton.Size = new System.Drawing.Size(218, 23); - this.headerButton.TabIndex = 27; - this.headerButton.Text = "Title"; - this.headerButton.UseVisualStyleBackColor = true; - this.headerButton.Click += new System.EventHandler(this.headerButton_Click); - // - // testItemsButton - // - this.testItemsButton.Enabled = false; - this.testItemsButton.Location = new System.Drawing.Point(142, 284); - this.testItemsButton.Name = "testItemsButton"; - this.testItemsButton.Size = new System.Drawing.Size(218, 23); - this.testItemsButton.TabIndex = 29; - this.testItemsButton.Text = "Test items"; - this.testItemsButton.UseVisualStyleBackColor = true; - this.testItemsButton.Click += new System.EventHandler(this.testItemsButton_Click); - // - // headerFontLabel - // - this.headerFontLabel.AutoSize = true; - this.headerFontLabel.Location = new System.Drawing.Point(16, 140); - this.headerFontLabel.Name = "headerFontLabel"; - this.headerFontLabel.Size = new System.Drawing.Size(112, 13); - this.headerFontLabel.TabIndex = 14; - this.headerFontLabel.Text = "Header font/size/style"; - // - // titleFontLabel - // - this.titleFontLabel.AutoSize = true; - this.titleFontLabel.Location = new System.Drawing.Point(16, 116); - this.titleFontLabel.Name = "titleFontLabel"; - this.titleFontLabel.Size = new System.Drawing.Size(97, 13); - this.titleFontLabel.TabIndex = 9; - this.titleFontLabel.Text = "Title font/size/style"; - // - // titleFontFamilyComboBox - // - this.titleFontFamilyComboBox.Enabled = false; - this.titleFontFamilyComboBox.FormattingEnabled = true; - this.titleFontFamilyComboBox.Location = new System.Drawing.Point(142, 113); - this.titleFontFamilyComboBox.Name = "titleFontFamilyComboBox"; - this.titleFontFamilyComboBox.Size = new System.Drawing.Size(110, 21); - this.titleFontFamilyComboBox.TabIndex = 10; - // - // headerFontFamilyComboBox - // - this.headerFontFamilyComboBox.Enabled = false; - this.headerFontFamilyComboBox.FormattingEnabled = true; - this.headerFontFamilyComboBox.Location = new System.Drawing.Point(142, 137); - this.headerFontFamilyComboBox.Name = "headerFontFamilyComboBox"; - this.headerFontFamilyComboBox.Size = new System.Drawing.Size(110, 21); - this.headerFontFamilyComboBox.TabIndex = 15; - // - // bodyFontFamilyComboBox - // - this.bodyFontFamilyComboBox.Enabled = false; - this.bodyFontFamilyComboBox.FormattingEnabled = true; - this.bodyFontFamilyComboBox.Location = new System.Drawing.Point(142, 161); - this.bodyFontFamilyComboBox.Name = "bodyFontFamilyComboBox"; - this.bodyFontFamilyComboBox.Size = new System.Drawing.Size(110, 21); - this.bodyFontFamilyComboBox.TabIndex = 20; - // - // bodyFontLabel - // - this.bodyFontLabel.AutoSize = true; - this.bodyFontLabel.Location = new System.Drawing.Point(16, 164); - this.bodyFontLabel.Name = "bodyFontLabel"; - this.bodyFontLabel.Size = new System.Drawing.Size(101, 13); - this.bodyFontLabel.TabIndex = 19; - this.bodyFontLabel.Text = "Body font/size/style"; - // - // titleFontSizeTextBox - // - this.titleFontSizeTextBox.Enabled = false; - this.titleFontSizeTextBox.Location = new System.Drawing.Point(258, 113); - this.titleFontSizeTextBox.Name = "titleFontSizeTextBox"; - this.titleFontSizeTextBox.Size = new System.Drawing.Size(30, 20); - this.titleFontSizeTextBox.TabIndex = 11; - // - // headerFontSizeTextBox - // - this.headerFontSizeTextBox.Enabled = false; - this.headerFontSizeTextBox.Location = new System.Drawing.Point(258, 137); - this.headerFontSizeTextBox.Name = "headerFontSizeTextBox"; - this.headerFontSizeTextBox.Size = new System.Drawing.Size(30, 20); - this.headerFontSizeTextBox.TabIndex = 16; - // - // bodyFontSizeTextBox - // - this.bodyFontSizeTextBox.Enabled = false; - this.bodyFontSizeTextBox.Location = new System.Drawing.Point(258, 161); - this.bodyFontSizeTextBox.Name = "bodyFontSizeTextBox"; - this.bodyFontSizeTextBox.Size = new System.Drawing.Size(29, 20); - this.bodyFontSizeTextBox.TabIndex = 21; - // - // titleBoldCheckBox - // - this.titleBoldCheckBox.AutoSize = true; - this.titleBoldCheckBox.Enabled = false; - this.titleBoldCheckBox.Location = new System.Drawing.Point(306, 116); - this.titleBoldCheckBox.Name = "titleBoldCheckBox"; - this.titleBoldCheckBox.Size = new System.Drawing.Size(15, 14); - this.titleBoldCheckBox.TabIndex = 12; - this.titleBoldCheckBox.UseVisualStyleBackColor = true; - // - // titleItalicCheckBox - // - this.titleItalicCheckBox.AutoSize = true; - this.titleItalicCheckBox.Enabled = false; - this.titleItalicCheckBox.Location = new System.Drawing.Point(334, 116); - this.titleItalicCheckBox.Name = "titleItalicCheckBox"; - this.titleItalicCheckBox.Size = new System.Drawing.Size(15, 14); - this.titleItalicCheckBox.TabIndex = 13; - this.titleItalicCheckBox.UseVisualStyleBackColor = true; - // - // headerItalicCheckBox - // - this.headerItalicCheckBox.AutoSize = true; - this.headerItalicCheckBox.Enabled = false; - this.headerItalicCheckBox.Location = new System.Drawing.Point(334, 140); - this.headerItalicCheckBox.Name = "headerItalicCheckBox"; - this.headerItalicCheckBox.Size = new System.Drawing.Size(15, 14); - this.headerItalicCheckBox.TabIndex = 18; - this.headerItalicCheckBox.UseVisualStyleBackColor = true; - // - // headerBoldCheckBox - // - this.headerBoldCheckBox.AutoSize = true; - this.headerBoldCheckBox.Enabled = false; - this.headerBoldCheckBox.Location = new System.Drawing.Point(306, 140); - this.headerBoldCheckBox.Name = "headerBoldCheckBox"; - this.headerBoldCheckBox.Size = new System.Drawing.Size(15, 14); - this.headerBoldCheckBox.TabIndex = 17; - this.headerBoldCheckBox.UseVisualStyleBackColor = true; - // - // bodyItalicCheckBox - // - this.bodyItalicCheckBox.AutoSize = true; - this.bodyItalicCheckBox.Enabled = false; - this.bodyItalicCheckBox.Location = new System.Drawing.Point(334, 164); - this.bodyItalicCheckBox.Name = "bodyItalicCheckBox"; - this.bodyItalicCheckBox.Size = new System.Drawing.Size(15, 14); - this.bodyItalicCheckBox.TabIndex = 23; - this.bodyItalicCheckBox.UseVisualStyleBackColor = true; - // - // bodyBoldCheckBox - // - this.bodyBoldCheckBox.AutoSize = true; - this.bodyBoldCheckBox.Enabled = false; - this.bodyBoldCheckBox.Location = new System.Drawing.Point(306, 164); - this.bodyBoldCheckBox.Name = "bodyBoldCheckBox"; - this.bodyBoldCheckBox.Size = new System.Drawing.Size(15, 14); - this.bodyBoldCheckBox.TabIndex = 22; - this.bodyBoldCheckBox.UseVisualStyleBackColor = true; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.label1.Location = new System.Drawing.Point(296, 100); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(32, 13); - this.label1.TabIndex = 31; - this.label1.Text = "Bold"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.label2.Location = new System.Drawing.Point(330, 100); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(24, 13); - this.label2.TabIndex = 32; - this.label2.Text = "Ital."; - // - // PrinterCfgCtrl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Controls.Add(this.bodyItalicCheckBox); - this.Controls.Add(this.bodyBoldCheckBox); - this.Controls.Add(this.headerItalicCheckBox); - this.Controls.Add(this.headerBoldCheckBox); - this.Controls.Add(this.titleItalicCheckBox); - this.Controls.Add(this.titleBoldCheckBox); - this.Controls.Add(this.bodyFontSizeTextBox); - this.Controls.Add(this.headerFontSizeTextBox); - this.Controls.Add(this.titleFontSizeTextBox); - this.Controls.Add(this.bodyFontFamilyComboBox); - this.Controls.Add(this.bodyFontLabel); - this.Controls.Add(this.headerFontFamilyComboBox); - this.Controls.Add(this.titleFontFamilyComboBox); - this.Controls.Add(this.cultureComboBox); - this.Controls.Add(this.cultureLabel); - this.Controls.Add(this.commonItemsButton); - this.Controls.Add(this.footerButton); - this.Controls.Add(this.headerButton); - this.Controls.Add(this.testItemsButton); - this.Controls.Add(this.bottomMarginTextBox); - this.Controls.Add(this.titleFontLabel); - this.Controls.Add(this.leftMarginTextBox); - this.Controls.Add(this.headerFontLabel); - this.Controls.Add(this.topMarginTextBox); - this.Controls.Add(this.topMarginLabel); - this.Controls.Add(this.orientationComboBox); - this.Controls.Add(this.orientationLabel); - 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(400, 350); - 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; - private System.Windows.Forms.Label orientationLabel; - private System.Windows.Forms.ComboBox orientationComboBox; - private System.Windows.Forms.TextBox topMarginTextBox; - private System.Windows.Forms.Label topMarginLabel; - private System.Windows.Forms.TextBox leftMarginTextBox; - private System.Windows.Forms.TextBox bottomMarginTextBox; - private System.Windows.Forms.ComboBox cultureComboBox; - private System.Windows.Forms.Label cultureLabel; - private System.Windows.Forms.Button commonItemsButton; - private System.Windows.Forms.Button footerButton; - private System.Windows.Forms.Button headerButton; - private System.Windows.Forms.Button testItemsButton; - private System.Windows.Forms.Label headerFontLabel; - private System.Windows.Forms.Label titleFontLabel; - private System.Windows.Forms.ComboBox titleFontFamilyComboBox; - private System.Windows.Forms.ComboBox headerFontFamilyComboBox; - private System.Windows.Forms.ComboBox bodyFontFamilyComboBox; - private System.Windows.Forms.Label bodyFontLabel; - private System.Windows.Forms.TextBox titleFontSizeTextBox; - private System.Windows.Forms.TextBox headerFontSizeTextBox; - private System.Windows.Forms.TextBox bodyFontSizeTextBox; - private System.Windows.Forms.CheckBox titleBoldCheckBox; - private System.Windows.Forms.CheckBox titleItalicCheckBox; - private System.Windows.Forms.CheckBox headerItalicCheckBox; - private System.Windows.Forms.CheckBox headerBoldCheckBox; - private System.Windows.Forms.CheckBox bodyItalicCheckBox; - private System.Windows.Forms.CheckBox bodyBoldCheckBox; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - } -} diff --git a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/FactoryCompound.cs b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/FactoryCompound.cs similarity index 84% rename from TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/FactoryCompound.cs rename to TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/FactoryCompound.cs index 6200b930e..15c75a2ab 100644 --- a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/FactoryCompound.cs +++ b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/FactoryCompound.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Output.Printers.OnePagePerMeter +namespace TBF.BenchControl.Output.Printers.OnePerMeter { public class FactoryCompound : IComponentFactory { @@ -16,7 +16,7 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Printer(cfg); } - public IComponentCfg DefaultConfig() { return new PrinterCfg("Printer.OnePagePerMeter.Compound", this, Config.Entities.MetersKind.Combined); } + public IComponentCfg DefaultConfig() { return new PrinterCfg("Printer.OnePerMeter.Compound", this, Config.Entities.MetersKind.Combined); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/FactoryHeatMeters.cs b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/FactoryHeatMeters.cs similarity index 84% rename from TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/FactoryHeatMeters.cs rename to TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/FactoryHeatMeters.cs index e9abdd65f..fafa36866 100644 --- a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/FactoryHeatMeters.cs +++ b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/FactoryHeatMeters.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Output.Printers.OnePagePerMeter +namespace TBF.BenchControl.Output.Printers.OnePerMeter { public class FactoryHeatMeters : IComponentFactory { @@ -16,7 +16,7 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Printer(cfg); } - public IComponentCfg DefaultConfig() { return new PrinterCfg("Printer.OnePagePerMeter.HeatMeters", this, Config.Entities.MetersKind.HeatMeter); } + public IComponentCfg DefaultConfig() { return new PrinterCfg("Printer.OnePerMeter.HeatMeters", this, Config.Entities.MetersKind.HeatMeter); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/FactorySingle.cs b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/FactorySingle.cs similarity index 85% rename from TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/FactorySingle.cs rename to TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/FactorySingle.cs index f4a9451c9..f93641d7b 100644 --- a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/FactorySingle.cs +++ b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/FactorySingle.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Output.Printers.OnePagePerMeter +namespace TBF.BenchControl.Output.Printers.OnePerMeter { public class FactorySingle : IComponentFactory { @@ -16,7 +16,7 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Printer(cfg); } - public IComponentCfg DefaultConfig() { return new PrinterCfg("Printer.OnePagePerMeter.Single", this, Config.Entities.MetersKind.Single); } + public IComponentCfg DefaultConfig() { return new PrinterCfg("Printer.OnePerMeter.Single", this, Config.Entities.MetersKind.Single); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/Printer.cs b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/Printer.cs similarity index 70% rename from TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/Printer.cs rename to TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/Printer.cs index e407581e1..a63b9f193 100644 --- a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/Printer.cs +++ b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/Printer.cs @@ -5,10 +5,10 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Threading; -using Results.Output.Printers.OnePagePerMeter; +using Results.Output.Printers.OnePerMeter; using log4net; -namespace TBF.BenchControl.Output.Printers.OnePagePerMeter +namespace TBF.BenchControl.Output.Printers.OnePerMeter { public class Printer : ComponentBase, IOperation, GenericDevices.IResultsPrinter { @@ -31,14 +31,8 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter string footer; - Thread thread; /// Thread where results are printed - bool completed; /// Set to 'true' by the thread when printing results is completed - bool abort; /// Set to 'true' by Stop() operation to abort printing results - - public Printer() { } - public Printer(Generic.IComponentCfg cfg) : base(cfg) { @@ -92,12 +86,16 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter printerCfg.BodyFntSz = newCfg.BodyFntSz; printerCfg.BodyFntSty = newCfg.BodyFntSty; - printerCfg.SupressPrinting = newCfg.SupressPrinting; + printerCfg.GoodOnly = newCfg.GoodOnly; + printerCfg.SupressPrinting = newCfg.SupressPrinting; printerCfg.Culture = newCfg.Culture; - printerCfg.CommonItems = newCfg.CommonItems; + printerCfg.Header = newCfg.Header; + printerCfg.CommonItems = newCfg.CommonItems; printerCfg.SelectedItems = newCfg.SelectedItems; - printerCfg.Header = newCfg.Header; - printerCfg.Footer = newCfg.Footer; + printerCfg.SelectedItems2 = newCfg.SelectedItems2; + printerCfg.Footer = newCfg.Footer; + printerCfg.TestsAreRows = newCfg.TestsAreRows; + printerCfg.TestsAreRows2 = newCfg.TestsAreRows2; ApplyConfig(); } @@ -122,10 +120,22 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter /// Start this operation public void Start() { + CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture; + + if (printerCfg.Culture != Culture.system) + { + Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString()); + } + foreach (var wm in batch.WaterMeters) { - PrintResults(batch, wm); + if (!printerCfg.GoodOnly || wm.Passed) + { + PrintResults(batch, wm); + } } + + Thread.CurrentThread.CurrentCulture = oriCulture; } /// Run this operation @@ -143,13 +153,9 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter void PrintResults(Results.Entities.Batch batch, Results.Entities.WaterMeter wm) { - CultureInfo culture = Thread.CurrentThread.CurrentCulture; - try { culture = new System.Globalization.CultureInfo(printerCfg.Culture.ToString()); } - catch { } - if (batch.WaterMeters.Count > 0) { - EnhancedPrinterCfg cfg = new EnhancedPrinterCfg { + OnePerMeterPrinterCfg cfg = new OnePerMeterPrinterCfg { PageOrientation = printerCfg.PageOrientation, TopMargin = printerCfg.TopMargin, BottomMargin = printerCfg.BottomMargin, @@ -163,15 +169,19 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter TitFntSty = printerCfg.TitFntSty, HdrFntSty = printerCfg.HdrFntSty, BodyFntSty = printerCfg.BodyFntSty, - SupressPrinting = printerCfg.SupressPrinting, - CultureInfo = culture, - Header = printerCfg.Header, + GoodOnly = printerCfg.GoodOnly, + SupressPrinting = printerCfg.SupressPrinting, + CultureInfo = (printerCfg.Culture == Culture.system) ? Thread.CurrentThread.CurrentCulture : new CultureInfo(printerCfg.Culture.ToString()), + Header = printerCfg.Header, CommonItems = printerCfg.CommonItems, TestItems = printerCfg.SelectedItems, - Footer = printerCfg.Footer, - }; + TestItems2 = printerCfg.SelectedItems2, + Footer = printerCfg.Footer, + TestsAreRows = printerCfg.TestsAreRows, + TestsAreRows2 = printerCfg.TestsAreRows2, + }; - new EnhancedPrintDocument(batch, cfg, wm).Print(); + new Results.Output.Printers.OnePerMeter.OnePerMeterPrintDocument(batch, cfg, wm).Print(); } } } diff --git a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/PrinterCfg.cs b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs similarity index 81% rename from TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/PrinterCfg.cs rename to TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs index 130c59676..e9a2840c9 100644 --- a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/PrinterCfg.cs +++ b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs @@ -5,7 +5,7 @@ using System.Xml.Serialization; using Config.Entities; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Output.Printers.OnePagePerMeter +namespace TBF.BenchControl.Output.Printers.OnePerMeter { public class PrinterCfg : ComponentCfgBase, Generic.IComponentCfg { @@ -30,12 +30,16 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter public int TitFntSty; public int HdrFntSty; public int BodyFntSty; - public bool SupressPrinting; /// Bypass printing when true + public bool GoodOnly; + public bool SupressPrinting; /// Bypass printing when true public Culture Culture; - public string[] CommonItems; + public string Header; /// =Title + public string[] CommonItems; public string[] SelectedItems; - public string Header; /// =Title - public string Footer; + public string[] SelectedItems2; + public string Footer; + public bool TestsAreRows; /// true = Tests are rows + public bool TestsAreRows2; /// true = Tests are rows [XmlIgnore] public Config.Entities.MetersKind MetersKind; @@ -66,6 +70,7 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter TitFntFml = "Arial"; TitFntSz = 10; TitFntSty = 0; + GoodOnly = false; SupressPrinting = false; Header = string.Empty; Footer = string.Empty; diff --git a/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs new file mode 100644 index 000000000..b83ce9077 --- /dev/null +++ b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs @@ -0,0 +1,514 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +namespace TBF.BenchControl.Output.Printers.OnePerMeter +{ + partial class PrinterCfgCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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.orientationLabel = new System.Windows.Forms.Label(); + this.orientationComboBox = new System.Windows.Forms.ComboBox(); + this.topMarginTextBox = new System.Windows.Forms.TextBox(); + this.topMarginLabel = new System.Windows.Forms.Label(); + this.leftMarginTextBox = new System.Windows.Forms.TextBox(); + this.bottomMarginTextBox = new System.Windows.Forms.TextBox(); + this.cultureComboBox = new System.Windows.Forms.ComboBox(); + this.cultureLabel = new System.Windows.Forms.Label(); + this.commonItemsButton = new System.Windows.Forms.Button(); + this.footerButton = new System.Windows.Forms.Button(); + this.headerButton = new System.Windows.Forms.Button(); + this.testItemsButton = new System.Windows.Forms.Button(); + this.headerFontLabel = new System.Windows.Forms.Label(); + this.titleFontLabel = new System.Windows.Forms.Label(); + this.titleFontFamilyComboBox = new System.Windows.Forms.ComboBox(); + this.headerFontFamilyComboBox = new System.Windows.Forms.ComboBox(); + this.bodyFontFamilyComboBox = new System.Windows.Forms.ComboBox(); + this.bodyFontLabel = new System.Windows.Forms.Label(); + this.titleFontSizeTextBox = new System.Windows.Forms.TextBox(); + this.headerFontSizeTextBox = new System.Windows.Forms.TextBox(); + this.bodyFontSizeTextBox = new System.Windows.Forms.TextBox(); + this.titleBoldCheckBox = new System.Windows.Forms.CheckBox(); + this.titleItalicCheckBox = new System.Windows.Forms.CheckBox(); + this.headerItalicCheckBox = new System.Windows.Forms.CheckBox(); + this.headerBoldCheckBox = new System.Windows.Forms.CheckBox(); + this.bodyItalicCheckBox = new System.Windows.Forms.CheckBox(); + this.bodyBoldCheckBox = new System.Windows.Forms.CheckBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.testsAreRowsCheckBox = new System.Windows.Forms.CheckBox(); + this.tests2AreRowsCheckBox = new System.Windows.Forms.CheckBox(); + this.testItems2Button = new System.Windows.Forms.Button(); + this.goodOnlyCheckBox = new System.Windows.Forms.CheckBox(); + this.SuspendLayout(); + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(142, 30); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(218, 20); + this.nameTextBox.TabIndex = 2; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(16, 33); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 1; + this.nameLabel.Text = "Name"; + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(139, 7); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(83, 13); + this.classNameLabel.TabIndex = 0; + this.classNameLabel.Text = "ComonentName"; + // + // supressPrintingCheckBox + // + this.supressPrintingCheckBox.AutoSize = true; + this.supressPrintingCheckBox.Enabled = false; + this.supressPrintingCheckBox.Location = new System.Drawing.Point(143, 178); + this.supressPrintingCheckBox.Name = "supressPrintingCheckBox"; + this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17); + this.supressPrintingCheckBox.TabIndex = 24; + this.supressPrintingCheckBox.Text = "Supress printing"; + this.supressPrintingCheckBox.UseVisualStyleBackColor = true; + // + // orientationLabel + // + this.orientationLabel.AutoSize = true; + this.orientationLabel.Location = new System.Drawing.Point(16, 57); + this.orientationLabel.Name = "orientationLabel"; + this.orientationLabel.Size = new System.Drawing.Size(84, 13); + this.orientationLabel.TabIndex = 3; + this.orientationLabel.Text = "Page orientation"; + // + // orientationComboBox + // + this.orientationComboBox.Enabled = false; + this.orientationComboBox.FormattingEnabled = true; + this.orientationComboBox.Location = new System.Drawing.Point(142, 54); + this.orientationComboBox.Name = "orientationComboBox"; + this.orientationComboBox.Size = new System.Drawing.Size(218, 21); + this.orientationComboBox.TabIndex = 4; + // + // topMarginTextBox + // + this.topMarginTextBox.Enabled = false; + this.topMarginTextBox.Location = new System.Drawing.Point(142, 79); + this.topMarginTextBox.Name = "topMarginTextBox"; + this.topMarginTextBox.Size = new System.Drawing.Size(44, 20); + this.topMarginTextBox.TabIndex = 6; + // + // topMarginLabel + // + this.topMarginLabel.AutoSize = true; + this.topMarginLabel.Location = new System.Drawing.Point(16, 82); + this.topMarginLabel.Name = "topMarginLabel"; + this.topMarginLabel.Size = new System.Drawing.Size(116, 13); + this.topMarginLabel.TabIndex = 5; + this.topMarginLabel.Text = "Top/bottom/left margin"; + // + // leftMarginTextBox + // + this.leftMarginTextBox.Enabled = false; + this.leftMarginTextBox.Location = new System.Drawing.Point(244, 79); + this.leftMarginTextBox.Name = "leftMarginTextBox"; + this.leftMarginTextBox.Size = new System.Drawing.Size(44, 20); + this.leftMarginTextBox.TabIndex = 8; + // + // bottomMarginTextBox + // + this.bottomMarginTextBox.Enabled = false; + this.bottomMarginTextBox.Location = new System.Drawing.Point(193, 79); + this.bottomMarginTextBox.Name = "bottomMarginTextBox"; + this.bottomMarginTextBox.Size = new System.Drawing.Size(44, 20); + this.bottomMarginTextBox.TabIndex = 7; + // + // cultureComboBox + // + this.cultureComboBox.Enabled = false; + this.cultureComboBox.FormattingEnabled = true; + this.cultureComboBox.Location = new System.Drawing.Point(142, 198); + this.cultureComboBox.Name = "cultureComboBox"; + this.cultureComboBox.Size = new System.Drawing.Size(218, 21); + this.cultureComboBox.TabIndex = 26; + // + // cultureLabel + // + this.cultureLabel.AutoSize = true; + this.cultureLabel.Location = new System.Drawing.Point(16, 201); + this.cultureLabel.Name = "cultureLabel"; + this.cultureLabel.Size = new System.Drawing.Size(42, 13); + this.cultureLabel.TabIndex = 25; + this.cultureLabel.Text = "Cullture"; + // + // commonItemsButton + // + this.commonItemsButton.Enabled = false; + this.commonItemsButton.Location = new System.Drawing.Point(142, 246); + this.commonItemsButton.Name = "commonItemsButton"; + this.commonItemsButton.Size = new System.Drawing.Size(218, 23); + this.commonItemsButton.TabIndex = 28; + this.commonItemsButton.Text = "Common items"; + this.commonItemsButton.UseVisualStyleBackColor = true; + this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click); + // + // footerButton + // + this.footerButton.Enabled = false; + this.footerButton.Location = new System.Drawing.Point(142, 318); + this.footerButton.Name = "footerButton"; + this.footerButton.Size = new System.Drawing.Size(218, 23); + this.footerButton.TabIndex = 30; + this.footerButton.Text = "Footer"; + this.footerButton.UseVisualStyleBackColor = true; + this.footerButton.Click += new System.EventHandler(this.footerButton_Click); + // + // headerButton + // + this.headerButton.Enabled = false; + this.headerButton.Location = new System.Drawing.Point(142, 222); + this.headerButton.Name = "headerButton"; + this.headerButton.Size = new System.Drawing.Size(218, 23); + this.headerButton.TabIndex = 27; + this.headerButton.Text = "Title"; + this.headerButton.UseVisualStyleBackColor = true; + this.headerButton.Click += new System.EventHandler(this.headerButton_Click); + // + // testItemsButton + // + this.testItemsButton.Enabled = false; + this.testItemsButton.Location = new System.Drawing.Point(142, 270); + this.testItemsButton.Name = "testItemsButton"; + this.testItemsButton.Size = new System.Drawing.Size(218, 23); + this.testItemsButton.TabIndex = 29; + this.testItemsButton.Text = "Test items - 1st table"; + this.testItemsButton.UseVisualStyleBackColor = true; + this.testItemsButton.Click += new System.EventHandler(this.testItemsButton_Click); + // + // headerFontLabel + // + this.headerFontLabel.AutoSize = true; + this.headerFontLabel.Location = new System.Drawing.Point(16, 130); + this.headerFontLabel.Name = "headerFontLabel"; + this.headerFontLabel.Size = new System.Drawing.Size(112, 13); + this.headerFontLabel.TabIndex = 14; + this.headerFontLabel.Text = "Header font/size/style"; + // + // titleFontLabel + // + this.titleFontLabel.AutoSize = true; + this.titleFontLabel.Location = new System.Drawing.Point(16, 106); + this.titleFontLabel.Name = "titleFontLabel"; + this.titleFontLabel.Size = new System.Drawing.Size(97, 13); + this.titleFontLabel.TabIndex = 9; + this.titleFontLabel.Text = "Title font/size/style"; + // + // titleFontFamilyComboBox + // + this.titleFontFamilyComboBox.Enabled = false; + this.titleFontFamilyComboBox.FormattingEnabled = true; + this.titleFontFamilyComboBox.Location = new System.Drawing.Point(142, 103); + this.titleFontFamilyComboBox.Name = "titleFontFamilyComboBox"; + this.titleFontFamilyComboBox.Size = new System.Drawing.Size(110, 21); + this.titleFontFamilyComboBox.TabIndex = 10; + // + // headerFontFamilyComboBox + // + this.headerFontFamilyComboBox.Enabled = false; + this.headerFontFamilyComboBox.FormattingEnabled = true; + this.headerFontFamilyComboBox.Location = new System.Drawing.Point(142, 127); + this.headerFontFamilyComboBox.Name = "headerFontFamilyComboBox"; + this.headerFontFamilyComboBox.Size = new System.Drawing.Size(110, 21); + this.headerFontFamilyComboBox.TabIndex = 15; + // + // bodyFontFamilyComboBox + // + this.bodyFontFamilyComboBox.Enabled = false; + this.bodyFontFamilyComboBox.FormattingEnabled = true; + this.bodyFontFamilyComboBox.Location = new System.Drawing.Point(142, 151); + this.bodyFontFamilyComboBox.Name = "bodyFontFamilyComboBox"; + this.bodyFontFamilyComboBox.Size = new System.Drawing.Size(110, 21); + this.bodyFontFamilyComboBox.TabIndex = 20; + // + // bodyFontLabel + // + this.bodyFontLabel.AutoSize = true; + this.bodyFontLabel.Location = new System.Drawing.Point(16, 154); + this.bodyFontLabel.Name = "bodyFontLabel"; + this.bodyFontLabel.Size = new System.Drawing.Size(101, 13); + this.bodyFontLabel.TabIndex = 19; + this.bodyFontLabel.Text = "Body font/size/style"; + // + // titleFontSizeTextBox + // + this.titleFontSizeTextBox.Enabled = false; + this.titleFontSizeTextBox.Location = new System.Drawing.Point(258, 103); + this.titleFontSizeTextBox.Name = "titleFontSizeTextBox"; + this.titleFontSizeTextBox.Size = new System.Drawing.Size(30, 20); + this.titleFontSizeTextBox.TabIndex = 11; + // + // headerFontSizeTextBox + // + this.headerFontSizeTextBox.Enabled = false; + this.headerFontSizeTextBox.Location = new System.Drawing.Point(258, 127); + this.headerFontSizeTextBox.Name = "headerFontSizeTextBox"; + this.headerFontSizeTextBox.Size = new System.Drawing.Size(30, 20); + this.headerFontSizeTextBox.TabIndex = 16; + // + // bodyFontSizeTextBox + // + this.bodyFontSizeTextBox.Enabled = false; + this.bodyFontSizeTextBox.Location = new System.Drawing.Point(258, 151); + this.bodyFontSizeTextBox.Name = "bodyFontSizeTextBox"; + this.bodyFontSizeTextBox.Size = new System.Drawing.Size(29, 20); + this.bodyFontSizeTextBox.TabIndex = 21; + // + // titleBoldCheckBox + // + this.titleBoldCheckBox.AutoSize = true; + this.titleBoldCheckBox.Enabled = false; + this.titleBoldCheckBox.Location = new System.Drawing.Point(306, 106); + this.titleBoldCheckBox.Name = "titleBoldCheckBox"; + this.titleBoldCheckBox.Size = new System.Drawing.Size(15, 14); + this.titleBoldCheckBox.TabIndex = 12; + this.titleBoldCheckBox.UseVisualStyleBackColor = true; + // + // titleItalicCheckBox + // + this.titleItalicCheckBox.AutoSize = true; + this.titleItalicCheckBox.Enabled = false; + this.titleItalicCheckBox.Location = new System.Drawing.Point(334, 106); + this.titleItalicCheckBox.Name = "titleItalicCheckBox"; + this.titleItalicCheckBox.Size = new System.Drawing.Size(15, 14); + this.titleItalicCheckBox.TabIndex = 13; + this.titleItalicCheckBox.UseVisualStyleBackColor = true; + // + // headerItalicCheckBox + // + this.headerItalicCheckBox.AutoSize = true; + this.headerItalicCheckBox.Enabled = false; + this.headerItalicCheckBox.Location = new System.Drawing.Point(334, 130); + this.headerItalicCheckBox.Name = "headerItalicCheckBox"; + this.headerItalicCheckBox.Size = new System.Drawing.Size(15, 14); + this.headerItalicCheckBox.TabIndex = 18; + this.headerItalicCheckBox.UseVisualStyleBackColor = true; + // + // headerBoldCheckBox + // + this.headerBoldCheckBox.AutoSize = true; + this.headerBoldCheckBox.Enabled = false; + this.headerBoldCheckBox.Location = new System.Drawing.Point(306, 130); + this.headerBoldCheckBox.Name = "headerBoldCheckBox"; + this.headerBoldCheckBox.Size = new System.Drawing.Size(15, 14); + this.headerBoldCheckBox.TabIndex = 17; + this.headerBoldCheckBox.UseVisualStyleBackColor = true; + // + // bodyItalicCheckBox + // + this.bodyItalicCheckBox.AutoSize = true; + this.bodyItalicCheckBox.Enabled = false; + this.bodyItalicCheckBox.Location = new System.Drawing.Point(334, 154); + this.bodyItalicCheckBox.Name = "bodyItalicCheckBox"; + this.bodyItalicCheckBox.Size = new System.Drawing.Size(15, 14); + this.bodyItalicCheckBox.TabIndex = 23; + this.bodyItalicCheckBox.UseVisualStyleBackColor = true; + // + // bodyBoldCheckBox + // + this.bodyBoldCheckBox.AutoSize = true; + this.bodyBoldCheckBox.Enabled = false; + this.bodyBoldCheckBox.Location = new System.Drawing.Point(306, 154); + this.bodyBoldCheckBox.Name = "bodyBoldCheckBox"; + this.bodyBoldCheckBox.Size = new System.Drawing.Size(15, 14); + this.bodyBoldCheckBox.TabIndex = 22; + this.bodyBoldCheckBox.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.label1.Location = new System.Drawing.Point(296, 90); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(32, 13); + this.label1.TabIndex = 31; + this.label1.Text = "Bold"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.label2.Location = new System.Drawing.Point(330, 90); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(24, 13); + this.label2.TabIndex = 32; + this.label2.Text = "Ital."; + // + // testsAreRowsCheckBox + // + this.testsAreRowsCheckBox.AutoSize = true; + this.testsAreRowsCheckBox.Enabled = false; + this.testsAreRowsCheckBox.Location = new System.Drawing.Point(19, 274); + this.testsAreRowsCheckBox.Name = "testsAreRowsCheckBox"; + this.testsAreRowsCheckBox.Size = new System.Drawing.Size(95, 17); + this.testsAreRowsCheckBox.TabIndex = 33; + this.testsAreRowsCheckBox.Text = "Tests are rows"; + this.testsAreRowsCheckBox.UseVisualStyleBackColor = true; + // + // tests2AreRowsCheckBox + // + this.tests2AreRowsCheckBox.AutoSize = true; + this.tests2AreRowsCheckBox.Enabled = false; + this.tests2AreRowsCheckBox.Location = new System.Drawing.Point(19, 298); + this.tests2AreRowsCheckBox.Name = "tests2AreRowsCheckBox"; + this.tests2AreRowsCheckBox.Size = new System.Drawing.Size(104, 17); + this.tests2AreRowsCheckBox.TabIndex = 35; + this.tests2AreRowsCheckBox.Text = "Tests are rows 2"; + this.tests2AreRowsCheckBox.UseVisualStyleBackColor = true; + // + // testItems2Button + // + this.testItems2Button.Enabled = false; + this.testItems2Button.Location = new System.Drawing.Point(142, 294); + this.testItems2Button.Name = "testItems2Button"; + this.testItems2Button.Size = new System.Drawing.Size(218, 23); + this.testItems2Button.TabIndex = 34; + this.testItems2Button.Text = "Test items - 2nd table"; + this.testItems2Button.UseVisualStyleBackColor = true; + this.testItems2Button.Click += new System.EventHandler(this.testItems2Button_Click); + // + // goodOnlyCheckBox + // + this.goodOnlyCheckBox.AutoSize = true; + this.goodOnlyCheckBox.Enabled = false; + this.goodOnlyCheckBox.Location = new System.Drawing.Point(19, 250); + this.goodOnlyCheckBox.Name = "goodOnlyCheckBox"; + this.goodOnlyCheckBox.Size = new System.Drawing.Size(74, 17); + this.goodOnlyCheckBox.TabIndex = 52; + this.goodOnlyCheckBox.Text = "Good only"; + this.goodOnlyCheckBox.UseVisualStyleBackColor = true; + // + // PrinterCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.goodOnlyCheckBox); + this.Controls.Add(this.tests2AreRowsCheckBox); + this.Controls.Add(this.testItems2Button); + this.Controls.Add(this.testsAreRowsCheckBox); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.bodyItalicCheckBox); + this.Controls.Add(this.bodyBoldCheckBox); + this.Controls.Add(this.headerItalicCheckBox); + this.Controls.Add(this.headerBoldCheckBox); + this.Controls.Add(this.titleItalicCheckBox); + this.Controls.Add(this.titleBoldCheckBox); + this.Controls.Add(this.bodyFontSizeTextBox); + this.Controls.Add(this.headerFontSizeTextBox); + this.Controls.Add(this.titleFontSizeTextBox); + this.Controls.Add(this.bodyFontFamilyComboBox); + this.Controls.Add(this.bodyFontLabel); + this.Controls.Add(this.headerFontFamilyComboBox); + this.Controls.Add(this.titleFontFamilyComboBox); + this.Controls.Add(this.cultureComboBox); + this.Controls.Add(this.cultureLabel); + this.Controls.Add(this.commonItemsButton); + this.Controls.Add(this.footerButton); + this.Controls.Add(this.headerButton); + this.Controls.Add(this.testItemsButton); + this.Controls.Add(this.bottomMarginTextBox); + this.Controls.Add(this.titleFontLabel); + this.Controls.Add(this.leftMarginTextBox); + this.Controls.Add(this.headerFontLabel); + this.Controls.Add(this.topMarginTextBox); + this.Controls.Add(this.topMarginLabel); + this.Controls.Add(this.orientationComboBox); + this.Controls.Add(this.orientationLabel); + 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(400, 350); + 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; + private System.Windows.Forms.Label orientationLabel; + private System.Windows.Forms.ComboBox orientationComboBox; + private System.Windows.Forms.TextBox topMarginTextBox; + private System.Windows.Forms.Label topMarginLabel; + private System.Windows.Forms.TextBox leftMarginTextBox; + private System.Windows.Forms.TextBox bottomMarginTextBox; + private System.Windows.Forms.ComboBox cultureComboBox; + private System.Windows.Forms.Label cultureLabel; + private System.Windows.Forms.Button commonItemsButton; + private System.Windows.Forms.Button footerButton; + private System.Windows.Forms.Button headerButton; + private System.Windows.Forms.Button testItemsButton; + private System.Windows.Forms.Label headerFontLabel; + private System.Windows.Forms.Label titleFontLabel; + private System.Windows.Forms.ComboBox titleFontFamilyComboBox; + private System.Windows.Forms.ComboBox headerFontFamilyComboBox; + private System.Windows.Forms.ComboBox bodyFontFamilyComboBox; + private System.Windows.Forms.Label bodyFontLabel; + private System.Windows.Forms.TextBox titleFontSizeTextBox; + private System.Windows.Forms.TextBox headerFontSizeTextBox; + private System.Windows.Forms.TextBox bodyFontSizeTextBox; + private System.Windows.Forms.CheckBox titleBoldCheckBox; + private System.Windows.Forms.CheckBox titleItalicCheckBox; + private System.Windows.Forms.CheckBox headerItalicCheckBox; + private System.Windows.Forms.CheckBox headerBoldCheckBox; + private System.Windows.Forms.CheckBox bodyItalicCheckBox; + private System.Windows.Forms.CheckBox bodyBoldCheckBox; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.CheckBox testsAreRowsCheckBox; + private System.Windows.Forms.CheckBox tests2AreRowsCheckBox; + private System.Windows.Forms.Button testItems2Button; + private System.Windows.Forms.CheckBox goodOnlyCheckBox; + } +} diff --git a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/PrinterCfgCtrl.cs b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs similarity index 85% rename from TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/PrinterCfgCtrl.cs rename to TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs index 84e0c2917..65e1c00e4 100644 --- a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/PrinterCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs @@ -9,7 +9,7 @@ using Config.Entities; using TBF.BenchControl.Generic; using TBF.Resources; -namespace TBF.BenchControl.Output.Printers.OnePagePerMeter +namespace TBF.BenchControl.Output.Printers.OnePerMeter { public partial class PrinterCfgCtrl : UserControl, IComponentCfgCtrl { @@ -31,7 +31,8 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter string header; string[] commonItems; string[] testItems; - string footer; + string[] testItems2; + string footer; public PrinterCfgCtrl() { @@ -56,7 +57,8 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter header = config.Header; commonItems = config.CommonItems; testItems = config.SelectedItems; - footer = config.Footer; + testItems2 = config.SelectedItems2; + footer = config.Footer; Redraw(); } @@ -108,7 +110,11 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter bodyItalicCheckBox.Checked = ((config.BodyFntSty & (int)System.Drawing.FontStyle.Italic) != 0); supressPrintingCheckBox.Checked = config.SupressPrinting; - cultureComboBox.Text = config.Culture.ToString(); + goodOnlyCheckBox.Checked = config.GoodOnly; + testsAreRowsCheckBox.Checked = config.TestsAreRows; + tests2AreRowsCheckBox.Checked = config.TestsAreRows2; + + cultureComboBox.Text = config.Culture.ToString(); } public void Unlock() @@ -131,12 +137,16 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter bodyBoldCheckBox.Enabled = true; bodyItalicCheckBox.Enabled = true; supressPrintingCheckBox.Enabled = true; - cultureComboBox.Enabled = true; + goodOnlyCheckBox.Enabled = true; + cultureComboBox.Enabled = true; headerButton.Enabled = true; commonItemsButton.Enabled = true; testItemsButton.Enabled = true; - footerButton.Enabled = true; - } + testItems2Button.Enabled = true; + footerButton.Enabled = true; + testsAreRowsCheckBox.Enabled = true; + tests2AreRowsCheckBox.Enabled = true; + } public CfgUpdateFlags VerifyCfg(ref string message) { @@ -311,6 +321,12 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); } + if (config.SelectedItems2 != testItems2) + { + config.SelectedItems2 = testItems2; + flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + } + if (config.Header != header) { config.Header = header; @@ -333,6 +349,24 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter } } + if (config.GoodOnly != goodOnlyCheckBox.Checked) + { + config.GoodOnly = goodOnlyCheckBox.Checked; + flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + } + + if (config.TestsAreRows != testsAreRowsCheckBox.Checked) + { + config.TestsAreRows = testsAreRowsCheckBox.Checked; + flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + } + + if (config.TestsAreRows2 != tests2AreRowsCheckBox.Checked) + { + config.TestsAreRows2 = tests2AreRowsCheckBox.Checked; + flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + } + if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0) { Printer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config)); @@ -378,6 +412,20 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter } } + private void testItems2Button_Click(object sender, EventArgs e) + { + Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg(true) + { + MetersKind = config.MetersKind, + SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(testItems2), + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + testItems2 = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems); + } + } + private void footerButton_Click(object sender, EventArgs e) { HeaderFooterDlg dlg = new HeaderFooterDlg(false, string.IsNullOrEmpty(footer) ? string.Empty : footer.Replace("~", Environment.NewLine)); diff --git a/TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/PrinterCfgCtrl.resx b/TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.resx similarity index 100% rename from TestBenchFramework/BenchControl/Output/Printers/OnePagePerMeter/PrinterCfgCtrl.resx rename to TestBenchFramework/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.resx diff --git a/TestBenchFramework/BenchControl/Output/Printers/Zapiska/Printer.cs b/TestBenchFramework/BenchControl/Output/Printers/Zapiska/Printer.cs index 1c61fab40..55c2aa483 100644 --- a/TestBenchFramework/BenchControl/Output/Printers/Zapiska/Printer.cs +++ b/TestBenchFramework/BenchControl/Output/Printers/Zapiska/Printer.cs @@ -19,6 +19,9 @@ namespace TBF.BenchControl.Output.Printers.Zapiska public bool SupressPrinting { get { return printerCfg.SupressPrinting; } } + /// Data to print + Results.Entities.Batch batch; + /// /// Items to print /// @@ -28,14 +31,8 @@ namespace TBF.BenchControl.Output.Printers.Zapiska string footer; - Thread thread; /// Thread where results are printed - bool completed; /// Set to 'true' by the thread when printing results is completed - bool abort; /// Set to 'true' by Stop() operation to abort printing results - - public Printer() { } - public Printer(Generic.IComponentCfg cfg) : base(cfg) { @@ -125,54 +122,40 @@ namespace TBF.BenchControl.Output.Printers.Zapiska /// Reference to the operation public IOperation PrintResultsOp(Results.Entities.Batch batch) { - thread = new Thread(() => - { - PrintResults(batch); - completed = true; - }); - - thread.CurrentCulture = Thread.CurrentThread.CurrentCulture; - thread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture; - - if (printerCfg.Culture > Culture.system && printerCfg.Culture < Culture.Count) - { - thread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString()); - } - - return this; + this.batch = batch; + return this; } /// Start this operation public void Start() { - completed = false; - abort = false; - thread.Start(); - } + CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture; + + if (printerCfg.Culture != Culture.system) + { + Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString()); + } + + PrintResults(batch); + + Thread.CurrentThread.CurrentCulture = oriCulture; + } /// Run this operation /// Event.ResultsPrinted public Event Run() { - if (completed) - return Event.ResultsPrinted; - else - return Event.Busy; + return Event.ResultsPrinted; } /// Stop this operation public void Stop() { - if (!completed) abort = true; } void PrintResults(Results.Entities.Batch batch) { - CultureInfo culture = Thread.CurrentThread.CurrentCulture; - try { culture = new System.Globalization.CultureInfo(printerCfg.Culture.ToString()); } - catch { } - if (batch.WaterMeters.Count > 0) { ZapiskaPrinterCfg cfg = new ZapiskaPrinterCfg { @@ -191,8 +174,8 @@ namespace TBF.BenchControl.Output.Printers.Zapiska BodyFntSty = printerCfg.BodyFntSty, SupressPrinting = printerCfg.SupressPrinting, GoodOnly = printerCfg.GoodOnly, - CultureInfo = culture, - Header = printerCfg.Header, + CultureInfo = (printerCfg.Culture == Culture.system) ? Thread.CurrentThread.CurrentCulture : new CultureInfo(printerCfg.Culture.ToString()), + Header = printerCfg.Header, ColW0Pct = printerCfg.ColW0Pct, ColW1Pct = printerCfg.ColW1Pct, ColW2Pct = printerCfg.ColW2Pct, diff --git a/TestBenchFramework/BenchControl/TbfComponents.cs b/TestBenchFramework/BenchControl/TbfComponents.cs index e7ce5b63e..ebfc23352 100644 --- a/TestBenchFramework/BenchControl/TbfComponents.cs +++ b/TestBenchFramework/BenchControl/TbfComponents.cs @@ -102,9 +102,9 @@ namespace TBF.BenchControl Factories.Add(new Output.Printers.Enhanced.FactorySingle()); Factories.Add(new Output.Printers.Enhanced.FactoryCompound()); Factories.Add(new Output.Printers.Enhanced.FactoryHeatMeters()); - Factories.Add(new Output.Printers.OnePagePerMeter.FactorySingle()); - Factories.Add(new Output.Printers.OnePagePerMeter.FactoryCompound()); - Factories.Add(new Output.Printers.OnePagePerMeter.FactoryHeatMeters()); + Factories.Add(new Output.Printers.OnePerMeter.FactorySingle()); + Factories.Add(new Output.Printers.OnePerMeter.FactoryCompound()); + Factories.Add(new Output.Printers.OnePerMeter.FactoryHeatMeters()); Factories.Add(new Output.Printers.Zapiska.FactorySingle()); Factories.Add(new Output.Printers.Zapiska.FactoryCompound()); Factories.Add(new Output.Printers.Zapiska.FactoryHeatMeters()); diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 5226e2e71..c5048b4c3 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.17.734.1")] -[assembly: AssemblyFileVersion("2.17.734.1")] +[assembly: AssemblyVersion("2.17.735.1")] +[assembly: AssemblyFileVersion("2.17.735.1")] diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 0d14a6fca..3b907a763 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -773,15 +773,15 @@ PrinterCfgCtrl.cs - - - - - - + + + + + + UserControl - + PrinterCfgCtrl.cs @@ -2199,7 +2199,7 @@ PrinterCfgCtrl.cs - + PrinterCfgCtrl.cs