Output.Printers.Label with water meter s/n printed as a QR code.

This commit is contained in:
Milan Hanajik 2020-02-10 15:38:05 +01:00
parent 3d3cac81b9
commit 09ccc282a5
12 changed files with 1677 additions and 499 deletions

View File

@ -4,8 +4,10 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Printing;
using System.IO;
using Gma.QrCodeNet.Encoding;
using Config.Entities;
using Results.Resources;
@ -13,6 +15,8 @@ namespace Results.Output.Printers.Label
{
public class LabelPrintDocument : PrintersCommon
{
static QrEncoder encoder = new QrEncoder();
/// Size of the printed area without margins, after taking into account 'pageOrientation'
readonly int printHeight;
readonly int printWidth;
@ -93,6 +97,44 @@ namespace Results.Output.Printers.Label
e.Graphics.DrawString(item.Print(wm), this.font, Brushes.Black, printArea);
}
}
if (cfg.DrawSNasBarcode)
{
if (cfg.IsQR)
{
QrCode qrCode = encoder.Encode(wm.SerialNr);
DrawQR(e.Graphics, qrCode, cfg.BarcodeLeft, cfg.BarcodeTop, cfg.BarcodeWidth, cfg.BarcodeHeight);
}
else
{
/// TODO
}
}
}
public static void DrawQR(Graphics g, QrCode qrCode, float left, float top, float width, float height)
{
/// Assuming 100 dpi (printer)
g.SmoothingMode = SmoothingMode.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
float qrPixWidth = width / qrCode.Matrix.Width;
float qrPixHeight = height / qrCode.Matrix.Height;
for (int i = 0; i < qrCode.Matrix.Height; i++)
{
for (int j = 0; j < qrCode.Matrix.Width; j++)
{
if (qrCode.Matrix[j, i])
{
g.FillRectangle(Brushes.Black, new RectangleF(left + j * qrPixWidth,
top + i * qrPixHeight,
qrPixWidth,
qrPixHeight));
}
}
}
}
}
}

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
/// Copyright (c) 2018-2020 Sensus Slovensko a.s.
///
namespace Results.Output.Printers.Label
@ -17,5 +17,11 @@ namespace Results.Output.Printers.Label
public System.Globalization.CultureInfo CultureInfo;
public bool GoodOnly;
public bool SupressPrinting; /// true = Bypass printing
public bool DrawSNasBarcode;
public bool IsQR;
public int BarcodeLeft;
public int BarcodeTop;
public int BarcodeWidth;
public int BarcodeHeight;
}
}

View File

@ -38,6 +38,9 @@
<Reference Include="FluentNHibernate">
<HintPath>..\packages\FluentNHibernate.2.0.3.0\lib\net40\FluentNHibernate.dll</HintPath>
</Reference>
<Reference Include="Gma.QrCodeNet.Encoding">
<HintPath>..\packages\QrCode.Net.0.4.0.0\net40\Gma.QrCodeNet.Encoding.dll</HintPath>
</Reference>
<Reference Include="Iesi.Collections">
<HintPath>..\packages\Iesi.Collections.4.0.0.4000\lib\net40\Iesi.Collections.dll</HintPath>
</Reference>

View File

@ -1,193 +0,0 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using Config.Entities;
using TBF.Resources;
namespace TBF.BenchControl.Output.Printers.Label
{
public class PrintLabelDocument : PrintDocument
{
const int FontSize = 9;
const string FontFamilyName = "Arial"; //"Times New Roman";
readonly int paperWidth;
readonly int paperHeight;
readonly string templateFile;
/// <summary> Property variable for the Font the user wishes to use </summary>
Font font;
///
/// Data to print
///
Results.Entities.Batch batch;
///
/// Layout and status
///
int nextWMNr; /// nr. of watermeter to be printed as the first one on the next page
int nrPages;
/// <summary>
/// Constructor
/// </summary>
/// <param name="textToPrint">Text to be printed</param>
public PrintLabelDocument(Results.Entities.Batch batch,
PageOrientation pageOrientation,
int paperWidth,
int paperHeight,
string templateFile)
{
this.batch = batch;
this.paperWidth = paperWidth;
this.paperHeight = paperHeight;
this.templateFile = templateFile;
DefaultPageSettings.Landscape = (pageOrientation == PageOrientation.Landscape);
/// 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 (DefaultPageSettings.Landscape)
{
int tmp = printHeight;
printHeight = printWidth;
printWidth = tmp;
}
/// One watermeter per label/page
nrPages = batch.WaterMeters.Count;
nextWMNr = 0;
}
/// <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);
if (font == null) { font = new Font(FontFamilyName, FontSize, FontStyle.Regular); }
}
/// <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)
{
/// Run base code
base.OnPrintPage(e);
if (File.Exists(templateFile))
{
Image img = Image.FromFile(templateFile);
e.Graphics.DrawImage(new Bitmap(img), new Rectangle(0, 0, paperWidth, paperHeight));
}
/// 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);
///--------
/// Body
///--------
PrintWM(e, nextWMNr);
nextWMNr++;
e.HasMorePages = (nextWMNr < batch.WaterMeters.Count);
}
/// <summary>
/// Print one water meter results
/// </summary>
/// <param name="wmNr">Water meter number (0-based)</param>
void PrintWM(System.Drawing.Printing.PrintPageEventArgs e, int wmNr)
{
if (wmNr >= batch.WaterMeters.Count) return;
Results.Entities.WaterMeter wm = batch.WaterMeters[wmNr];
if (wm == null) return;
/// Serial number
if (!string.IsNullOrEmpty(wm.SerialNr)) PrintAt(e, 20, 62, string.Format("S/N: {0}", wm.SerialNr));
/// Watermeter type
PrintAt(e, 20, 74, batch.ProtocolTitle);
/// Date
PrintAt(e, 135, 74, string.Format("{0:dd/MM/yy", batch.EndTime));
Results.WMeterRsltItemSpec item1 = Results.WMeterRsltItemSpec.GetItem(Results.ItemID.Test_name);
Results.WMeterRsltItemSpec item2 = Results.WMeterRsltItemSpec.GetItem(Results.ItemID.Error);
item2.Units = Config.Unit.Pct;
item2.Precision = "F2";
item2.Format = "{0}%";
int printPosition = 1;
foreach (var mtr in wm.MeterTestRslts)
{
item1.TestID = mtr.Name();
item2.TestID = mtr.Name();
PrintAt(e, 20, 6 + 14 * printPosition, item1.Print(wm));
PrintAt(e, 78, 6 + 14 * printPosition, item2.Print(wm));
printPosition++;
}
}
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, 18);
e.Graphics.DrawString(text, this.font, Brushes.Black, printArea);
}
}
}

View File

@ -76,6 +76,12 @@ namespace TBF.BenchControl.Output.Printers.Label
printerCfg.NrOfCopies = newCfg.NrOfCopies;
printerCfg.GoodOnly = newCfg.GoodOnly;
printerCfg.SupressPrinting = newCfg.SupressPrinting;
printerCfg.DrawSNasBarcode = newCfg.DrawSNasBarcode;
printerCfg.IsQR = newCfg.IsQR;
printerCfg.BarcodeLeft = newCfg.BarcodeLeft;
printerCfg.BarcodeTop = newCfg.BarcodeTop;
printerCfg.BarcodeWidth = newCfg.BarcodeWidth;
printerCfg.BarcodeHeight = newCfg.BarcodeHeight;
ApplyConfig();
}
@ -131,7 +137,6 @@ namespace TBF.BenchControl.Output.Printers.Label
}
void PrintResults(Results.Entities.Batch batch, Results.Entities.WaterMeter wm, string documentName)
{
LabelPrinterCfg cfg = new LabelPrinterCfg
@ -147,6 +152,12 @@ namespace TBF.BenchControl.Output.Printers.Label
CultureInfo = (printerCfg.Culture == Culture.system) ? Thread.CurrentThread.CurrentCulture : new CultureInfo(printerCfg.Culture.ToString()),
GoodOnly = printerCfg.GoodOnly,
SupressPrinting = printerCfg.SupressPrinting,
DrawSNasBarcode = printerCfg.DrawSNasBarcode,
IsQR = printerCfg.IsQR,
BarcodeLeft = printerCfg.BarcodeLeft,
BarcodeTop = printerCfg.BarcodeTop,
BarcodeWidth = printerCfg.BarcodeWidth,
BarcodeHeight = printerCfg.BarcodeHeight,
};
for (int i = 1; i <= printerCfg.NrOfCopies; i++)

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@ -33,6 +33,14 @@ namespace TBF.BenchControl.Output.Printers.Label
public bool GoodOnly;
public bool SupressPrinting; /// true = Bypass printing
public bool DrawSNasBarcode;
public bool IsQR;
public int BarcodeLeft;
public int BarcodeTop;
public int BarcodeWidth;
public int BarcodeHeight;
/// Private parameterless constructor invoked by all other (public) constructors
PrinterCfg()
{
@ -55,18 +63,20 @@ namespace TBF.BenchControl.Output.Printers.Label
NrOfCopies = 1;
GoodOnly = false;
SupressPrinting = false;
DrawSNasBarcode = false;
}
public string ToString(int i)
{
return string.Format("Name={0}, Orientation={1}, PaperWidth={2}, PaperHeight={3}, TemplateFile={4}, GoodOnly={5}, SupressPrinting={6}",
return string.Format("Name={0}, Orientation={1}, PaperWidth={2}, PaperHeight={3}, TemplateFile={4}, GoodOnly={5}, SupressPrinting={6}, Barcode={7}",
Name,
PageOrientation,
PaperWidth,
PaperHeight,
Template,
GoodOnly ? "yes" : "no",
SupressPrinting ? "yes" : "no"
SupressPrinting ? "yes" : "no",
DrawSNasBarcode ? "yes" : "no"
);
}
}

View File

@ -42,7 +42,6 @@ namespace TBF.BenchControl.Output.Printers.Label
this.paperWidthTextBox = new System.Windows.Forms.TextBox();
this.paperWidthLabel = new System.Windows.Forms.Label();
this.paperHeightTextBox = new System.Windows.Forms.TextBox();
this.paperHeightLabel = new System.Windows.Forms.Label();
this.italicCheckBox = new System.Windows.Forms.CheckBox();
this.boldCheckBox = new System.Windows.Forms.CheckBox();
this.fontSizeTextBox = new System.Windows.Forms.TextBox();
@ -56,6 +55,18 @@ namespace TBF.BenchControl.Output.Printers.Label
this.cultureComboBox = new System.Windows.Forms.ComboBox();
this.cultureLabel = new System.Windows.Forms.Label();
this.goodOnlyCheckBox = new System.Windows.Forms.CheckBox();
this.snBarcodeGroupBox = new System.Windows.Forms.GroupBox();
this.barcodeHeightLabel = new System.Windows.Forms.Label();
this.barcodeHeightTextBox = new System.Windows.Forms.TextBox();
this.isQrCheckBox = new System.Windows.Forms.CheckBox();
this.barcodeWidthLabel = new System.Windows.Forms.Label();
this.barcodeWidthTextBox = new System.Windows.Forms.TextBox();
this.barcodeTopLabel = new System.Windows.Forms.Label();
this.barcodeTopTextBox = new System.Windows.Forms.TextBox();
this.barcodeLeftTextBox = new System.Windows.Forms.TextBox();
this.barcodeLeftLabel = new System.Windows.Forms.Label();
this.snBarcodeCheckBox = new System.Windows.Forms.CheckBox();
this.snBarcodeGroupBox.SuspendLayout();
this.SuspendLayout();
//
// nameTextBox
@ -88,7 +99,7 @@ namespace TBF.BenchControl.Output.Printers.Label
//
this.supressPrintingCheckBox.AutoSize = true;
this.supressPrintingCheckBox.Enabled = false;
this.supressPrintingCheckBox.Location = new System.Drawing.Point(122, 283);
this.supressPrintingCheckBox.Location = new System.Drawing.Point(245, 200);
this.supressPrintingCheckBox.Name = "supressPrintingCheckBox";
this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17);
this.supressPrintingCheckBox.TabIndex = 11;
@ -143,68 +154,59 @@ namespace TBF.BenchControl.Output.Printers.Label
this.paperWidthLabel.AutoSize = true;
this.paperWidthLabel.Location = new System.Drawing.Point(8, 108);
this.paperWidthLabel.Name = "paperWidthLabel";
this.paperWidthLabel.Size = new System.Drawing.Size(63, 13);
this.paperWidthLabel.Size = new System.Drawing.Size(103, 13);
this.paperWidthLabel.TabIndex = 5;
this.paperWidthLabel.Text = "Paper width";
this.paperWidthLabel.Text = "Paper width / height";
//
// paperHeightTextBox
//
this.paperHeightTextBox.Enabled = false;
this.paperHeightTextBox.Location = new System.Drawing.Point(122, 128);
this.paperHeightTextBox.Location = new System.Drawing.Point(176, 105);
this.paperHeightTextBox.Name = "paperHeightTextBox";
this.paperHeightTextBox.Size = new System.Drawing.Size(51, 20);
this.paperHeightTextBox.TabIndex = 8;
//
// paperHeightLabel
//
this.paperHeightLabel.AutoSize = true;
this.paperHeightLabel.Location = new System.Drawing.Point(8, 131);
this.paperHeightLabel.Name = "paperHeightLabel";
this.paperHeightLabel.Size = new System.Drawing.Size(67, 13);
this.paperHeightLabel.TabIndex = 7;
this.paperHeightLabel.Text = "Paper height";
//
// bodyItalicCheckBox
// italicCheckBox
//
this.italicCheckBox.AutoSize = true;
this.italicCheckBox.Enabled = false;
this.italicCheckBox.Location = new System.Drawing.Point(335, 190);
this.italicCheckBox.Name = "bodyItalicCheckBox";
this.italicCheckBox.Location = new System.Drawing.Point(335, 134);
this.italicCheckBox.Name = "italicCheckBox";
this.italicCheckBox.Size = new System.Drawing.Size(15, 14);
this.italicCheckBox.TabIndex = 47;
this.italicCheckBox.UseVisualStyleBackColor = true;
//
// bodyBoldCheckBox
// boldCheckBox
//
this.boldCheckBox.AutoSize = true;
this.boldCheckBox.Enabled = false;
this.boldCheckBox.Location = new System.Drawing.Point(307, 190);
this.boldCheckBox.Name = "bodyBoldCheckBox";
this.boldCheckBox.Location = new System.Drawing.Point(307, 134);
this.boldCheckBox.Name = "boldCheckBox";
this.boldCheckBox.Size = new System.Drawing.Size(15, 14);
this.boldCheckBox.TabIndex = 46;
this.boldCheckBox.UseVisualStyleBackColor = true;
//
// bodyFontSizeTextBox
// fontSizeTextBox
//
this.fontSizeTextBox.Enabled = false;
this.fontSizeTextBox.Location = new System.Drawing.Point(259, 184);
this.fontSizeTextBox.Name = "bodyFontSizeTextBox";
this.fontSizeTextBox.Location = new System.Drawing.Point(259, 128);
this.fontSizeTextBox.Name = "fontSizeTextBox";
this.fontSizeTextBox.Size = new System.Drawing.Size(29, 20);
this.fontSizeTextBox.TabIndex = 45;
//
// bodyFontFamilyComboBox
// fontFamilyComboBox
//
this.fontFamilyComboBox.Enabled = false;
this.fontFamilyComboBox.FormattingEnabled = true;
this.fontFamilyComboBox.Location = new System.Drawing.Point(122, 184);
this.fontFamilyComboBox.Name = "bodyFontFamilyComboBox";
this.fontFamilyComboBox.Location = new System.Drawing.Point(122, 128);
this.fontFamilyComboBox.Name = "fontFamilyComboBox";
this.fontFamilyComboBox.Size = new System.Drawing.Size(130, 21);
this.fontFamilyComboBox.TabIndex = 44;
//
// bodyFontLabel
//
this.bodyFontLabel.AutoSize = true;
this.bodyFontLabel.Location = new System.Drawing.Point(8, 187);
this.bodyFontLabel.Location = new System.Drawing.Point(8, 131);
this.bodyFontLabel.Name = "bodyFontLabel";
this.bodyFontLabel.Size = new System.Drawing.Size(106, 13);
this.bodyFontLabel.TabIndex = 43;
@ -214,7 +216,7 @@ namespace TBF.BenchControl.Output.Printers.Label
//
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(331, 175);
this.label2.Location = new System.Drawing.Point(331, 119);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(24, 13);
this.label2.TabIndex = 49;
@ -224,7 +226,7 @@ namespace TBF.BenchControl.Output.Printers.Label
//
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(297, 175);
this.label1.Location = new System.Drawing.Point(297, 119);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(32, 13);
this.label1.TabIndex = 48;
@ -233,9 +235,9 @@ namespace TBF.BenchControl.Output.Printers.Label
// itemsToPrintButton
//
this.itemsToPrintButton.Enabled = false;
this.itemsToPrintButton.Location = new System.Drawing.Point(121, 154);
this.itemsToPrintButton.Location = new System.Drawing.Point(259, 85);
this.itemsToPrintButton.Name = "itemsToPrintButton";
this.itemsToPrintButton.Size = new System.Drawing.Size(132, 23);
this.itemsToPrintButton.Size = new System.Drawing.Size(91, 30);
this.itemsToPrintButton.TabIndex = 50;
this.itemsToPrintButton.Text = "Items to print";
this.itemsToPrintButton.UseVisualStyleBackColor = true;
@ -244,7 +246,7 @@ namespace TBF.BenchControl.Output.Printers.Label
// nrOfCopiesLabel
//
this.nrOfCopiesLabel.AutoSize = true;
this.nrOfCopiesLabel.Location = new System.Drawing.Point(8, 235);
this.nrOfCopiesLabel.Location = new System.Drawing.Point(8, 179);
this.nrOfCopiesLabel.Name = "nrOfCopiesLabel";
this.nrOfCopiesLabel.Size = new System.Drawing.Size(90, 13);
this.nrOfCopiesLabel.TabIndex = 52;
@ -253,7 +255,7 @@ namespace TBF.BenchControl.Output.Printers.Label
// nrOfCopiesTextBox
//
this.nrOfCopiesTextBox.Enabled = false;
this.nrOfCopiesTextBox.Location = new System.Drawing.Point(122, 232);
this.nrOfCopiesTextBox.Location = new System.Drawing.Point(122, 176);
this.nrOfCopiesTextBox.Name = "nrOfCopiesTextBox";
this.nrOfCopiesTextBox.Size = new System.Drawing.Size(51, 20);
this.nrOfCopiesTextBox.TabIndex = 51;
@ -262,15 +264,15 @@ namespace TBF.BenchControl.Output.Printers.Label
//
this.cultureComboBox.Enabled = false;
this.cultureComboBox.FormattingEnabled = true;
this.cultureComboBox.Location = new System.Drawing.Point(122, 208);
this.cultureComboBox.Location = new System.Drawing.Point(122, 152);
this.cultureComboBox.Name = "cultureComboBox";
this.cultureComboBox.Size = new System.Drawing.Size(218, 21);
this.cultureComboBox.Size = new System.Drawing.Size(228, 21);
this.cultureComboBox.TabIndex = 54;
//
// cultureLabel
//
this.cultureLabel.AutoSize = true;
this.cultureLabel.Location = new System.Drawing.Point(8, 211);
this.cultureLabel.Location = new System.Drawing.Point(8, 155);
this.cultureLabel.Name = "cultureLabel";
this.cultureLabel.Size = new System.Drawing.Size(42, 13);
this.cultureLabel.TabIndex = 53;
@ -280,17 +282,125 @@ namespace TBF.BenchControl.Output.Printers.Label
//
this.goodOnlyCheckBox.AutoSize = true;
this.goodOnlyCheckBox.Enabled = false;
this.goodOnlyCheckBox.Location = new System.Drawing.Point(122, 262);
this.goodOnlyCheckBox.Location = new System.Drawing.Point(245, 179);
this.goodOnlyCheckBox.Name = "goodOnlyCheckBox";
this.goodOnlyCheckBox.Size = new System.Drawing.Size(74, 17);
this.goodOnlyCheckBox.TabIndex = 55;
this.goodOnlyCheckBox.Text = "Good only";
this.goodOnlyCheckBox.UseVisualStyleBackColor = true;
//
// snBarcodeGroupBox
//
this.snBarcodeGroupBox.Controls.Add(this.barcodeHeightLabel);
this.snBarcodeGroupBox.Controls.Add(this.barcodeHeightTextBox);
this.snBarcodeGroupBox.Controls.Add(this.isQrCheckBox);
this.snBarcodeGroupBox.Controls.Add(this.barcodeWidthLabel);
this.snBarcodeGroupBox.Controls.Add(this.barcodeWidthTextBox);
this.snBarcodeGroupBox.Controls.Add(this.barcodeTopLabel);
this.snBarcodeGroupBox.Controls.Add(this.barcodeTopTextBox);
this.snBarcodeGroupBox.Controls.Add(this.barcodeLeftTextBox);
this.snBarcodeGroupBox.Controls.Add(this.barcodeLeftLabel);
this.snBarcodeGroupBox.Controls.Add(this.snBarcodeCheckBox);
this.snBarcodeGroupBox.Location = new System.Drawing.Point(11, 227);
this.snBarcodeGroupBox.Name = "snBarcodeGroupBox";
this.snBarcodeGroupBox.Size = new System.Drawing.Size(339, 59);
this.snBarcodeGroupBox.TabIndex = 56;
this.snBarcodeGroupBox.TabStop = false;
//
// barcodeHeightLabel
//
this.barcodeHeightLabel.AutoSize = true;
this.barcodeHeightLabel.Location = new System.Drawing.Point(207, 29);
this.barcodeHeightLabel.Name = "barcodeHeightLabel";
this.barcodeHeightLabel.Size = new System.Drawing.Size(38, 13);
this.barcodeHeightLabel.TabIndex = 18;
this.barcodeHeightLabel.Text = "Height";
//
// barcodeHeightTextBox
//
this.barcodeHeightTextBox.Enabled = false;
this.barcodeHeightTextBox.Location = new System.Drawing.Point(247, 25);
this.barcodeHeightTextBox.Name = "barcodeHeightTextBox";
this.barcodeHeightTextBox.Size = new System.Drawing.Size(32, 20);
this.barcodeHeightTextBox.TabIndex = 17;
//
// isQrCheckBox
//
this.isQrCheckBox.AutoSize = true;
this.isQrCheckBox.Location = new System.Drawing.Point(293, 27);
this.isQrCheckBox.Name = "isQrCheckBox";
this.isQrCheckBox.Size = new System.Drawing.Size(42, 17);
this.isQrCheckBox.TabIndex = 16;
this.isQrCheckBox.Text = "QR";
this.isQrCheckBox.UseVisualStyleBackColor = true;
//
// barcodeWidthLabel
//
this.barcodeWidthLabel.AutoSize = true;
this.barcodeWidthLabel.Location = new System.Drawing.Point(135, 29);
this.barcodeWidthLabel.Name = "barcodeWidthLabel";
this.barcodeWidthLabel.Size = new System.Drawing.Size(35, 13);
this.barcodeWidthLabel.TabIndex = 15;
this.barcodeWidthLabel.Text = "Width";
//
// barcodeWidthTextBox
//
this.barcodeWidthTextBox.Enabled = false;
this.barcodeWidthTextBox.Location = new System.Drawing.Point(171, 25);
this.barcodeWidthTextBox.Name = "barcodeWidthTextBox";
this.barcodeWidthTextBox.Size = new System.Drawing.Size(32, 20);
this.barcodeWidthTextBox.TabIndex = 14;
//
// barcodeTopLabel
//
this.barcodeTopLabel.AutoSize = true;
this.barcodeTopLabel.Location = new System.Drawing.Point(71, 29);
this.barcodeTopLabel.Name = "barcodeTopLabel";
this.barcodeTopLabel.Size = new System.Drawing.Size(26, 13);
this.barcodeTopLabel.TabIndex = 13;
this.barcodeTopLabel.Text = "Top";
//
// barcodeTopTextBox
//
this.barcodeTopTextBox.Enabled = false;
this.barcodeTopTextBox.Location = new System.Drawing.Point(99, 25);
this.barcodeTopTextBox.Name = "barcodeTopTextBox";
this.barcodeTopTextBox.Size = new System.Drawing.Size(32, 20);
this.barcodeTopTextBox.TabIndex = 11;
//
// barcodeLeftTextBox
//
this.barcodeLeftTextBox.Enabled = false;
this.barcodeLeftTextBox.Location = new System.Drawing.Point(35, 25);
this.barcodeLeftTextBox.Name = "barcodeLeftTextBox";
this.barcodeLeftTextBox.Size = new System.Drawing.Size(32, 20);
this.barcodeLeftTextBox.TabIndex = 10;
//
// barcodeLeftLabel
//
this.barcodeLeftLabel.AutoSize = true;
this.barcodeLeftLabel.Location = new System.Drawing.Point(8, 29);
this.barcodeLeftLabel.Name = "barcodeLeftLabel";
this.barcodeLeftLabel.Size = new System.Drawing.Size(25, 13);
this.barcodeLeftLabel.TabIndex = 9;
this.barcodeLeftLabel.Text = "Left";
//
// snBarcodeCheckBox
//
this.snBarcodeCheckBox.AutoSize = true;
this.snBarcodeCheckBox.Location = new System.Drawing.Point(10, 0);
this.snBarcodeCheckBox.Name = "snBarcodeCheckBox";
this.snBarcodeCheckBox.Size = new System.Drawing.Size(176, 17);
this.snBarcodeCheckBox.TabIndex = 0;
this.snBarcodeCheckBox.Text = "Print barcode with serial number";
this.snBarcodeCheckBox.UseVisualStyleBackColor = true;
this.snBarcodeCheckBox.CheckedChanged += new System.EventHandler(this.snBarcodeCheckBox_CheckedChanged);
//
// PrinterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.snBarcodeGroupBox);
this.Controls.Add(this.goodOnlyCheckBox);
this.Controls.Add(this.cultureComboBox);
this.Controls.Add(this.cultureLabel);
@ -305,7 +415,6 @@ namespace TBF.BenchControl.Output.Printers.Label
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.paperHeightTextBox);
this.Controls.Add(this.paperHeightLabel);
this.Controls.Add(this.paperWidthTextBox);
this.Controls.Add(this.paperWidthLabel);
this.Controls.Add(this.templateTextBox);
@ -319,6 +428,8 @@ namespace TBF.BenchControl.Output.Printers.Label
this.Name = "PrinterCfgCtrl";
this.Size = new System.Drawing.Size(372, 327);
this.Load += new System.EventHandler(this.PrinterCfgCtrl_Load);
this.snBarcodeGroupBox.ResumeLayout(false);
this.snBarcodeGroupBox.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -337,7 +448,6 @@ namespace TBF.BenchControl.Output.Printers.Label
private System.Windows.Forms.TextBox paperWidthTextBox;
private System.Windows.Forms.Label paperWidthLabel;
private System.Windows.Forms.TextBox paperHeightTextBox;
private System.Windows.Forms.Label paperHeightLabel;
private System.Windows.Forms.CheckBox italicCheckBox;
private System.Windows.Forms.CheckBox boldCheckBox;
private System.Windows.Forms.TextBox fontSizeTextBox;
@ -351,5 +461,16 @@ namespace TBF.BenchControl.Output.Printers.Label
private System.Windows.Forms.ComboBox cultureComboBox;
private System.Windows.Forms.Label cultureLabel;
private System.Windows.Forms.CheckBox goodOnlyCheckBox;
private System.Windows.Forms.GroupBox snBarcodeGroupBox;
private System.Windows.Forms.TextBox barcodeTopTextBox;
private System.Windows.Forms.TextBox barcodeLeftTextBox;
private System.Windows.Forms.Label barcodeLeftLabel;
private System.Windows.Forms.CheckBox snBarcodeCheckBox;
private System.Windows.Forms.Label barcodeWidthLabel;
private System.Windows.Forms.TextBox barcodeWidthTextBox;
private System.Windows.Forms.Label barcodeTopLabel;
private System.Windows.Forms.CheckBox isQrCheckBox;
private System.Windows.Forms.Label barcodeHeightLabel;
private System.Windows.Forms.TextBox barcodeHeightTextBox;
}
}

View File

@ -1,7 +1,8 @@
///
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using log4net;
@ -42,6 +43,8 @@ namespace TBF.BenchControl.Output.Printers.Label
{
fontFamilyComboBox.Items.Add(ff.Name);
}
ManageCheckGroupBox(snBarcodeCheckBox, snBarcodeGroupBox);
}
private void PrinterCfgCtrl_Load(object sender, EventArgs e)
@ -80,6 +83,13 @@ namespace TBF.BenchControl.Output.Printers.Label
nrOfCopiesTextBox.Text = config.NrOfCopies.ToString();
goodOnlyCheckBox.Checked = config.GoodOnly;
supressPrintingCheckBox.Checked = config.SupressPrinting;
snBarcodeCheckBox.Checked = config.DrawSNasBarcode;
isQrCheckBox.Checked = config.IsQR;
barcodeLeftTextBox.Text = config.BarcodeLeft.ToString();
barcodeTopTextBox.Text = config.BarcodeTop.ToString();
barcodeWidthTextBox.Text = config.BarcodeWidth.ToString();
barcodeHeightTextBox.Text = config.BarcodeHeight.ToString();
}
public void Unlock()
@ -98,6 +108,19 @@ namespace TBF.BenchControl.Output.Printers.Label
nrOfCopiesTextBox.Enabled = true;
goodOnlyCheckBox.Enabled = true;
supressPrintingCheckBox.Enabled = true;
snBarcodeCheckBox.Enabled = true;
ManageCheckGroupBox(snBarcodeCheckBox, snBarcodeGroupBox);
isQrCheckBox.Enabled = true;
barcodeLeftTextBox.Enabled = true;
barcodeTopTextBox.Enabled = true;
barcodeWidthTextBox.Enabled = true;
barcodeHeightTextBox.Enabled = true;
}
private void snBarcodeCheckBox_CheckedChanged(object sender, EventArgs e)
{
ManageCheckGroupBox(snBarcodeCheckBox, snBarcodeGroupBox);
}
public CfgUpdateFlags VerifyCfg(ref string message)
@ -142,6 +165,26 @@ namespace TBF.BenchControl.Output.Printers.Label
message += Environment.NewLine + "'Number of copies' should be between 0 and 9";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(barcodeLeftTextBox.Text, out dummy) || dummy < 0 || dummy > 2000)
{
message += Environment.NewLine + "Barcode 'Left' should be between 0 and 2000";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(barcodeTopTextBox.Text, out dummy) || dummy < 0 || dummy > 2000)
{
message += Environment.NewLine + "Barcode 'Top' should be between 0 and 2000";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(barcodeWidthTextBox.Text, out dummy) || dummy < 0 || dummy > 200)
{
message += Environment.NewLine + "Barcode 'Width' should be between 0 and 200";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(barcodeHeightTextBox.Text, out dummy) || dummy < 0 || dummy > 200)
{
message += Environment.NewLine + "Barcode 'Height' should be between 0 and 200";
flags |= CfgUpdateFlags.Error;
}
return flags;
}
@ -193,6 +236,13 @@ namespace TBF.BenchControl.Output.Printers.Label
flags |= UpdateDifferent(ref config.GoodOnly, goodOnlyCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.SupressPrinting, supressPrintingCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.DrawSNasBarcode, snBarcodeCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.IsQR, isQrCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.BarcodeLeft, barcodeLeftTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.BarcodeTop, barcodeTopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.BarcodeWidth, barcodeWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.BarcodeHeight, barcodeHeightTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Printer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
@ -214,6 +264,20 @@ namespace TBF.BenchControl.Output.Printers.Label
}
}
private void ManageCheckGroupBox(CheckBox chk, GroupBox grp)
{
/// Make sure the CheckBox isn't in the GroupBox. This will only happen the first time.
if (chk.Parent == grp)
{
grp.Parent.Controls.Add(chk); /// Reparent the CheckBox so it's not in the GroupBox.
chk.Location = new Point(chk.Left + grp.Left, chk.Top + grp.Top); /// Adjust the CheckBox's location.
chk.BringToFront(); /// Move the CheckBox to the top of the stacking order.
}
/// Enable or disable the GroupBox.
grp.Enabled = chk.Checked;
}
#region Configuration Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)

View File

@ -990,9 +990,6 @@
<DependentUpon>PrinterCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\Output\Printers\Label\Factory.cs" />
<Compile Include="BenchControl\Output\Printers\Label\PrintLabelDocument.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BenchControl\Output\Printers\Munich\Printer.cs" />
<Compile Include="BenchControl\Output\Printers\Munich\PrinterCfg.cs" />
<Compile Include="BenchControl\Output\Printers\Munich\PrinterCfgCtrl.cs">

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.