2017-05-04 03:11:50 +00:00
|
|
|
|
///
|
2023-03-13 14:31:39 +00:00
|
|
|
|
/// Copyright (c) 2017-2023 Sensus Slovensko a.s.
|
2017-05-04 03:11:50 +00:00
|
|
|
|
///
|
|
|
|
|
|
using System;
|
2023-03-13 14:31:39 +00:00
|
|
|
|
using System.Drawing.Printing;
|
2017-05-04 03:11:50 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using log4net;
|
2021-09-23 09:46:40 +00:00
|
|
|
|
using Common;
|
2020-07-28 14:01:34 +00:00
|
|
|
|
using Results.Output.Printers;
|
2021-10-26 09:23:57 +00:00
|
|
|
|
using TBF.Rig.Configs;
|
|
|
|
|
|
using TBF.Rig.Generic;
|
2017-05-04 03:11:50 +00:00
|
|
|
|
using TBF.Resources;
|
|
|
|
|
|
|
2021-10-26 09:23:57 +00:00
|
|
|
|
namespace TBF.Rig.Output.Printers.Enhanced
|
2017-05-04 03:11:50 +00:00
|
|
|
|
{
|
2017-12-04 07:58:02 +00:00
|
|
|
|
public partial class PrinterCfgCtrl : ConfigCtrlUtils, IComponentCfgCtrl
|
2017-05-04 03:11:50 +00:00
|
|
|
|
{
|
|
|
|
|
|
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 header;
|
|
|
|
|
|
string[] commonItems;
|
|
|
|
|
|
string[] testItems;
|
|
|
|
|
|
string footer;
|
|
|
|
|
|
|
|
|
|
|
|
public PrinterCfgCtrl()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
Localize();
|
|
|
|
|
|
|
|
|
|
|
|
orientationComboBox.Items.Add(PageOrientation.Portrait.ToString());
|
|
|
|
|
|
orientationComboBox.Items.Add(PageOrientation.Landscape.ToString());
|
2017-06-30 12:15:26 +00:00
|
|
|
|
|
|
|
|
|
|
foreach (var ff in System.Drawing.FontFamily.Families)
|
|
|
|
|
|
{
|
|
|
|
|
|
titleFontFamilyComboBox.Items.Add(ff.Name);
|
|
|
|
|
|
headerFontFamilyComboBox.Items.Add(ff.Name);
|
|
|
|
|
|
bodyFontFamilyComboBox.Items.Add(ff.Name);
|
2017-12-04 07:58:02 +00:00
|
|
|
|
footerFontFamilyComboBox.Items.Add(ff.Name);
|
|
|
|
|
|
}
|
2020-07-28 14:01:34 +00:00
|
|
|
|
|
|
|
|
|
|
for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++)
|
|
|
|
|
|
{
|
|
|
|
|
|
barcodeTypeComboBox.Items.Add(bt.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-05-04 03:11:50 +00:00
|
|
|
|
|
|
|
|
|
|
private void PrinterCfgCtrl_Load(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (Culture s = 0; s < Culture.Count; s++) cultureComboBox.Items.Add(s.ToString());
|
|
|
|
|
|
|
2023-03-13 14:31:39 +00:00
|
|
|
|
printerComboBox.Items.Add(Strings.default_printer);
|
|
|
|
|
|
foreach (var p in PrinterSettings.InstalledPrinters) printerComboBox.Items.Add(p);
|
|
|
|
|
|
|
2017-05-04 03:11:50 +00:00
|
|
|
|
header = config.Header;
|
|
|
|
|
|
commonItems = config.CommonItems;
|
|
|
|
|
|
testItems = config.SelectedItems;
|
|
|
|
|
|
footer = config.Footer;
|
|
|
|
|
|
|
|
|
|
|
|
Redraw();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Localize()
|
|
|
|
|
|
{
|
|
|
|
|
|
nameLabel.Text = Strings.Name;
|
2023-03-13 14:31:39 +00:00
|
|
|
|
printerLabel.Text = Strings.Printer;
|
|
|
|
|
|
selectPrinterButton.Text = "Select";
|
2017-05-04 03:11:50 +00:00
|
|
|
|
cultureLabel.Text = "Culture";
|
|
|
|
|
|
headerButton.Text = Strings.Header;
|
|
|
|
|
|
commonItemsButton.Text = "Common items";
|
|
|
|
|
|
testItemsButton.Text = "Test items";
|
|
|
|
|
|
footerButton.Text = Strings.Footer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Closing()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Redraw()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (config == null) return; /// Control was not loaded, settings were not changed
|
2023-11-28 13:21:05 +00:00
|
|
|
|
|
|
|
|
|
|
classNameLabel.Text = config.ClassName;
|
|
|
|
|
|
nameTextBox.Text = config.Name;
|
2023-03-13 14:31:39 +00:00
|
|
|
|
printerComboBox.Text = string.IsNullOrEmpty(config.PrinterName) ? Strings.default_printer : config.PrinterName;
|
2017-12-04 07:58:02 +00:00
|
|
|
|
templateTextBox.Text = config.Template;
|
|
|
|
|
|
orientationComboBox.Text = config.PageOrientation.ToString();
|
2017-05-04 03:11:50 +00:00
|
|
|
|
topMarginTextBox.Text = config.TopMargin.ToString();
|
|
|
|
|
|
bottomMarginTextBox.Text = config.BottomMargin.ToString();
|
|
|
|
|
|
leftMarginTextBox.Text = config.LeftMargin.ToString();
|
2017-06-30 12:15:26 +00:00
|
|
|
|
|
|
|
|
|
|
titleFontFamilyComboBox.Text = config.TitFntFml;
|
|
|
|
|
|
titleFontSizeTextBox.Text = config.TitFntSz.ToString();
|
|
|
|
|
|
titleBoldCheckBox.Checked = ((config.TitFntSty & (int)System.Drawing.FontStyle.Bold) != 0);
|
|
|
|
|
|
titleItalicCheckBox.Checked = ((config.TitFntSty & (int)System.Drawing.FontStyle.Italic) != 0);
|
|
|
|
|
|
|
|
|
|
|
|
headerFontFamilyComboBox.Text = config.HdrFntFml;
|
|
|
|
|
|
headerFontSizeTextBox.Text = config.HdrFntSz.ToString();
|
|
|
|
|
|
headerBoldCheckBox.Checked = ((config.HdrFntSty & (int)System.Drawing.FontStyle.Bold) != 0);
|
|
|
|
|
|
headerItalicCheckBox.Checked = ((config.HdrFntSty & (int)System.Drawing.FontStyle.Italic) != 0);
|
|
|
|
|
|
|
|
|
|
|
|
bodyFontFamilyComboBox.Text = config.BodyFntFml;
|
|
|
|
|
|
bodyFontSizeTextBox.Text = config.BodyFntSz.ToString();
|
|
|
|
|
|
bodyBoldCheckBox.Checked = ((config.BodyFntSty & (int)System.Drawing.FontStyle.Bold) != 0);
|
|
|
|
|
|
bodyItalicCheckBox.Checked = ((config.BodyFntSty & (int)System.Drawing.FontStyle.Italic) != 0);
|
|
|
|
|
|
|
2017-12-04 07:58:02 +00:00
|
|
|
|
footerFontFamilyComboBox.Text = config.FooterFntFml;
|
|
|
|
|
|
footerFontSizeTextBox.Text = config.FooterFntSz.ToString();
|
|
|
|
|
|
footerBoldCheckBox.Checked = ((config.FooterFntSty & (int)System.Drawing.FontStyle.Bold) != 0);
|
|
|
|
|
|
footerItalicCheckBox.Checked = ((config.FooterFntSty & (int)System.Drawing.FontStyle.Italic) != 0);
|
|
|
|
|
|
|
2017-05-04 03:11:50 +00:00
|
|
|
|
supressPrintingCheckBox.Checked = config.SupressPrinting;
|
2017-12-04 07:58:02 +00:00
|
|
|
|
goodOnlyCheckBox.Checked = config.GoodOnly;
|
|
|
|
|
|
cultureComboBox.Text = config.Culture.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
docNameTextBox.Text = config.DocName;
|
2018-09-14 07:02:21 +00:00
|
|
|
|
nrOfCopiesTextBox.Text = config.NrOfCopies.ToString();
|
2020-07-28 14:01:34 +00:00
|
|
|
|
|
|
|
|
|
|
barcodeTypeComboBox.Text = config.BarcodeType.ToString();
|
|
|
|
|
|
barcodeWidthTextBox.Text = config.BarcodeWidth.ToString();
|
|
|
|
|
|
barcodeHeightTextBox.Text = config.BarcodeHeight.ToString();
|
2017-12-04 07:58:02 +00:00
|
|
|
|
}
|
2017-05-04 03:11:50 +00:00
|
|
|
|
|
|
|
|
|
|
public void Unlock()
|
|
|
|
|
|
{
|
|
|
|
|
|
nameTextBox.Enabled = true;
|
2023-03-13 14:31:39 +00:00
|
|
|
|
printerComboBox.Enabled = true;
|
|
|
|
|
|
selectPrinterButton.Enabled = true;
|
2017-12-04 07:58:02 +00:00
|
|
|
|
templateTextBox.Enabled = true;
|
|
|
|
|
|
orientationComboBox.Enabled = true;
|
2017-05-04 03:11:50 +00:00
|
|
|
|
topMarginTextBox.Enabled = true;
|
|
|
|
|
|
bottomMarginTextBox.Enabled = true;
|
|
|
|
|
|
leftMarginTextBox.Enabled = true;
|
2017-06-30 12:15:26 +00:00
|
|
|
|
titleFontFamilyComboBox.Enabled = true;
|
|
|
|
|
|
titleFontSizeTextBox.Enabled = true;
|
|
|
|
|
|
titleBoldCheckBox.Enabled = true;
|
|
|
|
|
|
titleItalicCheckBox.Enabled = true;
|
|
|
|
|
|
headerFontFamilyComboBox.Enabled = true;
|
|
|
|
|
|
headerFontSizeTextBox.Enabled = true;
|
|
|
|
|
|
headerBoldCheckBox.Enabled = true;
|
|
|
|
|
|
headerItalicCheckBox.Enabled = true;
|
|
|
|
|
|
bodyFontFamilyComboBox.Enabled = true;
|
|
|
|
|
|
bodyFontSizeTextBox.Enabled = true;
|
|
|
|
|
|
bodyBoldCheckBox.Enabled = true;
|
|
|
|
|
|
bodyItalicCheckBox.Enabled = true;
|
2017-12-04 07:58:02 +00:00
|
|
|
|
footerFontFamilyComboBox.Enabled = true;
|
|
|
|
|
|
footerFontSizeTextBox.Enabled = true;
|
|
|
|
|
|
footerBoldCheckBox.Enabled = true;
|
|
|
|
|
|
footerItalicCheckBox.Enabled = true;
|
|
|
|
|
|
supressPrintingCheckBox.Enabled = true;
|
|
|
|
|
|
goodOnlyCheckBox.Enabled = true;
|
|
|
|
|
|
cultureComboBox.Enabled = true;
|
2017-05-04 03:11:50 +00:00
|
|
|
|
headerButton.Enabled = true;
|
|
|
|
|
|
commonItemsButton.Enabled = true;
|
|
|
|
|
|
testItemsButton.Enabled = true;
|
|
|
|
|
|
footerButton.Enabled = true;
|
2017-12-04 07:58:02 +00:00
|
|
|
|
docNameTextBox.Enabled = true;
|
2018-09-14 07:02:21 +00:00
|
|
|
|
nrOfCopiesTextBox.Enabled = true;
|
2020-07-28 14:01:34 +00:00
|
|
|
|
|
|
|
|
|
|
barcodeTypeComboBox.Enabled = true;
|
|
|
|
|
|
barcodeWidthTextBox.Enabled = true;
|
|
|
|
|
|
barcodeHeightTextBox.Enabled = true;
|
2017-12-04 07:58:02 +00:00
|
|
|
|
}
|
2017-05-04 03:11:50 +00:00
|
|
|
|
|
|
|
|
|
|
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(topMarginTextBox.Text, out dummy) || dummy < 0 || dummy > 500)
|
|
|
|
|
|
{
|
|
|
|
|
|
message += Environment.NewLine + "'Top margin' should be between 0 and 500";
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!int.TryParse(bottomMarginTextBox.Text, out dummy) || dummy < 0 || dummy > 200)
|
|
|
|
|
|
{
|
|
|
|
|
|
message += Environment.NewLine + "'Bottom margin' should be between 0 and 200";
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!int.TryParse(leftMarginTextBox.Text, out dummy) || dummy < 0 || dummy > 200)
|
|
|
|
|
|
{
|
|
|
|
|
|
message += Environment.NewLine + "Left margin' should be between 0 and 200";
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-06-30 12:15:26 +00:00
|
|
|
|
if (!int.TryParse(titleFontSizeTextBox.Text, out dummy) || dummy < 6 || dummy > 48)
|
|
|
|
|
|
{
|
|
|
|
|
|
message += Environment.NewLine + "Title font size' should be between 6 and 48";
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!int.TryParse(headerFontSizeTextBox.Text, out dummy) || dummy < 6 || dummy > 48)
|
|
|
|
|
|
{
|
|
|
|
|
|
message += Environment.NewLine + "Header font size' should be between 6 and 48";
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!int.TryParse(bodyFontSizeTextBox.Text, out dummy) || dummy < 6 || dummy > 48)
|
|
|
|
|
|
{
|
|
|
|
|
|
message += Environment.NewLine + "Body font size' should be between 6 and 48";
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-04 07:58:02 +00:00
|
|
|
|
if (!int.TryParse(footerFontSizeTextBox.Text, out dummy) || dummy < 4 || dummy > 48)
|
|
|
|
|
|
{
|
|
|
|
|
|
message += Environment.NewLine + "Footer font size' should be between 4 and 48";
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-05-04 03:11:50 +00:00
|
|
|
|
if (!cultureComboBox.Items.Contains(cultureComboBox.Text))
|
|
|
|
|
|
{
|
|
|
|
|
|
message += Environment.NewLine + "Invalid culture";
|
2018-09-14 07:02:21 +00:00
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!int.TryParse(nrOfCopiesTextBox.Text, out dummy) || dummy < 1 || dummy > 9)
|
|
|
|
|
|
{
|
|
|
|
|
|
message += Environment.NewLine + "'Copies' should be between 1 and 9";
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
}
|
2017-05-04 03:11:50 +00:00
|
|
|
|
|
2020-07-28 14:01:34 +00:00
|
|
|
|
if (!barcodeTypeComboBox.Items.Contains(barcodeTypeComboBox.Text))
|
|
|
|
|
|
{
|
|
|
|
|
|
message += Environment.NewLine + "Invalid barcode type";
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!int.TryParse(barcodeWidthTextBox.Text, out dummy) || dummy < 0 || dummy > 200)
|
|
|
|
|
|
{
|
|
|
|
|
|
message += Environment.NewLine + "Barcode 'Width' should be between 0 and 200";
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!int.TryParse(barcodeHeightTextBox.Text, out dummy) || dummy < 0 || dummy > 200)
|
|
|
|
|
|
{
|
|
|
|
|
|
message += Environment.NewLine + "Barcode 'Height' should be between 0 and 200";
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-05-04 03:11:50 +00:00
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-13 14:31:39 +00:00
|
|
|
|
string newPrinter = (printerComboBox.Text == Strings.default_printer) ? string.Empty : printerComboBox.Text;
|
|
|
|
|
|
if (config.PrinterName != newPrinter)
|
|
|
|
|
|
{
|
|
|
|
|
|
config.PrinterName = newPrinter;
|
|
|
|
|
|
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-05-04 03:11:50 +00:00
|
|
|
|
if (config.PageOrientation != GetOrientation(orientationComboBox.Text))
|
|
|
|
|
|
{
|
|
|
|
|
|
config.PageOrientation = GetOrientation(orientationComboBox.Text);
|
|
|
|
|
|
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-06 11:26:48 +00:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-04 07:58:02 +00:00
|
|
|
|
flags |= UpdateDifferent(ref config.Template, templateTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.TopMargin, topMarginTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.BottomMargin, bottomMarginTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.LeftMargin, leftMarginTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
|
|
|
|
|
|
/// Title font properties
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.TitFntFml, titleFontFamilyComboBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.TitFntSz, titleFontSizeTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
int tmp = (titleBoldCheckBox.Checked ? (int)System.Drawing.FontStyle.Bold : 0)
|
|
|
|
|
|
+ (titleItalicCheckBox.Checked ? (int)System.Drawing.FontStyle.Italic : 0);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.TitFntSty, tmp, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
|
|
|
|
|
|
/// Header font properties
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.HdrFntFml, headerFontFamilyComboBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.HdrFntSz, headerFontSizeTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
tmp = (headerBoldCheckBox.Checked ? (int)System.Drawing.FontStyle.Bold : 0)
|
|
|
|
|
|
+ (headerItalicCheckBox.Checked ? (int)System.Drawing.FontStyle.Italic : 0);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.HdrFntSty, tmp, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
|
|
|
|
|
|
/// Body font properties
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.BodyFntFml, bodyFontFamilyComboBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.BodyFntSz, int.Parse(bodyFontSizeTextBox.Text), CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
tmp = (bodyBoldCheckBox.Checked ? (int)System.Drawing.FontStyle.Bold : 0)
|
|
|
|
|
|
+ (bodyItalicCheckBox.Checked ? (int)System.Drawing.FontStyle.Italic : 0);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.BodyFntSty, tmp, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
|
|
|
|
|
|
/// Footer font properties
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.FooterFntFml, footerFontFamilyComboBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.FooterFntSz, int.Parse(footerFontSizeTextBox.Text), CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
tmp = (footerBoldCheckBox.Checked ? (int)System.Drawing.FontStyle.Bold : 0)
|
|
|
|
|
|
+ (footerItalicCheckBox.Checked ? (int)System.Drawing.FontStyle.Italic : 0);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.FooterFntSty, tmp, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.SupressPrinting, supressPrintingCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.GoodOnly, goodOnlyCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.Header, header, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.CommonItems, commonItems, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.SelectedItems, testItems, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.Footer, footer, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.DocName, docNameTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
2018-09-14 07:02:21 +00:00
|
|
|
|
flags |= UpdateDifferent(ref config.NrOfCopies, nrOfCopiesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
2017-12-04 07:58:02 +00:00
|
|
|
|
|
2020-07-28 14:01:34 +00:00
|
|
|
|
for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (bt.ToString().Equals(barcodeTypeComboBox.Text))
|
|
|
|
|
|
{
|
|
|
|
|
|
config.BarcodeType = bt;
|
|
|
|
|
|
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.BarcodeWidth, barcodeWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
flags |= UpdateDifferent(ref config.BarcodeHeight, barcodeHeightTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
|
|
|
|
|
|
2017-05-04 03:11:50 +00:00
|
|
|
|
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Printer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void headerButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
HeaderFooterDlg dlg = new HeaderFooterDlg(true, string.IsNullOrEmpty(header) ? string.Empty : header.Replace("~", Environment.NewLine));
|
|
|
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
header = dlg.EditedText.Replace(Environment.NewLine, "~");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void commonItemsButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg()
|
|
|
|
|
|
{
|
|
|
|
|
|
MetersKind = config.MetersKind,
|
|
|
|
|
|
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(commonItems),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
commonItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void testItemsButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg(true)
|
|
|
|
|
|
{
|
|
|
|
|
|
MetersKind = config.MetersKind,
|
|
|
|
|
|
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(testItems),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
testItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void footerButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
HeaderFooterDlg dlg = new HeaderFooterDlg(false, string.IsNullOrEmpty(footer) ? string.Empty : footer.Replace("~", Environment.NewLine));
|
|
|
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
footer = dlg.EditedText.Replace(Environment.NewLine, "~");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#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
|
2023-03-13 14:31:39 +00:00
|
|
|
|
|
|
|
|
|
|
private void selectPrinterButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
PrintDialog dlg = new PrintDialog();
|
|
|
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
printerComboBox.Text = dlg.PrinterSettings.PrinterName;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-05-04 03:11:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|