Test-Part used when printing results on screen

This commit is contained in:
Milan Hanajik 2015-01-17 07:20:05 +01:00
parent bd1eb31f37
commit cfd812eab6

View File

@ -184,46 +184,52 @@ namespace TBF.Screens
/// Pre-fetch the test results corresponding to the columns or rows in the ListView
/// </summary>
/// <returns>Ordered list of test results containing null-s for missing results</returns>
IList<Entities.TestResult> GetCurrentTestResults()
IList<Entities.TestResult> GetCurrentTestResults(int meterNr)
{
IList<Entities.TestResult> rslts = new List<Entities.TestResult>();
foreach (var test in tests)
{
for (int rpt = 1; rpt <= test.Repeats; rpt++)
if ((test.Part == 0) || (test.Part == meterNr + 1))
{
bool added = false;
if (testResults != null)
for (int rpt = 1; rpt <= test.Repeats; rpt++)
{
foreach (var testRslt in testResults)
bool added = false;
if (testResults != null)
{
if ((testRslt.TestId == test.Id) && (testRslt.RepetitionNr == rpt) && !testRslt.DoNotPublish)
foreach (var testRslt in testResults)
{
rslts.Add(testRslt);
added = true;
break;
if ((testRslt.TestId == test.Id) && (testRslt.RepetitionNr == rpt) && !testRslt.DoNotPublish)
{
rslts.Add(testRslt);
added = true;
break;
}
}
}
if (!added) rslts.Add(null);
}
if (!added) rslts.Add(null);
}
}
return rslts;
}
IList<string> GetAllDecoratedTestNames()
IList<string> GetAllDecoratedTestNames(int meterNr)
{
IList<string> rslt = new List<string>();
foreach (var test in tests)
{
if (test.Repeats == 1)
if ((test.Part == 0) || (test.Part == meterNr + 1))
{
rslt.Add(test.Name);
continue;
}
for (int rpt = 1; rpt <= test.Repeats; rpt++)
{
rslt.Add(test.Name + string.Format(" ({0}/{1})", rpt, test.Repeats));
if (test.Repeats == 1)
{
rslt.Add(test.Name);
continue;
}
for (int rpt = 1; rpt <= test.Repeats; rpt++)
{
rslt.Add(test.Name + string.Format(" ({0}/{1})", rpt, test.Repeats));
}
}
}
return rslt;
@ -264,9 +270,9 @@ namespace TBF.Screens
}
}
IList<string> testNames = GetAllDecoratedTestNames();
IList<string> testNames = GetAllDecoratedTestNames(mtr);
int ix = 0;
foreach (var testRslt in GetCurrentTestResults())
foreach (var testRslt in GetCurrentTestResults(mtr))
{
ListViewItem lvi = new ListViewItem(testNames[ix++]);
if (testRslt != null)
@ -327,7 +333,7 @@ namespace TBF.Screens
{
lview.Columns.Add((mtr + 1).ToString(), (ls.RsltsCombinedClmnCount > 0) ? ls.RsltsCombinedClmnWdths[0] : 40);
int i = 1;
foreach (var str in GetAllDecoratedTestNames())
foreach (var str in GetAllDecoratedTestNames(mtr))
{
lview.Columns.Add(str, (ls.RsltsCombinedClmnCount > i) ? ls.RsltsCombinedClmnWdths[i] : 70);
i++;
@ -337,14 +343,14 @@ namespace TBF.Screens
{
lview.Columns.Add((mtr + 1).ToString(), (ls.RsltsSingleClmnCount > 0) ? ls.RsltsSingleClmnWdths[0] : 40);
int i = 1;
foreach (var str in GetAllDecoratedTestNames())
foreach (var str in GetAllDecoratedTestNames(mtr))
{
lview.Columns.Add(str, (ls.RsltsSingleClmnCount > i) ? ls.RsltsSingleClmnWdths[i] : 70);
i++;
}
}
IList<Entities.TestResult> trs = GetCurrentTestResults();
IList<Entities.TestResult> trs = GetCurrentTestResults(mtr);
foreach (var item in items)
{