From eaf0e2cf2257f6d092d016b671330ae63b26350c Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Tue, 28 Jul 2020 16:01:34 +0200 Subject: [PATCH] Barcode printing in Output.Printers.Enhanced and Output.Printers.OnePerMeter, ver. 2.26.1508 --- .../Enhanced/EnhancedPrintDocument.cs | 143 +++++++++++++----- .../Printers/Enhanced/EnhancedPrinterCfg.cs | 7 +- .../OnePerMeter/OnePerMeterPrintDocument.cs | 58 ++++++- .../OnePerMeter/OnePerMeterPrinterCfg.cs | 7 +- .../Output/Printers/Enhanced/Printer.cs | 9 +- .../Output/Printers/Enhanced/PrinterCfg.cs | 6 +- .../Enhanced/PrinterCfgCtrl.Designer.cs | 94 ++++++++++-- .../Printers/Enhanced/PrinterCfgCtrl.cs | 48 +++++- .../Output/Printers/OnePerMeter/Printer.cs | 10 ++ .../Output/Printers/OnePerMeter/PrinterCfg.cs | 9 +- .../OnePerMeter/PrinterCfgCtrl.Designer.cs | 98 ++++++++++-- .../Printers/OnePerMeter/PrinterCfgCtrl.cs | 61 +++++++- TBF/Properties/AssemblyInfo.cs | 4 +- 13 files changed, 479 insertions(+), 75 deletions(-) diff --git a/Results/Output/Printers/Enhanced/EnhancedPrintDocument.cs b/Results/Output/Printers/Enhanced/EnhancedPrintDocument.cs index 3a4eebfc3..1ca9404ae 100644 --- a/Results/Output/Printers/Enhanced/EnhancedPrintDocument.cs +++ b/Results/Output/Printers/Enhanced/EnhancedPrintDocument.cs @@ -1,19 +1,24 @@ /// -/// Copyright (c) 2017 Sensus Metering Systems +/// Copyright (c) 2017-2020 Sensus Metering Systems /// using System; using System.Collections.Generic; using System.Drawing; +using System.Drawing.Drawing2D; using System.Drawing.Printing; using System.IO; using Config.Entities; +using GenCode128; +using Gma.QrCodeNet.Encoding; using Results.Resources; namespace Results.Output.Printers.Enhanced { public class EnhancedPrintDocument : PrintDocument { - /// Size of the printed area without margins, after taking into account 'pageOrientation' + static QrEncoder encoder = new QrEncoder(); + + /// Size of the printed area without margins, after taking into account 'pageOrientation' readonly int printHeight; readonly int printWidth; @@ -23,12 +28,14 @@ namespace Results.Output.Printers.Enhanced readonly int TitleX; readonly int TitleY; /// Depends on the size of the header - readonly int SpacingOne; - readonly int SpacingOneAndHalf; - readonly int SpacingOne4Header; - readonly int SpacingOneAndHalf4Header; + readonly int spacingOne; + readonly int spacingOneAndHalf; + readonly int spacingOne4Header; + readonly int spacingOneAndHalf4Header; + readonly int spacingOne4Footer; - readonly int SpacingOne4Footer; + int spacingAboveTable; + int spacingBelowTable; int CommonTop; /// = TitleY + 60 int BodyTop; /// = HdrTop + 160 @@ -124,11 +131,11 @@ namespace Results.Output.Printers.Enhanced } /// Document outline preliminary calculations - SpacingOne = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", font).Height; - SpacingOneAndHalf = (3 * SpacingOne) / 2; - SpacingOne4Header = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", headerFont).Height; - SpacingOneAndHalf4Header = (3 * SpacingOne4Header) / 2; - SpacingOne4Footer = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", footerFont).Height; + spacingOne = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", font).Height; + spacingOneAndHalf = (3 * spacingOne) / 2; + spacingOne4Header = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", headerFont).Height; + spacingOneAndHalf4Header = (3 * spacingOne4Header) / 2; + spacingOne4Footer = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", footerFont).Height; TitleX = cfg.LeftMargin; TitleY = cfg.TopMargin; @@ -178,17 +185,27 @@ namespace Results.Output.Printers.Enhanced /// Prepare document outline ///---------- titleHeight = System.Windows.Forms.TextRenderer.MeasureText(header, titleFont).Height; - CommonTop = TitleY + titleHeight + SpacingOne4Header; + CommonTop = TitleY + titleHeight + spacingOne4Header; - commonHeight = commonItems.Count * SpacingOne; - BodyTop = CommonTop + commonHeight + SpacingOne4Header; + commonHeight = commonItems.Count * spacingOne; + BodyTop = CommonTop + commonHeight + spacingOne4Header; Table table0 = Table.Create_TestsAreRows(batch.WaterMeters[0], testItems, style); SizeF tableSize = table0.Measure(e); - int wmSectionHeight = (int)tableSize.Height + SpacingOne4Header * ((tableSize.Height > 0) ? 3 : 2); - nrWMsOnFirstPage = (printHeight - BodyTop + TitleY - 2 * SpacingOne) / wmSectionHeight; - nrWMsOnNextPage = (printHeight - 2 * SpacingOne) / wmSectionHeight; + if (cfg.BarcodeType == BarcodeType.None) + { + spacingAboveTable = spacingOneAndHalf4Header; + } + else + { + spacingAboveTable = Math.Max(spacingOneAndHalf4Header, cfg.BarcodeHeight + spacingOne4Header / 2); + } + spacingBelowTable = (tableSize.Height > 0) ? spacingOneAndHalf4Header : (spacingOne4Header / 2); + + int wmSectionHeight = (int)tableSize.Height + spacingAboveTable + spacingBelowTable; + 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; @@ -221,8 +238,8 @@ namespace Results.Output.Printers.Enhanced /// 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]); } } @@ -241,7 +258,7 @@ namespace Results.Output.Printers.Enhanced int wmPosition = true ? batch.WaterMeters[wmNr].WMPosition : (wmNr + 1); if (!cfg.GoodOnly || batch.WaterMeters[wmNr].Passed) { - nextWmTop = (int)PrintWM(e, batch.WaterMeters[wmNr], wmPosition, nextWmTop) + SpacingOneAndHalf4Header; + nextWmTop = (int)PrintWM(e, batch.WaterMeters[wmNr], wmPosition, nextWmTop) + spacingBelowTable; } } @@ -252,11 +269,11 @@ namespace Results.Output.Printers.Enhanced /// Footer ///---------- int footerWidth = (int)e.Graphics.MeasureString(footer, footerFont).Width; - PrintFooterAt(e, leftMargin + (printWidth - footerWidth) / 2, topMargin + printHeight - 2 * SpacingOne, footer); + PrintFooterAt(e, leftMargin + (printWidth - footerWidth) / 2, 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); + PrintAt(e, leftMargin + (printWidth - pageNrWidth) / 2, topMargin + printHeight - spacingOne, pageNrText); } @@ -270,25 +287,48 @@ namespace Results.Output.Printers.Enhanced float PrintWM(System.Drawing.Printing.PrintPageEventArgs e, Results.Entities.WaterMeter wm, int printedWMNr, int top) { + int tableTop = top + spacingAboveTable; + /// Print the water meter number and the serial number - string wmText = string.Format("{0} {1}", Strings.Water_Meter, printedWMNr); - PrintHeaderAt(e, leftMargin, top, wmText); - if (!string.IsNullOrEmpty(wm.SerialNr)) + if (string.IsNullOrEmpty(wm.SerialNr)) { - PrintHeaderAt(e, leftMargin + (int)e.Graphics.MeasureString(wmText, headerFont).Width, top, - string.Format(" {0} = {1}", Strings.sn, wm.SerialNr)); + string wmText = string.Format("{0} {1}", Strings.Water_Meter, printedWMNr); + int wmTextWidth = (int)e.Graphics.MeasureString(wmText, headerFont).Width; + PrintHeaderAt(e, leftMargin, tableTop - spacingOneAndHalf4Header, wmText); + } + else + { + string wmText = string.Format("{0} {1} {2} = {3}", Strings.Water_Meter, printedWMNr, Strings.sn, wm.SerialNr); + int wmTextWidth = (int)e.Graphics.MeasureString(wmText, headerFont).Width; + PrintHeaderAt(e, leftMargin, tableTop - spacingOneAndHalf4Header, wmText); + + switch (cfg.BarcodeType) + { + case BarcodeType.Code_128_Horizontally: + { + Image img = Code128Rendering.MakeBarcodeImage(wm.SerialNr, 1, true); + e.Graphics.DrawImage(img, leftMargin + wmTextWidth + spacingOne4Header, top, cfg.BarcodeWidth, cfg.BarcodeHeight); + break; + } + case BarcodeType.Code_128_Vertically: + { + Image img = Code128Rendering.MakeBarcodeImage(wm.SerialNr, 1, true); + img.RotateFlip(RotateFlipType.Rotate90FlipNone); + e.Graphics.DrawImage(img, leftMargin + wmTextWidth + spacingOne4Header, top, cfg.BarcodeWidth, cfg.BarcodeHeight); + break; + } + case BarcodeType.QR_Code: + { + QrCode qrCode = encoder.Encode(wm.SerialNr); + DrawQR(e.Graphics, qrCode, leftMargin + wmTextWidth + spacingOne4Header, top, cfg.BarcodeWidth, cfg.BarcodeHeight); + break; + } + } } Table table = Table.Create_TestsAreRows(wm, testItems, style); - if (table.IsEmpty()) - { - return top; - } - else - { - return table.Draw(e, leftMargin, top + SpacingOneAndHalf4Header); - } + return table.IsEmpty() ? tableTop : table.Draw(e, leftMargin, tableTop); } @@ -298,7 +338,7 @@ namespace Results.Output.Printers.Enhanced } void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string text) { - RectangleF printArea = new RectangleF(x, y, 2000, SpacingOne); + RectangleF printArea = new RectangleF(x, y, 2000, spacingOne); e.Graphics.DrawString(text, this.font, Brushes.Black, printArea); } @@ -309,7 +349,7 @@ namespace Results.Output.Printers.Enhanced } void PrintHeaderAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string text) { - RectangleF printArea = new RectangleF(x, y, 2000, SpacingOne4Header); + RectangleF printArea = new RectangleF(x, y, 2000, spacingOne4Header); e.Graphics.DrawString(text, this.headerFont, Brushes.Black, printArea); } @@ -320,8 +360,33 @@ namespace Results.Output.Printers.Enhanced } void PrintFooterAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string text) { - RectangleF printArea = new RectangleF(x, y, 2000, SpacingOne4Footer); + RectangleF printArea = new RectangleF(x, y, 2000, spacingOne4Footer); e.Graphics.DrawString(text, this.footerFont, Brushes.Black, printArea); } + + + 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)); + } + } + } + } } } diff --git a/Results/Output/Printers/Enhanced/EnhancedPrinterCfg.cs b/Results/Output/Printers/Enhanced/EnhancedPrinterCfg.cs index 9635f68f8..1ca930fab 100644 --- a/Results/Output/Printers/Enhanced/EnhancedPrinterCfg.cs +++ b/Results/Output/Printers/Enhanced/EnhancedPrinterCfg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017 Sensus Slovensko a.s. +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// namespace Results.Output.Printers.Enhanced @@ -30,5 +30,8 @@ namespace Results.Output.Printers.Enhanced public string[] CommonItems; public string[] TestItems; public string Footer; - } + public BarcodeType BarcodeType; /// s/n is printed as barcode when valid (BarcodeType.None < BarcodeType < BarcodeType.Count) + public int BarcodeWidth; + public int BarcodeHeight; + } } diff --git a/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs b/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs index 2bea806ea..17a70fc06 100644 --- a/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs +++ b/Results/Output/Printers/OnePerMeter/OnePerMeterPrintDocument.cs @@ -1,12 +1,15 @@ /// -/// Copyright (c) 2017-2018 Sensus Slovensko a.s. +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using System.Drawing; +using System.Drawing.Drawing2D; using System.Drawing.Printing; using System.IO; using Config.Entities; +using GenCode128; +using Gma.QrCodeNet.Encoding; using Results.Resources; namespace Results.Output.Printers.OnePerMeter @@ -16,7 +19,9 @@ namespace Results.Output.Printers.OnePerMeter const float GapBetweenTableColumns = 10; const float GapBetweenCommonColumns = 10; - /// Size of the printed area without margins, after taking into account 'pageOrientation' + static QrEncoder encoder = new QrEncoder(); + + /// Size of the printed area without margins, after taking into account 'pageOrientation' readonly int printHeight; readonly int printWidth; @@ -158,6 +163,30 @@ namespace Results.Output.Printers.OnePerMeter WMChart.GetChart(wm, true).Printing.PrintPaint(e.Graphics, pos); } + if (cfg.BarcodeType != BarcodeType.None && cfg.BarcodeType < BarcodeType.Count && !string.IsNullOrEmpty(wm.SerialNr)) + { + try + { + if (cfg.BarcodeType == BarcodeType.QR_Code) + { + QrCode qrCode = encoder.Encode(wm.SerialNr); + DrawQR(e.Graphics, qrCode, cfg.BarcodeLeft, cfg.BarcodeTop, cfg.BarcodeWidth, cfg.BarcodeHeight); + } + else if (cfg.BarcodeType == BarcodeType.Code_128_Horizontally || cfg.BarcodeType == BarcodeType.Code_128_Vertically) + { + Image img = Code128Rendering.MakeBarcodeImage(wm.SerialNr, 1, true); + if (cfg.BarcodeType == BarcodeType.Code_128_Vertically) + { + img.RotateFlip(RotateFlipType.Rotate90FlipNone); + } + e.Graphics.DrawImage(img, cfg.BarcodeLeft, cfg.BarcodeTop, cfg.BarcodeWidth, cfg.BarcodeHeight); + } + } + catch (Exception) + { + } + } + float tableTop = cfg.TopMargin; if (pageNr == 1) @@ -351,5 +380,30 @@ namespace Results.Output.Printers.OnePerMeter pageNr++; } + + + 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)); + } + } + } + } } } diff --git a/Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs b/Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs index 748c68033..9a660a650 100644 --- a/Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs +++ b/Results/Output/Printers/OnePerMeter/OnePerMeterPrinterCfg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017-2019 Sensus Slovensko a.s. +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// namespace Results.Output.Printers.OnePerMeter @@ -54,5 +54,10 @@ namespace Results.Output.Printers.OnePerMeter public int ImgWid; public int ImgHgh; public string ImgFullPathName; + public BarcodeType BarcodeType; /// s/n is printed as barcode when valid (BarcodeType.None < BarcodeType < BarcodeType.Count) + public int BarcodeLeft; + public int BarcodeTop; + public int BarcodeWidth; + public int BarcodeHeight; } } diff --git a/TBF/BenchControl/Output/Printers/Enhanced/Printer.cs b/TBF/BenchControl/Output/Printers/Enhanced/Printer.cs index b298443cd..55c6adf1a 100644 --- a/TBF/BenchControl/Output/Printers/Enhanced/Printer.cs +++ b/TBF/BenchControl/Output/Printers/Enhanced/Printer.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017 Sensus Slovensko a.s. +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -102,6 +102,10 @@ namespace TBF.BenchControl.Output.Printers.Enhanced printerCfg.DocName = newCfg.DocName; printerCfg.NrOfCopies = newCfg.NrOfCopies; + printerCfg.BarcodeType = newCfg.BarcodeType; + printerCfg.BarcodeWidth = newCfg.BarcodeWidth; + printerCfg.BarcodeHeight = newCfg.BarcodeHeight; + ApplyConfig(); } } @@ -191,6 +195,9 @@ namespace TBF.BenchControl.Output.Printers.Enhanced CommonItems = printerCfg.CommonItems, TestItems = printerCfg.SelectedItems, Footer = printerCfg.Footer, + BarcodeType = printerCfg.BarcodeType, + BarcodeWidth = printerCfg.BarcodeWidth, + BarcodeHeight = printerCfg.BarcodeHeight, }; for (int i = 1; i <= printerCfg.NrOfCopies; i++) diff --git a/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfg.cs b/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfg.cs index 962d2e57e..d1dc8cfb8 100644 --- a/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfg.cs +++ b/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017 Sensus Slovensko a.s. +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System.Xml.Serialization; using Config.Entities; @@ -44,6 +44,10 @@ namespace TBF.BenchControl.Output.Printers.Enhanced public string DocName; public int NrOfCopies; + public Results.Output.Printers.BarcodeType BarcodeType; + public int BarcodeWidth; + public int BarcodeHeight; + [XmlIgnore] public Config.Entities.MetersKind MetersKind; diff --git a/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.Designer.cs b/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.Designer.cs index 8c110964d..bfaae2a56 100644 --- a/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.Designer.cs +++ b/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.Designer.cs @@ -76,6 +76,12 @@ namespace TBF.BenchControl.Output.Printers.Enhanced this.templateLabel = new System.Windows.Forms.Label(); this.nrOfCopiesTextBox = new System.Windows.Forms.TextBox(); this.nrOfCopiesLabel = new System.Windows.Forms.Label(); + this.barcodeTypeComboBox = new System.Windows.Forms.ComboBox(); + this.barcodeLabel = new System.Windows.Forms.Label(); + this.barcodeWidthTextBox = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.barcodeHeightTextBox = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // nameTextBox @@ -108,7 +114,7 @@ namespace TBF.BenchControl.Output.Printers.Enhanced // this.supressPrintingCheckBox.AutoSize = true; this.supressPrintingCheckBox.Enabled = false; - this.supressPrintingCheckBox.Location = new System.Drawing.Point(19, 259); + this.supressPrintingCheckBox.Location = new System.Drawing.Point(91, 307); this.supressPrintingCheckBox.Name = "supressPrintingCheckBox"; this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17); this.supressPrintingCheckBox.TabIndex = 33; @@ -187,9 +193,9 @@ namespace TBF.BenchControl.Output.Printers.Enhanced // commonItemsButton // this.commonItemsButton.Enabled = false; - this.commonItemsButton.Location = new System.Drawing.Point(142, 259); + this.commonItemsButton.Location = new System.Drawing.Point(193, 259); this.commonItemsButton.Name = "commonItemsButton"; - this.commonItemsButton.Size = new System.Drawing.Size(218, 23); + this.commonItemsButton.Size = new System.Drawing.Size(167, 23); this.commonItemsButton.TabIndex = 36; this.commonItemsButton.Text = "Common items"; this.commonItemsButton.UseVisualStyleBackColor = true; @@ -198,9 +204,9 @@ namespace TBF.BenchControl.Output.Printers.Enhanced // footerButton // this.footerButton.Enabled = false; - this.footerButton.Location = new System.Drawing.Point(142, 303); + this.footerButton.Location = new System.Drawing.Point(193, 303); this.footerButton.Name = "footerButton"; - this.footerButton.Size = new System.Drawing.Size(218, 23); + this.footerButton.Size = new System.Drawing.Size(167, 23); this.footerButton.TabIndex = 38; this.footerButton.Text = "Footer"; this.footerButton.UseVisualStyleBackColor = true; @@ -209,9 +215,9 @@ namespace TBF.BenchControl.Output.Printers.Enhanced // headerButton // this.headerButton.Enabled = false; - this.headerButton.Location = new System.Drawing.Point(142, 237); + this.headerButton.Location = new System.Drawing.Point(193, 237); this.headerButton.Name = "headerButton"; - this.headerButton.Size = new System.Drawing.Size(218, 23); + this.headerButton.Size = new System.Drawing.Size(167, 23); this.headerButton.TabIndex = 35; this.headerButton.Text = "Title"; this.headerButton.UseVisualStyleBackColor = true; @@ -220,9 +226,9 @@ namespace TBF.BenchControl.Output.Printers.Enhanced // testItemsButton // this.testItemsButton.Enabled = false; - this.testItemsButton.Location = new System.Drawing.Point(142, 281); + this.testItemsButton.Location = new System.Drawing.Point(193, 281); this.testItemsButton.Name = "testItemsButton"; - this.testItemsButton.Size = new System.Drawing.Size(218, 23); + this.testItemsButton.Size = new System.Drawing.Size(167, 23); this.testItemsButton.TabIndex = 37; this.testItemsButton.Text = "Test items"; this.testItemsButton.UseVisualStyleBackColor = true; @@ -251,9 +257,9 @@ namespace TBF.BenchControl.Output.Printers.Enhanced // docNameTextBox // this.docNameTextBox.Enabled = false; - this.docNameTextBox.Location = new System.Drawing.Point(197, 328); + this.docNameTextBox.Location = new System.Drawing.Point(193, 328); this.docNameTextBox.Name = "docNameTextBox"; - this.docNameTextBox.Size = new System.Drawing.Size(163, 20); + this.docNameTextBox.Size = new System.Drawing.Size(167, 20); this.docNameTextBox.TabIndex = 40; // // docNameLabel @@ -269,7 +275,7 @@ namespace TBF.BenchControl.Output.Printers.Enhanced // this.goodOnlyCheckBox.AutoSize = true; this.goodOnlyCheckBox.Enabled = false; - this.goodOnlyCheckBox.Location = new System.Drawing.Point(19, 281); + this.goodOnlyCheckBox.Location = new System.Drawing.Point(15, 307); this.goodOnlyCheckBox.Name = "goodOnlyCheckBox"; this.goodOnlyCheckBox.Size = new System.Drawing.Size(74, 17); this.goodOnlyCheckBox.TabIndex = 34; @@ -494,16 +500,74 @@ namespace TBF.BenchControl.Output.Printers.Enhanced this.nrOfCopiesLabel.TabIndex = 44; this.nrOfCopiesLabel.Text = "# copies"; // + // barcodeTypeComboBox + // + this.barcodeTypeComboBox.Enabled = false; + this.barcodeTypeComboBox.FormattingEnabled = true; + this.barcodeTypeComboBox.Location = new System.Drawing.Point(19, 257); + this.barcodeTypeComboBox.Name = "barcodeTypeComboBox"; + this.barcodeTypeComboBox.Size = new System.Drawing.Size(167, 21); + this.barcodeTypeComboBox.TabIndex = 45; + // + // barcodeLabel + // + this.barcodeLabel.AutoSize = true; + this.barcodeLabel.Location = new System.Drawing.Point(16, 241); + this.barcodeLabel.Name = "barcodeLabel"; + this.barcodeLabel.Size = new System.Drawing.Size(47, 13); + this.barcodeLabel.TabIndex = 46; + this.barcodeLabel.Text = "Barcode"; + // + // barcodeWidthTextBox + // + this.barcodeWidthTextBox.Enabled = false; + this.barcodeWidthTextBox.Location = new System.Drawing.Point(79, 281); + this.barcodeWidthTextBox.Name = "barcodeWidthTextBox"; + this.barcodeWidthTextBox.Size = new System.Drawing.Size(31, 20); + this.barcodeWidthTextBox.TabIndex = 14; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(42, 285); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(35, 13); + this.label5.TabIndex = 15; + this.label5.Text = "Width"; + // + // barcodeHeightTextBox + // + this.barcodeHeightTextBox.Enabled = false; + this.barcodeHeightTextBox.Location = new System.Drawing.Point(156, 281); + this.barcodeHeightTextBox.Name = "barcodeHeightTextBox"; + this.barcodeHeightTextBox.Size = new System.Drawing.Size(30, 20); + this.barcodeHeightTextBox.TabIndex = 17; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(116, 285); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(38, 13); + this.label6.TabIndex = 18; + this.label6.Text = "Height"; + // // PrinterCfgCtrl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.barcodeLabel); + this.Controls.Add(this.barcodeTypeComboBox); + this.Controls.Add(this.label6); this.Controls.Add(this.nrOfCopiesLabel); this.Controls.Add(this.nrOfCopiesTextBox); + this.Controls.Add(this.barcodeHeightTextBox); this.Controls.Add(this.templateTextBox); this.Controls.Add(this.templateLabel); + this.Controls.Add(this.label5); this.Controls.Add(this.footerItalicCheckBox); this.Controls.Add(this.footerBoldCheckBox); + this.Controls.Add(this.barcodeWidthTextBox); this.Controls.Add(this.footerFontSizeTextBox); this.Controls.Add(this.footerFontFamilyComboBox); this.Controls.Add(this.footerFontLabel); @@ -598,5 +662,11 @@ namespace TBF.BenchControl.Output.Printers.Enhanced private System.Windows.Forms.Label templateLabel; private System.Windows.Forms.TextBox nrOfCopiesTextBox; private System.Windows.Forms.Label nrOfCopiesLabel; + private System.Windows.Forms.ComboBox barcodeTypeComboBox; + private System.Windows.Forms.Label barcodeLabel; + private System.Windows.Forms.TextBox barcodeWidthTextBox; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox barcodeHeightTextBox; + private System.Windows.Forms.Label label6; } } diff --git a/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.cs b/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.cs index 0869150e4..3dba77cc4 100644 --- a/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.cs +++ b/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.cs @@ -1,14 +1,15 @@ /// -/// Copyright (c) 2017 Sensus Slovensko a.s. +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using System.Windows.Forms; using log4net; using Config.Entities; +using Results.Output.Printers; +using TBF.BenchControl.Configs; using TBF.BenchControl.Generic; using TBF.Resources; -using TBF.BenchControl.Configs; namespace TBF.BenchControl.Output.Printers.Enhanced { @@ -49,7 +50,12 @@ namespace TBF.BenchControl.Output.Printers.Enhanced bodyFontFamilyComboBox.Items.Add(ff.Name); footerFontFamilyComboBox.Items.Add(ff.Name); } - } + + for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++) + { + barcodeTypeComboBox.Items.Add(bt.ToString()); + } + } private void PrinterCfgCtrl_Load(object sender, EventArgs e) { @@ -114,6 +120,10 @@ namespace TBF.BenchControl.Output.Printers.Enhanced docNameTextBox.Text = config.DocName; nrOfCopiesTextBox.Text = config.NrOfCopies.ToString(); + + barcodeTypeComboBox.Text = config.BarcodeType.ToString(); + barcodeWidthTextBox.Text = config.BarcodeWidth.ToString(); + barcodeHeightTextBox.Text = config.BarcodeHeight.ToString(); } public void Unlock() @@ -149,6 +159,10 @@ namespace TBF.BenchControl.Output.Printers.Enhanced footerButton.Enabled = true; docNameTextBox.Enabled = true; nrOfCopiesTextBox.Enabled = true; + + barcodeTypeComboBox.Enabled = true; + barcodeWidthTextBox.Enabled = true; + barcodeHeightTextBox.Enabled = true; } public CfgUpdateFlags VerifyCfg(ref string message) @@ -216,6 +230,22 @@ namespace TBF.BenchControl.Output.Printers.Enhanced flags |= CfgUpdateFlags.Error; } + if (!barcodeTypeComboBox.Items.Contains(barcodeTypeComboBox.Text)) + { + message += Environment.NewLine + "Invalid barcode type"; + 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; } @@ -292,6 +322,18 @@ namespace TBF.BenchControl.Output.Printers.Enhanced flags |= UpdateDifferent(ref config.DocName, docNameTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.NrOfCopies, nrOfCopiesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++) + { + if (bt.ToString().Equals(barcodeTypeComboBox.Text)) + { + config.BarcodeType = bt; + flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + break; + } + } + 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)); diff --git a/TBF/BenchControl/Output/Printers/OnePerMeter/Printer.cs b/TBF/BenchControl/Output/Printers/OnePerMeter/Printer.cs index cfb49ae84..ba06fdac1 100644 --- a/TBF/BenchControl/Output/Printers/OnePerMeter/Printer.cs +++ b/TBF/BenchControl/Output/Printers/OnePerMeter/Printer.cs @@ -122,6 +122,11 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter printerCfg.ImgHgh = newCfg.ImgHgh; printerCfg.ImgName = newCfg.ImgName; printerCfg.DocName = newCfg.DocName; + printerCfg.BarcodeType = newCfg.BarcodeType; + printerCfg.BarcodeLeft = newCfg.BarcodeLeft; + printerCfg.BarcodeTop = newCfg.BarcodeTop; + printerCfg.BarcodeWidth = newCfg.BarcodeWidth; + printerCfg.BarcodeHeight = newCfg.BarcodeHeight; ApplyConfig(); } @@ -238,6 +243,11 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter ImgWid = printerCfg.ImgWid, ImgHgh = printerCfg.ImgHgh, ImgFullPathName = (wm.ArchivePath != null) ? System.IO.Path.Combine(wm.ArchivePath, printerCfg.ImgName) : null, + BarcodeType = printerCfg.BarcodeType, + BarcodeLeft = printerCfg.BarcodeLeft, + BarcodeTop = printerCfg.BarcodeTop, + BarcodeWidth = printerCfg.BarcodeWidth, + BarcodeHeight = printerCfg.BarcodeHeight, }; new OnePerMeterPrintDocument(batch, cfg, wm, documentName).Print(); diff --git a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs index ea2ac7723..018669de2 100644 --- a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs +++ b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017-2019 Sensus Slovensko a.s. +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System.Xml.Serialization; using Config.Entities; @@ -70,6 +70,12 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter public string ImgName; public string DocName; + public Results.Output.Printers.BarcodeType BarcodeType; /// s/n is printed as barcode when valid (BarcodeType.None < BarcodeType < BarcodeType.Count) + public int BarcodeLeft; + public int BarcodeTop; + public int BarcodeWidth; + public int BarcodeHeight; + [XmlIgnore] public Config.Entities.MetersKind MetersKind; @@ -109,6 +115,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter Footer = string.Empty; DocName = string.Empty; ImgName = string.Empty; + BarcodeType = Results.Output.Printers.BarcodeType.None; } public string ToString(int i) diff --git a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs index 0de3b1e0b..df5b017b0 100644 --- a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs +++ b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.Designer.cs @@ -107,6 +107,13 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter this.graphWidthTextBox = new System.Windows.Forms.TextBox(); this.graphTopTextBox = new System.Windows.Forms.TextBox(); this.graphLeftTextBox = new System.Windows.Forms.TextBox(); + this.label14 = new System.Windows.Forms.Label(); + this.barcodeLabel = new System.Windows.Forms.Label(); + this.barcodeHeightTextBox = new System.Windows.Forms.TextBox(); + this.barcodeWidthTextBox = new System.Windows.Forms.TextBox(); + this.barcodeTopTextBox = new System.Windows.Forms.TextBox(); + this.barcodeLeftTextBox = new System.Windows.Forms.TextBox(); + this.barcodeTypeComboBox = new System.Windows.Forms.ComboBox(); this.SuspendLayout(); // // nameTextBox @@ -139,7 +146,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // this.supressPrintingCheckBox.AutoSize = true; this.supressPrintingCheckBox.Enabled = false; - this.supressPrintingCheckBox.Location = new System.Drawing.Point(334, 26); + this.supressPrintingCheckBox.Location = new System.Drawing.Point(306, 5); this.supressPrintingCheckBox.Name = "supressPrintingCheckBox"; this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17); this.supressPrintingCheckBox.TabIndex = 33; @@ -421,7 +428,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // this.goodOnlyCheckBox.AutoSize = true; this.goodOnlyCheckBox.Enabled = false; - this.goodOnlyCheckBox.Location = new System.Drawing.Point(334, 44); + this.goodOnlyCheckBox.Location = new System.Drawing.Point(306, 21); this.goodOnlyCheckBox.Name = "goodOnlyCheckBox"; this.goodOnlyCheckBox.Size = new System.Drawing.Size(74, 17); this.goodOnlyCheckBox.TabIndex = 34; @@ -448,18 +455,18 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter // docNameLabel // this.docNameLabel.AutoSize = true; - this.docNameLabel.Location = new System.Drawing.Point(16, 331); + this.docNameLabel.Location = new System.Drawing.Point(297, 41); this.docNameLabel.Name = "docNameLabel"; - this.docNameLabel.Size = new System.Drawing.Size(246, 13); + this.docNameLabel.Size = new System.Drawing.Size(127, 13); this.docNameLabel.TabIndex = 42; - this.docNameLabel.Text = "Doc.name (0=start 1-end, 2=batch, 3=wm, 4=s/n) :"; + this.docNameLabel.Text = "Doc.name (0=start 1-end,"; // // docNameTextBox // this.docNameTextBox.Enabled = false; - this.docNameTextBox.Location = new System.Drawing.Point(261, 328); + this.docNameTextBox.Location = new System.Drawing.Point(302, 69); this.docNameTextBox.Name = "docNameTextBox"; - this.docNameTextBox.Size = new System.Drawing.Size(135, 20); + this.docNameTextBox.Size = new System.Drawing.Size(151, 20); this.docNameTextBox.TabIndex = 43; // // footerItalicCheckBox @@ -513,7 +520,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter this.imageNameTextBox.Enabled = false; this.imageNameTextBox.Location = new System.Drawing.Point(287, 306); this.imageNameTextBox.Name = "imageNameTextBox"; - this.imageNameTextBox.Size = new System.Drawing.Size(135, 20); + this.imageNameTextBox.Size = new System.Drawing.Size(166, 20); this.imageNameTextBox.TabIndex = 44; // // imageLeftTextBox @@ -758,7 +765,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter this.table1FormComboBox.FormattingEnabled = true; this.table1FormComboBox.Location = new System.Drawing.Point(392, 237); this.table1FormComboBox.Name = "table1FormComboBox"; - this.table1FormComboBox.Size = new System.Drawing.Size(64, 21); + this.table1FormComboBox.Size = new System.Drawing.Size(61, 21); this.table1FormComboBox.TabIndex = 78; // // label3 @@ -802,10 +809,76 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter this.graphLeftTextBox.Size = new System.Drawing.Size(33, 20); this.graphLeftTextBox.TabIndex = 79; // + // label14 + // + this.label14.AutoSize = true; + this.label14.Location = new System.Drawing.Point(339, 56); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(120, 13); + this.label14.TabIndex = 84; + this.label14.Text = " 2=batch, 3=wm, 4=s/n)"; + // + // barcodeLabel + // + this.barcodeLabel.AutoSize = true; + this.barcodeLabel.Location = new System.Drawing.Point(17, 330); + this.barcodeLabel.Name = "barcodeLabel"; + this.barcodeLabel.Size = new System.Drawing.Size(121, 13); + this.barcodeLabel.TabIndex = 89; + this.barcodeLabel.Text = "Barcode left/t/w/h/type"; + // + // barcodeHeightTextBox + // + this.barcodeHeightTextBox.Enabled = false; + this.barcodeHeightTextBox.Location = new System.Drawing.Point(245, 327); + this.barcodeHeightTextBox.Name = "barcodeHeightTextBox"; + this.barcodeHeightTextBox.Size = new System.Drawing.Size(31, 20); + this.barcodeHeightTextBox.TabIndex = 88; + // + // barcodeWidthTextBox + // + this.barcodeWidthTextBox.Enabled = false; + this.barcodeWidthTextBox.Location = new System.Drawing.Point(211, 327); + this.barcodeWidthTextBox.Name = "barcodeWidthTextBox"; + this.barcodeWidthTextBox.Size = new System.Drawing.Size(31, 20); + this.barcodeWidthTextBox.TabIndex = 87; + // + // barcodeTopTextBox + // + this.barcodeTopTextBox.Enabled = false; + this.barcodeTopTextBox.Location = new System.Drawing.Point(177, 327); + this.barcodeTopTextBox.Name = "barcodeTopTextBox"; + this.barcodeTopTextBox.Size = new System.Drawing.Size(31, 20); + this.barcodeTopTextBox.TabIndex = 86; + // + // barcodeLeftTextBox + // + this.barcodeLeftTextBox.Enabled = false; + this.barcodeLeftTextBox.Location = new System.Drawing.Point(141, 327); + this.barcodeLeftTextBox.Name = "barcodeLeftTextBox"; + this.barcodeLeftTextBox.Size = new System.Drawing.Size(33, 20); + this.barcodeLeftTextBox.TabIndex = 85; + // + // barcodeTypeComboBox + // + this.barcodeTypeComboBox.Enabled = false; + this.barcodeTypeComboBox.FormattingEnabled = true; + this.barcodeTypeComboBox.Location = new System.Drawing.Point(287, 327); + this.barcodeTypeComboBox.Name = "barcodeTypeComboBox"; + this.barcodeTypeComboBox.Size = new System.Drawing.Size(166, 21); + this.barcodeTypeComboBox.TabIndex = 90; + // // PrinterCfgCtrl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.barcodeTypeComboBox); + this.Controls.Add(this.barcodeLabel); + this.Controls.Add(this.barcodeHeightTextBox); + this.Controls.Add(this.barcodeWidthTextBox); + this.Controls.Add(this.barcodeTopTextBox); + this.Controls.Add(this.barcodeLeftTextBox); + this.Controls.Add(this.label14); this.Controls.Add(this.label3); this.Controls.Add(this.graphHeightTextBox); this.Controls.Add(this.graphWidthTextBox); @@ -968,5 +1041,12 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter private System.Windows.Forms.TextBox graphWidthTextBox; private System.Windows.Forms.TextBox graphTopTextBox; private System.Windows.Forms.TextBox graphLeftTextBox; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.Label barcodeLabel; + private System.Windows.Forms.TextBox barcodeHeightTextBox; + private System.Windows.Forms.TextBox barcodeWidthTextBox; + private System.Windows.Forms.TextBox barcodeTopTextBox; + private System.Windows.Forms.TextBox barcodeLeftTextBox; + private System.Windows.Forms.ComboBox barcodeTypeComboBox; } } diff --git a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs index ea0358581..d259a8c23 100644 --- a/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs +++ b/TBF/BenchControl/Output/Printers/OnePerMeter/PrinterCfgCtrl.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017-2019 Sensus Slovensko a.s. +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -7,6 +7,7 @@ using System.Linq; using System.Windows.Forms; using log4net; using Config.Entities; +using Results.Output.Printers; using TBF.BenchControl.Generic; using TBF.Resources; using TBF.BenchControl.Configs; @@ -61,7 +62,12 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter { table1FormComboBox.Items.Add(f.ToString()); } - } + + for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++) + { + barcodeTypeComboBox.Items.Add(bt.ToString()); + } + } private void PrinterCfgCtrl_Load(object sender, EventArgs e) { @@ -151,6 +157,12 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter docNameTextBox.Text = config.DocName; table1FormComboBox.Text = config.Form.ToString(); + + barcodeTypeComboBox.Text = config.BarcodeType.ToString(); + barcodeLeftTextBox.Text = config.BarcodeLeft.ToString(); + barcodeTopTextBox.Text = config.BarcodeTop.ToString(); + barcodeWidthTextBox.Text = config.BarcodeWidth.ToString(); + barcodeHeightTextBox.Text = config.BarcodeHeight.ToString(); } public void Unlock() @@ -207,6 +219,11 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter imageHeightTextBox.Enabled = true; imageNameTextBox.Enabled = true; docNameTextBox.Enabled = true; + barcodeTypeComboBox.Enabled = true; + barcodeLeftTextBox.Enabled = true; + barcodeTopTextBox.Enabled = true; + barcodeWidthTextBox.Enabled = true; + barcodeHeightTextBox.Enabled = true; } public CfgUpdateFlags VerifyCfg(ref string message) @@ -361,6 +378,32 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter flags |= CfgUpdateFlags.Error; } + if (!barcodeTypeComboBox.Items.Contains(barcodeTypeComboBox.Text)) + { + message += Environment.NewLine + "Invalid barcode type"; + 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; } @@ -471,6 +514,20 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter flags |= UpdateDifferent(ref config.DocName, docNameTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++) + { + if (bt.ToString().Equals(barcodeTypeComboBox.Text)) + { + config.BarcodeType = bt; + flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + break; + } + } + 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)); diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 70f5fc62b..eb4a359da 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.26.1505.0")] -[assembly: AssemblyFileVersion("2.26.1505.0")] +[assembly: AssemblyVersion("2.26.1508.0")] +[assembly: AssemblyFileVersion("2.26.1508.0")]