ProcedureDlg : Process tab : editing cells possible in case tm==null

This commit is contained in:
Milan Hanajik
2019-12-10 12:07:54 +01:00
parent e1a16528bb
commit 3cab98915f
+87 -75
View File
@@ -1266,6 +1266,7 @@ namespace TBF.UI.Procedures
void AddToProcessTab(Test test) void AddToProcessTab(Test test)
{ {
ITestMethod tm = TBF.BenchControl.TbfComponents.FindComponent(test.Method, TbfComponents) as ITestMethod; ITestMethod tm = TBF.BenchControl.TbfComponents.FindComponent(test.Method, TbfComponents) as ITestMethod;
bool isNotAHydroTest = (tm != null) && !tm.DoTransitions();
/// ///
/// Process item with subitems /// Process item with subitems
@@ -1273,23 +1274,8 @@ namespace TBF.UI.Procedures
ListViewItem lvi = new ListViewItem(test.Name); /// Name ListViewItem lvi = new ListViewItem(test.Name); /// Name
lvi.Tag = test; lvi.Tag = test;
lvi.SubItems.Add((test.Part == 0) ? "-" : test.Part.ToString()); /// Part lvi.SubItems.Add((test.Part == 0) ? "-" : test.Part.ToString()); /// Part
if (tm != null && tm.DoTransitions()) if (isNotAHydroTest)
{
lvi.SubItems.Add(test.DoDraining ? Strings.yes : Strings.no); /// Draining before test
lvi.SubItems.Add(test.DoDrainingAfter ? Strings.yes : Strings.no); /// Draining after test
lvi.SubItems.Add(test.FeedingPath);
lvi.SubItems.Add(test.BenchPath);
lvi.SubItems.Add(test.OutputPath);
#if HEAT_METERS
lvi.SubItems.Add(test.HeatMetersPath);
#endif
lvi.SubItems.Add(test.MetersPath);
lvi.SubItems.Add(string.IsNullOrEmpty(test.RelTransBefore) ? "---" : test.RelTransBefore);
lvi.SubItems.Add(string.IsNullOrEmpty(test.RelTransBetween) ? "---" : test.RelTransBetween);
lvi.SubItems.Add(string.IsNullOrEmpty(test.TransitionAfter) ? "---" : test.TransitionAfter);
}
else
{ {
lvi.SubItems.Add(string.Empty); /// Draining before test N/A lvi.SubItems.Add(string.Empty); /// Draining before test N/A
lvi.SubItems.Add(string.Empty); /// Draining after test N/A lvi.SubItems.Add(string.Empty); /// Draining after test N/A
@@ -1304,6 +1290,21 @@ namespace TBF.UI.Procedures
lvi.SubItems.Add(string.Empty); /// RelTransBetween N/A lvi.SubItems.Add(string.Empty); /// RelTransBetween N/A
lvi.SubItems.Add(string.Empty); /// TransitionAfter N/A lvi.SubItems.Add(string.Empty); /// TransitionAfter N/A
} }
else
{
lvi.SubItems.Add(test.DoDraining ? Strings.yes : Strings.no); /// Draining before test
lvi.SubItems.Add(test.DoDrainingAfter ? Strings.yes : Strings.no); /// Draining after test
lvi.SubItems.Add(test.FeedingPath);
lvi.SubItems.Add(test.BenchPath);
lvi.SubItems.Add(test.OutputPath);
#if HEAT_METERS
lvi.SubItems.Add(test.HeatMetersPath);
#endif
lvi.SubItems.Add(test.MetersPath);
lvi.SubItems.Add(string.IsNullOrEmpty(test.RelTransBefore) ? "---" : test.RelTransBefore);
lvi.SubItems.Add(string.IsNullOrEmpty(test.RelTransBetween) ? "---" : test.RelTransBetween);
lvi.SubItems.Add(string.IsNullOrEmpty(test.TransitionAfter) ? "---" : test.TransitionAfter);
}
processListViewEx.Items.Add(lvi); processListViewEx.Items.Add(lvi);
} }
@@ -1313,77 +1314,87 @@ namespace TBF.UI.Procedures
for (int i = 0; i < processListViewEx.Items.Count; i++) for (int i = 0; i < processListViewEx.Items.Count; i++)
{ {
ListViewItem lvi = processListViewEx.Items[i]; ListViewItem lvi = processListViewEx.Items[i];
Test entity = (Test)lvi.Tag; Test test = (Test)lvi.Tag;
entity.Name = lvi.Text; ITestMethod tm = TBF.BenchControl.TbfComponents.FindComponent(test.Method, TbfComponents) as ITestMethod;
entity.ItemNr = i; bool isNotAHydroTest = (tm != null) && !tm.DoTransitions();
int part = entity.Part; test.Name = lvi.Text;
test.ItemNr = i;
int part = test.Part;
if (lvi.SubItems[(int)ProcessClmn.Part].Text.Equals("-")) if (lvi.SubItems[(int)ProcessClmn.Part].Text.Equals("-"))
{ {
entity.Part = 0; test.Part = 0;
} }
else if (int.TryParse(lvi.SubItems[(int)ProcessClmn.Part].Text, out part)) else if (int.TryParse(lvi.SubItems[(int)ProcessClmn.Part].Text, out part))
{ {
entity.Part = part; test.Part = part;
} }
entity.DoDraining = lvi.SubItems[(int)ProcessClmn.DrainingBefore].Text.Equals(Strings.yes); int column;
entity.DoDrainingAfter = lvi.SubItems[(int)ProcessClmn.DrainingAfter].Text.Equals(Strings.yes); string subItemText;
if (!isNotAHydroTest)
{
/// Is a hydraulical test or test.Method component == null
test.DoDraining = lvi.SubItems[(int)ProcessClmn.DrainingBefore].Text.Equals(Strings.yes);
test.DoDrainingAfter = lvi.SubItems[(int)ProcessClmn.DrainingAfter].Text.Equals(Strings.yes);
int column = (int)ProcessClmn.Feeding; column = (int)ProcessClmn.Feeding;
string subItemText = lvi.SubItems[column].Text; subItemText = lvi.SubItems[column].Text;
if (string.IsNullOrEmpty(subItemText) || (processEditors[column] as ComboBox).Items.Contains(subItemText)) if (string.IsNullOrEmpty(subItemText) || (processEditors[column] as ComboBox).Items.Contains(subItemText))
{ {
entity.FeedingPath = subItemText; test.FeedingPath = subItemText;
} }
column = (int)ProcessClmn.Bench; column = (int)ProcessClmn.Bench;
subItemText = lvi.SubItems[column].Text; subItemText = lvi.SubItems[column].Text;
if (string.IsNullOrEmpty(subItemText) || (processEditors[column] as ComboBox).Items.Contains(subItemText)) if (string.IsNullOrEmpty(subItemText) || (processEditors[column] as ComboBox).Items.Contains(subItemText))
{ {
entity.BenchPath = subItemText; test.BenchPath = subItemText;
} }
column = (int)ProcessClmn.Output; column = (int)ProcessClmn.Output;
subItemText = lvi.SubItems[column].Text; subItemText = lvi.SubItems[column].Text;
if (string.IsNullOrEmpty(subItemText) || (processEditors[column] as ComboBox).Items.Contains(subItemText)) if (string.IsNullOrEmpty(subItemText) || (processEditors[column] as ComboBox).Items.Contains(subItemText))
{ {
entity.OutputPath = subItemText; test.OutputPath = subItemText;
} }
column = (int)ProcessClmn.TrnStart;
subItemText = lvi.SubItems[column].Text;
if (string.IsNullOrEmpty(subItemText) || (processEditors[column] as ComboBox).Items.Contains(subItemText))
{
test.RelTransBefore = (string.IsNullOrEmpty(subItemText) || subItemText.Equals("---")) ? string.Empty : subItemText;
}
column = (int)ProcessClmn.TrnBetween;
subItemText = lvi.SubItems[column].Text;
if (string.IsNullOrEmpty(subItemText) || (processEditors[column] as ComboBox).Items.Contains(subItemText))
{
test.RelTransBetween = (string.IsNullOrEmpty(subItemText) || subItemText.Equals("---")) ? string.Empty : subItemText;
}
column = (int)ProcessClmn.TrnStop;
subItemText = lvi.SubItems[column].Text;
if (string.IsNullOrEmpty(subItemText) || (processEditors[column] as ComboBox).Items.Contains(subItemText))
{
test.TransitionAfter = (string.IsNullOrEmpty(subItemText) || subItemText.Equals("---")) ? string.Empty : subItemText;
}
}
column = (int)ProcessClmn.Sensor; column = (int)ProcessClmn.Sensor;
subItemText = lvi.SubItems[column].Text; subItemText = lvi.SubItems[column].Text;
if ((processEditors[column] as ComboBox).Items.Contains(subItemText)) if ((processEditors[column] as ComboBox).Items.Contains(subItemText))
{ {
entity.MetersPath = subItemText; test.MetersPath = subItemText;
} }
#if HEAT_METERS #if HEAT_METERS
if ((processEditors[(int)ProcessClmn.HeatMeterSensors] as ComboBox).Items.Contains(lvi.SubItems[(int)ProcessClmn.HeatMeterSensors].Text)) if ((processEditors[(int)ProcessClmn.HeatMeterSensors] as ComboBox).Items.Contains(lvi.SubItems[(int)ProcessClmn.HeatMeterSensors].Text))
{ {
entity.HeatMetersPath = lvi.SubItems[(int)ProcessClmn.HeatMeterSensors].Text; entity.HeatMetersPath = lvi.SubItems[(int)ProcessClmn.HeatMeterSensors].Text;
} }
#endif #endif
column = (int)ProcessClmn.TrnStart;
subItemText = lvi.SubItems[column].Text;
if (string.IsNullOrEmpty(subItemText) || (processEditors[column] as ComboBox).Items.Contains(subItemText))
{
entity.RelTransBefore = (string.IsNullOrEmpty(subItemText) || subItemText.Equals("---")) ? string.Empty : subItemText;
}
column = (int)ProcessClmn.TrnBetween;
subItemText = lvi.SubItems[column].Text;
if (string.IsNullOrEmpty(subItemText) || (processEditors[column] as ComboBox).Items.Contains(subItemText))
{
entity.RelTransBetween = (string.IsNullOrEmpty(subItemText) || subItemText.Equals("---")) ? string.Empty : subItemText;
}
column = (int)ProcessClmn.TrnStop;
subItemText = lvi.SubItems[column].Text;
if (string.IsNullOrEmpty(subItemText) || (processEditors[column] as ComboBox).Items.Contains(subItemText))
{
entity.TransitionAfter = (string.IsNullOrEmpty(subItemText) || subItemText.Equals("---")) ? string.Empty : subItemText;
}
} }
} }
@@ -1398,17 +1409,18 @@ namespace TBF.UI.Procedures
if (((e.Item.Tag as Test).Profile >= TestProfile.Protected) && protectedColumns.Contains<ProcessClmn>((ProcessClmn)e.SubItem)) return; if (((e.Item.Tag as Test).Profile >= TestProfile.Protected) && protectedColumns.Contains<ProcessClmn>((ProcessClmn)e.SubItem)) return;
ITestMethod tm = TBF.BenchControl.TbfComponents.FindComponent((e.Item.Tag as Test).Method, TbfComponents) as ITestMethod; ITestMethod tm = TBF.BenchControl.TbfComponents.FindComponent((e.Item.Tag as Test).Method, TbfComponents) as ITestMethod;
bool isNotAHydroTest = (tm != null) && !tm.DoTransitions();
if (tm != null && (tm.DoTransitions() == false) && ((e.SubItem == (int)ProcessClmn.DrainingBefore) || if (isNotAHydroTest && ((e.SubItem == (int)ProcessClmn.DrainingBefore) ||
(e.SubItem == (int)ProcessClmn.DrainingAfter) || (e.SubItem == (int)ProcessClmn.DrainingAfter) ||
(e.SubItem == (int)ProcessClmn.Feeding) || (e.SubItem == (int)ProcessClmn.Feeding) ||
(e.SubItem == (int)ProcessClmn.Bench) || (e.SubItem == (int)ProcessClmn.Bench) ||
(e.SubItem == (int)ProcessClmn.Output) || (e.SubItem == (int)ProcessClmn.Output) ||
(e.SubItem == (int)ProcessClmn.TrnStart) || (e.SubItem == (int)ProcessClmn.TrnStart) ||
(e.SubItem == (int)ProcessClmn.TrnBetween) || (e.SubItem == (int)ProcessClmn.TrnBetween) ||
(e.SubItem == (int)ProcessClmn.TrnStop))) (e.SubItem == (int)ProcessClmn.TrnStop)))
{ {
return; return; /// Prevent editing these cells
} }
processListViewEx.StartEditing(processEditors[e.SubItem], e.Item, e.SubItem); processListViewEx.StartEditing(processEditors[e.SubItem], e.Item, e.SubItem);