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 03:17:51 +02:00
parent 38c4073632
commit 02c235d164
3 changed files with 43 additions and 35 deletions

View File

@ -50,6 +50,8 @@ namespace TBF.BenchControl.DataEntry.Combined
checkBoxes = new CheckBox[] { checkBox1, checkBox2, checkBox3 };
enabledComboBoxes = new List<ComboBox>();
this.WaterMetersCount = Program.WMsCount / 2; /// Default number of compound water meters
completed = false;
StartForceCloseHandler();
}
@ -57,16 +59,16 @@ namespace TBF.BenchControl.DataEntry.Combined
/// <summary>
/// Constructor
/// </summary>
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
public CycleBeginningForm(int waterMetersCount)
/// <param name="compoundWaterMetersCount">Number of text boxes for serial numbers</param>
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.
/// </summary>
void ShuffleTextBoxes()
/// <param name="compoundWMsCount">Numebr of combined watermeters</param>
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]);
}
}
}

View File

@ -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]);
}

View File

@ -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")]