From 0adec1cb511e2687253e8ce9835f40037fa7b314 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Thu, 15 Mar 2018 16:08:19 +0100 Subject: [PATCH] Output.Printers.OnePerMeter : Table class added, common items use Table class for printing, ver. 2.18.844 --- .../OnePerMeter/OnePerMeterPrintDocument.cs | 222 ++++++------------ .../OnePerMeter/OnePerMeterPrinterCfg.cs | 1 - Results/Output/Printers/PrintersCommon.cs | 150 +----------- Results/Output/Printers/Table.cs | 202 ++++++++++++++++ Results/Properties/AssemblyInfo.cs | 4 +- Results/Results.csproj | 1 + .../Output/Printers/OnePerMeter/Printer.cs | 2 - .../Output/Printers/OnePerMeter/PrinterCfg.cs | 1 - .../OnePerMeter/PrinterCfgCtrl.Designer.cs | 14 -- .../Printers/OnePerMeter/PrinterCfgCtrl.cs | 3 - TBF/Properties/AssemblyInfo.cs | 4 +- 11 files changed, 282 insertions(+), 322 deletions(-) create mode 100644 Results/Output/Printers/Table.cs diff --git a/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs b/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs index a3cf29929..c63853f79 100644 --- a/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs +++ b/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017 Sensus Metering Systems +/// Copyright (c) 2017-2018 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -161,131 +161,70 @@ namespace Results.Output.Printers.OnePerMeter catch (Exception) { } /// Cope with situations when file is missing or is not correct } - titleHeight = System.Windows.Forms.TextRenderer.MeasureText(header, titleFont).Height; - commonTop = TitleY + titleHeight + spacingOne4Header; - - commonHeight = commonItems.Count * spacingOne; - bodyTop = commonTop + commonHeight + spacingOne4Header; - /// /// Title /// RectangleF printArea = new RectangleF(TitleX, TitleY, printWidth, titleHeight); e.Graphics.DrawString(header, titleFont, Brushes.Black, printArea); + + titleHeight = System.Windows.Forms.TextRenderer.MeasureText(header, titleFont).Height; + commonTop = TitleY + titleHeight + spacingOne4Header; + /// /// Common items /// - string[] leftColumn = new string[commonItems.Count]; - string[] rightColumn = new string[commonItems.Count]; - - int cnt = 0; + Table table = new Table(2); + table.Style = new TableStyle { Font = font, MarginX = 5, MarginY = 3 }; + Alignment[] horizAlgn = new Alignment[] { Alignment.Left, Alignment.Left }; + VertAlignment[] vertAlgn = new VertAlignment[] { VertAlignment.Top, VertAlignment.Top }; + /// foreach (var v in commonItems) { - leftColumn[cnt] = v.Caption; - rightColumn[cnt] = (batch.WaterMeters.Count > 0) ? v.Print(batch.WaterMeters[0]) : string.Empty; - cnt++; + string[] row = new string[] { v.Caption, (batch.WaterMeters.Count > 0) ? v.Print(batch.WaterMeters[0]) : string.Empty }; + table.AddRow(row, horizAlgn, vertAlgn); } - - /// 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, leftColumn[i], font, leftMargin, commonTop + spacingOne * i, maxWidth, 0, Alignment.Left, VertAlignment.Top); - PrintAt(e, rightColumn[i], font, leftMargin + maxWidth + GapBetweenCommonColumns, commonTop + spacingOne * i, 0, 0, Alignment.Left, VertAlignment.Top); - } - } - /// - /// Body - /// - IList tableRows; - IList horizAlignment; - IList vertAlignment; - if (pageNr == 1) + bodyTop = table.Draw(e, (float)leftMargin, commonTop) + spacingOne4Header; + } + + /// + /// Draw table + /// + if (cfg.TestsAreRows) { - /// - /// Prepare table content: tableHeader + tableRows + itemAlignment - /// - if (cfg.TestsAreRows) + TableStyle style = new TableStyle { - GetContentTestsAreRows(wm, testItems, out tableRows, out horizAlignment, out vertAlignment); - DrawTable(e, (float)leftMargin, bodyTop, tableRows, horizAlignment, vertAlignment, - new TableStyle - { - Font = font, - HeaderFont = headerFont, - MarginX = 5, - MarginY = 3, - LineWidth = 1, - TopHeadersCount = 1, - HorizLines = TableLines.All, - VertLines = TableLines.All - }); - } - else - { - GetContentTestsAreColumns(wm, testItems, out tableRows, out horizAlignment, out vertAlignment); - DrawTable(e, (float)leftMargin, bodyTop, tableRows, horizAlignment, vertAlignment, - new TableStyle - { - Font = font, - HeaderFont = headerFont, - MarginX = 5, - MarginY = 3, - LineWidth = 1, - LeftHeadersCount = 1, - HorizLines = TableLines.All, - VertLines = TableLines.All - }); - } + Font = font, + HeaderFont = headerFont, + MarginX = 5, + MarginY = 3, + LineWidth = 1, + TopHeadersCount = 1, + HorizLines = TableLines.All, + VertLines = TableLines.FirstSecondAndLast + }; + + GetTable_TestsAreRows(wm, (pageNr == 1) ? testItems : testItems2, style).Draw(e, (float)leftMargin, bodyTop); } else { - /// - /// Prepare table content: tableHeader + tableRows + itemAlignment - /// - if (cfg.TestsAreRows2) + TableStyle style = new TableStyle { - GetContentTestsAreRows(wm, testItems2, out tableRows, out horizAlignment, out vertAlignment); - DrawTable(e, (float)leftMargin, bodyTop, tableRows, horizAlignment, vertAlignment, - new TableStyle - { - Font = font, - HeaderFont = headerFont, - MarginX = 5, - MarginY = 3, - LineWidth = 1, - TopHeadersCount = 1, - HorizLines = TableLines.All, - VertLines = TableLines.All - }); - } - else - { - GetContentTestsAreColumns(wm, testItems2, out tableRows, out horizAlignment, out vertAlignment); - DrawTable(e, (float)leftMargin, bodyTop, tableRows, horizAlignment, vertAlignment, - new TableStyle - { - Font = font, - HeaderFont = headerFont, - MarginX = 5, - MarginY = 3, - LineWidth = 1, - LeftHeadersCount = 1, - HorizLines = TableLines.All, - VertLines = TableLines.All - }); - } + Font = font, + HeaderFont = headerFont, + MarginX = 5, + MarginY = 3, + LineWidth = 1, + LeftHeadersCount = 1, + HorizLines = TableLines.FirstSecondAndLast, + VertLines = TableLines.All + }; + + GetTable_TestsAreColumns(wm, (pageNr == 1) ? testItems : testItems2, style).Draw(e, (float)leftMargin, bodyTop); } + if (pageNr == nrPages) { /// @@ -308,41 +247,34 @@ namespace Results.Output.Printers.OnePerMeter } - void GetContentTestsAreRows(Results.Entities.WaterMeter wm, IList items, - out IList tableRows, out IList horizAlignments, out IList vertAlignments) + Table GetTable_TestsAreRows(Results.Entities.WaterMeter wm, IList items, TableStyle style) { /// Top row contains column captions - int tableColumnsCount = items.Count; + Table table = new Table(items.Count); + table.Style = style; - tableRows = new List(); - horizAlignments = new List(); - vertAlignments = new List(); - - - string[] tableHeader = new string[tableColumnsCount]; - Alignment[] horizAlignment = new Alignment[tableColumnsCount]; - VertAlignment[] vertAlignment = new VertAlignment[tableColumnsCount]; - for (int i = 0; i < tableColumnsCount; i++) + string[] tableHeader = new string[table.ColumnsCount]; + Alignment[] horizAlignment = new Alignment[table.ColumnsCount]; + VertAlignment[] vertAlignment = new VertAlignment[table.ColumnsCount]; + for (int i = 0; i < table.ColumnsCount; i++) { tableHeader[i] = items[i].Caption; horizAlignment[i] = Alignment.Center; vertAlignment[i] = VertAlignment.Middle; } - tableRows.Add(tableHeader); - horizAlignments.Add(horizAlignment); - vertAlignments.Add(vertAlignment); + table.AddRow(tableHeader, horizAlignment, vertAlignment); WMeterRsltItemSpec.TableRowNr = 1; foreach (var mtr in wm.MeterTestRslts) { if (mtr != null && mtr.IsPilotRslt() && mtr.Publish() == Config.Entities.Publish.Always) { - string[] oneTableRow = new string[tableColumnsCount]; - horizAlignment = new Alignment[tableColumnsCount]; - vertAlignment = new VertAlignment[tableColumnsCount]; + string[] oneTableRow = new string[table.ColumnsCount]; + horizAlignment = new Alignment[table.ColumnsCount]; + vertAlignment = new VertAlignment[table.ColumnsCount]; - for (int i = 0; i < tableColumnsCount; i++) + for (int i = 0; i < table.ColumnsCount; i++) { WMeterRsltItemSpec.TableColumnNr = i + 1; oneTableRow[i] = items[i].Print(wm, mtr.Name()).Split(new char[] { '|' })[0]; @@ -350,48 +282,34 @@ namespace Results.Output.Printers.OnePerMeter vertAlignment[i] = VertAlignment.Middle; } - tableRows.Add(oneTableRow); - horizAlignments.Add(horizAlignment); - vertAlignments.Add(vertAlignment); + table.AddRow(oneTableRow, horizAlignment, vertAlignment); WMeterRsltItemSpec.TableRowNr++; } } + + return table; } - void GetContentTestsAreColumns(Results.Entities.WaterMeter wm, IList items, - out IList tableRows, out IList horizAlignments, out IList vertAlignments) + Table GetTable_TestsAreColumns(Results.Entities.WaterMeter wm, IList items, TableStyle style) { /// Left column contains row captions /// /// Calculate columns count /// - int tableColumnsCount = 1; /// Left column contains item caption + int columnsCount = 1; /// Left column contains item caption foreach (var mtr in wm.MeterTestRslts) { if (mtr != null && mtr.IsPilotRslt() && mtr.Publish() == Config.Entities.Publish.Always) { - tableColumnsCount++; /// One additional column for each test to be published + columnsCount++; /// One additional column for each test to be published } } - /// - /// Alignment of columns - /// - tableRows = new List(); - horizAlignments = new List(); - vertAlignments = new List(); - - int columnsCount = 1; - foreach (var mtr in wm.MeterTestRslts) - { - if (mtr != null && mtr.IsPilotRslt() && mtr.Publish() == Config.Entities.Publish.Always) - { - columnsCount++; - } - } + Table table = new Table(columnsCount); + table.Style = style; /// /// Table content @@ -399,9 +317,9 @@ namespace Results.Output.Printers.OnePerMeter WMeterRsltItemSpec.TableRowNr = 1; for (int i = 0; i < items.Count; i++) { - string[] oneTableRow = new string[tableColumnsCount]; - Alignment[] horizAlignment = new Alignment[tableColumnsCount]; - VertAlignment[] vertAlignment = new VertAlignment[tableColumnsCount]; + string[] oneTableRow = new string[columnsCount]; + Alignment[] horizAlignment = new Alignment[columnsCount]; + VertAlignment[] vertAlignment = new VertAlignment[columnsCount]; oneTableRow[0] = items[i].Caption; horizAlignment[0] = Alignment.Center; @@ -422,12 +340,12 @@ namespace Results.Output.Printers.OnePerMeter } } - tableRows.Add(oneTableRow); - horizAlignments.Add(horizAlignment); - vertAlignments.Add(vertAlignment); + table.AddRow(oneTableRow, horizAlignment, vertAlignment); WMeterRsltItemSpec.TableRowNr++; } + + return table; } } } diff --git a/Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs b/Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs index a4485c5ad..fdf0c9bc3 100644 --- a/Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs +++ b/Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs @@ -32,7 +32,6 @@ namespace Results.Output.Printers.OnePerMeter public string[] TestItems2; public string Footer; public bool TestsAreRows; - public bool TestsAreRows2; public string ImgFullPathName; public int ImgLeft; public int ImgTop; diff --git a/Results/Output/Printers/PrintersCommon.cs b/Results/Output/Printers/PrintersCommon.cs index 949cb01ad..79f8c3142 100644 --- a/Results/Output/Printers/PrintersCommon.cs +++ b/Results/Output/Printers/PrintersCommon.cs @@ -6,149 +6,8 @@ using Config.Entities; namespace Results.Output.Printers { - public enum TableLines - { - None, - FirstAndLast, - FirstSecondAndLast, - All, - } - - public class TableStyle - { - public float MarginX; - public float MarginY; - public Font Font; - public Font HeaderFont; - public int TopHeadersCount; - public int LeftHeadersCount; - public float LineWidth; - public TableLines HorizLines; - public TableLines VertLines; - } - public class PrintersCommon : PrintDocument { - protected SizeF MeasureTable(System.Drawing.Printing.PrintPageEventArgs e, IList rows, TableStyle tableStyle) - { - SizeF retVal = new SizeF(0, 0); - - if (rows == null || rows.Count == 0) return retVal; - - int tblColumnsCount = rows[0].Length; - - float[] columnWidth = new float[tblColumnsCount]; - float[] rowHeight = new float[rows.Count]; - - /// - /// Measure table column widths and header height - /// - for (int colIx = 0; colIx < tblColumnsCount; colIx++) - { - for (int rowIx = 0; rowIx < rows.Count; rowIx++) - { - bool isHeader = (colIx < tableStyle.LeftHeadersCount) || (rowIx < tableStyle.TopHeadersCount); - SizeF size = Measure(e, rows[rowIx][colIx], isHeader ? tableStyle.HeaderFont : tableStyle.Font); - if (size.Width > columnWidth[colIx]) columnWidth[colIx] = size.Width; - if (size.Height > rowHeight[rowIx]) rowHeight[rowIx] = size.Height; - } - retVal.Width += columnWidth[colIx] + 2 * tableStyle.MarginX; - } - for (int rowIx = 0; rowIx < rows.Count; rowIx++) - { - retVal.Height += rowHeight[rowIx] + 2 * tableStyle.MarginY; - } - - return retVal; - } - - - protected float DrawTable(System.Drawing.Printing.PrintPageEventArgs e, float left, float top, IList rows, - IList horizAlignments, IList vertAlignments, TableStyle tableStyle) - { - if (rows == null || rows.Count == 0) return top; - - int tblColumnsCount = rows[0].Length; - float[] columnWidth = new float[tblColumnsCount]; - float[] columnPos = new float[tblColumnsCount + 1]; - float[] rowHeight = new float[rows.Count]; - float[] rowPos = new float[rows.Count + 1]; - - /// - /// Measure table column widths and header height - /// - columnPos[0] = left; - rowPos[0] = top; - for (int colIx = 0; colIx < tblColumnsCount; colIx++) - { - for (int rowIx = 0; rowIx < rows.Count; rowIx++) - { - bool isHeader = (colIx < tableStyle.LeftHeadersCount) || (rowIx < tableStyle.TopHeadersCount); - SizeF size = Measure(e, rows[rowIx][colIx], isHeader ? tableStyle.HeaderFont : tableStyle.Font); - if (size.Width > columnWidth[colIx]) columnWidth[colIx] = size.Width; - if (size.Height > rowHeight[rowIx]) rowHeight[rowIx] = size.Height; - } - columnPos[colIx + 1] = columnPos[colIx] + columnWidth[colIx] + 2 * tableStyle.MarginX + tableStyle.LineWidth; - } - for (int rowIx = 0; rowIx < rows.Count; rowIx++) - { - rowPos[rowIx + 1] = rowPos[rowIx] + rowHeight[rowIx] + 2 * tableStyle.MarginY + tableStyle.LineWidth; - } - - /// Horizontal lines - float tableLeftX = left; - float tableRightX = columnPos[tblColumnsCount] + tableStyle.LineWidth; - if (tableStyle.HorizLines != TableLines.None) - { - for (int rowIx = 0; rowIx <= rows.Count; rowIx++) - { - if (tableStyle.HorizLines == TableLines.All || rowIx == 0 || rowIx == rows.Count || (tableStyle.HorizLines == TableLines.FirstSecondAndLast && rowIx == 1)) - { - e.Graphics.DrawLine(new Pen(Color.Black, tableStyle.LineWidth), new PointF(tableLeftX, rowPos[rowIx] + tableStyle.LineWidth / 2), new PointF(tableRightX, rowPos[rowIx] + tableStyle.LineWidth / 2)); - } - } - } - - /// Vertical lines - float tableTopY = top; - float tableBottomY = rowPos[rows.Count] + tableStyle.LineWidth; - if (tableStyle.VertLines != TableLines.None) - { - for (int colIx = 0; colIx <= tblColumnsCount; colIx++) - { - if (tableStyle.VertLines == TableLines.All || colIx == 0 || colIx == rows.Count || (tableStyle.VertLines == TableLines.FirstSecondAndLast && colIx == 1)) - { - e.Graphics.DrawLine(new Pen(Color.Black, tableStyle.LineWidth), new PointF(columnPos[colIx] + tableStyle.LineWidth / 2, tableTopY), new PointF(columnPos[colIx] + tableStyle.LineWidth / 2, tableBottomY)); - } - } - } - - /// - /// Draw table body - /// - for (int rowIndex = 0; rowIndex < rows.Count; rowIndex++) - { - string[] oneTableRow = rows[rowIndex]; - Alignment[] horizAlignment = horizAlignments[(horizAlignments.Count > rowIndex) ? rowIndex : 0]; - VertAlignment[] vertAlignment = vertAlignments[(vertAlignments.Count > rowIndex) ? rowIndex : 0]; - for (int colIndex = 0; colIndex < tblColumnsCount; colIndex++) - { - bool isHeader = (colIndex < tableStyle.LeftHeadersCount) || (rowIndex < tableStyle.TopHeadersCount); - PrintAt(e, oneTableRow[colIndex], - isHeader ? tableStyle.HeaderFont : tableStyle.Font, - columnPos[colIndex] + tableStyle.MarginX + tableStyle.LineWidth, - rowPos[rowIndex] + tableStyle.MarginY, - columnWidth[colIndex], - rowHeight[rowIndex], - horizAlignment[colIndex], - vertAlignment[colIndex]); - } - } - - return tableBottomY; - } - - static Font lastFont = null; static float lastSpacing = 0; @@ -159,7 +18,7 @@ namespace Results.Output.Printers /// Text, lines are separated by '~' /// Font /// Size of the paragraph of text - protected SizeF Measure(System.Drawing.Printing.PrintPageEventArgs e, string text, Font font) + public static SizeF Measure(System.Drawing.Printing.PrintPageEventArgs e, string text, Font font) { if (font != lastFont) { @@ -190,10 +49,11 @@ namespace Results.Output.Printers /// Height, 0 = no vertical centering /// Horizontal alignment /// Vertical alignment - protected void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, string text, Font font, - float x, float y, float width, float height, Alignment horizAlignment, VertAlignment vertAlignment) + public static void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, string text, Font font, + float x, float y, float width, float height, + Alignment horizAlignment, VertAlignment vertAlignment) { - SizeF size = Measure(e, text, font); + SizeF size = PrintersCommon.Measure(e, text, font); string[] lines = text.Split(new char[] { '~' }); diff --git a/Results/Output/Printers/Table.cs b/Results/Output/Printers/Table.cs new file mode 100644 index 000000000..d9a730a90 --- /dev/null +++ b/Results/Output/Printers/Table.cs @@ -0,0 +1,202 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Printing; +using Config.Entities; + +namespace Results.Output.Printers +{ + public enum TableLines + { + None, + FirstAndLast, + FirstSecondAndLast, + All, + } + + public class TableStyle + { + public float MarginX; + public float MarginY; + public Font Font; + public Font HeaderFont; + public int TopHeadersCount; + public int LeftHeadersCount; + public float LineWidth; + public TableLines HorizLines; + public TableLines VertLines; + } + + public class Table + { + public readonly int ColumnsCount; + public int RowsCount { get { return Rows.Count; } } + + public readonly IList Rows; + public readonly IList HorizAlignments; + public readonly IList VertAlignments; + public TableStyle Style; + + + public Table(int columnsCount) + { + ColumnsCount = columnsCount; + + Rows = new List(); + HorizAlignments = new List(); + VertAlignments = new List(); + Style = new TableStyle(); + } + + + public void AddRow(string[] texts, Alignment[] horizAlignment, VertAlignment[] vertAlignemnt) + { + Rows.Add(texts); + HorizAlignments.Add(horizAlignment); + VertAlignments.Add(vertAlignemnt); + } + + + public SizeF Measure(System.Drawing.Printing.PrintPageEventArgs e) + { + SizeF retVal = new SizeF(0, 0); + if (RowsCount == 0) return retVal; + + float[] columnWidth = new float[ColumnsCount]; + float[] rowHeight = new float[RowsCount]; + + /// + /// Measure table column widths and header height + /// + for (int colIx = 0; colIx < ColumnsCount; colIx++) + { + for (int rowIx = 0; rowIx < RowsCount; rowIx++) + { + bool isHeader = (colIx < Style.LeftHeadersCount) || (rowIx < Style.TopHeadersCount); + SizeF size = PrintersCommon.Measure(e, Rows[rowIx][colIx], isHeader ? Style.HeaderFont : Style.Font); + if (size.Width > columnWidth[colIx]) columnWidth[colIx] = size.Width; + if (size.Height > rowHeight[rowIx]) rowHeight[rowIx] = size.Height; + } + + bool hasLineToTheLeft = (Style.VertLines == TableLines.All) + || ((Style.VertLines == TableLines.FirstAndLast) && (colIx == 0)) + || ((Style.VertLines == TableLines.FirstSecondAndLast) && (colIx <= 1)); + + retVal.Width += columnWidth[colIx] + (hasLineToTheLeft ? (Style.LineWidth + Style.MarginX) : 0) + Style.MarginX; + } + for (int rowIx = 0; rowIx < RowsCount; rowIx++) + { + bool hasLineAbove = (Style.HorizLines == TableLines.All) + || ((Style.HorizLines == TableLines.FirstAndLast) && (rowIx == 0)) + || ((Style.HorizLines == TableLines.FirstSecondAndLast) && (rowIx <= 1)); + + retVal.Height += rowHeight[rowIx] + (hasLineAbove ? (Style.LineWidth + Style.MarginY) : 0) + Style.MarginY; + } + + if (Style.VertLines == TableLines.None) retVal.Width -= Style.MarginX; + if (Style.HorizLines == TableLines.None) retVal.Height -= Style.MarginY; + + return retVal; + } + + + public float Draw(System.Drawing.Printing.PrintPageEventArgs e, float left, float top) + { + if (RowsCount == 0) return top; + + int tblColumnsCount = Rows[0].Length; + + float[] columnWidth = new float[tblColumnsCount]; + float[] columnPos = new float[tblColumnsCount]; + float[] vertLinePos = new float[tblColumnsCount + 1]; + + float[] rowHeight = new float[RowsCount]; + float[] rowPos = new float[RowsCount]; + float[] horizLinePos = new float[RowsCount + 1]; + + /// + /// Measure table column widths and header height + /// + vertLinePos[0] = left; + horizLinePos[0] = top; + for (int colIx = 0; colIx < tblColumnsCount; colIx++) + { + for (int rowIx = 0; rowIx < RowsCount; rowIx++) + { + bool isHeader = (colIx < Style.LeftHeadersCount) || (rowIx < Style.TopHeadersCount); + SizeF size = PrintersCommon.Measure(e, Rows[rowIx][colIx], isHeader ? Style.HeaderFont : Style.Font); + if (size.Width > columnWidth[colIx]) columnWidth[colIx] = size.Width; + if (size.Height > rowHeight[rowIx]) rowHeight[rowIx] = size.Height; + } + + bool hasLineToTheLeft = (Style.VertLines == TableLines.All) + || ((Style.VertLines == TableLines.FirstAndLast) && (colIx == 0)) + || ((Style.VertLines == TableLines.FirstSecondAndLast) && (colIx <= 1)); + + columnPos[colIx] = vertLinePos[colIx] + (hasLineToTheLeft ? (Style.LineWidth + Style.MarginX) : 0); + vertLinePos[colIx + 1] = columnPos[colIx] + columnWidth[colIx] + Style.MarginX; + } + for (int rowIx = 0; rowIx < RowsCount; rowIx++) + { + bool hasLineAbove = (Style.HorizLines == TableLines.All) + || ((Style.HorizLines == TableLines.FirstAndLast) && (rowIx == 0)) + || ((Style.HorizLines == TableLines.FirstSecondAndLast) && (rowIx <= 1)); + + rowPos[rowIx] = horizLinePos[rowIx] + (hasLineAbove ? Style.MarginY : 0); + horizLinePos[rowIx + 1] = rowPos[rowIx] + rowHeight[rowIx] + Style.LineWidth + Style.MarginY; + } + + /// Horizontal lines + float tableLeftX = left; + float tableRightX = vertLinePos[tblColumnsCount] + Style.LineWidth; + if (Style.HorizLines != TableLines.None) + { + for (int rowIx = 0; rowIx <= RowsCount; rowIx++) + { + if (Style.HorizLines == TableLines.All || rowIx == 0 || rowIx == RowsCount || (Style.HorizLines == TableLines.FirstSecondAndLast && rowIx == 1)) + { + e.Graphics.DrawLine(new Pen(Color.Black, Style.LineWidth), new PointF(tableLeftX, horizLinePos[rowIx] + Style.LineWidth / 2), new PointF(tableRightX, horizLinePos[rowIx] + Style.LineWidth / 2)); + } + } + } + + /// Vertical lines + float tableTopY = top; + float tableBottomY = horizLinePos[RowsCount] + Style.LineWidth; + if (Style.VertLines != TableLines.None) + { + for (int colIx = 0; colIx <= tblColumnsCount; colIx++) + { + if (Style.VertLines == TableLines.All || colIx == 0 || colIx == RowsCount || (Style.VertLines == TableLines.FirstSecondAndLast && colIx == 1)) + { + e.Graphics.DrawLine(new Pen(Color.Black, Style.LineWidth), new PointF(vertLinePos[colIx] + Style.LineWidth / 2, tableTopY), new PointF(vertLinePos[colIx] + Style.LineWidth / 2, tableBottomY)); + } + } + } + + /// + /// Draw table body + /// + for (int rowIndex = 0; rowIndex < RowsCount; rowIndex++) + { + string[] oneTableRow = Rows[rowIndex]; + Alignment[] horizAlignment = HorizAlignments[(RowsCount > rowIndex) ? rowIndex : 0]; + VertAlignment[] vertAlignment = VertAlignments[(RowsCount > rowIndex) ? rowIndex : 0]; + for (int colIndex = 0; colIndex < tblColumnsCount; colIndex++) + { + bool isHeader = (colIndex < Style.LeftHeadersCount) || (rowIndex < Style.TopHeadersCount); + PrintersCommon.PrintAt(e, oneTableRow[colIndex], + isHeader ? Style.HeaderFont : Style.Font, + columnPos[colIndex], + rowPos[rowIndex], + columnWidth[colIndex], + rowHeight[rowIndex], + horizAlignment[colIndex], + vertAlignment[colIndex]); + } + } + + return tableBottomY; + } + } +} diff --git a/Results/Properties/AssemblyInfo.cs b/Results/Properties/AssemblyInfo.cs index 46dadaf37..b54da8918 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.18.825.0")] -[assembly: AssemblyFileVersion("2.18.825.0")] +[assembly: AssemblyVersion("2.18.844.0")] +[assembly: AssemblyFileVersion("2.18.844.0")] diff --git a/Results/Results.csproj b/Results/Results.csproj index c32d7bef0..864c24b16 100644 --- a/Results/Results.csproj +++ b/Results/Results.csproj @@ -114,6 +114,7 @@ Component + Component diff --git a/TBF/BenchControl/Output/Printers/OnePerMeter/Printer.cs b/TBF/BenchControl/Output/Printers/OnePerMeter/Printer.cs index 8f6a25a10..6fa672088 100644 --- a/TBF/BenchControl/Output/Printers/OnePerMeter/Printer.cs +++ b/TBF/BenchControl/Output/Printers/OnePerMeter/Printer.cs @@ -99,7 +99,6 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter printerCfg.SelectedItems2 = newCfg.SelectedItems2; printerCfg.Footer = newCfg.Footer; printerCfg.TestsAreRows = newCfg.TestsAreRows; - printerCfg.TestsAreRows2 = newCfg.TestsAreRows2; printerCfg.DocName = newCfg.DocName; printerCfg.ImgName = newCfg.ImgName; printerCfg.ImgLeft = newCfg.ImgLeft; @@ -203,7 +202,6 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter TestItems2 = printerCfg.SelectedItems2, Footer = printerCfg.Footer, TestsAreRows = printerCfg.TestsAreRows, - TestsAreRows2 = printerCfg.TestsAreRows2, ImgFullPathName = (wm.ArchivePath != null) ? System.IO.Path.Combine(wm.ArchivePath, printerCfg.ImgName) : null, ImgLeft = printerCfg.ImgLeft, ImgTop = printerCfg.ImgTop, diff --git a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs index f591f2778..58201933d 100644 --- a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs +++ b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs @@ -43,7 +43,6 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter public string[] SelectedItems2; public string Footer; public bool TestsAreRows; /// true = Tests are rows - public bool TestsAreRows2; /// true = Tests are rows public string DocName; public string ImgName; public int ImgLeft; diff --git a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs index db7f80490..053b16b11 100644 --- a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs +++ b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs @@ -65,7 +65,6 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter 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.templateTextBox = new System.Windows.Forms.TextBox(); @@ -409,17 +408,6 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter 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(192, 281); - this.tests2AreRowsCheckBox.Name = "tests2AreRowsCheckBox"; - this.tests2AreRowsCheckBox.Size = new System.Drawing.Size(104, 17); - this.tests2AreRowsCheckBox.TabIndex = 36; - this.tests2AreRowsCheckBox.Text = "Tests are rows 2"; - this.tests2AreRowsCheckBox.UseVisualStyleBackColor = true; - // // testItems2Button // this.testItems2Button.Enabled = false; @@ -641,7 +629,6 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter this.Controls.Add(this.templateTextBox); this.Controls.Add(this.templateLabel); 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); @@ -721,7 +708,6 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter 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; private System.Windows.Forms.TextBox templateTextBox; diff --git a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs index 02be40f8c..c4ccb3f23 100644 --- a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs +++ b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs @@ -122,7 +122,6 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter supressPrintingCheckBox.Checked = config.SupressPrinting; goodOnlyCheckBox.Checked = config.GoodOnly; testsAreRowsCheckBox.Checked = config.TestsAreRows; - tests2AreRowsCheckBox.Checked = config.TestsAreRows2; cultureComboBox.Text = config.Culture.ToString(); @@ -167,7 +166,6 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter testItems2Button.Enabled = true; footerButton.Enabled = true; testsAreRowsCheckBox.Enabled = true; - tests2AreRowsCheckBox.Enabled = true; docNameTextBox.Enabled = true; imageNameTextBox.Enabled = true; imageLeftTextBox.Enabled = true; @@ -319,7 +317,6 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter flags |= UpdateDifferent(ref config.SupressPrinting, supressPrintingCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.GoodOnly, goodOnlyCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.TestsAreRows, testsAreRowsCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); - flags |= UpdateDifferent(ref config.TestsAreRows2, tests2AreRowsCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.CommonItems, commonItems, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.SelectedItems, testItems, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 7fba4107b..7bf6fd9ba 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.18.843.0")] -[assembly: AssemblyFileVersion("2.18.843.0")] +[assembly: AssemblyVersion("2.18.844.0")] +[assembly: AssemblyFileVersion("2.18.844.0")]