Output.FileWriters.Enhanced : (1) Old style ResultsConfigDlg removed, (2) Configuration change handling, ver. 2 12.466
This commit is contained in:
@@ -20,14 +20,15 @@ namespace Results.Forms
|
||||
{
|
||||
Item,
|
||||
Caption,
|
||||
TestID,
|
||||
Units,
|
||||
Format,
|
||||
Precision,
|
||||
Width,
|
||||
Alignment,
|
||||
Count,
|
||||
TestID,
|
||||
Count,
|
||||
}
|
||||
|
||||
Control[] editors; /// all editors except of units
|
||||
ComboBox unitsCB; /// units combo box
|
||||
|
||||
@@ -35,14 +36,24 @@ namespace Results.Forms
|
||||
public IList<WMeterRsltItemSpec> AvailableItems;
|
||||
public IList<WMeterRsltItemSpec> SelectedItems;
|
||||
|
||||
|
||||
public MetersKind MetersKind;
|
||||
|
||||
|
||||
bool supressTestIDColumn;
|
||||
|
||||
|
||||
public ResultsConfigDlg(bool supressTestIDColumn)
|
||||
: this()
|
||||
{
|
||||
this.supressTestIDColumn = supressTestIDColumn;
|
||||
}
|
||||
|
||||
public ResultsConfigDlg()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
void Localize()
|
||||
{
|
||||
Text = Strings.Configuration;
|
||||
@@ -64,12 +75,15 @@ namespace Results.Forms
|
||||
/// Add columns to ListViewEx
|
||||
selectedResultsListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Item, Width = 120 });
|
||||
selectedResultsListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Caption });
|
||||
selectedResultsListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Test_ID });
|
||||
selectedResultsListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Units });
|
||||
selectedResultsListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Format });
|
||||
selectedResultsListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Precision });
|
||||
selectedResultsListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Width });
|
||||
selectedResultsListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Alignment });
|
||||
if (!supressTestIDColumn)
|
||||
{
|
||||
selectedResultsListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Test_ID });
|
||||
}
|
||||
|
||||
/// Create controls used by ListViewEx to edit items
|
||||
unitsCB = new ComboBox();
|
||||
@@ -83,13 +97,13 @@ namespace Results.Forms
|
||||
editors = new Control[]
|
||||
{
|
||||
null,
|
||||
new TextBox(),
|
||||
new TextBox(),
|
||||
new TextBox(), /// caption
|
||||
unitsCB,
|
||||
new TextBox(),
|
||||
new TextBox(),
|
||||
new TextBox(),
|
||||
new TextBox(), /// format
|
||||
new TextBox(), /// precision
|
||||
new TextBox(), /// width
|
||||
alignmentCB,
|
||||
new TextBox(), /// testID
|
||||
};
|
||||
foreach (var edi in editors)
|
||||
{
|
||||
@@ -120,7 +134,7 @@ namespace Results.Forms
|
||||
}
|
||||
selectedResultsListViewEx.StartEditing(unitsCB, e.Item, e.SubItem);
|
||||
}
|
||||
else if ((e.SubItem > 0) && (e.SubItem < (int)Column.Count))
|
||||
else if ((e.SubItem > 0) && (e.SubItem < (int)(supressTestIDColumn ? Column.TestID : Column.Count)))
|
||||
{
|
||||
selectedResultsListViewEx.StartEditing(editors[e.SubItem], e.Item, e.SubItem);
|
||||
}
|
||||
@@ -134,10 +148,6 @@ namespace Results.Forms
|
||||
switch ((Column)e.SubItem)
|
||||
{
|
||||
case Column.Caption: item.Caption = e.DisplayText; return;
|
||||
case Column.TestID: item.TestID = e.DisplayText; return;
|
||||
case Column.Format: item.Format = e.DisplayText; return;
|
||||
case Column.Precision: item.Precision = e.DisplayText; return;
|
||||
|
||||
case Column.Units:
|
||||
for (Config.Unit u = 0; u < Config.Unit.Count; u++)
|
||||
{
|
||||
@@ -149,6 +159,19 @@ namespace Results.Forms
|
||||
}
|
||||
break; /// Error
|
||||
|
||||
case Column.Format: item.Format = e.DisplayText; return;
|
||||
case Column.Precision: item.Precision = e.DisplayText; return;
|
||||
case Column.Width:
|
||||
{
|
||||
int width;
|
||||
if (Int32.TryParse(editors[e.SubItem].Text, out width) && width >= 0)
|
||||
{
|
||||
item.Width = width;
|
||||
return; /// OK
|
||||
}
|
||||
break; /// Error
|
||||
}
|
||||
|
||||
case Column.Alignment:
|
||||
for (Config.Entities.Alignment a = 0; a < Config.Entities.Alignment.Count; a++)
|
||||
{
|
||||
@@ -159,18 +182,10 @@ namespace Results.Forms
|
||||
}
|
||||
}
|
||||
break; /// Error
|
||||
|
||||
case Column.Width:
|
||||
{
|
||||
int width;
|
||||
if (Int32.TryParse(editors[e.SubItem].Text, out width) && width >= 0)
|
||||
{
|
||||
item.Width = width;
|
||||
return; /// OK
|
||||
}
|
||||
break; /// Error
|
||||
}
|
||||
default:
|
||||
|
||||
case Column.TestID: item.TestID = e.DisplayText; return;
|
||||
|
||||
default:
|
||||
return; /// OK
|
||||
}
|
||||
|
||||
@@ -204,12 +219,15 @@ namespace Results.Forms
|
||||
ListViewItem lvi = new ListViewItem(item.Name); /// Item
|
||||
lvi.Tag = item;
|
||||
lvi.SubItems.Add(item.Caption); /// Header
|
||||
lvi.SubItems.Add(item.TestID); /// TestID
|
||||
lvi.SubItems.Add(item.Units.ToDescription()); /// Units
|
||||
lvi.SubItems.Add(item.Format); /// Format
|
||||
lvi.SubItems.Add(item.Precision); /// Precision
|
||||
lvi.SubItems.Add(item.Width.ToString()); /// Width
|
||||
lvi.SubItems.Add(item.Alignment.ToDescription()); /// Alignment
|
||||
if (!supressTestIDColumn)
|
||||
{
|
||||
lvi.SubItems.Add(item.TestID); /// TestID
|
||||
}
|
||||
|
||||
selectedResultsListViewEx.Items.Add(lvi);
|
||||
}
|
||||
|
||||
@@ -48,9 +48,13 @@ namespace Results
|
||||
private readonly PrintDlgt printDlgt;
|
||||
|
||||
/// <summary> Safe wrapper which replaces null-s by empty strings </summary>
|
||||
public string Print(WaterMeter waterMeterResult)
|
||||
public string Print(WaterMeter waterMeterResult)
|
||||
{
|
||||
string str = printDlgt(waterMeterResult, TestID, Units, Format, Precision);
|
||||
return Print(waterMeterResult, TestID);
|
||||
}
|
||||
public string Print(WaterMeter waterMeterResult, string testId)
|
||||
{
|
||||
string str = printDlgt(waterMeterResult, testId, Units, Format, Precision);
|
||||
if (str == null) str = string.Empty;
|
||||
|
||||
if (!string.IsNullOrEmpty(Format))
|
||||
@@ -133,7 +137,7 @@ namespace Results
|
||||
AllItems.Add(new WMeterRsltItemSpec(ItemID.P_delta_mean, Strings.P_delta + "()", Quantity.Pressure, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : Config.Units.ConvertTo(u, w.GetTestRslt(t).PressDeltaMean).ToString(string.IsNullOrEmpty(p) ? "F3" : p)));
|
||||
AllItems.Add(new WMeterRsltItemSpec(ItemID.P_delta_start, Strings.P_delta_start + "()",Quantity.Pressure, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : Config.Units.ConvertTo(u, w.GetTestRslt(t).PressDeltaStart).ToString(string.IsNullOrEmpty(p) ? "F3" : p)));
|
||||
AllItems.Add(new WMeterRsltItemSpec(ItemID.P_delta_end, Strings.P_delta_end + "()", Quantity.Pressure, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : Config.Units.ConvertTo(u, w.GetTestRslt(t).PressDeltaEnd).ToString(string.IsNullOrEmpty(p) ? "F3" : p)));
|
||||
AllItems.Add(new WMeterRsltItemSpec(ItemID.Reference_error, Strings.ErrRef + "()", Quantity.Error, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : Config.Units.ConvertTo(u, w.GetTestRslt(t).ErrorMaster).ToString(string.IsNullOrEmpty(p) ? "F3" : p)));
|
||||
AllItems.Add(new WMeterRsltItemSpec(ItemID.Reference_error, Strings.ErrRef + "()", Quantity.Error, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : Config.Units.ConvertTo(u, w.GetTestRslt(t).ErrorMaster).ToString(string.IsNullOrEmpty(p) ? "F3" : p)));
|
||||
AllItems.Add(new WMeterRsltItemSpec(ItemID.Ambient_temperature, Strings.T_amb + "()", Quantity.Temperature, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? Config.Units.ConvertTo(u, w.Batch.AmbientTempAve()).ToString(string.IsNullOrEmpty(p) ? "F1" : p) : Config.Units.ConvertTo(u, w.GetTestRslt(t).AmbTempMean).ToString(string.IsNullOrEmpty(p) ? "F1" : p)));
|
||||
AllItems.Add(new WMeterRsltItemSpec(ItemID.Ambient_pressure, Strings.P_amb + "()", Quantity.Pressure, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? Config.Units.ConvertTo(u, w.Batch.AmbientPressAve()).ToString(string.IsNullOrEmpty(p) ? "F0" : p) : Config.Units.ConvertTo(u, w.GetTestRslt(t).AmbPressMean).ToString(string.IsNullOrEmpty(p) ? "F0" : p)));
|
||||
AllItems.Add(new WMeterRsltItemSpec(ItemID.Ambient_humidity, Strings.H_amb + "()", Quantity.Humidity, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? Config.Units.ConvertTo(u, w.Batch.AmbientHumiAve()).ToString(string.IsNullOrEmpty(p) ? "F1" : p) : Config.Units.ConvertTo(u, w.GetTestRslt(t).AmbHumiMean).ToString(string.IsNullOrEmpty(p) ? "F1" : p)));
|
||||
@@ -286,8 +290,11 @@ namespace Results
|
||||
{
|
||||
try
|
||||
{
|
||||
//if (strArray[i].Contains("~"))
|
||||
//{
|
||||
if (strArray[i].Contains("~"))
|
||||
{
|
||||
///
|
||||
/// Load the new style results item specification
|
||||
///
|
||||
string[] field = strArray[i].Split(new char[] { '~' });
|
||||
WMeterRsltItemSpec item = GetItem(int.Parse(field[0]));
|
||||
|
||||
@@ -308,10 +315,36 @@ namespace Results
|
||||
}
|
||||
|
||||
result.Add(item);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
///
|
||||
/// Try to load the old style results item specification
|
||||
///
|
||||
bool added = false;
|
||||
foreach (var it in AllItems)
|
||||
{
|
||||
if (strArray[i].Equals(it.OldUid))
|
||||
{
|
||||
WMeterRsltItemSpec item = it.Clone();
|
||||
item.Caption = item.Name.Replace("()", "").Replace(" *", "");
|
||||
item.Units = 0; /// use default units
|
||||
item.Format = null; /// the same like format string "{0}"
|
||||
item.Precision = null;
|
||||
item.Width = 0; /// do not ad any extra spaces
|
||||
item.Alignment = Alignment.Left;
|
||||
result.Add(item);
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!added)
|
||||
{
|
||||
WMeterRsltItemSpec item = GetItem(0);
|
||||
item.Format = string.Format("Parse error: {0}", strArray[i]);
|
||||
result.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user