Table rewritten, Cell, TopBorder, LeftBorder, BottomMerge, RightMerge added, merging OK, clean-up, ver. 3.8.2108
This commit is contained in:
@@ -13,9 +13,6 @@ namespace Results.Output.Printers.OnePerBatch
|
||||
{
|
||||
public class OnePerBatchPrintDocument : Common.Printers.PrintersCommon
|
||||
{
|
||||
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;
|
||||
@@ -28,39 +25,39 @@ namespace Results.Output.Printers.OnePerBatch
|
||||
|
||||
readonly int spacingOne;
|
||||
readonly int spacingOne4Header;
|
||||
|
||||
float titleHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Property variable for the Font the user wishes to use
|
||||
/// </summary>
|
||||
Font titleFont;
|
||||
Font headerFont;
|
||||
Font font;
|
||||
Font footerFont;
|
||||
|
||||
///
|
||||
/// Data to print
|
||||
///
|
||||
Results.Entities.Batch batch;
|
||||
OnePerBatchPrinterCfg cfg;
|
||||
Results.Entities.WaterMeter wm;
|
||||
readonly Font titleFont;
|
||||
readonly Font headerFont;
|
||||
readonly Font font;
|
||||
readonly Font footerFont;
|
||||
|
||||
///
|
||||
/// Items to print
|
||||
///
|
||||
string header;
|
||||
IList<WMeterRsltItemSpec> commonItems1;
|
||||
IList<WMeterRsltItemSpec> commonItems2;
|
||||
IList<WMeterRsltItemSpec> commonItems3;
|
||||
IList<WMeterRsltItemSpec> testItems;
|
||||
IList<WMeterRsltItemSpec> testItems2;
|
||||
IList<WMeterRsltItemSpec> belowItems1;
|
||||
IList<WMeterRsltItemSpec> belowItems2;
|
||||
IList<WMeterRsltItemSpec> belowItems3;
|
||||
string footer;
|
||||
readonly string header;
|
||||
readonly IList<WMeterRsltItemSpec> commonItems1;
|
||||
readonly IList<WMeterRsltItemSpec> commonItems2;
|
||||
readonly IList<WMeterRsltItemSpec> commonItems3;
|
||||
readonly IList<WMeterRsltItemSpec> testItems;
|
||||
readonly IList<WMeterRsltItemSpec> testItems2;
|
||||
readonly IList<WMeterRsltItemSpec> belowItems1;
|
||||
readonly IList<WMeterRsltItemSpec> belowItems2;
|
||||
readonly IList<WMeterRsltItemSpec> belowItems3;
|
||||
readonly string footer;
|
||||
|
||||
int nrPages;
|
||||
///
|
||||
/// Data to print
|
||||
///
|
||||
Results.Entities.Batch batch;
|
||||
OnePerBatchPrinterCfg cfg;
|
||||
Results.Entities.WaterMeter wm;
|
||||
|
||||
float titleHeight;
|
||||
|
||||
int nrPages;
|
||||
int pageNr; /// Page number to be printed at the bottom of the page
|
||||
|
||||
/// <summary>
|
||||
@@ -79,21 +76,21 @@ namespace Results.Output.Printers.OnePerBatch
|
||||
leftMargin = cfg.LeftMargin;
|
||||
|
||||
header = string.IsNullOrEmpty(cfg.Header) ? string.Empty : cfg.Header.Replace("~", Environment.NewLine);
|
||||
commonItems1 = Results.WMeterRsltItemSpec.FromStrArray(cfg.CommonItems1);
|
||||
commonItems2 = Results.WMeterRsltItemSpec.FromStrArray(cfg.CommonItems2);
|
||||
commonItems3 = Results.WMeterRsltItemSpec.FromStrArray(cfg.CommonItems3);
|
||||
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
|
||||
belowItems1 = Results.WMeterRsltItemSpec.FromStrArray(cfg.BelowItems1);
|
||||
belowItems2 = Results.WMeterRsltItemSpec.FromStrArray(cfg.BelowItems2);
|
||||
belowItems3 = Results.WMeterRsltItemSpec.FromStrArray(cfg.BelowItems3);
|
||||
commonItems1 = WMeterRsltItemSpec.FromStrArray(cfg.CommonItems1);
|
||||
commonItems2 = WMeterRsltItemSpec.FromStrArray(cfg.CommonItems2);
|
||||
commonItems3 = WMeterRsltItemSpec.FromStrArray(cfg.CommonItems3);
|
||||
testItems = WMeterRsltItemSpec.FromStrArray(cfg.TestItems); /// TestID info will be overwritten later on
|
||||
testItems2 = WMeterRsltItemSpec.FromStrArray(cfg.TestItems2); /// TestID info will be overwritten later on
|
||||
belowItems1 = WMeterRsltItemSpec.FromStrArray(cfg.BelowItems1);
|
||||
belowItems2 = WMeterRsltItemSpec.FromStrArray(cfg.BelowItems2);
|
||||
belowItems3 = WMeterRsltItemSpec.FromStrArray(cfg.BelowItems3);
|
||||
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);
|
||||
footerFont = new Font((cfg.FooterFntFml != null ? cfg.FooterFntFml : "Arial"), (cfg.FooterFntSz > 0 ? cfg.FooterFntSz : 10), (FontStyle)cfg.FooterFntSty);
|
||||
titleFont = new Font(cfg.TitFntFml ?? "Arial", cfg.TitFntSz > 0 ? cfg.TitFntSz : 10, (FontStyle)cfg.TitFntSty);
|
||||
headerFont = new Font(cfg.HdrFntFml ?? "Arial", cfg.HdrFntSz > 0 ? cfg.HdrFntSz : 10, (FontStyle)cfg.HdrFntSty);
|
||||
font = new Font(cfg.BodyFntFml ?? "Arial", cfg.BodyFntSz > 0 ? cfg.BodyFntSz : 10, (FontStyle)cfg.BodyFntSty);
|
||||
footerFont = new Font(cfg.FooterFntFml ?? "Arial", cfg.FooterFntSz > 0 ? cfg.FooterFntSz : 10, (FontStyle)cfg.FooterFntSty);
|
||||
|
||||
/// Set print area size and margins (in dots using 100 dpi)
|
||||
DefaultPageSettings.Landscape = (cfg.PageOrientation == PageOrientation.Landscape);
|
||||
@@ -125,7 +122,7 @@ namespace Results.Output.Printers.OnePerBatch
|
||||
/// </summary>
|
||||
/// <param name=e></param>
|
||||
/// <remarks></remarks>
|
||||
protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e)
|
||||
protected override void OnBeginPrint(PrintEventArgs e)
|
||||
{
|
||||
base.OnBeginPrint(e);
|
||||
}
|
||||
@@ -135,7 +132,7 @@ namespace Results.Output.Printers.OnePerBatch
|
||||
/// </summary>
|
||||
/// <param name=e></param>
|
||||
/// <remarks>This provides the print logic for our document</remarks>
|
||||
protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
|
||||
protected override void OnPrintPage(PrintPageEventArgs e)
|
||||
{
|
||||
/// Run base code
|
||||
base.OnPrintPage(e);
|
||||
@@ -194,35 +191,33 @@ namespace Results.Output.Printers.OnePerBatch
|
||||
float leftMarginCommon2 = leftMargin + printWidth * 0.01f * (cfg.ColW0Pct + cfg.ColW1Pct);
|
||||
float leftMarginCommon3 = leftMargin + printWidth * 0.01f * (cfg.ColW0Pct + cfg.ColW1Pct + cfg.ColW2Pct);
|
||||
|
||||
Alignment[] horizAlgn = new Alignment[] { Alignment.Left, Alignment.Left };
|
||||
VertAlignment[] vertAlgn = new VertAlignment[] { VertAlignment.Top, VertAlignment.Top };
|
||||
TableStyle commonTableStyle = new TableStyle { Font = font, MarginX = 5, MarginY = 3 };
|
||||
|
||||
Table table1 = new Table(2, cfg.AutoTestParam) { Style = commonTableStyle };
|
||||
var table1 = new Table(2, commonTableStyle, cfg.AutoTestParam);
|
||||
foreach (var item in commonItems1)
|
||||
{
|
||||
string[] row = new string[] { item.Caption, item.Print(wm).Split(new char[] { '|' })[0] };
|
||||
table1.AddRow(row, horizAlgn, vertAlgn);
|
||||
table1.AddRow(new Cell[] { new Cell(item.Caption, font),
|
||||
new Cell(item.Print(wm).Split(new char[] { '|' })[0], font) });
|
||||
}
|
||||
float bodyTop1 = table1.Draw(e, leftMarginCommon1, commonTop);
|
||||
|
||||
|
||||
table1 = new Table(2, cfg.AutoTestParam) { Style = commonTableStyle };
|
||||
var table2 = new Table(2, commonTableStyle, cfg.AutoTestParam);
|
||||
foreach (var item in commonItems2)
|
||||
{
|
||||
string[] row = new string[] { item.Caption, item.Print(wm).Split(new char[] { '|' })[0] };
|
||||
table1.AddRow(row, horizAlgn, vertAlgn);
|
||||
table2.AddRow(new Cell[] { new Cell(item.Caption, font),
|
||||
new Cell(item.Print(wm).Split(new char[] { '|' })[0], font) });
|
||||
}
|
||||
float bodyTop2 = table1.Draw(e, leftMarginCommon2, commonTop);
|
||||
float bodyTop2 = table2.Draw(e, leftMarginCommon2, commonTop);
|
||||
|
||||
|
||||
table1 = new Table(2, cfg.AutoTestParam) { Style = commonTableStyle };
|
||||
var table3 = new Table(2, commonTableStyle, cfg.AutoTestParam);
|
||||
foreach (var item in commonItems3)
|
||||
{
|
||||
string[] row = new string[] { item.Caption, item.Print(wm).Split(new char[] { '|' })[0] };
|
||||
table1.AddRow(row, horizAlgn, vertAlgn);
|
||||
table3.AddRow(new Cell[] { new Cell(item.Caption, font),
|
||||
new Cell(item.Print(wm).Split(new char[] { '|' })[0], font) });
|
||||
}
|
||||
float bodyTop3 = table1.Draw(e, leftMarginCommon3, commonTop);
|
||||
float bodyTop3 = table3.Draw(e, leftMarginCommon3, commonTop);
|
||||
|
||||
float bodyTop12 = (bodyTop1 > bodyTop2) ? bodyTop1 : bodyTop2;
|
||||
tableTop = (bodyTop12 > bodyTop3) ? bodyTop12 : bodyTop3; /// Max. of all three bodyTop-s
|
||||
@@ -302,35 +297,33 @@ namespace Results.Output.Printers.OnePerBatch
|
||||
float leftMarginBelow2 = leftMargin + printWidth * 0.01f * (cfg.BelowW0Pct + cfg.BelowW1Pct);
|
||||
float leftMarginBelow3 = leftMargin + printWidth * 0.01f * (cfg.BelowW0Pct + cfg.BelowW1Pct + cfg.BelowW2Pct);
|
||||
|
||||
Alignment[] horizAlgn = new Alignment[] { Alignment.Left, Alignment.Left };
|
||||
VertAlignment[] vertAlgn = new VertAlignment[] { VertAlignment.Top, VertAlignment.Top };
|
||||
TableStyle commonTableStyle = new TableStyle { Font = font, MarginX = 5, MarginY = 3 };
|
||||
|
||||
Table table2 = new Table(2, cfg.AutoTestParam) { Style = commonTableStyle };
|
||||
var table4 = new Table(2, commonTableStyle, cfg.AutoTestParam);
|
||||
foreach (var item in belowItems1)
|
||||
{
|
||||
string[] row = new string[] { item.Caption, item.Print(wm).Split(new char[] { '|' })[0] };
|
||||
table2.AddRow(row, horizAlgn, vertAlgn);
|
||||
table4.AddRow(new Cell[] { new Cell(item.Caption, font),
|
||||
new Cell(item.Print(wm).Split(new char[] { '|' })[0], font) });
|
||||
}
|
||||
table2.Draw(e, leftMarginBelow1, belowTop);
|
||||
table4.Draw(e, leftMarginBelow1, belowTop);
|
||||
|
||||
|
||||
table2 = new Table(2, cfg.AutoTestParam) { Style = commonTableStyle };
|
||||
var table5 = new Table(2, commonTableStyle, cfg.AutoTestParam);
|
||||
foreach (var item in belowItems2)
|
||||
{
|
||||
string[] row = new string[] { item.Caption, item.Print(wm).Split(new char[] { '|' })[0] };
|
||||
table2.AddRow(row, horizAlgn, vertAlgn);
|
||||
table5.AddRow(new Cell[] { new Cell(item.Caption, font),
|
||||
new Cell(item.Print(wm).Split(new char[] { '|' })[0], font) });
|
||||
}
|
||||
table2.Draw(e, leftMarginBelow2, belowTop);
|
||||
table5.Draw(e, leftMarginBelow2, belowTop);
|
||||
|
||||
|
||||
table2 = new Table(2, cfg.AutoTestParam) { Style = commonTableStyle };
|
||||
var table6 = new Table(2, commonTableStyle, cfg.AutoTestParam);
|
||||
foreach (var item in belowItems3)
|
||||
{
|
||||
string[] row = new string[] { item.Caption, item.Print(wm).Split(new char[] { '|' })[0] };
|
||||
table2.AddRow(row, horizAlgn, vertAlgn);
|
||||
table6.AddRow(new Cell[] { new Cell(item.Caption, font),
|
||||
new Cell(item.Print(wm).Split(new char[] { '|' })[0], font) });
|
||||
}
|
||||
table2.Draw(e, leftMarginBelow3, belowTop);
|
||||
table6.Draw(e, leftMarginBelow3, belowTop);
|
||||
|
||||
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user