Bug fixes in DataEntry/Standard24/CycleBeginningForm : crash in case LocalSettings.LastSNTexts were not initalized, ver. 1.5.60.

This commit is contained in:
Milan Hanajik
2015-06-25 04:48:24 +02:00
parent 38c4073632
commit 02c235d164
3 changed files with 43 additions and 35 deletions
@@ -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.
/// </summary>
void ShuffleTextBoxes()
/// <param name="wmsCount">Number of watermeters</param>
/// <param name="lineSize">Number of watermeters in one line</param>
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]);
}