From cd43aa2f42d6ec18a9b82c6f08dd080e99f659c9 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Thu, 19 May 2016 13:12:31 +0200 Subject: [PATCH] Results screen fixed for compound meters, ver.2.7.285 --- .../Screens/ResultsTabPageCtrl.cs | 87 +++++++++++-------- 1 file changed, 49 insertions(+), 38 deletions(-) diff --git a/TestBenchFramework/Screens/ResultsTabPageCtrl.cs b/TestBenchFramework/Screens/ResultsTabPageCtrl.cs index 639985fb5..705a1f778 100644 --- a/TestBenchFramework/Screens/ResultsTabPageCtrl.cs +++ b/TestBenchFramework/Screens/ResultsTabPageCtrl.cs @@ -250,8 +250,10 @@ namespace TBF.Screens foreach (var mtr in wMtr.MeterTestRslts) { - if (mtr.TestDone && (mtr.Publish() != Config.Entities.Publish.Never) - && (mtr.Publish() != Config.Entities.Publish.Internal)) + if ( (mtr.CompoundMeterId == (byte)CompoundMeterId.Single || mtr.CompoundMeterId == (byte)CompoundMeterId.Compound) + && mtr.TestDone + && (mtr.Publish() != Config.Entities.Publish.Never) + && (mtr.Publish() != Config.Entities.Publish.Internal)) { testNames.Add(mtr.Name()); } @@ -290,23 +292,25 @@ namespace TBF.Screens int ix = 0; foreach (var mtr in wMtr.MeterTestRslts) { - if (mtr.TestDone && (mtr.Publish() != Config.Entities.Publish.Never) - && (mtr.Publish() != Config.Entities.Publish.Internal)) - { + if ((mtr.CompoundMeterId == (byte)CompoundMeterId.Single || mtr.CompoundMeterId == (byte)CompoundMeterId.Compound) + && mtr.TestDone + && (mtr.Publish() != Config.Entities.Publish.Never) + && (mtr.Publish() != Config.Entities.Publish.Internal)) + { ListViewItem lvi = new ListViewItem(testNames[ix++]); foreach (var item in items) { string str; - /// TODO: Reimplement - //if (compound) - //{ - // str = item.CanPrintCombined ? item.PrintCombined(testRslt.Meters[2 * mtr - 2], - // testRslt.Meters[2 * mtr - 1], - // testRslt.CombinedMeters[mtr - 1]) - // : string.Empty; - //} - //else + if (compound) + { + var main = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain); + var aux = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux); + str = (item.CanPrintCombined && main != null && aux != null) + ? item.PrintCombined(main, aux, mtr) + : string.Empty; + } + else { str = item.CanPrintSingle ? item.Print(mtr) : string.Empty; } @@ -366,30 +370,37 @@ namespace TBF.Screens ListViewItem lvi = new ListViewItem(item.ClmnHeaderText); if (compound) { - /// TODO: Reimplement - //foreach (var mtr in wMtr.MeterTestRslts) - //{ - // string str = (!item.CanPrintCombined || (tr == null) || (2 * mtr > tr.Meters.Count) || (mtr > tr.CombinedMeters.Count)) - // ? string.Empty : item.PrintCombined(tr.Meters[2 * mtr - 2], - // tr.Meters[2 * mtr - 1], - // tr.CombinedMeters[mtr - 1]); - // string[] texts = str.Split(new char[] { '|' }); - // if (texts.Length == 1) - // { - // lvi.SubItems.Add(str); - // } - // else if (texts.Length == 2) - // { - // Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White); - // lvi.UseItemStyleForSubItems = false; - // lvi.SubItems.Add(texts[0]); - // lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color; - // } - // else - // { - // lvi.SubItems.Add(string.Empty); - // } - //} + foreach (var mtr in wMtr.MeterTestRslts) + { + if (mtr.CompoundMeterId == (byte)CompoundMeterId.Compound && mtr.TestDone + && (mtr.Publish() != Config.Entities.Publish.Never) + && (mtr.Publish() != Config.Entities.Publish.Internal)) + { + var main = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain); + var aux = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux); + + string str = (item.CanPrintCombined && main != null && aux != null) + ? item.PrintCombined(main, aux, mtr) + : string.Empty; + + string[] texts = str.Split(new char[] { '|' }); + if (texts.Length == 1) + { + lvi.SubItems.Add(str); + } + else if (texts.Length == 2) + { + Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White); + lvi.UseItemStyleForSubItems = false; + lvi.SubItems.Add(texts[0]); + lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color; + } + else + { + lvi.SubItems.Add(string.Empty); + } + } + } } else {