Bug fixed in Disabled watermeters will not appear in results...

When there were no results yet and Results screen was opened -> crash
This commit is contained in:
Milan Hanajik
2015-03-25 07:54:49 +01:00
parent 4f0ec7eb68
commit 3b1f0129ba
@@ -148,19 +148,20 @@ namespace TBF.Screens
{ {
for (int mtr0 = 0; mtr0 < Program.WMsCount; mtr0++) for (int mtr0 = 0; mtr0 < Program.WMsCount; mtr0++)
{ {
if (!testResults[0].Meters[mtr0].Disabled) enabledWMsCount++; if ((testResults != null) && (testResults.Count > 0) && !testResults[0].Meters[mtr0].Disabled)
enabledWMsCount++;
} }
} }
if (MetersArrangement == Forms.ResultsConfig.Meters.Horizontally) if (MetersArrangement == Forms.ResultsConfig.Meters.Horizontally)
{ {
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight; flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
lvWidth = (lvWidth + 5) / enabledWMsCount - 5; lvWidth = (lvWidth + 5) / Math.Max(enabledWMsCount, 1) - 5;
} }
else else
{ {
flowLayoutPanel.FlowDirection = FlowDirection.TopDown; flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
lvHeight = (lvHeight + 5) / enabledWMsCount - 5; lvHeight = (lvHeight + 5) / Math.Max(enabledWMsCount, 1) - 5;
} }
flowLayoutPanel.Controls.Clear(); flowLayoutPanel.Controls.Clear();
flowLayoutPanel.WrapContents = false; flowLayoutPanel.WrapContents = false;
@@ -170,7 +171,7 @@ namespace TBF.Screens
int printedWMNr = 1; int printedWMNr = 1;
for (int mtr = 1; mtr <= (combined ? Program.WMsCount / 2 : Program.WMsCount); mtr++) for (int mtr = 1; mtr <= (combined ? Program.WMsCount / 2 : Program.WMsCount); mtr++)
{ {
if (combined || !testResults[0].Meters[mtr - 1].Disabled) if (combined || (testResults != null && testResults.Count > 0 && !testResults[0].Meters[mtr - 1].Disabled))
{ {
if (TestsArrangement == Forms.ResultsConfig.TestsAre.Rows) if (TestsArrangement == Forms.ResultsConfig.TestsAre.Rows)
{ {