diff --git a/TestBenchFramework/BenchControl/DataEntry/Combined/CycleBeginningForm.cs b/TestBenchFramework/BenchControl/DataEntry/Combined/CycleBeginningForm.cs index aeecebbb4..33038a3a0 100644 --- a/TestBenchFramework/BenchControl/DataEntry/Combined/CycleBeginningForm.cs +++ b/TestBenchFramework/BenchControl/DataEntry/Combined/CycleBeginningForm.cs @@ -50,6 +50,8 @@ namespace TBF.BenchControl.DataEntry.Combined checkBoxes = new CheckBox[] { checkBox1, checkBox2, checkBox3 }; enabledComboBoxes = new List(); + this.WaterMetersCount = Program.WMsCount / 2; /// Default number of compound water meters + completed = false; StartForceCloseHandler(); } @@ -57,16 +59,16 @@ namespace TBF.BenchControl.DataEntry.Combined /// /// Constructor /// - /// Number of text boxes for serial numbers - public CycleBeginningForm(int waterMetersCount) + /// Number of text boxes for serial numbers + public CycleBeginningForm(int compoundWaterMetersCount) : this() { - this.WaterMetersCount = waterMetersCount; /// = Program.WMsCount / 2 - MainSNText = new string[waterMetersCount]; - AuxSNText = new string[waterMetersCount]; - Disabled = new bool[waterMetersCount]; + this.WaterMetersCount = compoundWaterMetersCount; /// = Program.WMsCount / 2 + MainSNText = new string[compoundWaterMetersCount]; + AuxSNText = new string[compoundWaterMetersCount]; + Disabled = new bool[compoundWaterMetersCount]; - ShuffleTextBoxes(); + ShuffleTextBoxes(compoundWaterMetersCount); //Height = 147 + WaterMetersCount * 90; } @@ -75,12 +77,10 @@ namespace TBF.BenchControl.DataEntry.Combined /// Make sure the layout of labels/text boxes on the screen /// corresponds to the layout of watermeters of the test bench. /// - void ShuffleTextBoxes() + /// Numebr of combined watermeters + void ShuffleTextBoxes(int compoundWMsCount) { - if (Program.WMsCount / 2 < TextBoxesCount) - { - TextBoxesCount = Program.WMsCount / 2; - } + if (compoundWMsCount < TextBoxesCount) TextBoxesCount = compoundWMsCount; } private void CycleBeginningForm_Load(object sender, EventArgs e) @@ -89,20 +89,23 @@ namespace TBF.BenchControl.DataEntry.Combined PrepareOrderCombo(orderComboBox); - TextBoxesCount = Math.Min(TextBoxesCount, WaterMetersCount); - if (WaterMetersCount >= 1) groupBox1.Visible = true; if (WaterMetersCount >= 2) groupBox2.Visible = true; if (WaterMetersCount >= 3) groupBox3.Visible = true; - for (int i = 0; i < TextBoxesCount; i++) + if (Program.LocalSettings.LastMainSNTextsCount == TextBoxesCount && + Program.LocalSettings.LastAuxSNTextsCount == TextBoxesCount) { - mainComboBoxes[i].Items.Add(Program.LocalSettings.LastMainSNTexts[i]); - mainLabels[i].Visible = mainComboBoxes[i].Visible = true; - auxLabels[i].Visible = auxComboBoxes[i].Visible = true; - checkBoxes[i].Visible = true; - enabledComboBoxes.Add(mainComboBoxes[i]); - enabledComboBoxes.Add(auxComboBoxes[i]); + for (int i = 0; i < TextBoxesCount; i++) + { + mainComboBoxes[i].Items.Add(Program.LocalSettings.LastMainSNTexts[i]); + auxComboBoxes[i].Items.Add(Program.LocalSettings.LastAuxSNTexts[i]); + mainLabels[i].Visible = mainComboBoxes[i].Visible = true; + auxLabels[i].Visible = auxComboBoxes[i].Visible = true; + checkBoxes[i].Visible = true; + enabledComboBoxes.Add(mainComboBoxes[i]); + enabledComboBoxes.Add(auxComboBoxes[i]); + } } } diff --git a/TestBenchFramework/BenchControl/DataEntry/Standard24/CycleBeginningForm.cs b/TestBenchFramework/BenchControl/DataEntry/Standard24/CycleBeginningForm.cs index 86d02adf8..3fdbba144 100644 --- a/TestBenchFramework/BenchControl/DataEntry/Standard24/CycleBeginningForm.cs +++ b/TestBenchFramework/BenchControl/DataEntry/Standard24/CycleBeginningForm.cs @@ -76,7 +76,7 @@ namespace TBF.BenchControl.DataEntry.Standard24 SNText = new string[WaterMetersCount]; Disabled = new bool[WaterMetersCount]; - ShuffleTextBoxes(); + ShuffleTextBoxes(Program.WMsCount, Program.LineSize); //Height = 147 + WaterMetersCount * 90; } @@ -85,25 +85,27 @@ namespace TBF.BenchControl.DataEntry.Standard24 /// Make sure the layout of labels/text boxes on the screen /// corresponds to the layout of watermeters of the test bench. /// - void ShuffleTextBoxes() + /// Number of watermeters + /// Number of watermeters in one line + void ShuffleTextBoxes(int wmsCount, int lineSize) { - if (Program.WMsCount < TextBoxesCount) + if (wmsCount < TextBoxesCount && lineSize > 0) { - int nrLines = Program.WMsCount / Program.LineSize; - int gap = (TextBoxesCount - Program.WMsCount) / nrLines; + int nrLines = (wmsCount + lineSize - 1) / lineSize; + int gap = (TextBoxesCount - wmsCount) / nrLines; int dest = 0; for (int l = 0; l < nrLines; l++) { - for (int i = 0; i < Program.LineSize; i++) + for (int i = 0; i < lineSize; i++) { - labels[dest] = labels[l * Program.LineSize + l * gap + i]; - comboBoxes[dest] = comboBoxes[l * Program.LineSize + l * gap + i]; - checkBoxes[dest] = checkBoxes[l * Program.LineSize + l * gap + i]; + labels[dest] = labels[l * lineSize + l * gap + i]; + comboBoxes[dest] = comboBoxes[l * lineSize + l * gap + i]; + checkBoxes[dest] = checkBoxes[l * lineSize + l * gap + i]; dest++; } } - TextBoxesCount = Program.WMsCount; + TextBoxesCount = wmsCount; } } @@ -113,9 +115,12 @@ namespace TBF.BenchControl.DataEntry.Standard24 PrepareOrderCombo(orderComboBox); - for (int i = 0; i < Math.Min(TextBoxesCount, WaterMetersCount); i++) + for (int i = 0; i < TextBoxesCount; i++) { - comboBoxes[i].Items.Add(Program.LocalSettings.LastSNTexts[i]); + if (Program.LocalSettings.LastSNTextsCount == TextBoxesCount) + { + comboBoxes[i].Items.Add(Program.LocalSettings.LastSNTexts[i]); + } labels[i].Visible = comboBoxes[i].Visible = checkBoxes[i].Visible = true; enabledComboBoxes.Add(comboBoxes[i]); } diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 49a71a41d..b4643e49d 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("1.5.59.1")] -[assembly: AssemblyFileVersion("1.5.59.1")] +[assembly: AssemblyVersion("1.5.60.1")] +[assembly: AssemblyFileVersion("1.5.60.1")]