2014-07-28 07:54:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using System.Drawing.Printing;
|
2015-01-28 06:24:03 +00:00
|
|
|
|
using System.IO;
|
2015-01-27 01:37:24 +00:00
|
|
|
|
using TBF.Resources;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.ResultsPrinters.Basic
|
|
|
|
|
|
{
|
|
|
|
|
|
public class BasicPrintDocument : PrintDocument
|
|
|
|
|
|
{
|
2015-01-27 01:37:24 +00:00
|
|
|
|
const string FontFamilyName = "Arial"; //"Times New Roman";
|
|
|
|
|
|
|
|
|
|
|
|
const int SpacingOne = 18;
|
|
|
|
|
|
const int SpacingOneAndHalf = (3 * SpacingOne) / 2;
|
|
|
|
|
|
const int TitleX = 100;
|
|
|
|
|
|
const int TitleY = 180; /// Depends on the size of the header
|
|
|
|
|
|
const int HdrTop = 240; /// Depends on the size of the header
|
2015-01-27 22:02:34 +00:00
|
|
|
|
const int BodyTop = 400;
|
2015-01-27 01:37:24 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Property variable for the Font the user wishes to use
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Font font;
|
2015-01-27 01:37:24 +00:00
|
|
|
|
Font boldFont;
|
2015-01-27 22:02:34 +00:00
|
|
|
|
Font titleFont;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2015-01-13 07:46:32 +00:00
|
|
|
|
///
|
2014-07-28 07:54:35 +00:00
|
|
|
|
/// Data to print
|
2015-01-13 07:46:32 +00:00
|
|
|
|
///
|
2015-01-27 01:37:24 +00:00
|
|
|
|
readonly BenchControl.BenchId.Component benchId;
|
2015-02-01 12:43:04 +00:00
|
|
|
|
readonly Entities.Procedure procedure;
|
|
|
|
|
|
readonly IList<Entities.TestResult> unsortedResults;
|
2015-01-27 01:37:24 +00:00
|
|
|
|
readonly bool combined;
|
|
|
|
|
|
readonly DateTime dateTime;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2015-01-13 07:46:32 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Items to print
|
|
|
|
|
|
///
|
2015-01-27 01:37:24 +00:00
|
|
|
|
readonly IList<TBF.Forms.ResultItemSpec> resultItems;
|
2015-01-13 07:46:32 +00:00
|
|
|
|
|
2015-02-01 12:43:04 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Constructor
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="textToPrint">Text to be printed</param>
|
|
|
|
|
|
public BasicPrintDocument(BenchControl.BenchId.Component benchId,
|
2015-02-01 12:43:04 +00:00
|
|
|
|
Entities.Procedure procedure,
|
|
|
|
|
|
IList<Entities.TestResult> unsortedResults)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
this.benchId = benchId;
|
2015-02-01 12:43:04 +00:00
|
|
|
|
this.procedure = procedure;
|
|
|
|
|
|
this.unsortedResults = unsortedResults;
|
|
|
|
|
|
|
2015-01-27 01:37:24 +00:00
|
|
|
|
dateTime = DateTime.Now;
|
|
|
|
|
|
|
2015-02-01 12:43:04 +00:00
|
|
|
|
if ((unsortedResults != null) && (unsortedResults.Count != 0) && (unsortedResults[0].MetersKind == Entities.MetersKind.Single))
|
2015-01-27 01:37:24 +00:00
|
|
|
|
{
|
|
|
|
|
|
resultItems = Forms.ResultItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_SingleWM);
|
|
|
|
|
|
combined = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
resultItems = Forms.ResultItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_CombinedWM);
|
|
|
|
|
|
combined = true;
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Override the default onbeginPrint method of the PrintDocument Object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name=e></param>
|
|
|
|
|
|
/// <remarks></remarks>
|
|
|
|
|
|
protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnBeginPrint(e);
|
2015-01-27 01:37:24 +00:00
|
|
|
|
|
|
|
|
|
|
if (font == null) { font = new Font(FontFamilyName, 10, FontStyle.Regular); }
|
|
|
|
|
|
if (boldFont == null) { boldFont = new Font(FontFamilyName, 10, FontStyle.Bold); }
|
2015-01-27 22:02:34 +00:00
|
|
|
|
if (titleFont == null) { titleFont = new Font(FontFamilyName, 18, FontStyle.Bold); }
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Override the default OnPrintPage method of the PrintDocument.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name=e></param>
|
|
|
|
|
|
/// <remarks>This provides the print logic for our document</remarks>
|
|
|
|
|
|
protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
|
|
|
|
|
|
{
|
2015-01-27 01:37:24 +00:00
|
|
|
|
/// Run base code
|
2014-07-28 07:54:35 +00:00
|
|
|
|
base.OnPrintPage(e);
|
|
|
|
|
|
|
2015-01-28 06:24:03 +00:00
|
|
|
|
if (File.Exists("C:\\TBF\\header.png"))
|
|
|
|
|
|
{
|
|
|
|
|
|
Image img = Image.FromFile("C:\\TBF\\header.png");
|
2015-02-02 14:04:48 +00:00
|
|
|
|
e.Graphics.DrawImage(new Bitmap(img), new Rectangle(0, 0, 827, 1169));
|
2015-01-28 06:24:03 +00:00
|
|
|
|
}
|
2015-01-27 01:37:24 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
/// Set print area size and margins (in dots using 80 dpi)
|
|
|
|
|
|
int printHeight = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom;
|
|
|
|
|
|
int printWidth = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right;
|
|
|
|
|
|
int leftMargin = base.DefaultPageSettings.Margins.Left; /// X
|
|
|
|
|
|
int topMargin = base.DefaultPageSettings.Margins.Top; /// Y
|
|
|
|
|
|
|
|
|
|
|
|
/// Check if the user selected to print in Landscape mode
|
|
|
|
|
|
/// if they did then we need to swap height/width parameters
|
|
|
|
|
|
if (base.DefaultPageSettings.Landscape)
|
|
|
|
|
|
{
|
|
|
|
|
|
int tmp = printHeight;
|
|
|
|
|
|
printHeight = printWidth;
|
|
|
|
|
|
printWidth = tmp;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int x = leftMargin;
|
|
|
|
|
|
int y = topMargin;
|
|
|
|
|
|
|
|
|
|
|
|
/// Use the StringFormat class for the text layout of our document
|
|
|
|
|
|
StringFormat format = new StringFormat(StringFormatFlags.LineLimit);
|
|
|
|
|
|
|
2015-01-27 01:37:24 +00:00
|
|
|
|
///----------
|
|
|
|
|
|
/// Header
|
|
|
|
|
|
///----------
|
|
|
|
|
|
RectangleF printArea = new RectangleF(TitleX, TitleY, 667, 40);
|
2015-02-01 12:43:04 +00:00
|
|
|
|
e.Graphics.DrawString(unsortedResults[0].ProtocolTitle, titleFont, Brushes.Black, printArea);
|
2015-01-27 01:37:24 +00:00
|
|
|
|
|
|
|
|
|
|
string[] leftColumn = new string[]
|
|
|
|
|
|
{
|
|
|
|
|
|
"Cycle number: ",
|
|
|
|
|
|
"Date and time: ",
|
|
|
|
|
|
"Procedure:",
|
|
|
|
|
|
Strings.User_,
|
|
|
|
|
|
"Ambient temperature: ",
|
|
|
|
|
|
"Ambient pressure: ",
|
|
|
|
|
|
"Ambient humidity: ",
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
string[] rightColumn = new string[]
|
|
|
|
|
|
{
|
2015-02-02 17:09:05 +00:00
|
|
|
|
unsortedResults[0].BatchNr.ToString(),
|
2015-01-27 01:37:24 +00:00
|
|
|
|
//dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString(),
|
|
|
|
|
|
string.Format("{0}.{1}.{2} {3}:{4}", dateTime.Year.ToString("D4"),
|
|
|
|
|
|
dateTime.Month.ToString("D2"),
|
|
|
|
|
|
dateTime.Day.ToString("D2"),
|
|
|
|
|
|
dateTime.Hour.ToString("D2"),
|
|
|
|
|
|
dateTime.Minute.ToString("D2")),
|
2015-02-01 12:43:04 +00:00
|
|
|
|
procedure.Name,
|
2015-01-27 01:37:24 +00:00
|
|
|
|
Entities.User.CurrentUser.Name,
|
2015-02-01 12:43:04 +00:00
|
|
|
|
unsortedResults[0].AmbientTempAve.ToString("F1") + " °C",
|
|
|
|
|
|
unsortedResults[0].AmbientPressAve.ToString("F0") + " mbar",
|
|
|
|
|
|
unsortedResults[0].AmbientHumiAve.ToString("F0") + " %",
|
2015-01-27 01:37:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// 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++)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2015-01-27 01:37:24 +00:00
|
|
|
|
PrintAt(e, 100, HdrTop + SpacingOne* i, leftColumn[i]);
|
|
|
|
|
|
PrintAt(e, 300, HdrTop + SpacingOne * i, rightColumn[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///--------
|
|
|
|
|
|
/// Body
|
|
|
|
|
|
///--------
|
|
|
|
|
|
int nrWMs = (combined ? Program.WMsCount / 2 : Program.WMsCount);
|
2015-02-01 12:43:04 +00:00
|
|
|
|
int nextWmTop = BodyTop;
|
2015-01-27 01:37:24 +00:00
|
|
|
|
if (combined)
|
|
|
|
|
|
{
|
2015-02-02 09:35:06 +00:00
|
|
|
|
for (int wmNr = 1; wmNr <= Program.WMsCount / 2; wmNr++)
|
2015-02-01 12:43:04 +00:00
|
|
|
|
{
|
2015-02-02 09:35:06 +00:00
|
|
|
|
nextWmTop += PrintCombinedWM(e, wmNr, nextWmTop); /// wmNr is 1-based
|
2015-02-01 12:43:04 +00:00
|
|
|
|
}
|
2015-01-27 01:37:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2015-02-02 09:35:06 +00:00
|
|
|
|
for (int wmNr = 1; wmNr <= Program.WMsCount; wmNr++)
|
2015-02-01 12:43:04 +00:00
|
|
|
|
{
|
2015-02-02 09:35:06 +00:00
|
|
|
|
nextWmTop += PrintSingleWM(e, wmNr, nextWmTop); /// wmNr is 1-based
|
2015-02-01 12:43:04 +00:00
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
e.HasMorePages = false;
|
|
|
|
|
|
}
|
2015-01-27 01:37:24 +00:00
|
|
|
|
|
2015-02-01 12:43:04 +00:00
|
|
|
|
|
2015-01-27 01:37:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Print one water meter results
|
|
|
|
|
|
/// </summary>
|
2015-02-02 09:35:06 +00:00
|
|
|
|
/// <param name="wmNr1">Water meter number (1-based)</param>
|
2015-01-27 01:37:24 +00:00
|
|
|
|
/// <param name="top">Top coordinate of watermeter data</param>
|
2015-02-01 12:43:04 +00:00
|
|
|
|
/// <returns>The height of the printed section</returns>
|
2015-02-02 09:35:06 +00:00
|
|
|
|
int PrintSingleWM(System.Drawing.Printing.PrintPageEventArgs e, int wmNr1, int top)
|
2015-01-27 01:37:24 +00:00
|
|
|
|
{
|
2015-02-02 09:35:06 +00:00
|
|
|
|
IList<Entities.TestResult> results = Utils.GetSortedTestResults(procedure, unsortedResults, wmNr1);
|
2015-02-01 12:43:04 +00:00
|
|
|
|
|
2015-01-27 01:37:24 +00:00
|
|
|
|
/// Determin column widths
|
2015-01-27 22:02:34 +00:00
|
|
|
|
float[] columnPos = new float[resultItems.Count + 1];
|
|
|
|
|
|
columnPos[0] = 100.0f;
|
|
|
|
|
|
|
2015-01-27 01:37:24 +00:00
|
|
|
|
for (int i = 0; i < resultItems.Count; i++)
|
|
|
|
|
|
{
|
2015-01-27 22:02:34 +00:00
|
|
|
|
float columnWidth = e.Graphics.MeasureString(resultItems[i].ClmnHeaderText, font).Width;
|
2015-01-27 01:37:24 +00:00
|
|
|
|
foreach (var tr in results)
|
|
|
|
|
|
{
|
2015-02-01 12:43:04 +00:00
|
|
|
|
if (tr != null)
|
|
|
|
|
|
{
|
2015-02-02 09:35:06 +00:00
|
|
|
|
float width = e.Graphics.MeasureString(resultItems[i].Print(tr.Meters[wmNr1 - 1]), font).Width;
|
2015-02-01 12:43:04 +00:00
|
|
|
|
if (width > columnWidth) columnWidth = width;
|
|
|
|
|
|
}
|
2015-01-27 01:37:24 +00:00
|
|
|
|
}
|
2015-01-27 22:02:34 +00:00
|
|
|
|
columnPos[i + 1] = columnPos[i] + columnWidth + 20.0f;
|
2015-01-27 01:37:24 +00:00
|
|
|
|
}
|
2015-01-27 22:02:34 +00:00
|
|
|
|
int tableLeftX = (int)columnPos[0];
|
|
|
|
|
|
int tableRightX = (int)columnPos[resultItems.Count] - 20;
|
2015-01-27 01:37:24 +00:00
|
|
|
|
|
2015-02-02 09:35:06 +00:00
|
|
|
|
string wmText = string.Format("Water meter {0}", wmNr1);
|
2015-01-27 22:02:34 +00:00
|
|
|
|
PrintAt(e, 100, top, wmText);
|
2015-02-02 09:35:06 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(unsortedResults[0].Meters[wmNr1 - 1].SerialNr))
|
2015-01-27 22:02:34 +00:00
|
|
|
|
{
|
|
|
|
|
|
PrintAt(e, 100 + (int)e.Graphics.MeasureString(wmText, font).Width, top,
|
2015-02-02 09:35:06 +00:00
|
|
|
|
string.Format(" s/n = {0}", unsortedResults[0].Meters[wmNr1 - 1].SerialNr));
|
2015-01-27 22:02:34 +00:00
|
|
|
|
}
|
2015-01-27 01:37:24 +00:00
|
|
|
|
|
2015-01-27 22:02:34 +00:00
|
|
|
|
/// Horizontal line
|
|
|
|
|
|
int horY = top + 25;
|
|
|
|
|
|
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeftX, horY), new Point(tableRightX, horY));
|
2015-01-27 01:37:24 +00:00
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < resultItems.Count; i++)
|
|
|
|
|
|
{
|
2015-01-27 22:02:34 +00:00
|
|
|
|
PrintAt(e, (int)columnPos[i], top + 27, resultItems[i].ClmnHeaderText);
|
2015-01-27 01:37:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-01-27 22:02:34 +00:00
|
|
|
|
/// Horizontal line
|
|
|
|
|
|
horY = top + 27 + SpacingOne;
|
|
|
|
|
|
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeftX, horY), new Point(tableRightX, horY));
|
2015-01-27 01:37:24 +00:00
|
|
|
|
|
|
|
|
|
|
for (int r = 0; r < results.Count; r++)
|
|
|
|
|
|
{
|
2015-02-01 12:43:04 +00:00
|
|
|
|
if (results[r] != null)
|
2015-01-27 01:37:24 +00:00
|
|
|
|
{
|
2015-02-01 12:43:04 +00:00
|
|
|
|
for (int i = 0; i < resultItems.Count; i++)
|
|
|
|
|
|
{
|
2015-02-02 09:35:06 +00:00
|
|
|
|
string text = resultItems[i].Print(results[r].Meters[wmNr1 - 1]);
|
2015-02-01 12:43:04 +00:00
|
|
|
|
|
|
|
|
|
|
string[] texts = text.Split(new char[] { '|' });
|
|
|
|
|
|
|
|
|
|
|
|
if (texts.Length == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
|
|
|
|
|
|
text = texts[0];
|
|
|
|
|
|
/// TODO: How to print colors?
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PrintAt(e, (int)columnPos[i], top + 30 + SpacingOne * (r + 1), text);
|
|
|
|
|
|
}
|
2015-01-27 01:37:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-01-27 22:02:34 +00:00
|
|
|
|
/// Horizontal line
|
|
|
|
|
|
horY = top + 30 + SpacingOne * (results.Count + 1);
|
|
|
|
|
|
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeftX, horY), new Point(tableRightX, horY));
|
2015-02-01 12:43:04 +00:00
|
|
|
|
|
|
|
|
|
|
return (results.Count + 4) * SpacingOne;
|
2015-01-27 01:37:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-02-01 12:43:04 +00:00
|
|
|
|
|
2015-01-27 01:37:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Print one combined water meter results
|
|
|
|
|
|
/// </summary>
|
2015-02-02 09:35:06 +00:00
|
|
|
|
/// <param name="wmNr1">Water meter number (1-based)</param>
|
2015-01-27 01:37:24 +00:00
|
|
|
|
/// <param name="top">Top coordinate of watermeter data</param>
|
2015-02-01 12:43:04 +00:00
|
|
|
|
/// <returns>The height of the printed section</returns>
|
2015-02-02 09:35:06 +00:00
|
|
|
|
int PrintCombinedWM(System.Drawing.Printing.PrintPageEventArgs e, int wmNr1, int top)
|
2015-01-27 01:37:24 +00:00
|
|
|
|
{
|
2015-02-02 09:35:06 +00:00
|
|
|
|
IList<Entities.TestResult> results = Utils.GetSortedTestResults(procedure, unsortedResults, wmNr1);
|
2015-02-01 12:43:04 +00:00
|
|
|
|
|
2015-01-27 22:02:34 +00:00
|
|
|
|
/// Determin column widths
|
|
|
|
|
|
float[] columnPos = new float[resultItems.Count + 1];
|
|
|
|
|
|
columnPos[0] = 100.0f;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < resultItems.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
float columnWidth = e.Graphics.MeasureString(resultItems[i].ClmnHeaderText, font).Width;
|
|
|
|
|
|
foreach (var tr in results)
|
|
|
|
|
|
{
|
2015-02-01 12:43:04 +00:00
|
|
|
|
if (tr != null)
|
|
|
|
|
|
{
|
2015-02-02 09:35:06 +00:00
|
|
|
|
float width = e.Graphics.MeasureString(resultItems[i].PrintCombined(tr.Meters[2 * wmNr1 - 2],
|
|
|
|
|
|
tr.Meters[2 * wmNr1 - 1],
|
|
|
|
|
|
tr.CombinedMeters[wmNr1 - 1]), font).Width;
|
2015-02-01 12:43:04 +00:00
|
|
|
|
if (width > columnWidth) columnWidth = width;
|
|
|
|
|
|
}
|
2015-01-27 22:02:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
columnPos[i + 1] = columnPos[i] + columnWidth + 20.0f;
|
|
|
|
|
|
}
|
|
|
|
|
|
int tableLeftX = (int)columnPos[0];
|
|
|
|
|
|
int tableRightX = (int)columnPos[resultItems.Count] - 20;
|
|
|
|
|
|
|
2015-02-02 09:35:06 +00:00
|
|
|
|
string wmText = string.Format("Water meter {0}", wmNr1);
|
2015-01-27 22:02:34 +00:00
|
|
|
|
PrintAt(e, 100, top, wmText);
|
2015-02-02 09:35:06 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(unsortedResults[0].Meters[2 * wmNr1 - 2].SerialNr))
|
2015-01-27 22:02:34 +00:00
|
|
|
|
{
|
|
|
|
|
|
PrintAt(e, 100 + (int)e.Graphics.MeasureString(wmText, font).Width, top,
|
2015-02-02 09:35:06 +00:00
|
|
|
|
string.Format(" Main s/n: {0} Aux. s/n:{1}",
|
|
|
|
|
|
unsortedResults[0].Meters[2 * wmNr1 - 2].SerialNr,
|
|
|
|
|
|
unsortedResults[0].Meters[2 * wmNr1 - 1].SerialNr));
|
2015-01-27 22:02:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Horizontal line
|
|
|
|
|
|
int horY = top + 25;
|
|
|
|
|
|
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeftX, horY), new Point(tableRightX, horY));
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < resultItems.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
PrintAt(e, (int)columnPos[i], top + 27, resultItems[i].ClmnHeaderText);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Horizontal line
|
|
|
|
|
|
horY = top + 27 + SpacingOne;
|
|
|
|
|
|
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeftX, horY), new Point(tableRightX, horY));
|
|
|
|
|
|
|
|
|
|
|
|
for (int r = 0; r < results.Count; r++)
|
|
|
|
|
|
{
|
2015-02-01 12:43:04 +00:00
|
|
|
|
if (results[r] != null)
|
2015-01-27 22:02:34 +00:00
|
|
|
|
{
|
2015-02-01 12:43:04 +00:00
|
|
|
|
for (int i = 0; i < resultItems.Count; i++)
|
|
|
|
|
|
{
|
2015-02-02 09:35:06 +00:00
|
|
|
|
string text = resultItems[i].PrintCombined(results[r].Meters[2 * wmNr1 - 2],
|
|
|
|
|
|
results[r].Meters[2 * wmNr1 - 1],
|
|
|
|
|
|
results[r].CombinedMeters[wmNr1 - 1]);
|
2015-02-01 12:43:04 +00:00
|
|
|
|
string[] texts = text.Split(new char[] { '|' });
|
|
|
|
|
|
|
|
|
|
|
|
if (texts.Length == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
|
|
|
|
|
|
text = texts[0];
|
|
|
|
|
|
/// TODO: How to print colors?
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PrintAt(e, (int)columnPos[i], top + 30 + SpacingOne * (r + 1), text);
|
|
|
|
|
|
}
|
2015-01-27 22:02:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Horizontal line
|
|
|
|
|
|
horY = top + 30 + SpacingOne * (results.Count + 1);
|
|
|
|
|
|
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeftX, horY), new Point(tableRightX, horY));
|
2015-02-01 12:43:04 +00:00
|
|
|
|
|
|
|
|
|
|
return (results.Count + 4) * SpacingOne;
|
2015-01-27 01:37:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, 667, SpacingOne);
|
|
|
|
|
|
e.Graphics.DrawString(text, this.font, Brushes.Black, printArea);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrintBoldAt(System.Drawing.Printing.PrintPageEventArgs e, Point p, string text)
|
|
|
|
|
|
{
|
|
|
|
|
|
PrintBoldAt(e, p.X, p.Y, text);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrintBoldAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string text)
|
|
|
|
|
|
{
|
|
|
|
|
|
RectangleF printArea = new RectangleF(x, y, 667, SpacingOne);
|
|
|
|
|
|
e.Graphics.DrawString(text, this.boldFont, Brushes.Black, printArea);
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|