Output.Printers.Label.Printer re-implemented using a configurable list of items, ver. 2.18.1109

This commit is contained in:
Milan Hanajik
2019-01-13 16:34:38 +02:00
parent 58f046ca34
commit d3ca871eb5
17 changed files with 906 additions and 405 deletions
@@ -0,0 +1,98 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using Config.Entities;
using Results.Resources;
namespace Results.Output.Printers.Label
{
public class LabelPrintDocument : PrintersCommon
{
/// Size of the printed area without margins, after taking into account 'pageOrientation'
readonly int printHeight;
readonly int printWidth;
/// Selected font
readonly Font font;
/// Data to print
Results.Entities.Batch batch;
LabelPrinterCfg cfg;
Results.Entities.WaterMeter wm;
/// Items to print
IList<WMeterRsltItemSpec> itemsToPrint;
/// <summary>
/// Constructor
/// </summary>
/// <param name="textToPrint">Text to be printed</param>
public LabelPrintDocument(Results.Entities.Batch batch, LabelPrinterCfg cfg, Results.Entities.WaterMeter wm, string documentName)
{
DocumentName = documentName;
this.batch = batch;
this.cfg = cfg;
this.wm = wm;
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);
///
printHeight = cfg.PaperHeight;
printWidth = cfg.PaperWidth;
}
/// <summary>
/// Override the default onbeginPrint method of the PrintDocument Object
/// </summary>
/// <param name=e></param>
/// <remarks></remarks>
protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e)
{
base.OnBeginPrint(e);
}
/// <summary>
/// Override the default OnPrintPage method of the PrintDocument.
/// </summary>
/// <param name=e></param>
/// <remarks>This provides the print logic for our document</remarks>
protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
{
/// Run base code
base.OnPrintPage(e);
if (!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), printWidth, printHeight), new Rectangle(0, 0, printWidth, printHeight));
}
}
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(x, y, printWidth, printHeight);
e.Graphics.DrawString(item.Print(wm), this.font, Brushes.Black, printArea);
}
}
}
}
}
@@ -0,0 +1,21 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
namespace Results.Output.Printers.Label
{
public class LabelPrinterCfg
{
public string Template; /// Full path to a 'png' file
public Config.Entities.PageOrientation PageOrientation;
public int PaperWidth; /// In 0,254 mm = 1/100 in = 100dpi pixels count
public int PaperHeight; /// In 0,254 mm = 1/100 in = 100dpi pixels count
public string[] ItemsToPrint;
public string FontFamily;
public int FontSize;
public int FontStyle;
public System.Globalization.CultureInfo CultureInfo;
public bool GoodOnly;
public bool SupressPrinting; /// true = Bypass printing
}
}
+2 -2
View File
@@ -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.1093.0")]
[assembly: AssemblyFileVersion("2.18.1093.0")]
[assembly: AssemblyVersion("2.18.1109.0")]
[assembly: AssemblyFileVersion("2.18.1109.0")]
+4
View File
@@ -104,6 +104,10 @@
<SubType>Component</SubType>
</Compile>
<Compile Include="Output\Printers\Enhanced\EnhancedPrinterCfg.cs" />
<Compile Include="Output\Printers\Label\LabelPrintDocument.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Output\Printers\Label\LabelPrinterCfg.cs" />
<Compile Include="Output\Printers\PrintersCommon.cs">
<SubType>Component</SubType>
</Compile>
@@ -32,8 +32,8 @@ namespace TBF.BenchControl.Output.Printers.Enhanced
public int FooterFntSz;
public int TitFntSty;
public int HdrFntSty;
public int BodyFntSty;
public int FooterFntSty;
public int BodyFntSty;
public int FooterFntSty;
public bool GoodOnly;
public bool SupressPrinting; /// Bypass printing when true
public Culture Culture;
@@ -4,9 +4,9 @@
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Output.Printers.LabelPrinter
namespace TBF.BenchControl.Output.Printers.Label
{
public class PrinterFactory : IComponentFactory
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
@@ -9,7 +9,7 @@ using System.IO;
using Config.Entities;
using TBF.Resources;
namespace TBF.BenchControl.Output.Printers.LabelPrinter
namespace TBF.BenchControl.Output.Printers.Label
{
public class PrintLabelDocument : PrintDocument
{
@@ -0,0 +1,159 @@
///
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using System.Globalization;
using System.Threading;
using Results.Output.Printers.Label;
namespace TBF.BenchControl.Output.Printers.Label
{
public class Printer : ComponentBase, IOperation, GenericDevices.IResultsPrinter
{
private static readonly ILog log = LogManager.GetLogger(typeof(Printer));
public override string ToString() { return string.Format("LabelPrinter({0})", Cfg.ToString(1)); }
readonly PrinterCfg printerCfg;
public bool SupressPrinting { get { return printerCfg.SupressPrinting; } }
/// <summary> Data to print </summary>
Results.Entities.Batch batch;
///
/// Items to print
///
IList<Results.WMeterRsltItemSpec> 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<CfgChangeArgs> 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.Template = newCfg.Template;
printerCfg.PageOrientation = newCfg.PageOrientation;
printerCfg.PaperWidth = newCfg.PaperWidth;
printerCfg.PaperHeight = newCfg.PaperHeight;
printerCfg.ItemsToPrint = newCfg.ItemsToPrint;
printerCfg.FontFamily = newCfg.FontFamily;
printerCfg.FontSize = newCfg.FontSize;
printerCfg.FontStyle = newCfg.FontStyle;
printerCfg.Culture = newCfg.Culture;
printerCfg.NrOfCopies = newCfg.NrOfCopies;
printerCfg.GoodOnly = newCfg.GoodOnly;
printerCfg.SupressPrinting = newCfg.SupressPrinting;
ApplyConfig();
}
}
};
}
#endregion Configuration Change Handling
/// <summary>
/// Prints the test cycle results, Events: Event.ResultsPrinted
/// </summary>
/// <param name="batch">Batch results to print</param>
/// <returns>Reference to the operation</returns>
public IOperation PrintResultsOp(Results.Entities.Batch batch)
{
this.batch = batch;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
foreach (var wm in batch.WaterMeters)
{
if (wm != null && (!printerCfg.GoodOnly || wm.Passed))
{
PrintResults(batch, wm, string.Format("{0}-{1}", batch.BatchNr, wm.WMPosition));
}
}
Thread.CurrentThread.CurrentCulture = oriCulture;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
return Event.ResultsPrinted;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
void PrintResults(Results.Entities.Batch batch, Results.Entities.WaterMeter wm, string documentName)
{
LabelPrinterCfg cfg = new LabelPrinterCfg
{
Template = printerCfg.Template,
PageOrientation = printerCfg.PageOrientation,
PaperWidth = printerCfg.PaperWidth,
PaperHeight = printerCfg.PaperHeight,
ItemsToPrint = printerCfg.ItemsToPrint,
FontFamily = printerCfg.FontFamily,
FontSize = printerCfg.FontSize,
FontStyle = printerCfg.FontStyle,
CultureInfo = (printerCfg.Culture == Culture.system) ? Thread.CurrentThread.CurrentCulture : new CultureInfo(printerCfg.Culture.ToString()),
GoodOnly = printerCfg.GoodOnly,
SupressPrinting = printerCfg.SupressPrinting,
};
for (int i = 1; i <= printerCfg.NrOfCopies; i++)
{
string docNameEx = string.Format(((printerCfg.NrOfCopies == 1) ? "{0}" : "{0}_{1}"), documentName, i);
new Results.Output.Printers.Label.LabelPrintDocument(batch, cfg, wm, docNameEx).Print();
}
}
}
}
@@ -8,7 +8,7 @@ using System.Xml.Serialization;
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Output.Printers.LabelPrinter
namespace TBF.BenchControl.Output.Printers.Label
{
public class PrinterCfg : ComponentCfgBase, Generic.IComponentCfg
{
@@ -20,10 +20,17 @@ namespace TBF.BenchControl.Output.Printers.LabelPrinter
///
/// Serialized parameters
///
public string Template; /// Full path to a 'png' file
public PageOrientation PageOrientation;
public int PaperWidth; /// In 0,254 mm = 1/100 in = 100dpi pixels count
public int PaperHeight; /// In 0,254 mm = 1/100 in = 100dpi pixels count
public string TemplateFile; /// Full path to a 'png' file
public string[] ItemsToPrint;
public string FontFamily;
public int FontSize;
public int FontStyle;
public Culture Culture;
public int NrOfCopies;
public bool GoodOnly;
public bool SupressPrinting; /// true = Bypass printing
/// Private parameterless constructor invoked by all other (public) constructors
@@ -37,21 +44,28 @@ namespace TBF.BenchControl.Output.Printers.LabelPrinter
this.Name = name;
this.Factory = factory;
ParentName = string.Empty;
PageOrientation = PageOrientation.Portrait;
Template = string.Empty;
PageOrientation = PageOrientation.Portrait;
PaperWidth = 827; /// A4 width
PaperHeight = 1169; /// A4 height
TemplateFile = "C:\\TBF\\Templates\\Label.png";
SupressPrinting = false;
FontFamily = "Arial";
FontSize = 10;
FontStyle = 0;
NrOfCopies = 1;
GoodOnly = false;
SupressPrinting = false;
}
public string ToString(int i)
{
return string.Format("Name={0}, Orientation={1}, PaperWidth={2}, PaperHeight={3}, TemplateFile={4}, SupressPrinting={5}",
return string.Format("Name={0}, Orientation={1}, PaperWidth={2}, PaperHeight={3}, TemplateFile={4}, GoodOnly={5}, SupressPrinting={6}",
Name,
PageOrientation,
PaperWidth,
PaperHeight,
TemplateFile,
Template,
GoodOnly ? "yes" : "no",
SupressPrinting ? "yes" : "no"
);
}
@@ -0,0 +1,355 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
///
namespace TBF.BenchControl.Output.Printers.Label
{
partial class PrinterCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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.supressPrintingCheckBox = new System.Windows.Forms.CheckBox();
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.paperWidthTextBox = new System.Windows.Forms.TextBox();
this.paperWidthLabel = new System.Windows.Forms.Label();
this.paperHeightTextBox = new System.Windows.Forms.TextBox();
this.paperHeightLabel = new System.Windows.Forms.Label();
this.italicCheckBox = new System.Windows.Forms.CheckBox();
this.boldCheckBox = new System.Windows.Forms.CheckBox();
this.fontSizeTextBox = new System.Windows.Forms.TextBox();
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.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";
//
// supressPrintingCheckBox
//
this.supressPrintingCheckBox.AutoSize = true;
this.supressPrintingCheckBox.Enabled = false;
this.supressPrintingCheckBox.Location = new System.Drawing.Point(122, 283);
this.supressPrintingCheckBox.Name = "supressPrintingCheckBox";
this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17);
this.supressPrintingCheckBox.TabIndex = 11;
this.supressPrintingCheckBox.Text = "Supress printing";
this.supressPrintingCheckBox.UseVisualStyleBackColor = true;
//
// orientationLabel
//
this.orientationLabel.AutoSize = true;
this.orientationLabel.Location = new System.Drawing.Point(8, 84);
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, 81);
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(122, 58);
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(8, 61);
this.templateLabel.Name = "templateLabel";
this.templateLabel.Size = new System.Drawing.Size(67, 13);
this.templateLabel.TabIndex = 9;
this.templateLabel.Text = "Template file";
//
// paperWidthTextBox
//
this.paperWidthTextBox.Enabled = false;
this.paperWidthTextBox.Location = new System.Drawing.Point(122, 105);
this.paperWidthTextBox.Name = "paperWidthTextBox";
this.paperWidthTextBox.Size = new System.Drawing.Size(51, 20);
this.paperWidthTextBox.TabIndex = 6;
//
// paperWidthLabel
//
this.paperWidthLabel.AutoSize = true;
this.paperWidthLabel.Location = new System.Drawing.Point(8, 108);
this.paperWidthLabel.Name = "paperWidthLabel";
this.paperWidthLabel.Size = new System.Drawing.Size(63, 13);
this.paperWidthLabel.TabIndex = 5;
this.paperWidthLabel.Text = "Paper width";
//
// paperHeightTextBox
//
this.paperHeightTextBox.Enabled = false;
this.paperHeightTextBox.Location = new System.Drawing.Point(122, 128);
this.paperHeightTextBox.Name = "paperHeightTextBox";
this.paperHeightTextBox.Size = new System.Drawing.Size(51, 20);
this.paperHeightTextBox.TabIndex = 8;
//
// paperHeightLabel
//
this.paperHeightLabel.AutoSize = true;
this.paperHeightLabel.Location = new System.Drawing.Point(8, 131);
this.paperHeightLabel.Name = "paperHeightLabel";
this.paperHeightLabel.Size = new System.Drawing.Size(67, 13);
this.paperHeightLabel.TabIndex = 7;
this.paperHeightLabel.Text = "Paper height";
//
// bodyItalicCheckBox
//
this.italicCheckBox.AutoSize = true;
this.italicCheckBox.Enabled = false;
this.italicCheckBox.Location = new System.Drawing.Point(335, 190);
this.italicCheckBox.Name = "bodyItalicCheckBox";
this.italicCheckBox.Size = new System.Drawing.Size(15, 14);
this.italicCheckBox.TabIndex = 47;
this.italicCheckBox.UseVisualStyleBackColor = true;
//
// bodyBoldCheckBox
//
this.boldCheckBox.AutoSize = true;
this.boldCheckBox.Enabled = false;
this.boldCheckBox.Location = new System.Drawing.Point(307, 190);
this.boldCheckBox.Name = "bodyBoldCheckBox";
this.boldCheckBox.Size = new System.Drawing.Size(15, 14);
this.boldCheckBox.TabIndex = 46;
this.boldCheckBox.UseVisualStyleBackColor = true;
//
// bodyFontSizeTextBox
//
this.fontSizeTextBox.Enabled = false;
this.fontSizeTextBox.Location = new System.Drawing.Point(259, 184);
this.fontSizeTextBox.Name = "bodyFontSizeTextBox";
this.fontSizeTextBox.Size = new System.Drawing.Size(29, 20);
this.fontSizeTextBox.TabIndex = 45;
//
// bodyFontFamilyComboBox
//
this.fontFamilyComboBox.Enabled = false;
this.fontFamilyComboBox.FormattingEnabled = true;
this.fontFamilyComboBox.Location = new System.Drawing.Point(122, 184);
this.fontFamilyComboBox.Name = "bodyFontFamilyComboBox";
this.fontFamilyComboBox.Size = new System.Drawing.Size(130, 21);
this.fontFamilyComboBox.TabIndex = 44;
//
// bodyFontLabel
//
this.bodyFontLabel.AutoSize = true;
this.bodyFontLabel.Location = new System.Drawing.Point(8, 187);
this.bodyFontLabel.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(331, 175);
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(297, 175);
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(121, 154);
this.itemsToPrintButton.Name = "itemsToPrintButton";
this.itemsToPrintButton.Size = new System.Drawing.Size(132, 23);
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, 235);
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, 232);
this.nrOfCopiesTextBox.Name = "nrOfCopiesTextBox";
this.nrOfCopiesTextBox.Size = new System.Drawing.Size(51, 20);
this.nrOfCopiesTextBox.TabIndex = 51;
//
// cultureComboBox
//
this.cultureComboBox.Enabled = false;
this.cultureComboBox.FormattingEnabled = true;
this.cultureComboBox.Location = new System.Drawing.Point(122, 208);
this.cultureComboBox.Name = "cultureComboBox";
this.cultureComboBox.Size = new System.Drawing.Size(218, 21);
this.cultureComboBox.TabIndex = 54;
//
// cultureLabel
//
this.cultureLabel.AutoSize = true;
this.cultureLabel.Location = new System.Drawing.Point(8, 211);
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(122, 262);
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;
//
// PrinterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.goodOnlyCheckBox);
this.Controls.Add(this.cultureComboBox);
this.Controls.Add(this.cultureLabel);
this.Controls.Add(this.nrOfCopiesLabel);
this.Controls.Add(this.nrOfCopiesTextBox);
this.Controls.Add(this.itemsToPrintButton);
this.Controls.Add(this.italicCheckBox);
this.Controls.Add(this.boldCheckBox);
this.Controls.Add(this.fontSizeTextBox);
this.Controls.Add(this.fontFamilyComboBox);
this.Controls.Add(this.bodyFontLabel);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.paperHeightTextBox);
this.Controls.Add(this.paperHeightLabel);
this.Controls.Add(this.paperWidthTextBox);
this.Controls.Add(this.paperWidthLabel);
this.Controls.Add(this.templateTextBox);
this.Controls.Add(this.templateLabel);
this.Controls.Add(this.orientationComboBox);
this.Controls.Add(this.orientationLabel);
this.Controls.Add(this.supressPrintingCheckBox);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "PrinterCfgCtrl";
this.Size = new System.Drawing.Size(372, 327);
this.Load += new System.EventHandler(this.PrinterCfgCtrl_Load);
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.CheckBox supressPrintingCheckBox;
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 paperWidthTextBox;
private System.Windows.Forms.Label paperWidthLabel;
private System.Windows.Forms.TextBox paperHeightTextBox;
private System.Windows.Forms.Label paperHeightLabel;
private System.Windows.Forms.CheckBox italicCheckBox;
private System.Windows.Forms.CheckBox boldCheckBox;
private System.Windows.Forms.TextBox fontSizeTextBox;
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;
}
}
@@ -0,0 +1,233 @@
///
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.BenchControl.Configs;
namespace TBF.BenchControl.Output.Printers.Label
{
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);
}
}
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;
templateTextBox.Text = config.Template;
orientationComboBox.Text = config.PageOrientation.ToString();
paperWidthTextBox.Text = config.PaperWidth.ToString();
paperHeightTextBox.Text = config.PaperHeight.ToString();
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();
nrOfCopiesTextBox.Text = config.NrOfCopies.ToString();
goodOnlyCheckBox.Checked = config.GoodOnly;
supressPrintingCheckBox.Checked = config.SupressPrinting;
}
public void Unlock()
{
nameTextBox.Enabled = true;
templateTextBox.Enabled = true;
orientationComboBox.Enabled = true;
paperWidthTextBox.Enabled = true;
paperHeightTextBox.Enabled = true;
itemsToPrintButton.Enabled = true;
fontFamilyComboBox.Enabled = true;
fontSizeTextBox.Enabled = true;
boldCheckBox.Enabled = true;
italicCheckBox.Enabled = true;
cultureComboBox.Enabled = true;
nrOfCopiesTextBox.Enabled = true;
goodOnlyCheckBox.Enabled = true;
supressPrintingCheckBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (!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(paperWidthTextBox.Text, out dummy) || dummy <= 0)
{
message += Environment.NewLine + "Invalid paper width";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(paperHeightTextBox.Text, out dummy) || dummy <= 0)
{
message += Environment.NewLine + "Invalid paper 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;
}
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);
}
flags |= UpdateDifferent(ref config.Template, templateTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
if (config.PageOrientation != GetOrientation(orientationComboBox.Text))
{
config.PageOrientation = GetOrientation(orientationComboBox.Text);
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
flags |= UpdateDifferent(ref config.PaperWidth, paperWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.PaperHeight, paperHeightTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.ItemsToPrint, itemsToPrint, 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;
}
}
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.SupressPrinting, supressPrintingCheckBox.Checked, 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<CmdResponseArgs> CmdResponseHandler;
public void StartResponseHandler() { }
public void StopResponseHandler() { }
#endregion Configuration Change Handling
}
}
@@ -1,67 +0,0 @@
///
/// Copyright (c) 2015-2016 Sensus Metering Systems
///
using log4net;
namespace TBF.BenchControl.Output.Printers.LabelPrinter
{
public class Printer : ComponentBase, IOperation, GenericDevices.IResultsPrinter
{
private static readonly ILog log = LogManager.GetLogger(typeof(Printer));
public override string ToString() { return string.Format("LabelPrinter({0})", Cfg.ToString(1)); }
readonly PrinterCfg printerCfg;
public bool SupressPrinting { get { return printerCfg.SupressPrinting; } }
/// <summary> Data to print </summary>
Results.Entities.Batch batch;
public Printer() { }
public Printer(Generic.IComponentCfg cfg)
: base(cfg)
{
printerCfg = cfg as PrinterCfg;
log.Debug(this.ToString());
}
/// <summary>
/// Prints the test cycle results, Events: Event.ResultsPrinted
/// </summary>
/// <param name="batch">Batch results to print</param>
/// <returns>Reference to the operation</returns>
public IOperation PrintResultsOp(Results.Entities.Batch batch)
{
this.batch = batch;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
if (batch.WaterMeters.Count > 0)
{
new PrintLabelDocument(batch,
printerCfg.PageOrientation,
printerCfg.PaperWidth,
printerCfg.PaperHeight,
printerCfg.TemplateFile).Print();
}
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
return Event.ResultsPrinted;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
}
}
@@ -1,193 +0,0 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
///
namespace TBF.BenchControl.Output.Printers.LabelPrinter
{
partial class PrinterCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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.supressPrintingCheckBox = new System.Windows.Forms.CheckBox();
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.paperWidthTextBox = new System.Windows.Forms.TextBox();
this.paperWidthLabel = new System.Windows.Forms.Label();
this.paperHeightTextBox = new System.Windows.Forms.TextBox();
this.paperHeightLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(98, 30);
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, 33);
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(95, 6);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// supressPrintingCheckBox
//
this.supressPrintingCheckBox.AutoSize = true;
this.supressPrintingCheckBox.Enabled = false;
this.supressPrintingCheckBox.Location = new System.Drawing.Point(98, 164);
this.supressPrintingCheckBox.Name = "supressPrintingCheckBox";
this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17);
this.supressPrintingCheckBox.TabIndex = 11;
this.supressPrintingCheckBox.Text = "Supress printing";
this.supressPrintingCheckBox.UseVisualStyleBackColor = true;
//
// orientationLabel
//
this.orientationLabel.AutoSize = true;
this.orientationLabel.Location = new System.Drawing.Point(8, 59);
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(98, 56);
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(98, 135);
this.templateTextBox.Name = "templateTextBox";
this.templateTextBox.Size = new System.Drawing.Size(187, 20);
this.templateTextBox.TabIndex = 10;
//
// templateLabel
//
this.templateLabel.AutoSize = true;
this.templateLabel.Location = new System.Drawing.Point(8, 138);
this.templateLabel.Name = "templateLabel";
this.templateLabel.Size = new System.Drawing.Size(67, 13);
this.templateLabel.TabIndex = 9;
this.templateLabel.Text = "Template file";
//
// paperWidthTextBox
//
this.paperWidthTextBox.Enabled = false;
this.paperWidthTextBox.Location = new System.Drawing.Point(98, 83);
this.paperWidthTextBox.Name = "paperWidthTextBox";
this.paperWidthTextBox.Size = new System.Drawing.Size(51, 20);
this.paperWidthTextBox.TabIndex = 6;
//
// paperWidthLabel
//
this.paperWidthLabel.AutoSize = true;
this.paperWidthLabel.Location = new System.Drawing.Point(8, 86);
this.paperWidthLabel.Name = "paperWidthLabel";
this.paperWidthLabel.Size = new System.Drawing.Size(63, 13);
this.paperWidthLabel.TabIndex = 5;
this.paperWidthLabel.Text = "Paper width";
//
// paperHeightTextBox
//
this.paperHeightTextBox.Enabled = false;
this.paperHeightTextBox.Location = new System.Drawing.Point(98, 109);
this.paperHeightTextBox.Name = "paperHeightTextBox";
this.paperHeightTextBox.Size = new System.Drawing.Size(51, 20);
this.paperHeightTextBox.TabIndex = 8;
//
// paperHeightLabel
//
this.paperHeightLabel.AutoSize = true;
this.paperHeightLabel.Location = new System.Drawing.Point(8, 112);
this.paperHeightLabel.Name = "paperHeightLabel";
this.paperHeightLabel.Size = new System.Drawing.Size(67, 13);
this.paperHeightLabel.TabIndex = 7;
this.paperHeightLabel.Text = "Paper height";
//
// PrinterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.paperHeightTextBox);
this.Controls.Add(this.paperHeightLabel);
this.Controls.Add(this.paperWidthTextBox);
this.Controls.Add(this.paperWidthLabel);
this.Controls.Add(this.templateTextBox);
this.Controls.Add(this.templateLabel);
this.Controls.Add(this.orientationComboBox);
this.Controls.Add(this.orientationLabel);
this.Controls.Add(this.supressPrintingCheckBox);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "PrinterCfgCtrl";
this.Size = new System.Drawing.Size(300, 200);
this.Load += new System.EventHandler(this.PrinterCfgCtrl_Load);
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.CheckBox supressPrintingCheckBox;
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 paperWidthTextBox;
private System.Windows.Forms.Label paperWidthLabel;
private System.Windows.Forms.TextBox paperHeightTextBox;
private System.Windows.Forms.Label paperHeightLabel;
}
}
@@ -1,123 +0,0 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
///
using System;
using System.IO;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Output.Printers.LabelPrinter
{
public partial class PrinterCfgCtrl : UserControl, 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();
}
}
public PrinterCfgCtrl()
{
InitializeComponent();
orientationComboBox.Items.Add(PageOrientation.Portrait.ToString());
orientationComboBox.Items.Add(PageOrientation.Landscape.ToString());
}
private void PrinterCfgCtrl_Load(object sender, EventArgs e)
{
Redraw();
}
public void Closing()
{
}
PageOrientation GetOrientation(string str)
{
if (str.Equals(PageOrientation.Landscape.ToString())) return PageOrientation.Landscape;
if (str.Equals(PageOrientation.Portrait.ToString())) return PageOrientation.Portrait;
return (PageOrientation)(-1);
}
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();
paperWidthTextBox.Text = config.PaperWidth.ToString();
paperHeightTextBox.Text = config.PaperHeight.ToString();
templateTextBox.Text = config.TemplateFile;
supressPrintingCheckBox.Checked = config.SupressPrinting;
}
public void Unlock()
{
nameTextBox.Enabled = true;
orientationComboBox.Enabled = true;
paperWidthTextBox.Enabled = true;
paperHeightTextBox.Enabled = true;
templateTextBox.Enabled = true;
supressPrintingCheckBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if ((int)GetOrientation(orientationComboBox.Text) < 0)
{
message += Environment.NewLine + "Invalid page orientation";
flags |= CfgUpdateFlags.Error;
}
int dummy;
if (!int.TryParse(paperWidthTextBox.Text, out dummy) || dummy <= 0)
{
message += Environment.NewLine + "Invalid paper width";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(paperHeightTextBox.Text, out dummy) || dummy <= 0)
{
message += Environment.NewLine + "Invalid paper height";
flags |= CfgUpdateFlags.Error;
}
if (!File.Exists(config.TemplateFile))
{
message += Environment.NewLine + "Template file missing";
flags |= CfgUpdateFlags.Error;
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
config.Name = nameTextBox.Text;
config.PageOrientation = GetOrientation(orientationComboBox.Text);
config.PaperWidth = int.Parse(paperWidthTextBox.Text);
config.PaperHeight = int.Parse(paperHeightTextBox.Text);
config.TemplateFile = templateTextBox.Text;
config.SupressPrinting = supressPrintingCheckBox.Checked;
return flags;
}
}
}
+1 -1
View File
@@ -133,7 +133,7 @@ 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.LabelPrinter.PrinterFactory()); /// LabelPrinter
Factories.Add(new Output.Printers.Label.Factory()); /// Label printer
Factories.Add(new Output.Printers.Munich.PrinterFactory());
Factories.Add(new Output.Printers.OnePerMeter.FactorySingle());
Factories.Add(new Output.Printers.OnePerMeter.FactoryCompound());
+7 -7
View File
@@ -865,16 +865,16 @@
<DependentUpon>PrinterCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\Output\Printers\Enhanced\FactorySingle.cs" />
<Compile Include="BenchControl\Output\Printers\LabelPrinter\Printer.cs" />
<Compile Include="BenchControl\Output\Printers\LabelPrinter\PrinterCfg.cs" />
<Compile Include="BenchControl\Output\Printers\LabelPrinter\PrinterCfgCtrl.cs">
<Compile Include="BenchControl\Output\Printers\Label\Printer.cs" />
<Compile Include="BenchControl\Output\Printers\Label\PrinterCfg.cs" />
<Compile Include="BenchControl\Output\Printers\Label\PrinterCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="BenchControl\Output\Printers\LabelPrinter\PrinterCfgCtrl.designer.cs">
<Compile Include="BenchControl\Output\Printers\Label\PrinterCfgCtrl.designer.cs">
<DependentUpon>PrinterCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\Output\Printers\LabelPrinter\PrinterFactory.cs" />
<Compile Include="BenchControl\Output\Printers\LabelPrinter\PrintLabelDocument.cs">
<Compile Include="BenchControl\Output\Printers\Label\Factory.cs" />
<Compile Include="BenchControl\Output\Printers\Label\PrintLabelDocument.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BenchControl\Output\Printers\Munich\Printer.cs" />
@@ -2549,7 +2549,7 @@
<EmbeddedResource Include="BenchControl\Output\Printers\Enhanced\PrinterCfgCtrl.resx">
<DependentUpon>PrinterCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\Output\Printers\LabelPrinter\PrinterCfgCtrl.resx">
<EmbeddedResource Include="BenchControl\Output\Printers\Label\PrinterCfgCtrl.resx">
<DependentUpon>PrinterCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\Output\Printers\Munich\PrinterCfgCtrl.resx">