From 7ba8648e48a968a5414ecf9501b5e68dffb9dee9 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Sat, 29 Feb 2020 08:03:08 +0100 Subject: [PATCH] 1. Algeria: Output.Printers.MultiLabel, 2. Localization to Romanian, ver. 2.18.1428 --- .../MultiLabel/MultiLabelPrintDocument.cs | 175 ++++++ .../MultiLabel/MultiLabelPrinterCfg.cs | 29 + Results/Properties/AssemblyInfo.cs | 4 +- Results/Results.csproj | 4 + .../Output/Printers/MultiLabel/Factory.cs | 26 + .../Output/Printers/MultiLabel/Printer.cs | 168 ++++++ .../Output/Printers/MultiLabel/PrinterCfg.cs | 82 +++ .../MultiLabel/PrinterCfgCtrl.Designer.cs | 529 ++++++++++++++++++ .../Printers/MultiLabel/PrinterCfgCtrl.cs | 310 ++++++++++ .../Printers/MultiLabel/PrinterCfgCtrl.resx | 120 ++++ TBF/BenchControl/TbfComponents.cs | 3 +- TBF/Program.cs | 5 +- TBF/Properties/AssemblyInfo.cs | 4 +- TBF/Resources/Strings.ro.resx | 3 + TBF/TBF.csproj | 12 + 15 files changed, 1467 insertions(+), 7 deletions(-) create mode 100644 Results/Output/Printers/MultiLabel/MultiLabelPrintDocument.cs create mode 100644 Results/Output/Printers/MultiLabel/MultiLabelPrinterCfg.cs create mode 100644 TBF/BenchControl/Output/Printers/MultiLabel/Factory.cs create mode 100644 TBF/BenchControl/Output/Printers/MultiLabel/Printer.cs create mode 100644 TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfg.cs create mode 100644 TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfgCtrl.Designer.cs create mode 100644 TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfgCtrl.cs create mode 100644 TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfgCtrl.resx diff --git a/Results/Output/Printers/MultiLabel/MultiLabelPrintDocument.cs b/Results/Output/Printers/MultiLabel/MultiLabelPrintDocument.cs new file mode 100644 index 000000000..155db79a6 --- /dev/null +++ b/Results/Output/Printers/MultiLabel/MultiLabelPrintDocument.cs @@ -0,0 +1,175 @@ +/// +/// Copyright (c) 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 Gma.QrCodeNet.Encoding; +using Config.Entities; +using Results.Resources; +using GenCode128; + +namespace Results.Output.Printers.MultiLabel +{ + public class MultiLabelPrintDocument : PrintersCommon + { + static QrEncoder encoder = new QrEncoder(); + + /// Size of the printed area without margins, after taking into account 'pageOrientation' + readonly int labelHeight; + readonly int labelWidth; + + /// Selected font + readonly Font font; + + /// Data to print + Results.Entities.Batch batch; + MultiLabelPrinterCfg cfg; + IList waterMeters; + + /// Items to print + IList itemsToPrint; + + /// + /// Constructor + /// + /// Text to be printed + public MultiLabelPrintDocument(Results.Entities.Batch batch, MultiLabelPrinterCfg cfg, string documentName) + { + DocumentName = documentName; + + this.batch = batch; + this.waterMeters = batch.WaterMeters; + this.cfg = cfg; + this.itemsToPrint = Results.WMeterRsltItemSpec.FromStrArray(cfg.ItemsToPrint); + + /// Initialize fonts + font = new Font((cfg.FontFamily != null ? cfg.FontFamily : "Arial"), + (cfg.FontSize > 0 ? cfg.FontSize : 10), + (FontStyle)cfg.FontStyle); + + /// Set print area size and margins (in dots using 100 dpi) + DefaultPageSettings.Landscape = (cfg.PageOrientation == PageOrientation.Landscape); + /// + labelHeight = cfg.LabelHeight; + labelWidth = cfg.LabelWidth; + } + + /// + /// Override the default onbeginPrint method of the PrintDocument Object + /// + /// + /// + protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e) + { + base.OnBeginPrint(e); + } + + /// + /// Override the default OnPrintPage method of the PrintDocument. + /// + /// + /// This provides the print logic for our document + protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e) + { + /// Run base code + base.OnPrintPage(e); + + int labelColumn = 0; + int labelLeft = cfg.LeftTopLabelLeft; + int labelTop = cfg.LeftTopLabelTop; + foreach (var wm in waterMeters) + { + if (!wm.Disabled && (!cfg.GoodOnly || wm.Passed)) + { + if (!string.IsNullOrEmpty(cfg.Template)) + { + string templatePath = Path.Combine("C:\\TBF\\Templates\\", cfg.Template); + if (File.Exists(templatePath)) + { + e.Graphics.DrawImage(new Bitmap(Image.FromFile(templatePath), labelWidth, labelHeight), new Rectangle(labelLeft, labelTop, labelWidth, labelHeight)); + } + } + + foreach (var item in itemsToPrint) + { + string[] coords = item.Caption.Split(new char[] { ';' }); + int x, y; + if (coords.Length >= 2 && int.TryParse(coords[0].Trim(new char[] { ' ' }), out x) + && int.TryParse(coords[1].Trim(new char[] { ' ' }), out y)) + { + RectangleF printArea = new RectangleF(labelLeft + x, labelTop + y, labelWidth - x, labelHeight - y); + e.Graphics.DrawString(item.Print(wm), this.font, Brushes.Black, printArea); + } + } + + if (cfg.BarcodeType != BarcodeType.None && cfg.BarcodeType < BarcodeType.Count) + { + try + { + if (cfg.BarcodeType == BarcodeType.QR_Code) + { + QrCode qrCode = encoder.Encode(wm.SerialNr); + DrawQR(e.Graphics, qrCode, labelLeft + cfg.BarcodeLeft, labelTop + 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, labelLeft + cfg.BarcodeLeft, labelTop + cfg.BarcodeTop, cfg.BarcodeWidth, cfg.BarcodeHeight); + } + } + catch (Exception) + { + } + } + + /// + /// Move (labelLeft, labelTop) coordinates to the next label + /// + if (++labelColumn == cfg.LabelColumnsCount) + { + labelColumn = 0; + labelLeft = cfg.LeftTopLabelLeft; + labelTop += cfg.LabelHeight; + } + else + { + labelLeft += cfg.LabelWidth; + } + } + } + } + + + 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/MultiLabel/MultiLabelPrinterCfg.cs b/Results/Output/Printers/MultiLabel/MultiLabelPrinterCfg.cs new file mode 100644 index 000000000..877495b32 --- /dev/null +++ b/Results/Output/Printers/MultiLabel/MultiLabelPrinterCfg.cs @@ -0,0 +1,29 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// + +namespace Results.Output.Printers.MultiLabel +{ + public class MultiLabelPrinterCfg + { + public Config.Entities.PageOrientation PageOrientation; + public int LabelColumnsCount; + public int LeftTopLabelLeft; + public int LeftTopLabelTop; + public bool GoodOnly; + + public string[] ItemsToPrint; + public int LabelWidth; /// In 0,254 mm = 1/100 in = 100dpi pixels count + public int LabelHeight; /// In 0,254 mm = 1/100 in = 100dpi pixels count + public string Template; /// Full path to a 'png' file + public string FontFamily; + public int FontSize; + public int FontStyle; + public System.Globalization.CultureInfo CultureInfo; + 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/Results/Properties/AssemblyInfo.cs b/Results/Properties/AssemblyInfo.cs index e398aad59..7353f9adf 100644 --- a/Results/Properties/AssemblyInfo.cs +++ b/Results/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.18.1423.0")] -[assembly: AssemblyFileVersion("2.18.1423.0")] +[assembly: AssemblyVersion("2.18.1428.0")] +[assembly: AssemblyFileVersion("2.18.1428.0")] diff --git a/Results/Results.csproj b/Results/Results.csproj index 212f7ab4f..c68264749 100644 --- a/Results/Results.csproj +++ b/Results/Results.csproj @@ -139,6 +139,10 @@ Component + + Component + + Component diff --git a/TBF/BenchControl/Output/Printers/MultiLabel/Factory.cs b/TBF/BenchControl/Output/Printers/MultiLabel/Factory.cs new file mode 100644 index 000000000..d398477e2 --- /dev/null +++ b/TBF/BenchControl/Output/Printers/MultiLabel/Factory.cs @@ -0,0 +1,26 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.Output.Printers.MultiLabel +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + public void ResetStaticProperties() { Printer.ResetStaticProperties(); } + + public IComponent DummyComponent() { return new Printer(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Printer(cfg); } + + public IComponentCfg DefaultConfig() { return new PrinterCfg(this.GetType().Namespace.Substring(24), this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(PrinterCfg.Serializer, component, this); + } + } +} diff --git a/TBF/BenchControl/Output/Printers/MultiLabel/Printer.cs b/TBF/BenchControl/Output/Printers/MultiLabel/Printer.cs new file mode 100644 index 000000000..5d26020f2 --- /dev/null +++ b/TBF/BenchControl/Output/Printers/MultiLabel/Printer.cs @@ -0,0 +1,168 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using log4net; +using System.Globalization; +using System.Threading; +using Results.Output.Printers.MultiLabel; + +namespace TBF.BenchControl.Output.Printers.MultiLabel +{ + public class Printer : ComponentBase, IOperation, GenericDevices.IResultsPrinter + { + private static readonly ILog log = LogManager.GetLogger(typeof(Printer)); + public override string ToString() { return string.Format("MultiLabel.Printer({0})", Cfg.ToString(1)); } + + readonly PrinterCfg printerCfg; + + public bool SupressPrinting { get { return (printerCfg.NrOfCopies == 0); } } + + /// Data to print + Results.Entities.Batch batch; + + /// + /// Items to print + /// + IList commonItems; + + + public Printer() { } + + public Printer(Generic.IComponentCfg cfg) + : base(cfg) + { + printerCfg = cfg as PrinterCfg; + ApplyConfig(); + log.Debug(this.ToString()); + } + + void ApplyConfig() + { + commonItems = Results.WMeterRsltItemSpec.FromStrArray(printerCfg.ItemsToPrint); + } + + + #region Configuration Change Handling + + public static void OnCfgChange(object sender, CfgChangeArgs args) + { + if (CfgChangeHandler == null) return; + try { CfgChangeHandler(sender, args); } + catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); } + } + + public static event EventHandler CfgChangeHandler; + + public override void StartChangeHandler() + { + CfgChangeHandler += delegate(object sender, CfgChangeArgs args) + { + PrinterCfg newCfg = args.Cfg as PrinterCfg; + if (newCfg != null && newCfg.Name.Equals(Name)) + { + if (args.Command == CfgChangeCmd.CfgChange) + { + printerCfg.PageOrientation = newCfg.PageOrientation; + printerCfg.LabelColumnsCount = newCfg.LabelColumnsCount; + printerCfg.LeftTopLabelLeft = newCfg.LeftTopLabelLeft; + printerCfg.LeftTopLabelTop = newCfg.LeftTopLabelTop; + printerCfg.NrOfCopies = newCfg.NrOfCopies; + printerCfg.GoodOnly = newCfg.GoodOnly; + + printerCfg.ItemsToPrint = newCfg.ItemsToPrint; + printerCfg.LabelWidth = newCfg.LabelWidth; + printerCfg.LabelHeight = newCfg.LabelHeight; + printerCfg.Template = newCfg.Template; + printerCfg.FontFamily = newCfg.FontFamily; + printerCfg.FontSize = newCfg.FontSize; + printerCfg.FontStyle = newCfg.FontStyle; + printerCfg.Culture = newCfg.Culture; + printerCfg.BarcodeType = newCfg.BarcodeType; + printerCfg.BarcodeLeft = newCfg.BarcodeLeft; + printerCfg.BarcodeTop = newCfg.BarcodeTop; + printerCfg.BarcodeWidth = newCfg.BarcodeWidth; + printerCfg.BarcodeHeight = newCfg.BarcodeHeight; + + ApplyConfig(); + } + } + }; + } + + #endregion Configuration Change Handling + + + /// + /// Prints the test cycle results, Events: Event.ResultsPrinted + /// + /// Batch results to print + /// Reference to the operation + public IOperation PrintResultsOp(Results.Entities.Batch batch) + { + this.batch = batch; + return this; + } + + /// Start this operation + public void Start() + { + CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture; + + if (printerCfg.Culture != Culture.system) + { + Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString()); + } + + PrintResults(batch, string.Format("{0}", batch.BatchNr)); + + Thread.CurrentThread.CurrentCulture = oriCulture; + } + + /// Run this operation + /// Event.ResultsPrinted + public Event Run() + { + return Event.ResultsPrinted; + } + + /// Stop this operation + public void Stop() + { + } + + + void PrintResults(Results.Entities.Batch batch, string documentName) + { + MultiLabelPrinterCfg cfg = new MultiLabelPrinterCfg + { + PageOrientation = printerCfg.PageOrientation, + LabelColumnsCount = printerCfg.LabelColumnsCount, + LeftTopLabelLeft = printerCfg.LeftTopLabelLeft, + LeftTopLabelTop = printerCfg.LeftTopLabelTop, + GoodOnly = printerCfg.GoodOnly, + + ItemsToPrint = printerCfg.ItemsToPrint, + LabelWidth = printerCfg.LabelWidth, + LabelHeight = printerCfg.LabelHeight, + Template = printerCfg.Template, + FontFamily = printerCfg.FontFamily, + FontSize = printerCfg.FontSize, + FontStyle = printerCfg.FontStyle, + CultureInfo = (printerCfg.Culture == Culture.system) ? Thread.CurrentThread.CurrentCulture : new CultureInfo(printerCfg.Culture.ToString()), + BarcodeType = printerCfg.BarcodeType, + BarcodeLeft = printerCfg.BarcodeLeft, + BarcodeTop = printerCfg.BarcodeTop, + BarcodeWidth = printerCfg.BarcodeWidth, + BarcodeHeight = printerCfg.BarcodeHeight, + }; + + for (int i = 1; i <= printerCfg.NrOfCopies; i++) + { + string docNameEx = string.Format(((printerCfg.NrOfCopies == 1) ? "{0}" : "{0}_{1}"), documentName, i); + new Results.Output.Printers.MultiLabel.MultiLabelPrintDocument(batch, cfg, docNameEx).Print(); + } + } + } +} diff --git a/TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfg.cs b/TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfg.cs new file mode 100644 index 000000000..358492116 --- /dev/null +++ b/TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfg.cs @@ -0,0 +1,82 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.Output.Printers.MultiLabel +{ + public class PrinterCfg : ComponentCfgBase, Generic.IComponentCfg + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(PrinterCfg) })[0]; + public override XmlSerializer GetSerializer() { return Serializer; } + + public IComponentCfgCtrl GetControl() { return new PrinterCfgCtrl(); } + + /// + /// Serialized parameters + /// + public PageOrientation PageOrientation; + public int LabelColumnsCount; + public int LeftTopLabelLeft; + public int LeftTopLabelTop; + public int NrOfCopies; + public bool GoodOnly; + + public string[] ItemsToPrint; + public int LabelWidth; /// In 0,254 mm = 1/100 in = 100dpi pixels count + public int LabelHeight; /// In 0,254 mm = 1/100 in = 100dpi pixels count + public string Template; /// Full path to a 'png' file + public string FontFamily; + public int FontSize; + public int FontStyle; + public Culture Culture; + public Results.Output.Printers.BarcodeType BarcodeType; + public int BarcodeLeft; + public int BarcodeTop; + public int BarcodeWidth; + public int BarcodeHeight; + + + /// Private parameterless constructor invoked by all other (public) constructors + PrinterCfg() + { + } + + public PrinterCfg(string name, IComponentFactory factory) + : this() + { + this.Name = name; + this.Factory = factory; + ParentName = string.Empty; + + Template = string.Empty; + PageOrientation = PageOrientation.Portrait; + LabelWidth = 827; /// A4 width + LabelHeight = 1169; /// A4 height + FontFamily = "Arial"; + FontSize = 10; + FontStyle = 0; + NrOfCopies = 1; + GoodOnly = false; + BarcodeType = Results.Output.Printers.BarcodeType.None; + } + + public string ToString(int i) + { + return string.Format("Name={0}, Orientation={1}, LabelClmnsCnt={2}, LabelW={3}, LabelH={4}, Barcode={5}, TemplateFile={6}", + Name, + PageOrientation, + LabelColumnsCount, + LabelWidth, + LabelHeight, + BarcodeType.ToString(), + Template + ); + } + } +} diff --git a/TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfgCtrl.Designer.cs b/TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfgCtrl.Designer.cs new file mode 100644 index 000000000..933450071 --- /dev/null +++ b/TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfgCtrl.Designer.cs @@ -0,0 +1,529 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +namespace TBF.BenchControl.Output.Printers.MultiLabel +{ + partial class PrinterCfgCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.nameLabel = new System.Windows.Forms.Label(); + this.classNameLabel = new System.Windows.Forms.Label(); + this.orientationLabel = new System.Windows.Forms.Label(); + this.orientationComboBox = new System.Windows.Forms.ComboBox(); + this.templateTextBox = new System.Windows.Forms.TextBox(); + this.templateLabel = new System.Windows.Forms.Label(); + this.labelWidthTextBox = new System.Windows.Forms.TextBox(); + this.paperWidthLabel = new System.Windows.Forms.Label(); + this.labelHeightTextBox = new System.Windows.Forms.TextBox(); + this.italicCheckBox = new System.Windows.Forms.CheckBox(); + this.boldCheckBox = new System.Windows.Forms.CheckBox(); + this.fontSizeTextBox = new System.Windows.Forms.TextBox(); + this.fontFamilyComboBox = new System.Windows.Forms.ComboBox(); + this.bodyFontLabel = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.itemsToPrintButton = new System.Windows.Forms.Button(); + this.nrOfCopiesLabel = new System.Windows.Forms.Label(); + this.nrOfCopiesTextBox = new System.Windows.Forms.TextBox(); + this.cultureComboBox = new System.Windows.Forms.ComboBox(); + this.cultureLabel = new System.Windows.Forms.Label(); + this.goodOnlyCheckBox = new System.Windows.Forms.CheckBox(); + this.barcodeLeftLabel = new System.Windows.Forms.Label(); + this.barcodeLeftTextBox = new System.Windows.Forms.TextBox(); + this.barcodeTopTextBox = new System.Windows.Forms.TextBox(); + this.barcodeTopLabel = new System.Windows.Forms.Label(); + this.barcodeWidthTextBox = new System.Windows.Forms.TextBox(); + this.barcodeWidthLabel = new System.Windows.Forms.Label(); + this.barcodeHeightTextBox = new System.Windows.Forms.TextBox(); + this.barcodeHeightLabel = new System.Windows.Forms.Label(); + this.barcodeTypeComboBox = new System.Windows.Forms.ComboBox(); + this.barcodeLabel = new System.Windows.Forms.Label(); + this.leftTopLabelTopLabel = new System.Windows.Forms.Label(); + this.leftTopLabelTopTextBox = new System.Windows.Forms.TextBox(); + this.leftTopLabelLeftTextBox = new System.Windows.Forms.TextBox(); + this.leftTopLabelLeftLabel = new System.Windows.Forms.Label(); + this.labelColumnsCountTextBox = new System.Windows.Forms.TextBox(); + this.labelColumnsCountLabel = new System.Windows.Forms.Label(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(122, 35); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(130, 20); + this.nameTextBox.TabIndex = 2; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(8, 38); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 1; + this.nameLabel.Text = "Name"; + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(119, 11); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(61, 13); + this.classNameLabel.TabIndex = 0; + this.classNameLabel.Text = "Class name"; + // + // orientationLabel + // + this.orientationLabel.AutoSize = true; + this.orientationLabel.Location = new System.Drawing.Point(8, 60); + this.orientationLabel.Name = "orientationLabel"; + this.orientationLabel.Size = new System.Drawing.Size(84, 13); + this.orientationLabel.TabIndex = 3; + this.orientationLabel.Text = "Page orientation"; + // + // orientationComboBox + // + this.orientationComboBox.Enabled = false; + this.orientationComboBox.FormattingEnabled = true; + this.orientationComboBox.Location = new System.Drawing.Point(122, 57); + this.orientationComboBox.Name = "orientationComboBox"; + this.orientationComboBox.Size = new System.Drawing.Size(130, 21); + this.orientationComboBox.TabIndex = 4; + // + // templateTextBox + // + this.templateTextBox.Enabled = false; + this.templateTextBox.Location = new System.Drawing.Point(120, 22); + this.templateTextBox.Name = "templateTextBox"; + this.templateTextBox.Size = new System.Drawing.Size(228, 20); + this.templateTextBox.TabIndex = 10; + // + // templateLabel + // + this.templateLabel.AutoSize = true; + this.templateLabel.Location = new System.Drawing.Point(6, 25); + this.templateLabel.Name = "templateLabel"; + this.templateLabel.Size = new System.Drawing.Size(67, 13); + this.templateLabel.TabIndex = 9; + this.templateLabel.Text = "Template file"; + // + // labelWidthTextBox + // + this.labelWidthTextBox.Enabled = false; + this.labelWidthTextBox.Location = new System.Drawing.Point(120, 44); + this.labelWidthTextBox.Name = "labelWidthTextBox"; + this.labelWidthTextBox.Size = new System.Drawing.Size(51, 20); + this.labelWidthTextBox.TabIndex = 6; + // + // paperWidthLabel + // + this.paperWidthLabel.AutoSize = true; + this.paperWidthLabel.Location = new System.Drawing.Point(6, 47); + this.paperWidthLabel.Name = "paperWidthLabel"; + this.paperWidthLabel.Size = new System.Drawing.Size(101, 13); + this.paperWidthLabel.TabIndex = 5; + this.paperWidthLabel.Text = "Label width / height"; + // + // labelHeightTextBox + // + this.labelHeightTextBox.Enabled = false; + this.labelHeightTextBox.Location = new System.Drawing.Point(174, 44); + this.labelHeightTextBox.Name = "labelHeightTextBox"; + this.labelHeightTextBox.Size = new System.Drawing.Size(51, 20); + this.labelHeightTextBox.TabIndex = 8; + // + // italicCheckBox + // + this.italicCheckBox.AutoSize = true; + this.italicCheckBox.Enabled = false; + this.italicCheckBox.Location = new System.Drawing.Point(333, 72); + this.italicCheckBox.Name = "italicCheckBox"; + this.italicCheckBox.Size = new System.Drawing.Size(15, 14); + this.italicCheckBox.TabIndex = 47; + this.italicCheckBox.UseVisualStyleBackColor = true; + // + // boldCheckBox + // + this.boldCheckBox.AutoSize = true; + this.boldCheckBox.Enabled = false; + this.boldCheckBox.Location = new System.Drawing.Point(305, 72); + this.boldCheckBox.Name = "boldCheckBox"; + this.boldCheckBox.Size = new System.Drawing.Size(15, 14); + this.boldCheckBox.TabIndex = 46; + this.boldCheckBox.UseVisualStyleBackColor = true; + // + // fontSizeTextBox + // + this.fontSizeTextBox.Enabled = false; + this.fontSizeTextBox.Location = new System.Drawing.Point(257, 66); + this.fontSizeTextBox.Name = "fontSizeTextBox"; + this.fontSizeTextBox.Size = new System.Drawing.Size(29, 20); + this.fontSizeTextBox.TabIndex = 45; + // + // fontFamilyComboBox + // + this.fontFamilyComboBox.Enabled = false; + this.fontFamilyComboBox.FormattingEnabled = true; + this.fontFamilyComboBox.Location = new System.Drawing.Point(120, 66); + 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(6, 69); + this.bodyFontLabel.Name = "bodyFontLabel"; + this.bodyFontLabel.Size = new System.Drawing.Size(106, 13); + this.bodyFontLabel.TabIndex = 43; + this.bodyFontLabel.Text = "Font family/size/style"; + // + // label2 + // + 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(329, 57); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(24, 13); + this.label2.TabIndex = 49; + this.label2.Text = "Ital."; + // + // label1 + // + 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(295, 57); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(32, 13); + this.label1.TabIndex = 48; + this.label1.Text = "Bold"; + // + // itemsToPrintButton + // + this.itemsToPrintButton.Enabled = false; + this.itemsToPrintButton.Location = new System.Drawing.Point(257, 96); + this.itemsToPrintButton.Name = "itemsToPrintButton"; + this.itemsToPrintButton.Size = new System.Drawing.Size(91, 30); + this.itemsToPrintButton.TabIndex = 50; + this.itemsToPrintButton.Text = "Items to print"; + this.itemsToPrintButton.UseVisualStyleBackColor = true; + this.itemsToPrintButton.Click += new System.EventHandler(this.itemsToPrintButton_Click); + // + // nrOfCopiesLabel + // + this.nrOfCopiesLabel.AutoSize = true; + this.nrOfCopiesLabel.Location = new System.Drawing.Point(8, 105); + this.nrOfCopiesLabel.Name = "nrOfCopiesLabel"; + this.nrOfCopiesLabel.Size = new System.Drawing.Size(90, 13); + this.nrOfCopiesLabel.TabIndex = 52; + this.nrOfCopiesLabel.Text = "Number of copies"; + // + // nrOfCopiesTextBox + // + this.nrOfCopiesTextBox.Enabled = false; + this.nrOfCopiesTextBox.Location = new System.Drawing.Point(122, 102); + this.nrOfCopiesTextBox.Name = "nrOfCopiesTextBox"; + this.nrOfCopiesTextBox.Size = new System.Drawing.Size(32, 20); + this.nrOfCopiesTextBox.TabIndex = 51; + // + // cultureComboBox + // + this.cultureComboBox.Enabled = false; + this.cultureComboBox.FormattingEnabled = true; + this.cultureComboBox.Location = new System.Drawing.Point(120, 89); + this.cultureComboBox.Name = "cultureComboBox"; + this.cultureComboBox.Size = new System.Drawing.Size(130, 21); + this.cultureComboBox.TabIndex = 54; + // + // cultureLabel + // + this.cultureLabel.AutoSize = true; + this.cultureLabel.Location = new System.Drawing.Point(6, 92); + this.cultureLabel.Name = "cultureLabel"; + this.cultureLabel.Size = new System.Drawing.Size(42, 13); + this.cultureLabel.TabIndex = 53; + this.cultureLabel.Text = "Cullture"; + // + // goodOnlyCheckBox + // + this.goodOnlyCheckBox.AutoSize = true; + this.goodOnlyCheckBox.Enabled = false; + this.goodOnlyCheckBox.Location = new System.Drawing.Point(261, 104); + 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; + // + // barcodeLeftLabel + // + this.barcodeLeftLabel.AutoSize = true; + this.barcodeLeftLabel.Location = new System.Drawing.Point(95, 139); + this.barcodeLeftLabel.Name = "barcodeLeftLabel"; + this.barcodeLeftLabel.Size = new System.Drawing.Size(25, 13); + this.barcodeLeftLabel.TabIndex = 9; + this.barcodeLeftLabel.Text = "Left"; + // + // barcodeLeftTextBox + // + this.barcodeLeftTextBox.Enabled = false; + this.barcodeLeftTextBox.Location = new System.Drawing.Point(120, 135); + this.barcodeLeftTextBox.Name = "barcodeLeftTextBox"; + this.barcodeLeftTextBox.Size = new System.Drawing.Size(31, 20); + this.barcodeLeftTextBox.TabIndex = 10; + // + // barcodeTopTextBox + // + this.barcodeTopTextBox.Enabled = false; + this.barcodeTopTextBox.Location = new System.Drawing.Point(179, 135); + this.barcodeTopTextBox.Name = "barcodeTopTextBox"; + this.barcodeTopTextBox.Size = new System.Drawing.Size(31, 20); + this.barcodeTopTextBox.TabIndex = 11; + // + // barcodeTopLabel + // + this.barcodeTopLabel.AutoSize = true; + this.barcodeTopLabel.Location = new System.Drawing.Point(153, 139); + this.barcodeTopLabel.Name = "barcodeTopLabel"; + this.barcodeTopLabel.Size = new System.Drawing.Size(26, 13); + this.barcodeTopLabel.TabIndex = 13; + this.barcodeTopLabel.Text = "Top"; + // + // barcodeWidthTextBox + // + this.barcodeWidthTextBox.Enabled = false; + this.barcodeWidthTextBox.Location = new System.Drawing.Point(247, 135); + this.barcodeWidthTextBox.Name = "barcodeWidthTextBox"; + this.barcodeWidthTextBox.Size = new System.Drawing.Size(31, 20); + this.barcodeWidthTextBox.TabIndex = 14; + // + // barcodeWidthLabel + // + this.barcodeWidthLabel.AutoSize = true; + this.barcodeWidthLabel.Location = new System.Drawing.Point(212, 139); + this.barcodeWidthLabel.Name = "barcodeWidthLabel"; + this.barcodeWidthLabel.Size = new System.Drawing.Size(35, 13); + this.barcodeWidthLabel.TabIndex = 15; + this.barcodeWidthLabel.Text = "Width"; + // + // barcodeHeightTextBox + // + this.barcodeHeightTextBox.Enabled = false; + this.barcodeHeightTextBox.Location = new System.Drawing.Point(318, 135); + this.barcodeHeightTextBox.Name = "barcodeHeightTextBox"; + this.barcodeHeightTextBox.Size = new System.Drawing.Size(30, 20); + this.barcodeHeightTextBox.TabIndex = 17; + // + // barcodeHeightLabel + // + this.barcodeHeightLabel.AutoSize = true; + this.barcodeHeightLabel.Location = new System.Drawing.Point(280, 139); + this.barcodeHeightLabel.Name = "barcodeHeightLabel"; + this.barcodeHeightLabel.Size = new System.Drawing.Size(38, 13); + this.barcodeHeightLabel.TabIndex = 18; + this.barcodeHeightLabel.Text = "Height"; + // + // barcodeTypeComboBox + // + this.barcodeTypeComboBox.Enabled = false; + this.barcodeTypeComboBox.FormattingEnabled = true; + this.barcodeTypeComboBox.Location = new System.Drawing.Point(120, 112); + this.barcodeTypeComboBox.Name = "barcodeTypeComboBox"; + this.barcodeTypeComboBox.Size = new System.Drawing.Size(130, 21); + this.barcodeTypeComboBox.TabIndex = 19; + // + // barcodeLabel + // + this.barcodeLabel.AutoSize = true; + this.barcodeLabel.Location = new System.Drawing.Point(6, 115); + this.barcodeLabel.Name = "barcodeLabel"; + this.barcodeLabel.Size = new System.Drawing.Size(88, 13); + this.barcodeLabel.TabIndex = 56; + this.barcodeLabel.Text = "Barcode with s/n"; + // + // leftTopLabelTopLabel + // + this.leftTopLabelTopLabel.AutoSize = true; + this.leftTopLabelTopLabel.Location = new System.Drawing.Point(294, 84); + this.leftTopLabelTopLabel.Name = "leftTopLabelTopLabel"; + this.leftTopLabelTopLabel.Size = new System.Drawing.Size(26, 13); + this.leftTopLabelTopLabel.TabIndex = 60; + this.leftTopLabelTopLabel.Text = "Top"; + // + // leftTopLabelTopTextBox + // + this.leftTopLabelTopTextBox.Enabled = false; + this.leftTopLabelTopTextBox.Location = new System.Drawing.Point(320, 80); + this.leftTopLabelTopTextBox.Name = "leftTopLabelTopTextBox"; + this.leftTopLabelTopTextBox.Size = new System.Drawing.Size(31, 20); + this.leftTopLabelTopTextBox.TabIndex = 59; + // + // leftTopLabelLeftTextBox + // + this.leftTopLabelLeftTextBox.Enabled = false; + this.leftTopLabelLeftTextBox.Location = new System.Drawing.Point(261, 80); + this.leftTopLabelLeftTextBox.Name = "leftTopLabelLeftTextBox"; + this.leftTopLabelLeftTextBox.Size = new System.Drawing.Size(31, 20); + this.leftTopLabelLeftTextBox.TabIndex = 58; + // + // leftTopLabelLeftLabel + // + this.leftTopLabelLeftLabel.AutoSize = true; + this.leftTopLabelLeftLabel.Location = new System.Drawing.Point(167, 83); + this.leftTopLabelLeftLabel.Name = "leftTopLabelLeftLabel"; + this.leftTopLabelLeftLabel.Size = new System.Drawing.Size(93, 13); + this.leftTopLabelLeftLabel.TabIndex = 57; + this.leftTopLabelLeftLabel.Text = "Left-Top label Left"; + // + // labelColumnsCountTextBox + // + this.labelColumnsCountTextBox.Enabled = false; + this.labelColumnsCountTextBox.Location = new System.Drawing.Point(122, 80); + this.labelColumnsCountTextBox.Name = "labelColumnsCountTextBox"; + this.labelColumnsCountTextBox.Size = new System.Drawing.Size(32, 20); + this.labelColumnsCountTextBox.TabIndex = 61; + // + // labelColumnsCountLabel + // + this.labelColumnsCountLabel.AutoSize = true; + this.labelColumnsCountLabel.Location = new System.Drawing.Point(9, 83); + this.labelColumnsCountLabel.Name = "labelColumnsCountLabel"; + this.labelColumnsCountLabel.Size = new System.Drawing.Size(105, 13); + this.labelColumnsCountLabel.TabIndex = 62; + this.labelColumnsCountLabel.Text = "Label columns count"; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.templateLabel); + this.groupBox1.Controls.Add(this.templateTextBox); + this.groupBox1.Controls.Add(this.paperWidthLabel); + this.groupBox1.Controls.Add(this.labelWidthTextBox); + this.groupBox1.Controls.Add(this.labelHeightTextBox); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Controls.Add(this.barcodeLabel); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.itemsToPrintButton); + this.groupBox1.Controls.Add(this.barcodeTypeComboBox); + this.groupBox1.Controls.Add(this.bodyFontLabel); + this.groupBox1.Controls.Add(this.barcodeHeightLabel); + this.groupBox1.Controls.Add(this.fontFamilyComboBox); + this.groupBox1.Controls.Add(this.fontSizeTextBox); + this.groupBox1.Controls.Add(this.barcodeHeightTextBox); + this.groupBox1.Controls.Add(this.boldCheckBox); + this.groupBox1.Controls.Add(this.cultureComboBox); + this.groupBox1.Controls.Add(this.italicCheckBox); + this.groupBox1.Controls.Add(this.barcodeWidthLabel); + this.groupBox1.Controls.Add(this.barcodeLeftLabel); + this.groupBox1.Controls.Add(this.cultureLabel); + this.groupBox1.Controls.Add(this.barcodeLeftTextBox); + this.groupBox1.Controls.Add(this.barcodeWidthTextBox); + this.groupBox1.Controls.Add(this.barcodeTopLabel); + this.groupBox1.Controls.Add(this.barcodeTopTextBox); + this.groupBox1.Location = new System.Drawing.Point(3, 127); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(366, 164); + this.groupBox1.TabIndex = 63; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "One label"; + // + // PrinterCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.labelColumnsCountLabel); + this.Controls.Add(this.labelColumnsCountTextBox); + this.Controls.Add(this.leftTopLabelTopLabel); + this.Controls.Add(this.leftTopLabelTopTextBox); + this.Controls.Add(this.leftTopLabelLeftTextBox); + this.Controls.Add(this.leftTopLabelLeftLabel); + this.Controls.Add(this.orientationComboBox); + this.Controls.Add(this.orientationLabel); + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Controls.Add(this.goodOnlyCheckBox); + this.Controls.Add(this.nrOfCopiesLabel); + this.Controls.Add(this.nrOfCopiesTextBox); + this.Name = "PrinterCfgCtrl"; + this.Size = new System.Drawing.Size(372, 299); + this.Load += new System.EventHandler(this.PrinterCfgCtrl_Load); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.Label classNameLabel; + private System.Windows.Forms.Label orientationLabel; + private System.Windows.Forms.ComboBox orientationComboBox; + private System.Windows.Forms.TextBox templateTextBox; + private System.Windows.Forms.Label templateLabel; + private System.Windows.Forms.TextBox labelWidthTextBox; + private System.Windows.Forms.Label paperWidthLabel; + private System.Windows.Forms.TextBox labelHeightTextBox; + private System.Windows.Forms.CheckBox italicCheckBox; + private System.Windows.Forms.CheckBox boldCheckBox; + private System.Windows.Forms.TextBox fontSizeTextBox; + private System.Windows.Forms.ComboBox fontFamilyComboBox; + private System.Windows.Forms.Label bodyFontLabel; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button itemsToPrintButton; + private System.Windows.Forms.Label nrOfCopiesLabel; + private System.Windows.Forms.TextBox nrOfCopiesTextBox; + private System.Windows.Forms.ComboBox cultureComboBox; + private System.Windows.Forms.Label cultureLabel; + private System.Windows.Forms.CheckBox goodOnlyCheckBox; + private System.Windows.Forms.Label barcodeLeftLabel; + private System.Windows.Forms.TextBox barcodeLeftTextBox; + private System.Windows.Forms.TextBox barcodeTopTextBox; + private System.Windows.Forms.Label barcodeTopLabel; + private System.Windows.Forms.TextBox barcodeWidthTextBox; + private System.Windows.Forms.Label barcodeWidthLabel; + private System.Windows.Forms.TextBox barcodeHeightTextBox; + private System.Windows.Forms.Label barcodeHeightLabel; + private System.Windows.Forms.ComboBox barcodeTypeComboBox; + private System.Windows.Forms.Label barcodeLabel; + private System.Windows.Forms.Label leftTopLabelTopLabel; + private System.Windows.Forms.TextBox leftTopLabelTopTextBox; + private System.Windows.Forms.TextBox leftTopLabelLeftTextBox; + private System.Windows.Forms.Label leftTopLabelLeftLabel; + private System.Windows.Forms.TextBox labelColumnsCountTextBox; + private System.Windows.Forms.Label labelColumnsCountLabel; + private System.Windows.Forms.GroupBox groupBox1; + } +} diff --git a/TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfgCtrl.cs b/TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfgCtrl.cs new file mode 100644 index 000000000..bc0f6541e --- /dev/null +++ b/TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfgCtrl.cs @@ -0,0 +1,310 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.IO; +using System.Windows.Forms; +using log4net; +using Config.Entities; +using Results.Output.Printers; +using TBF.BenchControl.Generic; +using TBF.BenchControl.Configs; + +namespace TBF.BenchControl.Output.Printers.MultiLabel +{ + public partial class PrinterCfgCtrl : ConfigCtrlUtils, IComponentCfgCtrl + { + static readonly ILog log = LogManager.GetLogger(typeof(PrinterCfgCtrl)); + + public bool ShowMore { get { return false; } } + + PrinterCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as PrinterCfg; + Redraw(); + } + } + + string[] itemsToPrint; + + public PrinterCfgCtrl() + { + InitializeComponent(); + Localize(); + + orientationComboBox.Items.Add(PageOrientation.Portrait.ToString()); + orientationComboBox.Items.Add(PageOrientation.Landscape.ToString()); + + foreach (var ff in System.Drawing.FontFamily.Families) + { + fontFamilyComboBox.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) + { + for (Culture s = 0; s < Culture.Count; s++) cultureComboBox.Items.Add(s.ToString()); + + itemsToPrint = config.ItemsToPrint; + + Redraw(); + } + + void Localize() + { + } + + public void Closing() + { + } + + void Redraw() + { + if (config == null) return; /// Control was not loaded, settings were not changed + classNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + orientationComboBox.Text = config.PageOrientation.ToString(); + labelColumnsCountTextBox.Text = config.LabelColumnsCount.ToString(); + leftTopLabelLeftTextBox.Text = config.LeftTopLabelLeft.ToString(); + leftTopLabelTopTextBox.Text = config.LeftTopLabelTop.ToString(); + nrOfCopiesTextBox.Text = config.NrOfCopies.ToString(); + goodOnlyCheckBox.Checked = config.GoodOnly; + + labelWidthTextBox.Text = config.LabelWidth.ToString(); + labelHeightTextBox.Text = config.LabelHeight.ToString(); + templateTextBox.Text = config.Template; + fontFamilyComboBox.Text = config.FontFamily; + fontSizeTextBox.Text = config.FontSize.ToString(); + boldCheckBox.Checked = ((config.FontStyle & (int)System.Drawing.FontStyle.Bold) != 0); + italicCheckBox.Checked = ((config.FontStyle & (int)System.Drawing.FontStyle.Italic) != 0); + cultureComboBox.Text = config.Culture.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() + { + nameTextBox.Enabled = true; + orientationComboBox.Enabled = true; + labelColumnsCountTextBox.Enabled = true; + leftTopLabelLeftTextBox.Enabled = true; + leftTopLabelTopTextBox.Enabled = true; + nrOfCopiesTextBox.Enabled = true; + goodOnlyCheckBox.Enabled = true; + + itemsToPrintButton.Enabled = true; + labelWidthTextBox.Enabled = true; + labelHeightTextBox.Enabled = true; + templateTextBox.Enabled = true; + fontFamilyComboBox.Enabled = true; + fontSizeTextBox.Enabled = true; + boldCheckBox.Enabled = true; + italicCheckBox.Enabled = true; + cultureComboBox.Enabled = true; + + barcodeTypeComboBox.Enabled = true; + barcodeLeftTextBox.Enabled = true; + barcodeTopTextBox.Enabled = true; + barcodeWidthTextBox.Enabled = true; + barcodeHeightTextBox.Enabled = true; + } + + public CfgUpdateFlags VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + + if (!string.IsNullOrEmpty(templateTextBox.Text) && !File.Exists(Path.Combine("C:\\TBF\\Templates", templateTextBox.Text))) + { + message += Environment.NewLine + "Template file missing"; + flags |= CfgUpdateFlags.Error; + } + + if ((int)GetOrientation(orientationComboBox.Text) < 0) + { + message += Environment.NewLine + "Invalid page orientation"; + flags |= CfgUpdateFlags.Error; + } + + int dummy; + if (!int.TryParse(labelColumnsCountTextBox.Text, out dummy) || dummy < 1) + { + message += Environment.NewLine + "Invalid label columns count"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(leftTopLabelLeftTextBox.Text, out dummy) || dummy < 0) + { + message += Environment.NewLine + "Invalid left-top label left"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(leftTopLabelTopTextBox.Text, out dummy) || dummy < 0) + { + message += Environment.NewLine + "Invalid left-top label top"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(labelWidthTextBox.Text, out dummy) || dummy <= 0) + { + message += Environment.NewLine + "Invalid label width"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(labelHeightTextBox.Text, out dummy) || dummy <= 0) + { + message += Environment.NewLine + "Invalid label height"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(fontSizeTextBox.Text, out dummy) || dummy < 6 || dummy > 48) + { + message += Environment.NewLine + "Font size' should be between 6 and 48"; + flags |= CfgUpdateFlags.Error; + } + if (!cultureComboBox.Items.Contains(cultureComboBox.Text)) + { + message += Environment.NewLine + "Invalid culture"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(nrOfCopiesTextBox.Text, out dummy) || dummy < 0 || dummy > 9) + { + message += Environment.NewLine + "'Number of copies' should be between 0 and 9"; + 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; + } + + public CfgUpdateFlags UpdateCfg() + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + + if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed + + + if (config.Name != nameTextBox.Text) + { + config.Name = nameTextBox.Text; + flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange); + } + + if (config.PageOrientation != GetOrientation(orientationComboBox.Text)) + { + config.PageOrientation = GetOrientation(orientationComboBox.Text); + flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + } + flags |= UpdateDifferent(ref config.LabelColumnsCount, labelColumnsCountTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.LeftTopLabelLeft, leftTopLabelLeftTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.LeftTopLabelTop, leftTopLabelTopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.NrOfCopies, nrOfCopiesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.GoodOnly, goodOnlyCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + + flags |= UpdateDifferent(ref config.ItemsToPrint, itemsToPrint, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.LabelWidth, labelWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.LabelHeight, labelHeightTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.Template, templateTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + + + /// Body font properties + flags |= UpdateDifferent(ref config.FontFamily, fontFamilyComboBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.FontSize, int.Parse(fontSizeTextBox.Text), CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + int tmp = (boldCheckBox.Checked ? (int)System.Drawing.FontStyle.Bold : 0) + + (italicCheckBox.Checked ? (int)System.Drawing.FontStyle.Italic : 0); + flags |= UpdateDifferent(ref config.FontStyle, tmp, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + + for (Culture i = 0; i < Culture.Count; i++) + { + if (i.ToString().Equals(cultureComboBox.Text) && (config.Culture != i)) + { + config.Culture = i; + flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + break; + } + } + + 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)); + } + + return flags; + } + + private void itemsToPrintButton_Click(object sender, EventArgs e) + { + Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg() + { + SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(itemsToPrint), + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + itemsToPrint = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems); + } + } + + #region Configuration Change Handling + + public static void OnCmdResponse(object sender, CmdResponseArgs args) + { + if (CmdResponseHandler == null) return; + try { CmdResponseHandler(sender, args); } + catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); } + } + + public static event EventHandler CmdResponseHandler; + + public void StartResponseHandler() { } + public void StopResponseHandler() { } + + #endregion Configuration Change Handling + } +} diff --git a/TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfgCtrl.resx b/TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TBF/BenchControl/Output/Printers/MultiLabel/PrinterCfgCtrl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TBF/BenchControl/TbfComponents.cs b/TBF/BenchControl/TbfComponents.cs index 5bf3c736b..75d245ca4 100644 --- a/TBF/BenchControl/TbfComponents.cs +++ b/TBF/BenchControl/TbfComponents.cs @@ -148,7 +148,8 @@ namespace TBF.BenchControl Factories.Add(new Output.Printers.Enhanced.FactorySingle()); Factories.Add(new Output.Printers.Enhanced.FactoryCompound()); Factories.Add(new Output.Printers.Enhanced.FactoryHeatMeters()); - Factories.Add(new Output.Printers.Label.Factory()); /// Label printer + Factories.Add(new Output.Printers.Label.Factory()); + Factories.Add(new Output.Printers.MultiLabel.Factory()); Factories.Add(new Output.Printers.Munich.PrinterFactory()); Factories.Add(new Output.Printers.OnePerMeter.FactorySingle()); Factories.Add(new Output.Printers.OnePerMeter.FactoryCompound()); diff --git a/TBF/Program.cs b/TBF/Program.cs index 239b5e42b..91324aac1 100644 --- a/TBF/Program.cs +++ b/TBF/Program.cs @@ -180,8 +180,9 @@ namespace TBF try { - string culture = LocalSettings.Language.Replace('_', '-'); - System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culture); + System.Threading.Thread.CurrentThread.CurrentUICulture + = System.Threading.Thread.CurrentThread.CurrentCulture + = new System.Globalization.CultureInfo(LocalSettings.Language.Replace('_', '-')); } catch (Exception e) { diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 494fde1b8..ee10e61ce 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.18.1426.0")] -[assembly: AssemblyFileVersion("2.18.1426.0")] +[assembly: AssemblyVersion("2.18.1428.0")] +[assembly: AssemblyFileVersion("2.18.1428.0")] diff --git a/TBF/Resources/Strings.ro.resx b/TBF/Resources/Strings.ro.resx index 2102d6c9d..16370b04b 100644 --- a/TBF/Resources/Strings.ro.resx +++ b/TBF/Resources/Strings.ro.resx @@ -834,4 +834,7 @@ Evaporare + + Alimentare + \ No newline at end of file diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index da67e3f62..538179b64 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -990,6 +990,15 @@ PrinterCfgCtrl.cs + + + + + UserControl + + + PrinterCfgCtrl.cs + @@ -2811,6 +2820,9 @@ PrinterCfgCtrl.cs + + PrinterCfgCtrl.cs + PrinterCfgCtrl.cs