From b2a7cfb0d4c1dbcc4d51eb7afd1e2829b095ff4b Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Fri, 12 May 2023 15:36:27 +0200 Subject: [PATCH] DataEntry.Uni Items passed in a list, w/o limits, Cfg with arrays, TODO: TestStartEndForm --- TBF/LocalSettings.cs | 5 + .../ParamsProvider/ComponentCfgCtrl.cs | 8 +- TBF/Rig/DataEntry/Uni/CycleBgEnForm.cs | 441 ++-- TBF/Rig/DataEntry/Uni/DEItem.cs | 30 +- TBF/Rig/DataEntry/Uni/DEUtils.cs | 83 + TBF/Rig/DataEntry/Uni/EntryFormCfg.cs | 1782 ++++++++--------- TBF/Rig/DataEntry/Uni/EntryFormNoStartEnd.cs | 56 +- TBF/TBF.csproj | 1 + 8 files changed, 1136 insertions(+), 1270 deletions(-) create mode 100644 TBF/Rig/DataEntry/Uni/DEUtils.cs diff --git a/TBF/LocalSettings.cs b/TBF/LocalSettings.cs index 072623c39..d114867bb 100644 --- a/TBF/LocalSettings.cs +++ b/TBF/LocalSettings.cs @@ -249,17 +249,22 @@ namespace TBF public string[] LastBgComm1; public string[] LastBgComm2; public string[] LastBgComm3; + /// public string[] LastBgColA; public string[] LastBgColB; public string[] LastBgColC; public string[] LastBgColD; + public string[] LastBgColE; + /// public string[] LastEnComm1; public string[] LastEnComm2; public string[] LastEnComm3; + /// public string[] LastEnColA; public string[] LastEnColB; public string[] LastEnColC; public string[] LastEnColD; + public string[] LastEnColE; /// Purchase order history public string[] PurchaseOrderHistory; diff --git a/TBF/Rig/Configs/ParamsProvider/ComponentCfgCtrl.cs b/TBF/Rig/Configs/ParamsProvider/ComponentCfgCtrl.cs index dc22e05c3..212b52fb2 100644 --- a/TBF/Rig/Configs/ParamsProvider/ComponentCfgCtrl.cs +++ b/TBF/Rig/Configs/ParamsProvider/ComponentCfgCtrl.cs @@ -71,8 +71,9 @@ namespace TBF.Rig.Configs.ParamsProvider foreach (var p in parents) parentComboBox.Items.Add(p.Name); } - editors = new Control[paramsProvider.ParamsCount()]; - for (int i = 0; i < paramsProvider.ParamsCount(); i++) + int paramsCount = paramsProvider.ParamsCount(); + editors = new Control[paramsCount]; + for (int i = 0; i < paramsCount; i++) { ICollection values = paramsProvider.ParamValues(i); if (values == null) @@ -130,7 +131,8 @@ namespace TBF.Rig.Configs.ParamsProvider if (parentComboBox.Visible) parentComboBox.Text = Config.ParentName; paramsListViewEx.Items.Clear(); - for (int i = 0; i < paramsProvider.ParamsCount(); i++) + int paramsCount = paramsProvider.ParamsCount(); + for (int i = 0; i < paramsCount; i++) { ListViewItem lvi = new ListViewItem(paramsProvider.ParamName(i)); lvi.SubItems.Add(paramsProvider.ToString(i)); diff --git a/TBF/Rig/DataEntry/Uni/CycleBgEnForm.cs b/TBF/Rig/DataEntry/Uni/CycleBgEnForm.cs index b696d8c22..7e57633bb 100644 --- a/TBF/Rig/DataEntry/Uni/CycleBgEnForm.cs +++ b/TBF/Rig/DataEntry/Uni/CycleBgEnForm.cs @@ -21,9 +21,7 @@ namespace TBF.Rig.DataEntry.Uni readonly int lineSize; readonly Sz sz; readonly bool isLrOrder; /// true = controls obtain focus after ENTER key in left-right order, false = top-down order - readonly DEItem item1; - readonly DEItem item2; - readonly DEItem item3; + readonly IList commonItems; readonly IList colItems; readonly bool isEnd; readonly string formCloseKeys; @@ -32,6 +30,7 @@ namespace TBF.Rig.DataEntry.Uni readonly WaterMeter firstValidWM; readonly int wmsCount; readonly int linesCount; + readonly int commonItemsCount; /// Size and layout related values readonly Font font; @@ -45,13 +44,14 @@ namespace TBF.Rig.DataEntry.Uni readonly int checkBoxWid; /// UI elements - readonly ComboBox comboBox1; /// Combo box for the 1st common item - readonly ComboBox comboBox2; /// Combo box for the 2nd common item - readonly ComboBox comboBox3; /// Combo box for the 3rd common item + readonly Label[] commonLabels; + readonly ComboBox[] commonComboBoxes; readonly Label[] labels; /// Labels for water meter numbers readonly ComboBox[,] comboBoxes; /// Combo boxes for values in columns readonly CheckBox[] checkBoxes; /// Check boxes for water meter enable/disable + readonly LocalSettings ls; + bool isHandlersEnabled; /// Initially false, set to true after ComboBoxes are filled with data /// Set to 'true' when the form closes @@ -74,7 +74,7 @@ namespace TBF.Rig.DataEntry.Uni /// /// Number of text boxes for serial numbers public CycleBgEnForm(IList waterMeters, int lineSize, string title, Sz sz, bool isLrOrder, string formCloseKeys, - DEItem item1, DEItem item2, DEItem item3, IList colItems, bool isEnd = false) + IList commonItems, IList colItems, bool isEnd = false) { InitializeComponent(); ControlBox = false; @@ -86,17 +86,20 @@ namespace TBF.Rig.DataEntry.Uni this.sz = sz; this.isLrOrder = isLrOrder; this.formCloseKeys = !string.IsNullOrEmpty(formCloseKeys) ? formCloseKeys : string.Empty; - this.item1 = item1; - this.item2 = item2; - this.item3 = item3; + this.commonItems = commonItems; this.colItems = colItems; this.isEnd = isEnd; + ls = Program.LocalSettings; + /// Readonly variables derived from arguments + commonItemsCount = (commonItems == null) ? 0 : commonItems.Count; wmsCount = (waterMeters == null) ? 0 : waterMeters.Count; linesCount = (wmsCount + Math.Max(1, lineSize) - 1) / Math.Max(1, lineSize); firstValidWM = (waterMeters != null) ? waterMeters.FirstOrDefault(x => (x != null && !x.Disabled)) : null; /// + commonLabels = new Label[commonItemsCount]; + commonComboBoxes = new ComboBox[commonItemsCount]; labels = new Label[wmsCount]; comboBoxes = new ComboBox[colItems.Count, wmsCount]; checkBoxes = new CheckBox[wmsCount]; @@ -146,128 +149,63 @@ namespace TBF.Rig.DataEntry.Uni /// /// Group box with common items /// - int groupBoxHeight = 0; int groupBoxWidth = 0; - if (item1.Content != Content.None) + int groupBoxHeight = 0; + if (commonItemsCount > 0) { var groupBox = new GroupBox(); - int label1Width = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(item1.Caption, font).Width); - var label1 = new Label + int labelsWidth = 0; + for (int ix = 0; ix < commonItemsCount; ix++) { - Text = item1.Caption, - Font = font, - Location = new Point(margin, 2 * spacing), - Size = new Size(label1Width + spacing, meterHeight), - TextAlign = ContentAlignment.MiddleLeft, - TabIndex = tabIndex++, - Parent = groupBox, - }; - groupBox.Controls.Add(label1); - int labelsWidth = label1Width; - - if (item2.Content != Content.None) - { - int label2Width = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(item2.Caption, font).Width); - var label2 = new Label + int oneLabelWidth = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(commonItems[ix].Caption, font).Width); + var oneLabel = new Label { - Text = item2.Caption, + Text = commonItems[ix].Caption, Font = font, - Location = new Point(margin, 3 * spacing + meterHeight), - Size = new Size(label2Width + spacing, meterHeight), + Location = new Point(margin, (ix + 2) * spacing + ix * meterHeight), + Size = new Size(oneLabelWidth + spacing, meterHeight), TextAlign = ContentAlignment.MiddleLeft, TabIndex = tabIndex++, Parent = groupBox, }; - groupBox.Controls.Add(label2); - labelsWidth = Math.Max(labelsWidth, label2Width); - - if (item3.Content != Content.None) - { - int label3Width = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(item3.Caption, font).Width); - var label3 = new Label - { - Text = item3.Caption, - Font = font, - Location = new Point(margin, 4 * spacing + 2 * meterHeight), - Size = new Size(label3Width + spacing, meterHeight), - TextAlign = ContentAlignment.MiddleLeft, - TabIndex = tabIndex++, - Parent = groupBox, - }; - groupBox.Controls.Add(label3); - labelsWidth = Math.Max(labelsWidth, label3Width); - } + groupBox.Controls.Add(oneLabel); + labelsWidth = Math.Max(labelsWidth, oneLabelWidth); } - comboBox1 = new ComboBox + int combosWidth = 0; + for (int ix = 0; ix < commonItemsCount; ix++) { - Name = "-1~1", - Location = new Point(margin + spacing + labelsWidth, 2 * spacing), - Size = new Size(item1.Width, meterHeight), - Enabled = (item1.Action != Action.LoadReadOnly), - Font = font, - TabIndex = tabIndex++, - Parent = groupBox, - }; - - comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged); - comboBox1.TextChanged += new System.EventHandler(this.comboBox_TextChanged); - comboBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBox_KeyPress); - - AddHistoryToCombo(comboBox1, isEnd ? Program.LocalSettings.LastEnComm1 : Program.LocalSettings.LastBgComm1); - groupBox.Controls.Add(comboBox1); - int combosWidth = item1.Width; - - if (item2.Content != Content.None) - { - comboBox2 = new ComboBox + var cb = new ComboBox { - Name = "-1~2", - Location = new Point(margin + spacing + labelsWidth, 3 * spacing + meterHeight), - Size = new Size(item2.Width, meterHeight), - Enabled = (item2.Action != Action.LoadReadOnly), + Name = string.Format("-1~{0}", ix + 1), + Location = new Point(margin + spacing + labelsWidth, (ix + 2) * spacing + ix * meterHeight), + Size = new Size(commonItems[ix].Width, meterHeight), + Enabled = (commonItems[ix].Action != Ac.LoadReadOnly), Font = font, TabIndex = tabIndex++, Parent = groupBox, }; - comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged); - comboBox2.TextChanged += new System.EventHandler(this.comboBox_TextChanged); - comboBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBox_KeyPress); + cb.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged); + cb.TextChanged += new System.EventHandler(this.comboBox_TextChanged); + cb.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBox_KeyPress); - AddHistoryToCombo(comboBox2, isEnd ? Program.LocalSettings.LastEnComm2 : Program.LocalSettings.LastBgComm2); - groupBox.Controls.Add(comboBox2); - combosWidth = Math.Max(combosWidth, item2.Width); - - if (item3.Content != Content.None) + switch (ix) { - comboBox3 = new ComboBox - { - Name = "-1~3", - Location = new Point(margin + spacing + labelsWidth, 4 * spacing + 2 * meterHeight), - Size = new Size(item3.Width, meterHeight), - Enabled = (item3.Action != Action.LoadReadOnly), - Font = font, - TabIndex = tabIndex++, - Parent = groupBox, - }; - - comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged); - comboBox3.TextChanged += new System.EventHandler(this.comboBox_TextChanged); - comboBox3.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBox_KeyPress); - - AddHistoryToCombo(comboBox3, isEnd ? Program.LocalSettings.LastEnComm3 : Program.LocalSettings.LastBgComm3); - groupBox.Controls.Add(comboBox3); - combosWidth = Math.Max(combosWidth, item3.Width); + case 0: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm1 : ls.LastBgComm1); break; + case 1: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm2 : ls.LastBgComm2); break; + case 2: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm3 : ls.LastBgComm3); break; } - } + commonComboBoxes[ix] = cb; + groupBox.Controls.Add(cb); + combosWidth = Math.Max(combosWidth, commonItems[ix].Width); + } + /// groupBox.Location = new Point(margin, margin - spacing); groupBoxWidth = labelsWidth + combosWidth + 2 * margin + spacing; - groupBoxHeight = (item3.Content != Content.None) ? 3 * meterHeight + 5 * spacing - : (item2.Content != Content.None) ? 2 * meterHeight + 4 * spacing - : meterHeight + 3 * spacing; + groupBoxHeight = commonItemsCount * meterHeight + (commonItemsCount + 2) * spacing; groupBox.Size = new Size(groupBoxWidth, groupBoxHeight); groupBox.Font = font; groupBox.TabIndex = tabIndex++; @@ -331,7 +269,7 @@ namespace TBF.Rig.DataEntry.Uni Name = string.Format("{0}~{1}", k, wmPos0), Location = new Point(left, top), Size = new Size(ci.Width, meterHeight), - Enabled = (ci.Action != Action.LoadReadOnly && !waterMeters[wmPos0].Disabled), + Enabled = (ci.Action != Ac.LoadReadOnly && !waterMeters[wmPos0].Disabled), Font = font, TabIndex = tabIndex++, Parent = this, @@ -373,19 +311,17 @@ namespace TBF.Rig.DataEntry.Uni InitializeBoxes(); /// Set focus to the first enabled ComboBox - if (comboBox1 != null && comboBox1.Enabled) + bool activeControlFound = false; + for (int ix = 0; ix < commonItemsCount; ix++) { - ActiveControl = comboBox1; + if (commonComboBoxes[ix].Enabled) + { + ActiveControl = commonComboBoxes[ix]; + activeControlFound = true; + break; + } } - else if (comboBox2 != null && comboBox2.Enabled) - { - ActiveControl = comboBox2; - } - else if (comboBox3 != null && comboBox3.Enabled) - { - ActiveControl = comboBox3; - } - else + if (!activeControlFound) { /// Initialize k,j so that after the 1st increment k = 0 and j = 0 int k, j; @@ -421,7 +357,7 @@ namespace TBF.Rig.DataEntry.Uni } /// - /// Returns an array of strings from Program.LocalSettings. + /// Returns an array of strings from ls. /// Never returns null, null is converted to new string[0]. /// /// false = Beginning of cycle, true = End of cycle @@ -433,38 +369,24 @@ namespace TBF.Rig.DataEntry.Uni { switch (k) { - default: - case 0: - if (Program.LocalSettings.LastEnColA == null) Program.LocalSettings.LastEnColA = new string[0]; - return Program.LocalSettings.LastEnColA; - case 1: - if (Program.LocalSettings.LastEnColB == null) Program.LocalSettings.LastEnColB = new string[0]; - return Program.LocalSettings.LastEnColB; - case 2: - if (Program.LocalSettings.LastEnColC == null) Program.LocalSettings.LastEnColC = new string[0]; - return Program.LocalSettings.LastEnColC; - case 3: - if (Program.LocalSettings.LastEnColD == null) Program.LocalSettings.LastEnColD = new string[0]; - return Program.LocalSettings.LastEnColD; + case 0: if (ls.LastEnColA == null) ls.LastEnColA = new string[0]; return ls.LastEnColA; + case 1: if (ls.LastEnColB == null) ls.LastEnColB = new string[0]; return ls.LastEnColB; + case 2: if (ls.LastEnColC == null) ls.LastEnColC = new string[0]; return ls.LastEnColC; + case 3: if (ls.LastEnColD == null) ls.LastEnColD = new string[0]; return ls.LastEnColD; + case 4: if (ls.LastEnColE == null) ls.LastEnColE = new string[0]; return ls.LastEnColE; + default: return new string[0]; } } else { switch (k) { - default: - case 0: - if (Program.LocalSettings.LastBgColA == null) Program.LocalSettings.LastBgColA = new string[0]; - return Program.LocalSettings.LastBgColA; - case 1: - if (Program.LocalSettings.LastBgColB == null) Program.LocalSettings.LastBgColB = new string[0]; - return Program.LocalSettings.LastBgColB; - case 2: - if (Program.LocalSettings.LastBgColC == null) Program.LocalSettings.LastBgColC = new string[0]; - return Program.LocalSettings.LastBgColC; - case 3: - if (Program.LocalSettings.LastBgColD == null) Program.LocalSettings.LastBgColD = new string[0]; - return Program.LocalSettings.LastBgColD; + case 0: if (ls.LastBgColA == null) ls.LastBgColA = new string[0]; return ls.LastBgColA; + case 1: if (ls.LastBgColB == null) ls.LastBgColB = new string[0]; return ls.LastBgColB; + case 2: if (ls.LastBgColC == null) ls.LastBgColC = new string[0]; return ls.LastBgColC; + case 3: if (ls.LastBgColD == null) ls.LastBgColD = new string[0]; return ls.LastBgColD; + case 4: if (ls.LastBgColE == null) ls.LastBgColE = new string[0]; return ls.LastBgColE; + default: return new string[0]; } } } @@ -484,30 +406,26 @@ namespace TBF.Rig.DataEntry.Uni isHandlersEnabled = false; /// Common combo boxes - var commCBs = new ComboBox[] { comboBox1, comboBox2, comboBox3 }; - int ix = 0; - foreach (var commItem in new DEItem[] { item1, item2, item3 }) + for (int ix = 0; ix < commonItemsCount; ix++) { - if (commItem.Content == Content.None) break; - - switch (commItem.Action) + switch (commonItems[ix].Action) { default: - case Action.Clear: - commCBs[ix].Text = string.Empty; + case Ac.Clear: + commonComboBoxes[ix].Text = string.Empty; break; - case Action.HistoryLast: - commCBs[ix].Text = commCBs[ix].Items.Count > 0 ? commCBs[ix].Items[0].ToString() : string.Empty; + case Ac.HistoryLast: + commonComboBoxes[ix].Text = (commonComboBoxes[ix].Items.Count > 0) + ? commonComboBoxes[ix].Items[0].ToString() + : string.Empty; break; - case Action.Load: - case Action.LoadReadOnly: - commCBs[ix].Text = GetContent(commItem.Content, firstValidWM); + case Ac.Load: + case Ac.LoadReadOnly: + commonComboBoxes[ix].Text = DEUtils.GetContent(commonItems[ix].Content, firstValidWM); break; } - - ix++; } /// Table @@ -516,22 +434,22 @@ namespace TBF.Rig.DataEntry.Uni switch (colItems[k].Action) { default: - case Action.Clear: + case Ac.Clear: for (int i = 0; i < wmsCount; i++) comboBoxes[k, i].Text = string.Empty; break; - case Action.HistoryLast: + case Ac.HistoryLast: for (int i = 0; i < wmsCount; i++) { comboBoxes[k, i].Text = comboBoxes[k, i].Items.Count > 0 ? comboBoxes[k, i].Items[0].ToString() : string.Empty; } break; - case Action.Load: - case Action.LoadReadOnly: + case Ac.Load: + case Ac.LoadReadOnly: for (int i = 0; i < wmsCount; i++) { - comboBoxes[k, i].Text = GetContent(colItems[k].Content, WaterMeters[i]); + comboBoxes[k, i].Text = DEUtils.GetContent(colItems[k].Content, WaterMeters[i]); } break; } @@ -551,31 +469,27 @@ namespace TBF.Rig.DataEntry.Uni /// void UpdateWMsFromBoxes() { - if (item1.Content != Content.None && firstValidWM != null) + for (int ix = 0; ix < commonItemsCount; ix++ ) { - PutContent(item1.Content, firstValidWM, comboBox1.Text); - if (item1.Action != Action.LoadReadOnly) + DEUtils.PutContent(commonItems[ix].Content, firstValidWM, commonComboBoxes[ix].Text); + if (commonItems[ix].Action != Ac.LoadReadOnly) { - if (isEnd) Program.LocalSettings.UpdateHistory(comboBox1.Text, ref Program.LocalSettings.LastEnComm1); - else Program.LocalSettings.UpdateHistory(comboBox1.Text, ref Program.LocalSettings.LastBgComm1); - } - - if (item2.Content != Content.None) - { - PutContent(item2.Content, firstValidWM, comboBox2.Text); - if (item2.Action != Action.LoadReadOnly) + if (isEnd) { - if (isEnd) Program.LocalSettings.UpdateHistory(comboBox2.Text, ref Program.LocalSettings.LastEnComm2); - else Program.LocalSettings.UpdateHistory(comboBox2.Text, ref Program.LocalSettings.LastBgComm2); - } - - if (item3.Content != Content.None) - { - PutContent(item3.Content, firstValidWM, comboBox3.Text); - if (item3.Action != Action.LoadReadOnly) + switch (ix) { - if (isEnd) Program.LocalSettings.UpdateHistory(comboBox3.Text, ref Program.LocalSettings.LastEnComm3); - else Program.LocalSettings.UpdateHistory(comboBox3.Text, ref Program.LocalSettings.LastBgComm3); + case 0: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm1); break; + case 1: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm2); break; + case 2: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm3); break; + } + } + else + { + switch (ix) + { + case 0: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm1); break; + case 1: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm2); break; + case 2: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm3); break; } } } @@ -584,29 +498,18 @@ namespace TBF.Rig.DataEntry.Uni /// Propagate common (batch) values to water meters in case of /// Content.BatchAndWmOrder, Content.BatchAndWmRemark, Content.YearOfCalibration and Content.ArchivePath /// - if (item1.Content == Content.BatchAndWmOrder || - (item1.Content != Content.None && item2.Content == Content.BatchAndWmOrder) || - (item1.Content != Content.None && item2.Content != Content.None && item2.Content == Content.BatchAndWmOrder)) + foreach (var wm in WaterMeters) { - foreach (var wm in WaterMeters) if (wm != null && !wm.Disabled) wm.PurchaseOrder = firstValidWM.Batch.PurchaseOrder; - } - else if (item1.Content == Content.BatchAndWmRemark || - (item1.Content != Content.None && item2.Content == Content.BatchAndWmRemark) || - (item1.Content != Content.None && item2.Content != Content.None && item2.Content == Content.BatchAndWmRemark)) - { - foreach (var wm in WaterMeters) if (wm != null && !wm.Disabled) wm.Remark = firstValidWM.Batch.Remark; - } - else if (item1.Content == Content.YearOfCalibration || - (item1.Content != Content.None && item2.Content == Content.YearOfCalibration) || - (item1.Content != Content.None && item2.Content != Content.None && item2.Content == Content.YearOfCalibration)) - { - foreach (var wm in WaterMeters) if (wm != null && !wm.Disabled) wm.YearOfProduction = firstValidWM.YearOfProduction; - } - else if (item1.Content == Content.ArchivePath || - (item1.Content != Content.None && item2.Content == Content.ArchivePath) || - (item1.Content != Content.None && item2.Content != Content.None && item2.Content == Content.ArchivePath)) - { - foreach (var wm in WaterMeters) if (wm != null && !wm.Disabled) wm.ArchivePath = firstValidWM.ArchivePath; + if (wm != null && !wm.Disabled) + { + switch (commonItems[ix].Content) + { + case Ct.BatchAndWmOrder: wm.PurchaseOrder = firstValidWM.Batch.PurchaseOrder; break; + case Ct.BatchAndWmRemark: wm.Remark = firstValidWM.Batch.Remark; break; + case Ct.YearOfCalibration: wm.YearOfProduction = firstValidWM.YearOfProduction; break; + case Ct.ArchivePath: wm.ArchivePath = firstValidWM.ArchivePath; break; + } + } } } @@ -616,33 +519,33 @@ namespace TBF.Rig.DataEntry.Uni var currentVals = new string[wmsCount]; for (int i = 0; i < wmsCount; i++) { - PutContent(colItems[k].Content, WaterMeters[i], comboBoxes[k, i].Text); + DEUtils.PutContent(colItems[k].Content, WaterMeters[i], comboBoxes[k, i].Text); currentVals[i] = comboBoxes[k, i].Text; } /// Update history - if (colItems[k].Action != Action.LoadReadOnly) + if (colItems[k].Action != Ac.LoadReadOnly) { if (isEnd) { switch (k) { - default: - case 0: Program.LocalSettings.LastEnColA = currentVals; break; - case 1: Program.LocalSettings.LastEnColB = currentVals; break; - case 2: Program.LocalSettings.LastEnColC = currentVals; break; - case 3: Program.LocalSettings.LastEnColD = currentVals; break; + case 0: ls.LastEnColA = currentVals; break; + case 1: ls.LastEnColB = currentVals; break; + case 2: ls.LastEnColC = currentVals; break; + case 3: ls.LastEnColD = currentVals; break; + case 4: ls.LastEnColE = currentVals; break; } } else { switch (k) { - default: - case 0: Program.LocalSettings.LastBgColA = currentVals; break; - case 1: Program.LocalSettings.LastBgColB = currentVals; break; - case 2: Program.LocalSettings.LastBgColC = currentVals; break; - case 3: Program.LocalSettings.LastBgColD = currentVals; break; + case 0: ls.LastBgColA = currentVals; break; + case 1: ls.LastBgColB = currentVals; break; + case 2: ls.LastBgColC = currentVals; break; + case 3: ls.LastBgColD = currentVals; break; + case 4: ls.LastBgColE = currentVals; break; } } } @@ -654,79 +557,6 @@ namespace TBF.Rig.DataEntry.Uni } } - string GetContent(Content content, WaterMeter wm) - { - if (wm == null) return string.Empty; - - switch (content) - { - default: - case Content.None: return string.Empty; - case Content.SerialNr: return (!wm.Disabled && wm.SerialNr != null) ? wm.SerialNr : string.Empty; - case Content.SerialNrAux: return (!wm.Disabled && wm.SerialNrAux != null) ? wm.SerialNrAux : string.Empty; - case Content.RadioAddress: return (!wm.Disabled && wm.RadioAddress != null) ? wm.RadioAddress : string.Empty; - case Content.YearOfCalibration: return (!wm.Disabled) ? wm.YearOfProduction.ToString() : string.Empty; - case Content.StartState: return (!wm.Disabled && wm.GetStartState() != null) ? wm.GetStartState() : string.Empty; - case Content.EndState: return (!wm.Disabled && wm.EndState != null) ? wm.EndState : string.Empty; - case Content.ArchivePath: return (!wm.Disabled && wm.ArchivePath != null) ? wm.ArchivePath : string.Empty; - - case Content.WmOrder: return (!wm.Disabled && wm.PurchaseOrder != null) ? wm.PurchaseOrder : string.Empty; - case Content.BatchOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty; - case Content.BatchAndWmOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty; - - case Content.WmRemark: return (!wm.Disabled && wm.Remark != null) ? wm.Remark : string.Empty; - case Content.BatchRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty; - case Content.BatchAndWmRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty; -#if ORACLE_DB - case Content.Prefix: return (!wm.Disabled && wm.Prefix != null) ? wm.Prefix : string.Empty; - case Content.Suffix: return (!wm.Disabled && wm.Suffix != null) ? wm.Suffix : string.Empty; -#endif - } - } - - void PutContent(Content content, WaterMeter wm, string value) - { - if (wm == null || wm.Disabled) return; - - int year; - - switch (content) - { - default: - case Content.None: return; - case Content.SerialNr: wm.SerialNr = value; return; - case Content.SerialNrAux: wm.SerialNrAux = value; return; - case Content.RadioAddress: wm.RadioAddress = value; return; - case Content.YearOfCalibration: if (int.TryParse(value, out year)) wm.YearOfProduction = year; return; - case Content.StartState: wm.SetStartState(value); return; - case Content.EndState: wm.EndState = value; return; - case Content.ArchivePath: wm.ArchivePath = value; return; - - case Content.WmOrder: - wm.PurchaseOrder = value; - return; - - case Content.BatchOrder: - case Content.BatchAndWmOrder: - if (wm.Batch != null) wm.Batch.PurchaseOrder = value; - return; - - case Content.WmRemark: - wm.Remark = value; - return; - - case Content.BatchRemark: - case Content.BatchAndWmRemark: - if (wm.Batch != null) wm.Batch.Remark = value; - return; -#if ORACLE_DB - case Content.Prefix: wm.Prefix = value; return; - case Content.Suffix: wm.Suffix = value; return; -#endif - } - } - - private void clearButton_Click(object sender, EventArgs e) { InitializeBoxes(); @@ -783,22 +613,19 @@ namespace TBF.Rig.DataEntry.Uni { if (k < 0) { - if (j == 1 && comboBox2 != null) + for (int ix = j; ix < commonItemsCount; ix++) { - comboBox2.Focus(); - return; - } - else if (j == 2 && comboBox3 != null) - { - comboBox3.Focus(); - return; - } - else - { - /// Initialize k,j so that after the 1st increment k = 0 and j = 0 - if (isLrOrder) { k = -1; j = 0; } - else { k = 0; j = -1; } + if (commonComboBoxes[ix].Enabled) + { + commonComboBoxes[ix].Focus(); + return; + } } + + /// No next enabled common item found: + /// Initialize k,j so that after the 1st increment k = 0 and j = 0 + if (isLrOrder) { k = -1; j = 0; } + else { k = 0; j = -1; } } /// Change focus diff --git a/TBF/Rig/DataEntry/Uni/DEItem.cs b/TBF/Rig/DataEntry/Uni/DEItem.cs index 407d504a3..20bdc0afb 100644 --- a/TBF/Rig/DataEntry/Uni/DEItem.cs +++ b/TBF/Rig/DataEntry/Uni/DEItem.cs @@ -7,7 +7,10 @@ using Common; namespace TBF.Rig.DataEntry.Uni { - public enum Action + /// + /// Ac = Action + /// + public enum Ac { [Description("Clear")] Clear, /// Clear when the form is open, save on OK [Description("Last from history")] HistoryLast, @@ -16,7 +19,10 @@ namespace TBF.Rig.DataEntry.Uni Count, } - public enum Content + /// + /// Ct = Content + /// + public enum Ct { [Description("None")] None, [Description("Serial nr.")] SerialNr, @@ -41,12 +47,12 @@ namespace TBF.Rig.DataEntry.Uni public class DEItem { - public readonly Content Content; + public readonly Ct Content; public readonly string Caption; - public readonly Action Action; + public readonly Ac Action; public readonly int Width; - public DEItem(Content content, string caption, Action action, int width) + public DEItem(Ct content, string caption, Ac action, int width) { Content = content; Caption = caption; @@ -54,11 +60,23 @@ namespace TBF.Rig.DataEntry.Uni Width = width; } + + static IList items = new List(); + /// + public static void ClearItems() { items.Clear(); } + public static void AddItem(DEItem item) { items.Add(item); } + public static void AddItem(Ct content, string caption, Ac action, int width) + { + items.Add(new DEItem(content, caption, action, width)); + } + public static IList GetItems() { return items; } + + static IList columns = new List(); /// public static void ClearColumns() { columns.Clear(); } public static void AddColumn(DEItem column) { columns.Add(column); } - public static void AddColumn(Content content, string caption, Action action, int width) + public static void AddColumn(Ct content, string caption, Ac action, int width) { columns.Add(new DEItem(content, caption, action, width)); } diff --git a/TBF/Rig/DataEntry/Uni/DEUtils.cs b/TBF/Rig/DataEntry/Uni/DEUtils.cs new file mode 100644 index 000000000..2f8f9f7fb --- /dev/null +++ b/TBF/Rig/DataEntry/Uni/DEUtils.cs @@ -0,0 +1,83 @@ +/// +/// Copyright (c) 2023 Sensus Slovensko a.s. +/// +using System; +using Results.Entities; + +namespace TBF.Rig.DataEntry.Uni +{ + public class DEUtils + { + public static string GetContent(Ct content, WaterMeter wm) + { + if (wm == null) return string.Empty; + + switch (content) + { + default: + case Ct.None: return string.Empty; + case Ct.SerialNr: return (!wm.Disabled && wm.SerialNr != null) ? wm.SerialNr : string.Empty; + case Ct.SerialNrAux: return (!wm.Disabled && wm.SerialNrAux != null) ? wm.SerialNrAux : string.Empty; + case Ct.RadioAddress: return (!wm.Disabled && wm.RadioAddress != null) ? wm.RadioAddress : string.Empty; + case Ct.YearOfCalibration: return (!wm.Disabled) ? wm.YearOfProduction.ToString() : string.Empty; + case Ct.StartState: return (!wm.Disabled && wm.GetStartState() != null) ? wm.GetStartState() : string.Empty; + case Ct.EndState: return (!wm.Disabled && wm.EndState != null) ? wm.EndState : string.Empty; + case Ct.ArchivePath: return (!wm.Disabled && wm.ArchivePath != null) ? wm.ArchivePath : string.Empty; + + case Ct.WmOrder: return (!wm.Disabled && wm.PurchaseOrder != null) ? wm.PurchaseOrder : string.Empty; + case Ct.BatchOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty; + case Ct.BatchAndWmOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty; + + case Ct.WmRemark: return (!wm.Disabled && wm.Remark != null) ? wm.Remark : string.Empty; + case Ct.BatchRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty; + case Ct.BatchAndWmRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty; +#if ORACLE_DB + case Content.Prefix: return (!wm.Disabled && wm.Prefix != null) ? wm.Prefix : string.Empty; + case Content.Suffix: return (!wm.Disabled && wm.Suffix != null) ? wm.Suffix : string.Empty; +#endif + } + } + + public static void PutContent(Ct content, WaterMeter wm, string value) + { + if (wm == null || wm.Disabled) return; + + int year; + + switch (content) + { + default: + case Ct.None: return; + case Ct.SerialNr: wm.SerialNr = value; return; + case Ct.SerialNrAux: wm.SerialNrAux = value; return; + case Ct.RadioAddress: wm.RadioAddress = value; return; + case Ct.YearOfCalibration: if (int.TryParse(value, out year)) wm.YearOfProduction = year; return; + case Ct.StartState: wm.SetStartState(value); return; + case Ct.EndState: wm.EndState = value; return; + case Ct.ArchivePath: wm.ArchivePath = value; return; + + case Ct.WmOrder: + wm.PurchaseOrder = value; + return; + + case Ct.BatchOrder: + case Ct.BatchAndWmOrder: + if (wm.Batch != null) wm.Batch.PurchaseOrder = value; + return; + + case Ct.WmRemark: + wm.Remark = value; + return; + + case Ct.BatchRemark: + case Ct.BatchAndWmRemark: + if (wm.Batch != null) wm.Batch.Remark = value; + return; +#if ORACLE_DB + case Content.Prefix: wm.Prefix = value; return; + case Content.Suffix: wm.Suffix = value; return; +#endif + } + } + } +} diff --git a/TBF/Rig/DataEntry/Uni/EntryFormCfg.cs b/TBF/Rig/DataEntry/Uni/EntryFormCfg.cs index 8450d0b31..3a59019e4 100644 --- a/TBF/Rig/DataEntry/Uni/EntryFormCfg.cs +++ b/TBF/Rig/DataEntry/Uni/EntryFormCfg.cs @@ -33,91 +33,281 @@ namespace TBF.Rig.DataEntry.Uni /// /// Serialized parameters /// - public bool ShowCycleBeginningForm; /// 0 - public string BgTitle; /// 1 - public Sz BgSize; /// 2 - public bool BgIsLrOrder; /// 3 - public string BgFormCloseKeys; /// 4 + public bool BgShowForm; /// 0 + public string BgTitle; /// 1 + public Sz BgSize; /// 2 + // int BgItemsCount; /// 3 + // int BgColumnsCount; /// 4 + public bool BgIsLrOrder; /// 5 + public bool BgIsVertArrangement; /// 6 + public string BgFormCloseKeys; /// 7 + + public bool EnShowForm; /// 8 + public string EnTitle; /// 9 + public Sz EnSize; /// 10 + // int EnItemsCount; /// 11 + // int EnColumnsCount; /// 12 + public bool EnIsLrOrder; /// 13 + public bool EnIsVertArrangement; /// 14 + public string EnFormCloseKeys; /// 15 + + public bool TestStartEndShowForm; /// 16 + public string TestTitle; /// 17 + public Sz TestSize; /// 18 + // int TestColumnsCount; /// 19 + public bool TestIsLrOrder; /// 20 + public bool TestIsVertArrangement; /// 21 + public string TestFormCloseKeys; /// 22 - public bool ShowCycleEndForm; /// 5 - public string EnTitle; /// 6 - public Sz EnSize; /// 7 - public bool EnIsLrOrder; /// 8 - public string EnFormCloseKeys; /// 9 + public Ct[] BgItemContent; /// 23 + 4 * ix + public string[] BgItemCaption; /// 24 + 4 * ix + public Ac[] BgItemAction; /// 25 + 4 * ix + public int[] BgItemWidth; /// 26 + 4 * ix - public bool ShowTestStartEndForm; /// 10 - public string TestTitle; /// 11 - public Sz TestSize; /// 12 - public string TestFormCloseKeys; /// 13 + public Ct[] BgColumnContent; /// 23 + 4 * ix + public string[] BgColumnCaption; /// 24 + 4 * ix + public Ac[] BgColumnAction; /// 25 + 4 * ix + public int[] BgColumnWidth; /// 26 + 4 * ix - public Content BgItem1Content; /// 14 - public string BgItem1Caption; /// 15 - public Action BgItem1Action; /// 16 - public int BgItem1Width; /// 17 - public Content BgItem2Content; /// 18 - public string BgItem2Caption; /// 19 - public Action BgItem2Action; /// 20 - public int BgItem2Width; /// 21 - public Content BgItem3Content; /// 22 - public string BgItem3Caption; /// 23 - public Action BgItem3Action; /// 24 - public int BgItem3Width; /// 25 - public Content BgColAContent; /// 26 - public string BgColACaption; /// 27 - public Action BgColAAction; /// 28 - public int BgColAWidth; /// 29 - public Content BgColBContent; /// 30 - public string BgColBCaption; /// 31 - public Action BgColBAction; /// 32 - public int BgColBWidth; /// 33 - public Content BgColCContent; /// 34 - public string BgColCCaption; /// 35 - public Action BgColCAction; /// 36 - public int BgColCWidth; /// 37 - public Content BgColDContent; /// 38 - public string BgColDCaption; /// 39 - public Action BgColDAction; /// 40 - public int BgColDWidth; /// 41 - public Content BgColEContent; /// 42 - public string BgColECaption; /// 43 - public Action BgColEAction; /// 44 - public int BgColEWidth; /// 45 + public Ct[] EnItemContent; /// 23 + 4 * ix + public string[] EnItemCaption; /// 24 + 4 * ix + public Ac[] EnItemAction; /// 25 + 4 * ix + public int[] EnItemWidth; /// 26 + 4 * ix - public Content EnItem1Content; /// 46 - public string EnItem1Caption; /// 47 - public Action EnItem1Action; /// 48 - public int EnItem1Width; /// 49 - public Content EnItem2Content; /// 50 - public string EnItem2Caption; /// 51 - public Action EnItem2Action; /// 52 - public int EnItem2Width; /// 53 - public Content EnItem3Content; /// 54 - public string EnItem3Caption; /// 55 - public Action EnItem3Action; /// 56 - public int EnItem3Width; /// 57 - public Content EnColAContent; /// 58 - public string EnColACaption; /// 59 - public Action EnColAAction; /// 60 - public int EnColAWidth; /// 61 - public Content EnColBContent; /// 62 - public string EnColBCaption; /// 63 - public Action EnColBAction; /// 64 - public int EnColBWidth; /// 65 - public Content EnColCContent; /// 66 - public string EnColCCaption; /// 67 - public Action EnColCAction; /// 68 - public int EnColCWidth; /// 69 - public Content EnColDContent; /// 70 - public string EnColDCaption; /// 71 - public Action EnColDAction; /// 72 - public int EnColDWidth; /// 73 - public Content EnColEContent; /// 74 - public string EnColECaption; /// 75 - public Action EnColEAction; /// 76 - public int EnColEWidth; /// 77 + public Ct[] EnColumnContent; /// 23 + 4 * ix + public string[] EnColumnCaption; /// 24 + 4 * ix + public Ac[] EnColumnAction; /// 25 + 4 * ix + public int[] EnColumnWidth; /// 26 + 4 * ix + public Ct[] TestColumnContent; /// 23 + 4 * ix + public string[] TestColumnCaption; /// 24 + 4 * ix + public Ac[] TestColumnAction; /// 25 + 4 * ix + public int[] TestColumnWidth; /// 26 + 4 * ix + + /// + /// Not serialized + /// + int oriBgItemsCount = -1; + int oriBgColumnsCount = -1; + int oriEnItemsCount = -1; + int oriEnColumnsCount = -1; + int oriTestColumnsCount = -1; + + /// + /// Wrappers + /// + public int GetBgItemsCount() { return (BgItemContent == null) ? 0 : BgItemContent.Length; } + public int GetBgColumnsCount() { return (BgColumnContent == null) ? 0 : BgColumnContent.Length; } + public int GetEnItemsCount() { return (EnItemContent == null) ? 0 : EnItemContent.Length; } + public int GetEnColumnsCount() { return (EnColumnContent == null) ? 0 : EnColumnContent.Length; } + public int GetTestColumnsCount() { return (TestColumnContent == null) ? 0 : TestColumnContent.Length; } + /// + void SetBgItemsCount(int newCount) + { + if (oriBgItemsCount < 0) oriBgItemsCount = GetBgItemsCount(); + if (newCount == GetBgItemsCount()) return; + + int oldCount = (BgItemContent == null) ? 0 : BgItemContent.Length; + var oldContent = BgItemContent; + var oldCaption = BgItemCaption; + var oldAction = BgItemAction; + var oldWidth = BgItemWidth; + + BgItemContent = new Ct[newCount]; + BgItemCaption = new string[newCount]; + BgItemAction = new Ac[newCount]; + BgItemWidth = new int[newCount]; + + for (int i = 0; i < newCount; i++) + { + if (i < oldCount) + { + BgItemContent[i] = oldContent[i]; + BgItemCaption[i] = oldCaption[i]; + BgItemAction[i] = oldAction[i]; + BgItemWidth[i] = oldWidth[i]; + } + else + { + BgItemContent[i] = Ct.None; + BgItemCaption[i] = string.Empty; + BgItemAction[i] = Ac.Clear; + BgItemWidth[i] = 0; + } + } + } + /// + void SetBgColumnsCount(int newCount) + { + if (oriBgColumnsCount < 0) oriBgColumnsCount = GetBgColumnsCount(); + if (newCount == GetBgColumnsCount()) return; + + int oldCount = (BgColumnContent == null) ? 0 : BgColumnContent.Length; + var oldContent = BgColumnContent; + var oldCaption = BgColumnCaption; + var oldAction = BgColumnAction; + var oldWidth = BgColumnWidth; + + BgColumnContent = new Ct[newCount]; + BgColumnCaption = new string[newCount]; + BgColumnAction = new Ac[newCount]; + BgColumnWidth = new int[newCount]; + + for (int i = 0; i < newCount; i++) + { + if (i < oldCount) + { + BgColumnContent[i] = oldContent[i]; + BgColumnCaption[i] = oldCaption[i]; + BgColumnAction[i] = oldAction[i]; + BgColumnWidth[i] = oldWidth[i]; + } + else + { + BgColumnContent[i] = Ct.None; + BgColumnCaption[i] = string.Empty; + BgColumnAction[i] = Ac.Clear; + BgColumnWidth[i] = 0; + } + } + } + /// + void SetEnItemsCount(int newCount) + { + if (oriEnItemsCount < 0) oriEnItemsCount = GetEnItemsCount(); + if (newCount == GetEnItemsCount()) return; + + int oldCount = (EnItemContent == null) ? 0 : EnItemContent.Length; + var oldContent = EnItemContent; + var oldCaption = EnItemCaption; + var oldAction = EnItemAction; + var oldWidth = EnItemWidth; + + EnItemContent = new Ct[newCount]; + EnItemCaption = new string[newCount]; + EnItemAction = new Ac[newCount]; + EnItemWidth = new int[newCount]; + + for (int i = 0; i < newCount; i++) + { + if (i < oldCount) + { + EnItemContent[i] = oldContent[i]; + EnItemCaption[i] = oldCaption[i]; + EnItemAction[i] = oldAction[i]; + EnItemWidth[i] = oldWidth[i]; + } + else + { + EnItemContent[i] = Ct.None; + EnItemCaption[i] = string.Empty; + EnItemAction[i] = Ac.Clear; + EnItemWidth[i] = 0; + } + } + } + /// + void SetEnColumnsCount(int newCount) + { + if (oriEnColumnsCount < 0) oriEnColumnsCount = GetEnColumnsCount(); + if (newCount == GetEnColumnsCount()) return; + + int oldCount = (EnColumnContent == null) ? 0 : EnColumnContent.Length; + var oldContent = EnColumnContent; + var oldCaption = EnColumnCaption; + var oldAction = EnColumnAction; + var oldWidth = EnColumnWidth; + + EnColumnContent = new Ct[newCount]; + EnColumnCaption = new string[newCount]; + EnColumnAction = new Ac[newCount]; + EnColumnWidth = new int[newCount]; + + for (int i = 0; i < newCount; i++) + { + if (i < oldCount) + { + EnColumnContent[i] = oldContent[i]; + EnColumnCaption[i] = oldCaption[i]; + EnColumnAction[i] = oldAction[i]; + EnColumnWidth[i] = oldWidth[i]; + } + else + { + EnColumnContent[i] = Ct.None; + EnColumnCaption[i] = string.Empty; + EnColumnAction[i] = Ac.Clear; + EnColumnWidth[i] = 0; + } + } + } + /// + void SetTestColumnsCount(int newCount) + { + if (oriTestColumnsCount < 0) oriTestColumnsCount = GetTestColumnsCount(); + if (newCount == GetTestColumnsCount()) return; + + int oldCount = (TestColumnContent == null) ? 0 : TestColumnContent.Length; + var oldContent = TestColumnContent; + var oldCaption = TestColumnCaption; + var oldAction = TestColumnAction; + var oldWidth = TestColumnWidth; + + TestColumnContent = new Ct[newCount]; + TestColumnCaption = new string[newCount]; + TestColumnAction = new Ac[newCount]; + TestColumnWidth = new int[newCount]; + + for (int i = 0; i < newCount; i++) + { + if (i < oldCount) + { + TestColumnContent[i] = oldContent[i]; + TestColumnCaption[i] = oldCaption[i]; + TestColumnAction[i] = oldAction[i]; + TestColumnWidth[i] = oldWidth[i]; + } + else + { + TestColumnContent[i] = Ct.None; + TestColumnCaption[i] = string.Empty; + TestColumnAction[i] = Ac.Clear; + TestColumnWidth[i] = 0; + } + } + } + /// + int GetOriBgItemsCount() + { + if (oriBgItemsCount < 0) oriBgItemsCount = GetBgItemsCount(); + return oriBgItemsCount; + } + int GetOriBgColumnsCount() + { + if (oriBgColumnsCount < 0) oriBgColumnsCount = GetBgColumnsCount(); + return oriBgColumnsCount; + } + int GetOriEnItemsCount() + { + if (oriEnItemsCount < 0) oriEnItemsCount = GetEnItemsCount(); + return oriEnItemsCount; + } + int GetOriEnColumnsCount() + { + if (oriEnColumnsCount < 0) oriEnColumnsCount = GetEnColumnsCount(); + return oriEnColumnsCount; + } + int GetOriTestColumnsCount() + { + if (oriTestColumnsCount < 0) oriTestColumnsCount = GetTestColumnsCount(); + return oriTestColumnsCount; + } + + + /// /// Private parameterless constructor invoked by all other (public) constructors - EntryFormCfg() { } + /// + EntryFormCfg() { } public EntryFormCfg(IComponentFactory factory, string name) : this() @@ -132,227 +322,230 @@ namespace TBF.Rig.DataEntry.Uni public void InitializeAll() { - ShowCycleBeginningForm = true; + BgShowForm = true; BgTitle = "Enter water meter data"; BgSize = Sz.M; BgIsLrOrder = false; + BgIsVertArrangement = false; BgFormCloseKeys = string.Empty; - ShowCycleEndForm = false; + EnShowForm = false; EnTitle = "Enter water meter data"; EnSize = Sz.M; EnIsLrOrder = false; + EnIsVertArrangement = false; EnFormCloseKeys = string.Empty; - ShowTestStartEndForm = true; + TestStartEndShowForm = true; TestTitle = "Enter states of water meters"; TestSize = Sz.M; + TestIsLrOrder = false; + TestIsVertArrangement = false; TestFormCloseKeys = string.Empty; - BgItem1Content = Content.BatchAndWmOrder; - BgItem1Caption = "Order nr."; - BgItem1Action = Action.HistoryLast; - BgItem1Width = 160; - - BgItem2Content = Content.None; - BgItem3Content = Content.None; - - BgColAContent = Content.SerialNr; - BgColACaption = "Serial nr."; - BgItem1Action = Action.Clear; - BgColAWidth = 160; + BgItemContent = new Ct[1] { Ct.BatchAndWmOrder }; + BgItemCaption = new string[1] { "Order nr." }; + BgItemAction = new Ac[1] { Ac.Clear }; + BgItemWidth = new int[1] { 200 }; - BgColBContent = Content.None; - BgColCContent = Content.None; - BgColDContent = Content.None; - BgColEContent = Content.None; + BgColumnContent = new Ct[1] { Ct.SerialNr }; + BgColumnCaption = new string[1] { "S/N" }; + BgColumnAction = new Ac[1] { Ac.Clear }; + BgColumnWidth = new int[1] { 200 }; + EnItemContent = new Ct[2] { Ct.BatchAndWmOrder, Ct.BatchRemark }; + EnItemCaption = new string[2] { "Order nr.","Remark" }; + EnItemAction = new Ac[2] { Ac.LoadReadOnly, Ac.HistoryLast }; + EnItemWidth = new int[2] { 200, 200 }; - EnItem1Content = Content.BatchRemark; - EnItem1Caption = "Remark"; - EnItem1Action = Action.HistoryLast; - EnItem1Width = 160; + EnColumnContent = new Ct[2] { Ct.SerialNr, Ct.EndState }; + EnColumnCaption = new string[2] { "S/N", "End state" }; + EnColumnAction = new Ac[2] { Ac.LoadReadOnly, Ac.Clear }; + EnColumnWidth = new int[2] { 200, 200 }; - EnItem2Content = Content.None; - EnItem3Content = Content.None; - - EnColAContent = Content.SerialNr; - EnColACaption = "Serial nr."; - EnColAAction = Action.LoadReadOnly; - EnColAWidth = -160; - - EnColBCaption = "End state"; - EnColBContent = Content.EndState; - EnColBAction = Action.Clear; - EnColBWidth = 160; - - EnColCContent = Content.None; - EnColDContent = Content.None; - EnColEContent = Content.None; + TestColumnContent = new Ct[3] { Ct.SerialNr, Ct.StartState, Ct.EndState }; + TestColumnCaption = new string[3] { "S/N", "Start state", "End state" }; + TestColumnAction = new Ac[3] { Ac.LoadReadOnly, Ac.Clear, Ac.Clear }; + TestColumnWidth = new int[3] { 200, 200, 200 }; } string[] paramNames = new string[] { - Strings.Show_cycle_beginning_form, - "Beginning: Title", - "Beginning: Size", + "Beginning: Show form", + "Beginning: Form title", + "Beginning: Font ize", + "Beginning: Common items count", + "Beginning: Columns count", "Beginning: Left-to-right order", + "Beginning: Vertical arrangement (2 lines)", "Beginning: Keys to close the form", - Strings.Show_cycle_end_form, - "End: Title", - "End: Size", + "End: Show form", + "End: Form title", + "End: Font size", + "End: Common items count", + "End: Columns count", "End: Left-to-right order", + "End: Vertical arrangement (2 lines)", "End: Keys to close the form", - "Show test start/end form", - "Test start/end: Title", - "Test start/end: Size", + "Test start/end: Show form", + "Test start/end: Form title", + "Test start/end: Font size", + "Test start/end: Columns count", + "Test start/end: Left-to-right order", + "Test start/end: Vertical arrangement (2 lines)", "Test start/end: Keys to close the form", - - "Beginning: Item 1 content", - "Beginning: Item 1 caption", - "Beginning: Item 1 action", - "Beginning: Item 1 width", - "Beginning: Item 2 content", - "Beginning: Item 2 caption", - "Beginning: Item 2 action", - "Beginning: Item 2 width", - "Beginning: Item 3 content", - "Beginning: Item 3 caption", - "Beginning: Item 3 action", - "Beginning: Item 3 width", - "Beginning: Column A content", - "Beginning: Column A caption", - "Beginning: Column A action", - "Beginning: Column A width", - "Beginning: Column B content", - "Beginning: Column B caption", - "Beginning: Column B action", - "Beginning: Column B width", - "Beginning: Column C content", - "Beginning: Column C caption", - "Beginning: Column C action", - "Beginning: Column C width", - "Beginning: Column D content", - "Beginning: Column D caption", - "Beginning: Column D action", - "Beginning: Column D width", - "Beginning: Column E content", - "Beginning: Column E caption", - "Beginning: Column E action", - "Beginning: Column E width", - - "End: Item 1 content", - "End: Item 1 caption", - "End: Item 1 action", - "End: Item 1 width", - "End: Item 2 content", - "End: Item 2 caption", - "End: Item 2 action", - "End: Item 2 width", - "End: Item 3 content", - "End: Item 3 caption", - "End: Item 3 action", - "End: Item 3 width", - "End: Column A content", - "End: Column A caption", - "End: Column A action", - "End: Column A width", - "End: Column B content", - "End: Column B caption", - "End: Column B action", - "End: Column B width", - "End: Column C content", - "End: Column C caption", - "End: Column C action", - "End: Column C width", - "End: Column D content", - "End: Column D caption", - "End: Column D action", - "End: Column D width", - "End: Column E content", - "End: Column E caption", - "End: Column E action", - "End: Column E width", }; - public string ParamName(int i) { return paramNames[i]; } - public int ParamsCount() { return paramNames.Length; } + public string ParamName(int i) + { + if (i < paramNames.Length) return paramNames[i]; + int ix = i - paramNames.Length; + + if (ix < 4 * GetOriBgItemsCount()) + { + int j = ix / 4 + 1; + switch (ix % 4) + { + case 0: return string.Format("Beginning: Item {0} content", j); + case 1: return string.Format("Beginning: Item {0} caption", j); + case 2: return string.Format("Beginning: Item {0} action", j); + case 3: return string.Format("Beginning: Item {0} width", j); + } + } + ix -= 4 * GetOriBgItemsCount(); + + if (ix < 4 * GetOriBgColumnsCount()) + { + char c = Convert.ToChar(ix / 4 + 65); + switch (ix % 4) + { + case 0: return string.Format("Beginning: Column {0} content", c); + case 1: return string.Format("Beginning: Column {0} caption", c); + case 2: return string.Format("Beginning: Column {0} action", c); + case 3: return string.Format("Beginning: Column {0} width", c); + } + } + ix -= 4 * GetOriBgColumnsCount(); + + if (ix < 4 * GetOriEnItemsCount()) + { + int j = ix / 4 + 1; + switch (ix % 4) + { + case 0: return string.Format("End: Item {0} content", j); + case 1: return string.Format("End: Item {0} caption", j); + case 2: return string.Format("End: Item {0} action", j); + case 3: return string.Format("End: Item {0} width", j); + } + } + ix -= 4 * GetOriEnItemsCount(); + + if (ix < 4 * GetOriEnColumnsCount()) + { + char c = Convert.ToChar(ix / 4 + 65); + switch (ix % 4) + { + case 0: return string.Format("End: Column {0} content", c); + case 1: return string.Format("End: Column {0} caption", c); + case 2: return string.Format("End: Column {0} action", c); + case 3: return string.Format("End: Column {0} width", c); + } + } + ix -= 4 * GetOriEnColumnsCount(); + + if (ix < 4 * GetOriTestColumnsCount()) + { + char c = Convert.ToChar(ix / 4 + 65); + switch (ix % 4) + { + case 0: return string.Format("Test start/end: Column {0} content", c); + case 1: return string.Format("Test start/end: Column {0} caption", c); + case 2: return string.Format("Test start/end: Column {0} action", c); + case 3: return string.Format("Test start/end: Column {0} width", c); + } + } + + return string.Empty; + } + + public int ParamsCount() + { + int itemsCount = GetOriBgItemsCount() + GetOriBgColumnsCount() + + GetOriEnItemsCount() + GetOriEnColumnsCount() + GetOriTestColumnsCount(); + return paramNames.Length + 4 * itemsCount; + } public ICollection ParamValues(int i) { var list = new List(); - switch (i) + if (i < paramNames.Length) + { + switch (i) + { + case 0: + case 5: + case 6: + case 8: + case 13: + case 14: + case 16: + case 20: + case 21: + return new string[] { Strings.yes, Strings.no }; + case 2: + case 10: + case 18: + for (Sz sz = 0; sz < Sz.Count; sz++) list.Add(sz.ToDescription()); + return list; + default: + return null; + } + } + + i -= paramNames.Length; + + switch (i % 4) { case 0: - case 3: - case 5: - case 8: - case 10: - return new string[] { Strings.yes, Strings.no }; - case 14: - case 18: - case 22: - case 46: - case 50: - case 54: - return new string[] + bool isCommon = (i < 4 * GetOriBgItemsCount()) + || (i >= 4 * (GetOriBgItemsCount() + GetOriBgColumnsCount()) + && i < 4 * (GetOriBgItemsCount() + GetOriBgColumnsCount() + GetOriEnItemsCount())); + if (isCommon) { - Content.None.ToDescription(), - Content.YearOfCalibration.ToDescription(), - Content.ArchivePath.ToDescription(), - Content.BatchOrder.ToDescription(), - Content.BatchAndWmOrder.ToDescription(), - Content.BatchRemark.ToDescription(), - Content.BatchAndWmRemark.ToDescription(), - }; - case 26: - case 30: - case 34: - case 38: - case 42: - case 58: - case 62: - case 66: - case 70: - case 74: - return new string[] + return new string[] + { + Ct.None.ToDescription(), + Ct.YearOfCalibration.ToDescription(), + Ct.ArchivePath.ToDescription(), + Ct.BatchOrder.ToDescription(), + Ct.BatchAndWmOrder.ToDescription(), + Ct.BatchRemark.ToDescription(), + Ct.BatchAndWmRemark.ToDescription(), + }; + } + else { - Content.None.ToDescription(), - Content.SerialNr.ToDescription(), - Content.SerialNrAux.ToDescription(), - Content.RadioAddress.ToDescription(), - Content.YearOfCalibration.ToDescription(), - Content.StartState.ToDescription(), - Content.EndState.ToDescription(), - Content.ArchivePath.ToDescription(), - Content.WmOrder.ToDescription(), - Content.WmRemark.ToDescription(), - }; - case 16: - case 20: - case 24: - case 28: - case 32: - case 36: - case 40: - case 44: - case 48: - case 52: - case 56: - case 60: - case 64: - case 68: - case 72: - case 76: - for (Action a = 0; a < Action.Count; a++) list.Add(a.ToDescription()); - return list; + return new string[] + { + Ct.None.ToDescription(), + Ct.SerialNr.ToDescription(), + Ct.SerialNrAux.ToDescription(), + Ct.RadioAddress.ToDescription(), + Ct.YearOfCalibration.ToDescription(), + Ct.StartState.ToDescription(), + Ct.EndState.ToDescription(), + Ct.ArchivePath.ToDescription(), + Ct.WmOrder.ToDescription(), + Ct.WmRemark.ToDescription(), + }; + } case 2: - case 7: - case 12: - for (Sz sz = 0; sz < Sz.Count; sz++) list.Add(sz.ToDescription()); + for (Ac a = 0; a < Ac.Count; a++) list.Add(a.ToDescription()); return list; + case 1: + case 3: default: return null; } @@ -360,626 +553,347 @@ namespace TBF.Rig.DataEntry.Uni public string ToString(int i) { - switch (i) + if (i < 0) { - case 0: return ShowCycleBeginningForm ? Strings.yes : Strings.no; - case 1: return BgTitle; - case 2: return BgSize.ToDescription(); - case 3: return BgIsLrOrder ? Strings.yes : Strings.no; - case 4: return BgFormCloseKeys; - - case 5: return ShowCycleEndForm ? Strings.yes : Strings.no; - case 6: return EnTitle; - case 7: return EnSize.ToDescription(); - case 8: return EnIsLrOrder ? Strings.yes : Strings.no; - case 9: return EnFormCloseKeys; - - case 10: return ShowTestStartEndForm ? Strings.yes : Strings.no; - case 11: return TestTitle; - case 12: return TestSize.ToDescription(); - case 13: return TestFormCloseKeys; - - case 14: return BgItem1Content.ToDescription(); - case 15: return BgItem1Caption; - case 16: return BgItem1Action.ToDescription(); - case 17: return BgItem1Width.ToString(); - - case 18: return BgItem2Content.ToDescription(); - case 19: return BgItem2Caption; - case 20: return BgItem2Action.ToDescription(); - case 21: return BgItem2Width.ToString(); - - case 22: return BgItem3Content.ToDescription(); - case 23: return BgItem3Caption; - case 24: return BgItem3Action.ToDescription(); - case 25: return BgItem3Width.ToString(); - - case 26: return BgColAContent.ToDescription(); - case 27: return BgColACaption; - case 28: return BgColAAction.ToDescription(); - case 29: return BgColAWidth.ToString(); - - case 30: return BgColBContent.ToDescription(); - case 31: return BgColBCaption; - case 32: return BgColBAction.ToDescription(); - case 33: return BgColBWidth.ToString(); - - case 34: return BgColCContent.ToDescription(); - case 35: return BgColCCaption; - case 36: return BgColCAction.ToDescription(); - case 37: return BgColCWidth.ToString(); - - case 38: return BgColDContent.ToDescription(); - case 39: return BgColDCaption; - case 40: return BgColDAction.ToDescription(); - case 41: return BgColDWidth.ToString(); - - case 42: return BgColEContent.ToDescription(); - case 43: return BgColECaption; - case 44: return BgColEAction.ToDescription(); - case 45: return BgColEWidth.ToString(); - - case 46: return EnItem1Content.ToDescription(); - case 47: return EnItem1Caption; - case 48: return EnItem1Action.ToDescription(); - case 49: return EnItem1Width.ToString(); - - case 50: return EnItem2Content.ToDescription(); - case 51: return EnItem2Caption; - case 52: return EnItem2Action.ToDescription(); - case 53: return EnItem2Width.ToString(); - - case 54: return EnItem3Content.ToDescription(); - case 55: return EnItem3Caption; - case 56: return EnItem3Action.ToDescription(); - case 57: return EnItem3Width.ToString(); - - case 58: return EnColAContent.ToDescription(); - case 59: return EnColACaption; - case 60: return EnColAAction.ToDescription(); - case 61: return EnColAWidth.ToString(); - - case 62: return EnColBContent.ToDescription(); - case 63: return EnColBCaption; - case 64: return EnColBAction.ToDescription(); - case 65: return EnColBWidth.ToString(); - - case 66: return EnColCContent.ToDescription(); - case 67: return EnColCCaption; - case 68: return EnColCAction.ToDescription(); - case 69: return EnColCWidth.ToString(); - - case 70: return EnColDContent.ToDescription(); - case 71: return EnColDCaption; - case 72: return EnColDAction.ToDescription(); - case 73: return EnColDWidth.ToString(); - - case 74: return EnColEContent.ToDescription(); - case 75: return EnColECaption; - case 76: return EnColEAction.ToDescription(); - case 77: return EnColEWidth.ToString(); - - default: - return string.Format("Name={0}, Show cycle beginning form={1}, Show cycle end form={2}", Name, ShowCycleBeginningForm, ShowCycleEndForm); + return string.Format("Name={0}, Show cycle beginning form={1}, Show cycle end form={2}", + Name, BgShowForm, EnShowForm); } + + if (i < paramNames.Length) + { + switch (i) + { + case 0: return BgShowForm ? Strings.yes : Strings.no; + case 1: return BgTitle; + case 2: return BgSize.ToDescription(); + case 3: return GetBgItemsCount().ToString(); + case 4: return GetBgColumnsCount().ToString(); + case 5: return BgIsLrOrder ? Strings.yes : Strings.no; + case 6: return BgIsVertArrangement ? Strings.yes : Strings.no; + case 7: return BgFormCloseKeys; + + case 8: return EnShowForm ? Strings.yes : Strings.no; + case 9: return EnTitle; + case 10: return EnSize.ToDescription(); + case 11: return GetEnItemsCount().ToString(); + case 12: return GetEnColumnsCount().ToString(); + case 13: return EnIsLrOrder ? Strings.yes : Strings.no; + case 14: return EnIsVertArrangement ? Strings.yes : Strings.no; + case 15: return EnFormCloseKeys; + + case 16: return TestStartEndShowForm ? Strings.yes : Strings.no; + case 17: return TestTitle; + case 18: return TestSize.ToDescription(); + case 19: return GetTestColumnsCount().ToString(); + case 20: return TestIsLrOrder ? Strings.yes : Strings.no; + case 21: return TestIsVertArrangement ? Strings.yes : Strings.no; + case 22: return TestFormCloseKeys; + + default: return string.Empty; + } + } + + int ix = i - paramNames.Length; + + if (ix < 4 * GetOriBgItemsCount()) + { + int j = ix / 4; + switch (ix % 4) + { + case 0: return (j < GetBgItemsCount()) ? BgItemContent[j].ToDescription() : Ct.None.ToDescription(); + case 1: return (j < GetBgItemsCount()) ? BgItemCaption[j] : string.Empty; + case 2: return (j < GetBgItemsCount()) ? BgItemAction[j].ToDescription() : Ac.Clear.ToDescription(); + case 3: return (j < GetBgItemsCount()) ? BgItemWidth[j].ToString() : "0"; + } + } + ix -= 4 * GetOriBgItemsCount(); + + if (ix < 4 * GetOriBgColumnsCount()) + { + int j = ix / 4; + switch (ix % 4) + { + case 0: return (j < GetBgColumnsCount()) ? BgColumnContent[j].ToDescription() : Ct.None.ToDescription(); + case 1: return (j < GetBgColumnsCount()) ? BgColumnCaption[j] : string.Empty; + case 2: return (j < GetBgColumnsCount()) ? BgColumnAction[j].ToDescription() : Ac.Clear.ToDescription(); + case 3: return (j < GetBgColumnsCount()) ? BgColumnWidth[j].ToString() : "0"; + } + } + ix -= 4 * GetOriBgColumnsCount(); + + if (ix < 4 * GetOriEnItemsCount()) + { + int j = ix / 4; + switch (ix % 4) + { + case 0: return (j < GetEnItemsCount()) ? EnItemContent[j].ToDescription() : Ct.None.ToDescription(); + case 1: return (j < GetEnItemsCount()) ? EnItemCaption[j] : string.Empty; + case 2: return (j < GetEnItemsCount()) ? EnItemAction[j].ToDescription() : Ac.Clear.ToDescription(); + case 3: return (j < GetEnItemsCount()) ? EnItemWidth[j].ToString() : "0"; + } + } + ix -= 4 * GetOriEnItemsCount(); + + if (ix < 4 * GetOriEnColumnsCount()) + { + int j = ix / 4; + switch (ix % 4) + { + case 0: return (j < GetEnColumnsCount()) ? EnColumnContent[j].ToDescription() : Ct.None.ToDescription(); + case 1: return (j < GetEnColumnsCount()) ? EnColumnCaption[j] : string.Empty; + case 2: return (j < GetEnColumnsCount()) ? EnColumnAction[j].ToDescription() : Ac.Clear.ToDescription(); + case 3: return (j < GetEnColumnsCount()) ? EnColumnWidth[j].ToString() : "0"; + } + } + ix -= 4 * GetOriEnColumnsCount(); + + if (ix < 4 * GetOriTestColumnsCount()) + { + int j = ix / 4; + switch (ix % 4) + { + case 0: return (j < GetTestColumnsCount()) ? TestColumnContent[j].ToDescription() : Ct.None.ToDescription(); + case 1: return (j < GetTestColumnsCount()) ? TestColumnCaption[j] : string.Empty; + case 2: return (j < GetTestColumnsCount()) ? TestColumnAction[j].ToDescription() : Ac.Clear.ToDescription(); + case 3: return (j < GetTestColumnsCount()) ? TestColumnWidth[j].ToString() : "0"; + } + } + + return string.Empty; } public CfgUpdateFlags UpdateParam(int i, string str) { - switch (i) + if (i < paramNames.Length) { - case 0: ShowCycleBeginningForm = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; - case 1: BgTitle = str; return CfgUpdateFlags.RestartRqrd; - case 2: - for (Sz sz = 0; sz < Sz.Count; sz++) - { - if (str == sz.ToDescription()) + switch (i) + { + case 0: BgShowForm = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; + case 1: BgTitle = str; return CfgUpdateFlags.RestartRqrd; + case 2: + for (Sz sz = 0; sz < Sz.Count; sz++) { - BgSize = sz; - return CfgUpdateFlags.RestartRqrd; + if (str == sz.ToDescription()) + { + BgSize = sz; + return CfgUpdateFlags.RestartRqrd; + } } - } - return CfgUpdateFlags.None; - case 3: BgIsLrOrder = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; - case 4: BgFormCloseKeys = str; return CfgUpdateFlags.RestartRqrd; + return CfgUpdateFlags.None; + case 3: SetBgItemsCount(int.Parse(str)); return CfgUpdateFlags.RestartRqrd; + case 4: SetBgColumnsCount(int.Parse(str)); return CfgUpdateFlags.RestartRqrd; + case 5: BgIsLrOrder = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; + case 6: BgIsVertArrangement = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; + case 7: BgFormCloseKeys = str; return CfgUpdateFlags.RestartRqrd; - case 5: ShowCycleEndForm = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; - case 6: EnTitle = str; return CfgUpdateFlags.RestartRqrd; - case 7: - for (Sz sz = 0; sz < Sz.Count; sz++) - { - if (str == sz.ToDescription()) + case 8: EnShowForm = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; + case 9: EnTitle = str; return CfgUpdateFlags.RestartRqrd; + case 10: + for (Sz sz = 0; sz < Sz.Count; sz++) { - EnSize = sz; - return CfgUpdateFlags.RestartRqrd; + if (str == sz.ToDescription()) + { + EnSize = sz; + return CfgUpdateFlags.RestartRqrd; + } } - } - return CfgUpdateFlags.None; - case 8: EnIsLrOrder = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; - case 9: EnFormCloseKeys = str; return CfgUpdateFlags.RestartRqrd; + return CfgUpdateFlags.None; + case 11: SetEnItemsCount(int.Parse(str)); return CfgUpdateFlags.RestartRqrd; + case 12: SetEnColumnsCount(int.Parse(str)); return CfgUpdateFlags.RestartRqrd; + case 13: EnIsLrOrder = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; + case 14: EnIsVertArrangement = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; + case 15: EnFormCloseKeys = str; return CfgUpdateFlags.RestartRqrd; - case 10: ShowTestStartEndForm = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; - case 11: TestTitle = str; return CfgUpdateFlags.RestartRqrd; - case 12: - for (Sz sz = 0; sz < Sz.Count; sz++) - { - if (str == sz.ToDescription()) + case 16: TestStartEndShowForm = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; + case 17: TestTitle = str; return CfgUpdateFlags.RestartRqrd; + case 18: + for (Sz sz = 0; sz < Sz.Count; sz++) { - TestSize = sz; - return CfgUpdateFlags.RestartRqrd; + if (str == sz.ToDescription()) + { + TestSize = sz; + return CfgUpdateFlags.RestartRqrd; + } } - } - return CfgUpdateFlags.None; - case 13: TestFormCloseKeys = str; return CfgUpdateFlags.RestartRqrd; + return CfgUpdateFlags.None; + case 19: SetTestColumnsCount(int.Parse(str)); return CfgUpdateFlags.RestartRqrd; + case 20: TestIsLrOrder = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; + case 21: TestIsVertArrangement = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; + case 22: TestFormCloseKeys = str; return CfgUpdateFlags.RestartRqrd; - case 14: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - BgItem1Content = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 15: BgItem1Caption = str; return CfgUpdateFlags.RestartRqrd; - case 16: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - BgItem1Action = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 17: BgItem1Width = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 18: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - BgItem2Content = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 19: BgItem2Caption = str; return CfgUpdateFlags.RestartRqrd; - case 20: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - BgItem2Action = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 21: BgItem2Width = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 22: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - BgItem3Content = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 23: BgItem3Caption = str; return CfgUpdateFlags.RestartRqrd; - case 24: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - BgItem3Action = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 25: BgItem3Width = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 26: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - BgColAContent = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 27: BgColACaption = str; return CfgUpdateFlags.RestartRqrd; - case 28: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - BgColAAction = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 29: BgColAWidth = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 30: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - BgColBContent = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 31: BgColBCaption = str; return CfgUpdateFlags.RestartRqrd; - case 32: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - BgColBAction = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 33: BgColBWidth = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 34: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - BgColCContent = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 35: BgColCCaption = str; return CfgUpdateFlags.RestartRqrd; - case 36: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - BgColCAction = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 37: BgColCWidth = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 38: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - BgColDContent = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 39: BgColDCaption = str; return CfgUpdateFlags.RestartRqrd; - case 40: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - BgColDAction = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 41: BgColDWidth = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 42: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - BgColEContent = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 43: BgColECaption = str; return CfgUpdateFlags.RestartRqrd; - case 44: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - BgColEAction = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 45: BgColEWidth = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 46: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - EnItem1Content = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 47: EnItem1Caption = str; return CfgUpdateFlags.RestartRqrd; - case 48: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - EnItem1Action = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 49: EnItem1Width = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 50: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - EnItem2Content = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 51: EnItem2Caption = str; return CfgUpdateFlags.RestartRqrd; - case 52: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - EnItem2Action = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 53: EnItem2Width = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 54: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - EnItem3Content = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 55: EnItem3Caption = str; return CfgUpdateFlags.RestartRqrd; - case 56: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - EnItem3Action = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 57: EnItem3Width = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 58: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - EnColAContent = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 59: EnColACaption = str; return CfgUpdateFlags.RestartRqrd; - case 60: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - EnColAAction = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 61: EnColAWidth = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 62: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - EnColBContent = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 63: EnColBCaption = str; return CfgUpdateFlags.RestartRqrd; - case 64: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - EnColBAction = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 65: EnColBWidth = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 66: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - EnColCContent = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 67: EnColCCaption = str; return CfgUpdateFlags.RestartRqrd; - case 68: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - EnColCAction = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 69: EnColCWidth = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 70: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - EnColDContent = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 71: EnColDCaption = str; return CfgUpdateFlags.RestartRqrd; - case 72: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - EnColDAction = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 73: EnColDWidth = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - - case 74: - for (Content c = 0; c < Content.Count; c++) - { - if (str == c.ToDescription()) - { - EnColEContent = c; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 75: EnColECaption = str; return CfgUpdateFlags.RestartRqrd; - case 76: - for (Action a = 0; a < Action.Count; a++) - { - if (str == a.ToDescription()) - { - EnColEAction = a; - return CfgUpdateFlags.RestartRqrd; - } - } - return CfgUpdateFlags.None; - case 77: EnColEWidth = int.Parse(str); return CfgUpdateFlags.RestartRqrd; - default: - return CfgUpdateFlags.None; + default: + return CfgUpdateFlags.None; + } } + + int ix = i - paramNames.Length; + + if (ix < 4 * GetOriBgItemsCount()) + { + int j = ix / 4; + if (j < GetBgItemsCount()) + { + switch (ix % 4) + { + case 0: BgItemContent[j] = Str2Content(str); return CfgUpdateFlags.RestartRqrd; + case 1: BgItemCaption[j] = str; return CfgUpdateFlags.RestartRqrd; + case 2: BgItemAction[j] = Str2Action(str); return CfgUpdateFlags.RestartRqrd; + case 3: BgItemWidth[j] = int.Parse(str); return CfgUpdateFlags.RestartRqrd; + } + } + } + ix -= 4 * GetOriBgItemsCount(); + + if (ix < 4 * GetOriBgColumnsCount()) + { + int j = ix / 4; + if (j < GetBgColumnsCount()) + { + switch (ix % 4) + { + case 0: BgColumnContent[j] = Str2Content(str); return CfgUpdateFlags.RestartRqrd; + case 1: BgColumnCaption[j] = str; return CfgUpdateFlags.RestartRqrd; + case 2: BgColumnAction[j] = Str2Action(str); return CfgUpdateFlags.RestartRqrd; + case 3: BgColumnWidth[j] = int.Parse(str); return CfgUpdateFlags.RestartRqrd; + } + } + } + ix -= 4 * GetOriBgColumnsCount(); + + if (ix < 4 * GetOriEnItemsCount()) + { + int j = ix / 4; + if (j < GetEnItemsCount()) + { + switch (ix % 4) + { + case 0: EnItemContent[j] = Str2Content(str); return CfgUpdateFlags.RestartRqrd; + case 1: EnItemCaption[j] = str; return CfgUpdateFlags.RestartRqrd; + case 2: EnItemAction[j] = Str2Action(str); return CfgUpdateFlags.RestartRqrd; + case 3: EnItemWidth[j] = int.Parse(str); return CfgUpdateFlags.RestartRqrd; + } + } + } + ix -= 4 * GetOriEnItemsCount(); + + if (ix < 4 * GetOriEnColumnsCount()) + { + int j = ix / 4; + if (j < GetEnColumnsCount()) + { + switch (ix % 4) + { + case 0: EnColumnContent[j] = Str2Content(str); return CfgUpdateFlags.RestartRqrd; + case 1: EnColumnCaption[j] = str; return CfgUpdateFlags.RestartRqrd; + case 2: EnColumnAction[j] = Str2Action(str); return CfgUpdateFlags.RestartRqrd; + case 3: EnColumnWidth[j] = int.Parse(str); return CfgUpdateFlags.RestartRqrd; + } + } + } + ix -= 4 * GetOriEnColumnsCount(); + + if (ix < 4 * GetOriTestColumnsCount()) + { + int j = ix / 4; + if (j < GetTestColumnsCount()) + { + switch (ix % 4) + { + case 0: TestColumnContent[j] = Str2Content(str); return CfgUpdateFlags.RestartRqrd; + case 1: TestColumnCaption[j] = str; return CfgUpdateFlags.RestartRqrd; + case 2: TestColumnAction[j] = Str2Action(str); return CfgUpdateFlags.RestartRqrd; + case 3: TestColumnWidth[j] = int.Parse(str); return CfgUpdateFlags.RestartRqrd; + } + } + } + + return CfgUpdateFlags.RestartRqrd; + } + + Ct Str2Content(string str) + { + for (Ct c = 0; c < Ct.Count; c++) + { + if (str == c.ToDescription()) return c; + } + return Ct.None; + } + + Ac Str2Action(string str) + { + for (Ac a = 0; a < Ac.Count; a++) + { + if (str == a.ToDescription()) return a; + } + return Ac.Clear; } public bool ValidateParam(int i, string str, out string message) { int idummy; - switch (i) + if (i < paramNames.Length) { - case 0: - case 2: - case 3: - case 5: - case 7: - case 8: - case 10: - case 12: - case 14: - case 16: - case 18: - case 20: - case 22: - case 24: - case 26: - case 28: - case 30: - case 32: - case 34: - case 36: - case 38: - case 40: - case 42: - case 44: - case 46: - case 48: - case 50: - case 52: - case 54: - case 56: - case 58: - case 60: - case 62: - case 64: - case 66: - case 68: - case 70: - case 72: - case 74: - case 76: - message = string.Empty; - if (ParamValues(i).Contains(str)) return true; - break; - case 17: - case 21: - case 25: - case 29: - case 33: - case 37: - case 41: - case 45: - case 49: - case 53: - case 57: - case 61: - case 65: - case 69: - case 73: - case 77: - message = string.Empty; - if (int.TryParse(str, out idummy)) return true; - break; - case 1: - case 4: - case 6: - case 9: - case 11: - case 13: - case 15: - case 19: - case 23: - case 27: - case 31: - case 35: - case 39: - case 43: - case 47: - case 51: - case 55: - case 59: - case 63: - case 67: - case 71: - case 75: - message = string.Empty; - return true; - default: - message = "Invalid index"; - return false; + switch (i) + { + case 0: + case 2: + case 5: + case 6: + case 8: + case 10: + case 13: + case 14: + case 16: + case 18: + case 20: + case 21: + message = string.Empty; + if (ParamValues(i).Contains(str)) return true; + break; + case 3: + case 4: + case 11: + case 12: + case 19: + message = string.Empty; + if (int.TryParse(str, out idummy)) return true; + break; + case 1: + case 7: + case 9: + case 15: + case 17: + case 22: + message = string.Empty; + return true; + default: + message = "Invalid index"; + return false; + } + } + + if (i < ParamsCount()) + { + switch ((i - paramNames.Length) % 4) + { + case 0: + case 2: + message = string.Empty; + if (ParamValues(i).Contains(str)) return true; + break; + case 1: + message = string.Empty; + return true; + case 3: + message = string.Empty; + if (int.TryParse(str, out idummy)) return true; + break; + default: + message = "Invalid index"; + return false; + } } message = string.Format(Strings.Invalid_0, ParamName(i)) ; @@ -988,87 +902,91 @@ namespace TBF.Rig.DataEntry.Uni void CopyContentTo(EntryFormCfg prms) { - prms.ShowCycleBeginningForm = ShowCycleBeginningForm; - prms.BgTitle = BgTitle; - prms.BgSize = BgSize; - prms.BgIsLrOrder = BgIsLrOrder; - prms.BgFormCloseKeys = BgFormCloseKeys; + prms.BgShowForm = BgShowForm; + prms.BgTitle = BgTitle; + prms.BgSize = BgSize; + prms.BgIsLrOrder = BgIsLrOrder; + prms.BgIsVertArrangement = BgIsVertArrangement; + prms.BgFormCloseKeys = BgFormCloseKeys; - prms.ShowCycleEndForm = ShowCycleEndForm; - prms.EnTitle = EnTitle; - prms.EnSize = EnSize; - prms.EnIsLrOrder = EnIsLrOrder; - prms.EnFormCloseKeys = EnFormCloseKeys; + prms.EnShowForm = EnShowForm; + prms.EnTitle = EnTitle; + prms.EnSize = EnSize; + prms.EnIsLrOrder = EnIsLrOrder; + prms.EnIsVertArrangement = EnIsVertArrangement; + prms.EnFormCloseKeys = EnFormCloseKeys; - prms.ShowTestStartEndForm = ShowTestStartEndForm; - prms.TestTitle = TestTitle; - prms.TestSize = TestSize; - prms.TestFormCloseKeys = TestFormCloseKeys; + prms.TestStartEndShowForm = TestStartEndShowForm; + prms.TestTitle = TestTitle; + prms.TestSize = TestSize; + prms.TestIsLrOrder = TestIsLrOrder; + prms.TestIsVertArrangement = TestIsVertArrangement; + prms.TestFormCloseKeys = TestFormCloseKeys; - prms.BgItem1Caption = BgItem1Caption; - prms.BgItem1Content = BgItem1Content; - prms.BgItem1Action = BgItem1Action; - prms.BgItem1Width = BgItem1Width; - prms.BgItem2Caption = BgItem2Caption; - prms.BgItem2Content = BgItem2Content; - prms.BgItem2Action = BgItem2Action; - prms.BgItem2Width = BgItem2Width; - prms.BgItem3Caption = BgItem3Caption; - prms.BgItem3Content = BgItem3Content; - prms.BgItem3Action = BgItem3Action; - prms.BgItem3Width = BgItem3Width; - prms.BgColACaption = BgColACaption; - prms.BgColAContent = BgColAContent; - prms.BgColAAction = BgColAAction; - prms.BgColAWidth = BgColAWidth; - prms.BgColBCaption = BgColBCaption; - prms.BgColBContent = BgColBContent; - prms.BgColBAction = BgColBAction; - prms.BgColBWidth = BgColBWidth; - prms.BgColCCaption = BgColCCaption; - prms.BgColCContent = BgColCContent; - prms.BgColCAction = BgColCAction; - prms.BgColCWidth = BgColCWidth; - prms.BgColDCaption = BgColDCaption; - prms.BgColDContent = BgColDContent; - prms.BgColDAction = BgColDAction; - prms.BgColDWidth = BgColDWidth; - prms.BgColECaption = BgColECaption; - prms.BgColEContent = BgColEContent; - prms.BgColEAction = BgColEAction; - prms.BgColEWidth = BgColEWidth; - prms.EnItem1Caption = EnItem1Caption; - prms.EnItem1Content = EnItem1Content; - prms.EnItem1Action = EnItem1Action; - prms.EnItem1Width = EnItem1Width; - prms.EnItem2Caption = EnItem2Caption; - prms.EnItem2Content = EnItem2Content; - prms.EnItem2Action = EnItem2Action; - prms.EnItem2Width = EnItem2Width; - prms.EnItem3Caption = EnItem3Caption; - prms.EnItem3Content = EnItem3Content; - prms.EnItem3Action = EnItem3Action; - prms.EnItem3Width = EnItem3Width; - prms.EnColACaption = EnColACaption; - prms.EnColAContent = EnColAContent; - prms.EnColAAction = EnColAAction; - prms.EnColAWidth = EnColAWidth; - prms.EnColBCaption = EnColBCaption; - prms.EnColBContent = EnColBContent; - prms.EnColBAction = EnColBAction; - prms.EnColBWidth = EnColBWidth; - prms.EnColCCaption = EnColCCaption; - prms.EnColCContent = EnColCContent; - prms.EnColCAction = EnColCAction; - prms.EnColCWidth = EnColCWidth; - prms.EnColDCaption = EnColDCaption; - prms.EnColDContent = EnColDContent; - prms.EnColDAction = EnColDAction; - prms.EnColDWidth = EnColDWidth; - prms.EnColECaption = EnColECaption; - prms.EnColEContent = EnColEContent; - prms.EnColEAction = EnColEAction; - prms.EnColEWidth = EnColEWidth; + prms.BgItemContent = new Ct[GetBgItemsCount()]; + prms.BgItemCaption = new string[GetBgItemsCount()]; + prms.BgItemAction = new Ac[GetBgItemsCount()]; + prms.BgItemWidth = new int[GetBgItemsCount()]; + /// + for (int ix = 0; ix < GetBgItemsCount(); ix++) + { + prms.BgItemContent[ix] = BgItemContent[ix]; + prms.BgItemCaption[ix] = BgItemCaption[ix]; + prms.BgItemAction[ix] = BgItemAction[ix]; + prms.BgItemWidth[ix] = BgItemWidth[ix]; + } + + prms.BgColumnContent = new Ct[GetBgColumnsCount()]; + prms.BgColumnCaption = new string[GetBgColumnsCount()]; + prms.BgColumnAction = new Ac[GetBgColumnsCount()]; + prms.BgColumnWidth = new int[GetBgColumnsCount()]; + /// + for (int ix = 0; ix < GetBgColumnsCount(); ix++) + { + prms.BgColumnContent[ix] = BgColumnContent[ix]; + prms.BgColumnCaption[ix] = BgColumnCaption[ix]; + prms.BgColumnAction[ix] = BgColumnAction[ix]; + prms.BgColumnWidth[ix] = BgColumnWidth[ix]; + } + + prms.EnItemContent = new Ct[GetEnItemsCount()]; + prms.EnItemCaption = new string[GetEnItemsCount()]; + prms.EnItemAction = new Ac[GetEnItemsCount()]; + prms.EnItemWidth = new int[GetEnItemsCount()]; + /// + for (int ix = 0; ix < GetEnItemsCount(); ix++) + { + prms.EnItemContent[ix] = EnItemContent[ix]; + prms.EnItemCaption[ix] = EnItemCaption[ix]; + prms.EnItemAction[ix] = EnItemAction[ix]; + prms.EnItemWidth[ix] = EnItemWidth[ix]; + } + + prms.EnColumnContent = new Ct[GetEnColumnsCount()]; + prms.EnColumnCaption = new string[GetEnColumnsCount()]; + prms.EnColumnAction = new Ac[GetEnColumnsCount()]; + prms.EnColumnWidth = new int[GetEnColumnsCount()]; + /// + for (int ix = 0; ix < GetEnColumnsCount(); ix++) + { + prms.EnColumnContent[ix] = EnColumnContent[ix]; + prms.EnColumnCaption[ix] = EnColumnCaption[ix]; + prms.EnColumnAction[ix] = EnColumnAction[ix]; + prms.EnColumnWidth[ix] = EnColumnWidth[ix]; + } + + prms.TestColumnContent = new Ct[GetTestColumnsCount()]; + prms.TestColumnCaption = new string[GetTestColumnsCount()]; + prms.TestColumnAction = new Ac[GetTestColumnsCount()]; + prms.TestColumnWidth = new int[GetTestColumnsCount()]; + /// + for (int ix = 0; ix < GetTestColumnsCount(); ix++) + { + prms.TestColumnContent[ix] = TestColumnContent[ix]; + prms.TestColumnCaption[ix] = TestColumnCaption[ix]; + prms.TestColumnAction[ix] = TestColumnAction[ix]; + prms.TestColumnWidth[ix] = TestColumnWidth[ix]; + } } public IParamsProvider Clone() diff --git a/TBF/Rig/DataEntry/Uni/EntryFormNoStartEnd.cs b/TBF/Rig/DataEntry/Uni/EntryFormNoStartEnd.cs index a9da727e5..a73cb2372 100644 --- a/TBF/Rig/DataEntry/Uni/EntryFormNoStartEnd.cs +++ b/TBF/Rig/DataEntry/Uni/EntryFormNoStartEnd.cs @@ -132,39 +132,51 @@ namespace TBF.Rig.DataEntry.Uni /// void OpenBeginningDlg(EntryFormNoStartEnd myRef) { - var item1 = new DEItem(myCfg.BgItem1Content, myCfg.BgItem1Caption, myCfg.BgItem1Action, myCfg.BgItem1Width); - var item2 = new DEItem(myCfg.BgItem2Content, myCfg.BgItem2Caption, myCfg.BgItem2Action, myCfg.BgItem2Width); - var item3 = new DEItem(myCfg.BgItem3Content, myCfg.BgItem3Caption, myCfg.BgItem3Action, myCfg.BgItem3Width); + DEItem.ClearItems(); + for (int i = 0; i < myCfg.GetBgItemsCount(); i++) + { + if (myCfg.BgItemContent[i] != Ct.None) + { + DEItem.AddItem(myCfg.BgItemContent[i], myCfg.BgItemCaption[i], myCfg.BgItemAction[i], myCfg.BgItemWidth[i]); + } + } DEItem.ClearColumns(); - if (myCfg.BgColAContent != Content.None) DEItem.AddColumn(myCfg.BgColAContent, myCfg.BgColACaption, myCfg.BgColAAction, myCfg.BgColAWidth); - if (myCfg.BgColBContent != Content.None) DEItem.AddColumn(myCfg.BgColBContent, myCfg.BgColBCaption, myCfg.BgColBAction, myCfg.BgColBWidth); - if (myCfg.BgColCContent != Content.None) DEItem.AddColumn(myCfg.BgColCContent, myCfg.BgColCCaption, myCfg.BgColCAction, myCfg.BgColCWidth); - if (myCfg.BgColDContent != Content.None) DEItem.AddColumn(myCfg.BgColDContent, myCfg.BgColDCaption, myCfg.BgColDAction, myCfg.BgColDWidth); - if (myCfg.BgColEContent != Content.None) DEItem.AddColumn(myCfg.BgColEContent, myCfg.BgColECaption, myCfg.BgColEAction, myCfg.BgColEWidth); - var columns = DEItem.GetColumns(); + for (int i = 0; i < myCfg.GetBgColumnsCount(); i++) + { + if (myCfg.BgColumnContent[i] != Ct.None) + { + DEItem.AddColumn(myCfg.BgColumnContent[i], myCfg.BgColumnCaption[i], myCfg.BgColumnAction[i], myCfg.BgColumnWidth[i]); + } + } modelessDlg = new CycleBgEnForm(waterMeters, TBF.Data.LineSize, myCfg.BgTitle, myCfg.BgSize, myCfg.BgIsLrOrder, myCfg.BgFormCloseKeys, - item1, item2, item3, columns, false); + DEItem.GetItems(), DEItem.GetColumns(), false); modelessDlg.Show(); } /// void OpenEndDlg(EntryFormNoStartEnd myRef) { - var item1 = new DEItem(myCfg.EnItem1Content, myCfg.EnItem1Caption, myCfg.EnItem1Action, myCfg.EnItem1Width); - var item2 = new DEItem(myCfg.EnItem2Content, myCfg.EnItem2Caption, myCfg.EnItem2Action, myCfg.EnItem2Width); - var item3 = new DEItem(myCfg.EnItem3Content, myCfg.EnItem3Caption, myCfg.EnItem3Action, myCfg.EnItem3Width); + DEItem.ClearItems(); + for (int i = 0; i < myCfg.GetEnItemsCount(); i++) + { + if (myCfg.EnItemContent[i] != Ct.None) + { + DEItem.AddItem(myCfg.EnItemContent[i], myCfg.EnItemCaption[i], myCfg.EnItemAction[i], myCfg.EnItemWidth[i]); + } + } DEItem.ClearColumns(); - if (myCfg.EnColAContent != Content.None) DEItem.AddColumn(myCfg.EnColAContent, myCfg.EnColACaption, myCfg.EnColAAction, myCfg.EnColAWidth); - if (myCfg.EnColBContent != Content.None) DEItem.AddColumn(myCfg.EnColBContent, myCfg.EnColBCaption, myCfg.EnColBAction, myCfg.EnColBWidth); - if (myCfg.EnColCContent != Content.None) DEItem.AddColumn(myCfg.EnColCContent, myCfg.EnColCCaption, myCfg.EnColCAction, myCfg.EnColCWidth); - if (myCfg.EnColDContent != Content.None) DEItem.AddColumn(myCfg.EnColDContent, myCfg.EnColDCaption, myCfg.EnColDAction, myCfg.EnColDWidth); - if (myCfg.EnColEContent != Content.None) DEItem.AddColumn(myCfg.EnColEContent, myCfg.EnColECaption, myCfg.EnColEAction, myCfg.EnColEWidth); - var columns = DEItem.GetColumns(); + for (int i = 0; i < myCfg.GetEnColumnsCount(); i++) + { + if (myCfg.EnColumnContent[i] != Ct.None) + { + DEItem.AddColumn(myCfg.EnColumnContent[i], myCfg.EnColumnCaption[i], myCfg.EnColumnAction[i], myCfg.EnColumnWidth[i]); + } + } modelessDlg = new CycleBgEnForm(waterMeters, TBF.Data.LineSize, myCfg.EnTitle, myCfg.EnSize, myCfg.EnIsLrOrder, myCfg.EnFormCloseKeys, - item1, item2, item3, columns, true); + DEItem.GetItems(), DEItem.GetColumns(), true); modelessDlg.Show(); } /// @@ -189,13 +201,13 @@ namespace TBF.Rig.DataEntry.Uni switch (currentOp) { case CurrentOp.ShowFormAtCycleBeginning: - if (myCfg.ShowCycleBeginningForm) + if (myCfg.BgShowForm) { Program.MainWnd.Invoke(new EntryFormDlgt(OpenBeginningDlg), this); } break; case CurrentOp.ShowFormAtCycleEnd: - if (myCfg.ShowCycleEndForm) + if (myCfg.EnShowForm) { Program.MainWnd.Invoke(new EntryFormDlgt(OpenEndDlg), this); } diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index b2e667e5d..9caba8753 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -541,6 +541,7 @@ CycleBgEnForm.cs +