Previous results display fixed.
This commit is contained in:
parent
294cc73e36
commit
c776cbcdf1
@ -27,8 +27,9 @@ namespace Results.Forms
|
||||
public TestsArrangement TestsArrangement;
|
||||
public int NrMetersInOneGroup;
|
||||
|
||||
public IList<Results.ItemSpec> RsltItems_Screen_SingleWM;
|
||||
public IList<Results.ItemSpec> RsltItems_Screen_CombinedWM;
|
||||
public IList<Results.WMeterRsltItemSpec> RsltItems_Screen_SingleWM;
|
||||
public IList<Results.WMeterRsltItemSpec> RsltItems_Screen_CombinedWM;
|
||||
public IList<Results.WMeterRsltItemSpec> RsltItems_Screen_HeatM;
|
||||
public int[] RsltsClmnWidths { set { rsltsClmnWidths = value; } }
|
||||
|
||||
public int PopupResultsLeft;
|
||||
@ -42,7 +43,7 @@ namespace Results.Forms
|
||||
/// Private members
|
||||
///
|
||||
Results.BatchResults results;
|
||||
bool compound;
|
||||
MetersKind metersKind;
|
||||
|
||||
ListView firstListView;
|
||||
public int[] rsltsClmnWidths;
|
||||
@ -87,6 +88,23 @@ namespace Results.Forms
|
||||
}
|
||||
|
||||
|
||||
IList<Results.WMeterRsltItemSpec> GetRsltItems(MetersKind metersKind)
|
||||
{
|
||||
IList<Results.WMeterRsltItemSpec> srcItems;
|
||||
switch (metersKind)
|
||||
{
|
||||
default:
|
||||
case MetersKind.Single: srcItems = RsltItems_Screen_SingleWM; break;
|
||||
case MetersKind.Combined: srcItems = RsltItems_Screen_CombinedWM; break;
|
||||
case MetersKind.HeatMeter: srcItems = RsltItems_Screen_HeatM; break;
|
||||
}
|
||||
|
||||
IList<Results.WMeterRsltItemSpec> copiedItems = new List<Results.WMeterRsltItemSpec>();
|
||||
foreach (var it in srcItems) copiedItems.Add(it.Clone());
|
||||
return copiedItems;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Re-draw the results. Apply new settings if they changed.
|
||||
/// </summary>
|
||||
@ -109,7 +127,7 @@ namespace Results.Forms
|
||||
}
|
||||
|
||||
int metersInOneGroup = Math.Max(1, Math.Min(enabledWMsCount, NrMetersInOneGroup));
|
||||
int nrGroups = Math.Max(1, (enabledWMsCount + NrMetersInOneGroup - 1) / metersInOneGroup);
|
||||
int nrGroups = Math.Max(1, (enabledWMsCount + metersInOneGroup - 1) / metersInOneGroup);
|
||||
|
||||
if (MetersArrangement == MetersArrangement.Horizontally)
|
||||
{
|
||||
@ -211,20 +229,21 @@ namespace Results.Forms
|
||||
/// <returns>ListView object</returns>
|
||||
ListView GetResultsTestsAreRows(Results.Entities.WaterMeter wMtr, int printedWMNr)
|
||||
{
|
||||
compound = wMtr.Compound();
|
||||
metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single);
|
||||
|
||||
ListView lview = GetListView();
|
||||
|
||||
IList<Results.ItemSpec> items = (compound ? RsltItems_Screen_CombinedWM : RsltItems_Screen_SingleWM);
|
||||
IList<Results.WMeterRsltItemSpec> items = GetRsltItems(metersKind);
|
||||
|
||||
if (items == null || items.Count == 0) return lview;
|
||||
|
||||
// Header
|
||||
lview.Columns.Add(printedWMNr.ToString(), (rsltsClmnCount > 0) ? rsltsClmnWidths[0] : 40);
|
||||
int i = 1;
|
||||
int col = 1;
|
||||
foreach (var item in items)
|
||||
{
|
||||
lview.Columns.Add(item.ClmnHeaderText, (rsltsClmnCount > i) ? rsltsClmnWidths[i] : 70);
|
||||
i++;
|
||||
lview.Columns.Add(item.Caption, (rsltsClmnCount > col) ? rsltsClmnWidths[col] : 70);
|
||||
col++;
|
||||
}
|
||||
|
||||
|
||||
@ -232,29 +251,21 @@ namespace Results.Forms
|
||||
int ix = 0;
|
||||
foreach (var mtr in wMtr.MeterTestRslts)
|
||||
{
|
||||
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))
|
||||
if (mtr != null &&
|
||||
(mtr.CompoundMeterId == (byte)CompoundMeterId.Single ||
|
||||
mtr.CompoundMeterId == (byte)CompoundMeterId.Compound ||
|
||||
mtr.CompoundMeterId == (byte)CompoundMeterId.HeatMeterEnergy) &&
|
||||
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)
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
string str;
|
||||
if (compound)
|
||||
{
|
||||
var main = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain);
|
||||
var aux = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux);
|
||||
str = (item.CanPrintCompoundMeter && main != null && aux != null)
|
||||
? item.PrintCombined(main, aux, mtr)
|
||||
: string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
str = item.CanPrintSingle ? item.Print(mtr) : string.Empty;
|
||||
}
|
||||
string str = items[i].Print(wMtr, mtr.Name());
|
||||
|
||||
/// Extract and use color information
|
||||
string[] texts = str.Split(new char[] { '|' });
|
||||
if (texts.Length == 1)
|
||||
{
|
||||
@ -288,11 +299,12 @@ namespace Results.Forms
|
||||
/// <returns>ListView object</returns>
|
||||
ListView GetResultsTestsAreColumns(Results.Entities.WaterMeter wMtr, int printedWMNr)
|
||||
{
|
||||
compound = wMtr.Compound();
|
||||
metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single);
|
||||
|
||||
ListView lview = GetListView();
|
||||
|
||||
IList<Results.ItemSpec> items = (compound ? RsltItems_Screen_CombinedWM : RsltItems_Screen_SingleWM);
|
||||
IList<Results.WMeterRsltItemSpec> items = GetRsltItems(metersKind);
|
||||
|
||||
if (items == null || items.Count == 0) return lview;
|
||||
|
||||
// Header
|
||||
@ -306,69 +318,39 @@ namespace Results.Forms
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
ListViewItem lvi = new ListViewItem(item.ClmnHeaderText);
|
||||
if (compound)
|
||||
ListViewItem lvi = new ListViewItem(item.Caption);
|
||||
|
||||
foreach (var mtr in wMtr.MeterTestRslts)
|
||||
{
|
||||
foreach (var mtr in wMtr.MeterTestRslts)
|
||||
if (mtr != null &&
|
||||
(mtr.CompoundMeterId == (byte)CompoundMeterId.Single ||
|
||||
mtr.CompoundMeterId == (byte)CompoundMeterId.Compound ||
|
||||
mtr.CompoundMeterId == (byte)CompoundMeterId.HeatMeterEnergy) &&
|
||||
mtr.TestDone &&
|
||||
mtr.Publish() != Config.Entities.Publish.Never &&
|
||||
mtr.Publish() != Config.Entities.Publish.Internal)
|
||||
{
|
||||
if (mtr.CompoundMeterId == (byte)CompoundMeterId.Compound && mtr.TestDone
|
||||
&& (mtr.Publish() != Config.Entities.Publish.Never)
|
||||
&& (mtr.Publish() != Config.Entities.Publish.Internal))
|
||||
string str = items[i].Print(wMtr, mtr.Name());
|
||||
|
||||
string[] texts = str.Split(new char[] { '|' });
|
||||
if (texts.Length == 1)
|
||||
{
|
||||
var main = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain);
|
||||
var aux = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux);
|
||||
|
||||
string str = (item.CanPrintCompoundMeter && 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);
|
||||
}
|
||||
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
|
||||
{
|
||||
foreach (var mtr in wMtr.MeterTestRslts)
|
||||
{
|
||||
if (mtr.TestDone && (mtr.Publish() != Config.Entities.Publish.Never)
|
||||
&& (mtr.Publish() != Config.Entities.Publish.Internal))
|
||||
{
|
||||
string str = !item.CanPrintSingle ? string.Empty : item.Print(mtr);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lview.Items.Add(lvi);
|
||||
}
|
||||
|
||||
|
||||
@ -189,8 +189,9 @@ namespace TBF.Forms
|
||||
dlg.TestsArrangement = Program.LocalSettings.ResultsConfigTests;
|
||||
dlg.NrMetersInOneGroup = Math.Max(1, Program.LocalSettings.ResultsConfigMetersInOneGroup);
|
||||
|
||||
dlg.RsltItems_Screen_SingleWM = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_SingleWM);
|
||||
dlg.RsltItems_Screen_CombinedWM = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_CombinedWM);
|
||||
dlg.RsltItems_Screen_SingleWM = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_SingleWM);
|
||||
dlg.RsltItems_Screen_CombinedWM = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_CombinedWM);
|
||||
dlg.RsltItems_Screen_HeatM = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_HeatM);
|
||||
dlg.RsltsClmnWidths = Program.LocalSettings.RsltsClmnWidths;
|
||||
|
||||
foreach (var b in batches)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user