Output.Printers.OnePagePerMeter.Printer implemented, fixes in Culture configuration, ver. 2.17.695
This commit is contained in:
parent
7d4f1b2a44
commit
c9c57db7c1
@ -45,8 +45,8 @@ namespace Results.Output.Printers.OnePagePerMeter
|
||||
/// Data to print
|
||||
///
|
||||
Results.Entities.Batch batch;
|
||||
|
||||
EnhancedPrinterCfg cfg;
|
||||
Results.Entities.WaterMeter wm;
|
||||
|
||||
///
|
||||
/// Items to print
|
||||
@ -56,25 +56,16 @@ namespace Results.Output.Printers.OnePagePerMeter
|
||||
IList<WMeterRsltItemSpec> testItems;
|
||||
string footer;
|
||||
|
||||
///
|
||||
/// Layout and status
|
||||
///
|
||||
int nrWMsOnFirstPage;
|
||||
int nrWMsOnNextPage;
|
||||
int nextWMNr; /// nr. of watermeter to be printed as the first one on the next page
|
||||
int nrPages;
|
||||
int pageNr; /// Page number to be printed at the bottom of the page
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="textToPrint">Text to be printed</param>
|
||||
public EnhancedPrintDocument(Results.Entities.Batch batch, EnhancedPrinterCfg cfg)
|
||||
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;
|
||||
@ -85,9 +76,9 @@ namespace Results.Output.Printers.OnePagePerMeter
|
||||
footer = string.IsNullOrEmpty(cfg.Footer) ? string.Empty : cfg.Footer.Replace("~", Environment.NewLine);
|
||||
|
||||
/// Initialize fonts
|
||||
titleFont = new Font(cfg.TitFntFml, cfg.TitFntSz, (FontStyle)cfg.TitFntSty);
|
||||
headerFont = new Font(cfg.HdrFntFml, cfg.HdrFntSz, (FontStyle)cfg.HdrFntSty);
|
||||
font = new Font(cfg.BodyFntFml, cfg.BodyFntSz, (FontStyle)cfg.BodyFntSty);
|
||||
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);
|
||||
@ -110,12 +101,9 @@ namespace Results.Output.Printers.OnePagePerMeter
|
||||
|
||||
/// Calculate the tests count
|
||||
int testsCount = 0;
|
||||
if (batch.WaterMeters.Count > 0)
|
||||
foreach (var mtr in wm.MeterTestRslts)
|
||||
{
|
||||
foreach (var mtr in batch.WaterMeters[0].MeterTestRslts)
|
||||
{
|
||||
if (mtr.Publish() == Config.Entities.Publish.Always && mtr.IsPilotRslt()) testsCount++;
|
||||
}
|
||||
if (mtr.Publish() == Config.Entities.Publish.Always && mtr.IsPilotRslt()) testsCount++;
|
||||
}
|
||||
|
||||
/// Prepare document outline
|
||||
@ -129,15 +117,6 @@ namespace Results.Output.Printers.OnePagePerMeter
|
||||
BodyTop = CommonTop + commonHeight + SpacingOne4Header;
|
||||
|
||||
int wmSectionHeight = (testsCount + 1) * SpacingOne + 3 * SpacingOne4Header;
|
||||
|
||||
nrWMsOnFirstPage = (printHeight - BodyTop + TitleY - 2 * SpacingOne) / wmSectionHeight;
|
||||
nrWMsOnNextPage = (printHeight - 2 * SpacingOne) / wmSectionHeight;
|
||||
nrWMsOnNextPage = Math.Max(nrWMsOnNextPage, 1); /// Prevent division by zero if there are too many WM tests
|
||||
|
||||
nrPages = 1 + (batch.WaterMeters.Count - nrWMsOnFirstPage + nrWMsOnNextPage - 1) / nrWMsOnNextPage;
|
||||
|
||||
pageNr = 1;
|
||||
nextWMNr = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -169,38 +148,35 @@ namespace Results.Output.Printers.OnePagePerMeter
|
||||
/// 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 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++)
|
||||
{
|
||||
///----------
|
||||
/// 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]);
|
||||
}
|
||||
PrintAt(e, leftMargin, CommonTop + SpacingOne * i, leftColumn[i]);
|
||||
PrintAt(e, 300, CommonTop + SpacingOne * i, rightColumn[i]);
|
||||
}
|
||||
|
||||
///--------
|
||||
@ -209,28 +185,21 @@ namespace Results.Output.Printers.OnePagePerMeter
|
||||
|
||||
/// 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 = (pageNr == 1) ? BodyTop : TitleY;
|
||||
int nextWmTop = BodyTop;
|
||||
int wmPosition = wm.WMPosition;
|
||||
nextWmTop += PrintWM(e, wm, wmPosition, nextWmTop);
|
||||
|
||||
int nrWMsOnPage = (pageNr == 1) ? nrWMsOnFirstPage : nrWMsOnNextPage;
|
||||
|
||||
for (int wmNr = nextWMNr; wmNr < Math.Min(nextWMNr + nrWMsOnPage, batch.WaterMeters.Count); wmNr++) /// wmNr is 0-based
|
||||
{
|
||||
int wmPosition = true ? batch.WaterMeters[wmNr].WMPosition : (wmNr + 1);
|
||||
nextWmTop += PrintWM(e, batch.WaterMeters[wmNr], wmPosition, nextWmTop);
|
||||
}
|
||||
|
||||
nextWMNr += nrWMsOnPage;
|
||||
e.HasMorePages = (nextWMNr < batch.WaterMeters.Count);
|
||||
e.HasMorePages = false;
|
||||
|
||||
///----------
|
||||
/// Footer
|
||||
///----------
|
||||
int footerWidth = (int)e.Graphics.MeasureString(footer, font).Width;
|
||||
PrintAt(e, leftMargin + (printWidth - footerWidth) / 2, topMargin + printHeight - 2 * SpacingOne, footer);
|
||||
PrintAt(e, leftMargin, topMargin + printHeight - 2 * SpacingOne, footer);
|
||||
|
||||
string pageNrText = string.Format("{0} {1}/{2}", Strings.Page, pageNr++, nrPages);
|
||||
int pageNrWidth = (int)e.Graphics.MeasureString(pageNrText, font).Width;
|
||||
PrintAt(e, leftMargin + (printWidth - pageNrWidth) / 2, topMargin + printHeight - SpacingOne, pageNrText);
|
||||
//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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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.693.0")]
|
||||
[assembly: AssemblyFileVersion("2.17.693.0")]
|
||||
[assembly: AssemblyVersion("2.17.695.0")]
|
||||
[assembly: AssemblyFileVersion("2.17.695.0")]
|
||||
|
||||
@ -435,4 +435,7 @@
|
||||
<data name="Yes" xml:space="preserve">
|
||||
<value>Да</value>
|
||||
</data>
|
||||
<data name="Water_Meter" xml:space="preserve">
|
||||
<value>Счетчик воды</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -9,6 +9,9 @@ namespace TBF.BenchControl.Output
|
||||
EN,
|
||||
DE,
|
||||
SK,
|
||||
CS,
|
||||
PL,
|
||||
RU,
|
||||
Count
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,6 +323,16 @@ namespace TBF.BenchControl.Output.Printers.Enhanced
|
||||
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
}
|
||||
|
||||
for (Culture i = 0; i < Culture.Count; i++)
|
||||
{
|
||||
if (i.ToString().Equals(cultureComboBox.Text) && (config.Culture != i))
|
||||
{
|
||||
config.Culture = i;
|
||||
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
|
||||
{
|
||||
Printer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
|
||||
|
||||
@ -5,7 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using Results.Output.Printers.Enhanced;
|
||||
using Results.Output.Printers.OnePagePerMeter;
|
||||
using log4net;
|
||||
|
||||
namespace TBF.BenchControl.Output.Printers.OnePagePerMeter
|
||||
@ -19,6 +19,9 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter
|
||||
|
||||
public bool SupressPrinting { get { return printerCfg.SupressPrinting; } }
|
||||
|
||||
/// <summary> Data to print </summary>
|
||||
Results.Entities.Batch batch;
|
||||
|
||||
///
|
||||
/// Items to print
|
||||
///
|
||||
@ -112,49 +115,33 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter
|
||||
/// <returns>Reference to the operation</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
completed = false;
|
||||
abort = false;
|
||||
thread.Start();
|
||||
}
|
||||
foreach (var wm in batch.WaterMeters)
|
||||
{
|
||||
PrintResults(batch, wm);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>Event.ResultsPrinted</returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (completed)
|
||||
return Event.ResultsPrinted;
|
||||
else
|
||||
return Event.Busy;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
if (!completed) abort = true;
|
||||
}
|
||||
|
||||
|
||||
void PrintResults(Results.Entities.Batch batch)
|
||||
void PrintResults(Results.Entities.Batch batch, Results.Entities.WaterMeter wm)
|
||||
{
|
||||
CultureInfo culture = Thread.CurrentThread.CurrentCulture;
|
||||
try { culture = new System.Globalization.CultureInfo(printerCfg.Culture.ToString()); }
|
||||
@ -184,7 +171,7 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter
|
||||
Footer = printerCfg.Footer,
|
||||
};
|
||||
|
||||
new Results.Output.Printers.Enhanced.EnhancedPrintDocument(batch, cfg).Print();
|
||||
new EnhancedPrintDocument(batch, cfg, wm).Print();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,6 +323,16 @@ namespace TBF.BenchControl.Output.Printers.OnePagePerMeter
|
||||
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
}
|
||||
|
||||
for (Culture i = 0; i < Culture.Count; i++)
|
||||
{
|
||||
if (i.ToString().Equals(cultureComboBox.Text) && (config.Culture != i))
|
||||
{
|
||||
config.Culture = i;
|
||||
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
|
||||
{
|
||||
Printer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
|
||||
|
||||
@ -437,6 +437,16 @@ namespace TBF.BenchControl.Output.Printers.Zapiska
|
||||
|
||||
if (config.Footer != footer) { config.Footer = footer; flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); }
|
||||
|
||||
for (Culture i = 0; i < Culture.Count; i++)
|
||||
{
|
||||
if (i.ToString().Equals(cultureComboBox.Text) && (config.Culture != i))
|
||||
{
|
||||
config.Culture = i;
|
||||
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
|
||||
{
|
||||
Printer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.17.694.1")]
|
||||
[assembly: AssemblyFileVersion("2.17.694.1")]
|
||||
[assembly: AssemblyVersion("2.17.695.1")]
|
||||
[assembly: AssemblyFileVersion("2.17.695.1")]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user