/// /// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using log4net; using Config.Entities; using Results.Output.Printers; using TBF.BenchControl.Generic; using TBF.Resources; using TBF.BenchControl.Configs; namespace TBF.BenchControl.Output.Printers.OnePerMeter { 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 header; string[] commonItems1; string[] commonItems2; string[] commonItems3; string[] testItems; string[] testItems2; string[] belowItems1; string[] belowItems2; string[] belowItems3; string footer; public PrinterCfgCtrl() { InitializeComponent(); Localize(); orientationComboBox.Items.Add(PageOrientation.Portrait.ToString()); orientationComboBox.Items.Add(PageOrientation.Landscape.ToString()); foreach (var ff in System.Drawing.FontFamily.Families) { titleFontFamilyComboBox.Items.Add(ff.Name); headerFontFamilyComboBox.Items.Add(ff.Name); bodyFontFamilyComboBox.Items.Add(ff.Name); footerFontFamilyComboBox.Items.Add(ff.Name); } for (TableForm f = 0; f < TableForm.Count; f++) { table1FormComboBox.Items.Add(f.ToString()); } for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++) { barcodeTypeComboBox.Items.Add(bt.ToString()); } } private void PrinterCfgCtrl_Load(object sender, EventArgs e) { for (Culture s = 0; s < Culture.Count; s++) cultureComboBox.Items.Add(s.ToString()); header = config.Header; commonItems1 = config.CommonItems1; commonItems2 = config.CommonItems2; commonItems3 = config.CommonItems3; testItems = config.SelectedItems; testItems2 = config.SelectedItems2; belowItems1 = config.BelowItems1; belowItems2 = config.BelowItems2; belowItems3 = config.BelowItems3; footer = config.Footer; Redraw(); } void Localize() { nameLabel.Text = Strings.Name; templateLabel.Text = "Template"; cultureLabel.Text = "Culture"; headerButton.Text = Strings.Header; footerButton.Text = Strings.Footer; } 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(); topMarginTextBox.Text = config.TopMargin.ToString(); bottomMarginTextBox.Text = config.BottomMargin.ToString(); leftMarginTextBox.Text = config.LeftMargin.ToString(); 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); 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); colW0TextBox.Text = config.ColW0Pct.ToString(); colW1TextBox.Text = config.ColW1Pct.ToString(); colW2TextBox.Text = config.ColW2Pct.ToString(); belowW0TextBox.Text = config.BelowW0Pct.ToString(); belowW1TextBox.Text = config.BelowW1Pct.ToString(); belowW2TextBox.Text = config.BelowW2Pct.ToString(); supressPrintingCheckBox.Checked = config.SupressPrinting; goodOnlyCheckBox.Checked = config.GoodOnly; cultureComboBox.Text = config.Culture.ToString(); graphLeftTextBox.Text = config.GraphLeft.ToString(); graphTopTextBox.Text = config.GraphTop.ToString(); graphWidthTextBox.Text = config.GraphWid.ToString(); graphHeightTextBox.Text = config.GraphHgh.ToString(); imageLeftTextBox.Text = config.ImgLeft.ToString(); imageTopTextBox.Text = config.ImgTop.ToString(); imageWidthTextBox.Text = config.ImgWid.ToString(); imageHeightTextBox.Text = config.ImgHgh.ToString(); imageNameTextBox.Text = config.ImgName; docNameTextBox.Text = config.DocName; table1FormComboBox.Text = config.Form.ToString(); barcodeTypeComboBox.Text = config.BarcodeType.ToString(); barcodeLeftTextBox.Text = config.BarcodeLeft.ToString(); barcodeTopTextBox.Text = config.BarcodeTop.ToString(); barcodeWidthTextBox.Text = config.BarcodeWidth.ToString(); barcodeHeightTextBox.Text = config.BarcodeHeight.ToString(); } public void Unlock() { nameTextBox.Enabled = true; templateTextBox.Enabled = true; orientationComboBox.Enabled = true; topMarginTextBox.Enabled = true; bottomMarginTextBox.Enabled = true; leftMarginTextBox.Enabled = true; 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; footerFontFamilyComboBox.Enabled = true; footerFontSizeTextBox.Enabled = true; footerBoldCheckBox.Enabled = true; footerItalicCheckBox.Enabled = true; supressPrintingCheckBox.Enabled = true; goodOnlyCheckBox.Enabled = true; cultureComboBox.Enabled = true; headerButton.Enabled = true; colW0TextBox.Enabled = true; colW1TextBox.Enabled = true; colW2TextBox.Enabled = true; commonItems1Button.Enabled = true; commonItems2Button.Enabled = true; commonItems3Button.Enabled = true; table1FormComboBox.Enabled = true; testItemsButton.Enabled = true; testItems2Button.Enabled = true; belowW0TextBox.Enabled = true; belowW1TextBox.Enabled = true; belowW2TextBox.Enabled = true; belowItems1Button.Enabled = true; belowItems2Button.Enabled = true; belowItems3Button.Enabled = true; footerButton.Enabled = true; graphLeftTextBox.Enabled = true; graphTopTextBox.Enabled = true; graphWidthTextBox.Enabled = true; graphHeightTextBox.Enabled = true; imageLeftTextBox.Enabled = true; imageTopTextBox.Enabled = true; imageWidthTextBox.Enabled = true; imageHeightTextBox.Enabled = true; imageNameTextBox.Enabled = true; docNameTextBox.Enabled = true; barcodeTypeComboBox.Enabled = true; barcodeLeftTextBox.Enabled = true; barcodeTopTextBox.Enabled = true; barcodeWidthTextBox.Enabled = true; barcodeHeightTextBox.Enabled = true; } public CfgUpdateFlags VerifyCfg(ref string message) { CfgUpdateFlags flags = CfgUpdateFlags.None; if ((int)GetOrientation(orientationComboBox.Text) < 0) { message += Environment.NewLine + "Invalid 'Page orientation'"; flags |= CfgUpdateFlags.Error; } int dummy, dummy2, dummy3; 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; } 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; } 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; } if (!cultureComboBox.Items.Contains(cultureComboBox.Text)) { flags |= CfgUpdateFlags.Error; message += Environment.NewLine + "Invalid culture"; } if (!int.TryParse(colW0TextBox.Text, out dummy) || dummy < 0 || dummy > 100) { message += Environment.NewLine + "Column width 0 should be between 0 and 100"; flags |= CfgUpdateFlags.Error; } if (!int.TryParse(colW1TextBox.Text, out dummy2) || dummy2 < 0 || dummy2 > 100) { message += Environment.NewLine + "Column width 1 should be between 0 and 100"; flags |= CfgUpdateFlags.Error; } if (!int.TryParse(colW2TextBox.Text, out dummy3) || dummy3 < 0 || dummy3 > 100) { message += Environment.NewLine + "Column width 2 should be between 0 and 100"; flags |= CfgUpdateFlags.Error; } if (dummy + dummy2 + dummy3 > 100) { message += Environment.NewLine + "Sum of above column widths should be <= 100"; flags |= CfgUpdateFlags.Error; } if (!int.TryParse(belowW0TextBox.Text, out dummy) || dummy < 0 || dummy > 100) { message += Environment.NewLine + "Column width 0 should be between 0 and 100"; flags |= CfgUpdateFlags.Error; } if (!int.TryParse(belowW1TextBox.Text, out dummy2) || dummy2 < 0 || dummy2 > 100) { message += Environment.NewLine + "Column width 1 should be between 0 and 100"; flags |= CfgUpdateFlags.Error; } if (!int.TryParse(belowW2TextBox.Text, out dummy3) || dummy3 < 0 || dummy3 > 100) { message += Environment.NewLine + "Column width 2 should be between 0 and 100"; flags |= CfgUpdateFlags.Error; } if (dummy + dummy2 + dummy3 > 100) { message += Environment.NewLine + "Sum of below column widths should be <= 100"; flags |= CfgUpdateFlags.Error; } if (!int.TryParse(graphLeftTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) { message += Environment.NewLine + "Graph left' should be between 0 and 1100"; flags |= CfgUpdateFlags.Error; } if (!int.TryParse(graphTopTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) { message += Environment.NewLine + "Graph top' should be between 0 and 1100"; flags |= CfgUpdateFlags.Error; } if (!int.TryParse(graphWidthTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) { message += Environment.NewLine + "Graph width' should be between 0 and 1100"; flags |= CfgUpdateFlags.Error; } if (!int.TryParse(graphHeightTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) { message += Environment.NewLine + "Graph height' should be between 0 and 1100"; flags |= CfgUpdateFlags.Error; } if (!int.TryParse(imageLeftTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) { message += Environment.NewLine + "Image left' should be between 0 and 1100"; flags |= CfgUpdateFlags.Error; } if (!int.TryParse(imageTopTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) { message += Environment.NewLine + "Image top' should be between 0 and 1100"; flags |= CfgUpdateFlags.Error; } if (!int.TryParse(imageWidthTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) { message += Environment.NewLine + "Image width' should be between 0 and 1100"; flags |= CfgUpdateFlags.Error; } if (!int.TryParse(imageHeightTextBox.Text, out dummy) || dummy < 0 || dummy > 1100) { message += Environment.NewLine + "Image height' should be between 0 and 1100"; flags |= CfgUpdateFlags.Error; } if (!table1FormComboBox.Items.Contains(table1FormComboBox.Text)) { message += Environment.NewLine + "Invalid 'Table form'"; 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; } 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.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.ColW0Pct, colW0TextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.ColW1Pct, colW1TextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.ColW2Pct, colW2TextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.BelowW0Pct, belowW0TextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.BelowW1Pct, belowW1TextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.BelowW2Pct, belowW2TextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.Header, header, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.CommonItems1, commonItems1, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.CommonItems2, commonItems2, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.CommonItems3, commonItems3, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.SelectedItems, testItems, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.SelectedItems2, testItems2, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.BelowItems1, belowItems1, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.BelowItems2, belowItems2, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.BelowItems3, belowItems3, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.Footer, footer, 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 (TableForm f = 0; f < TableForm.Count; f++) { if (f.ToString().Equals(table1FormComboBox.Text)) { config.Form = f; flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); } } flags |= UpdateDifferent(ref config.GraphLeft, graphLeftTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.GraphTop, graphTopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.GraphWid, graphWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.GraphHgh, graphHeightTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.ImgLeft, imageLeftTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.ImgTop, imageTopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.ImgWid, imageWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.ImgHgh, imageHeightTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.ImgName, imageNameTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.DocName, docNameTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++) { if (bt.ToString().Equals(barcodeTypeComboBox.Text)) { config.BarcodeType = bt; flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); break; } } flags |= UpdateDifferent(ref config.BarcodeLeft, barcodeLeftTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.BarcodeTop, barcodeTopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.BarcodeWidth, barcodeWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.BarcodeHeight, barcodeHeightTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0) { Printer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config)); } 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 commonItems1Button_Click(object sender, EventArgs e) { Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg() { MetersKind = config.MetersKind, SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(commonItems1), }; if (dlg.ShowDialog() == DialogResult.OK) { commonItems1 = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems); } } private void commonItems2Button_Click(object sender, EventArgs e) { Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg() { MetersKind = config.MetersKind, SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(commonItems2), }; if (dlg.ShowDialog() == DialogResult.OK) { commonItems2 = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems); } } private void commonItems3Button_Click(object sender, EventArgs e) { Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg() { MetersKind = config.MetersKind, SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(commonItems3), }; if (dlg.ShowDialog() == DialogResult.OK) { commonItems3 = 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 testItems2Button_Click(object sender, EventArgs e) { Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg(true) { MetersKind = config.MetersKind, SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(testItems2), }; if (dlg.ShowDialog() == DialogResult.OK) { testItems2 = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems); } } private void belowItems1Button_Click(object sender, EventArgs e) { Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg() { MetersKind = config.MetersKind, SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(belowItems1), }; if (dlg.ShowDialog() == DialogResult.OK) { belowItems1 = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems); } } private void belowItems2Button_Click(object sender, EventArgs e) { Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg() { MetersKind = config.MetersKind, SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(belowItems2), }; if (dlg.ShowDialog() == DialogResult.OK) { belowItems2 = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems); } } private void belowItems3Button_Click(object sender, EventArgs e) { Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg() { MetersKind = config.MetersKind, SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(belowItems3), }; if (dlg.ShowDialog() == DialogResult.OK) { belowItems3 = 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 CmdResponseHandler; public void StartResponseHandler() { } public void StopResponseHandler() { } #endregion Configuration Change Handling } }