diff --git a/Doc/Virtual-bench-components.ods b/Doc/Virtual-bench-components.ods new file mode 100644 index 000000000..070bf79fa Binary files /dev/null and b/Doc/Virtual-bench-components.ods differ diff --git a/TestBenchFramework/Entities/VirtualBenchSequence.cs b/TestBenchFramework/Entities/VirtualBenchSequence.cs new file mode 100644 index 000000000..b1a118181 --- /dev/null +++ b/TestBenchFramework/Entities/VirtualBenchSequence.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; + +namespace TBF.Entities +{ + public class VirtualBenchSequence : IHasItemNr + { + public virtual int Id { get; protected set; } + public virtual int ItemNr { get; set; } + public virtual string Name { get; set; } + public virtual string Description { get; set; } /// Short description + public virtual IList VirtualBenchSteps { get; set; } + + public VirtualBenchSequence() + { + VirtualBenchSteps = new List(); + } + + public VirtualBenchSequence(string name, int itemNr) + : this() + { + Name = name; + ItemNr = itemNr; + } + + public virtual VirtualBenchSequence Clone() + { + VirtualBenchSequence result = new VirtualBenchSequence(); + result.Name = Name; + result.Description = Description; + foreach (var step in VirtualBenchSteps) { result.VirtualBenchSteps.Add(step.Clone()); } + return result; + } + } +} diff --git a/TestBenchFramework/Entities/VirtualBenchStep.cs b/TestBenchFramework/Entities/VirtualBenchStep.cs new file mode 100644 index 000000000..62829d01f --- /dev/null +++ b/TestBenchFramework/Entities/VirtualBenchStep.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; + +namespace TBF.Entities +{ + public class VirtualBenchStep : IHasItemNr + { + public virtual int Id { get; protected set; } + public virtual int ItemNr { get; set; } /// Order of the preparation step + public virtual int Duration { get; set; } /// Duration in seconds + /// + + public virtual VirtualBenchSequence VirtualBenchSequence { get; set; } + + /// ------------- Additional stuff not mapped into the database ------------- + + public VirtualBenchStep() + { + Duration = 5; /// sec. + } + + public VirtualBenchStep(int itemNr, VirtualBenchSequence sequence) + : this() + { + ItemNr = itemNr; + VirtualBenchSequence = sequence; + } + + public virtual VirtualBenchStep Clone() + { + VirtualBenchStep result = new VirtualBenchStep(ItemNr, VirtualBenchSequence); + + return result; + } + } +} diff --git a/TestBenchFramework/Forms/TabNameDlg.Designer.cs b/TestBenchFramework/Forms/TabNameDlg.Designer.cs index 24302293f..540709b15 100644 --- a/TestBenchFramework/Forms/TabNameDlg.Designer.cs +++ b/TestBenchFramework/Forms/TabNameDlg.Designer.cs @@ -28,40 +28,66 @@ /// private void InitializeComponent() { - this.tabNameTextBox = new System.Windows.Forms.TextBox(); - this.okButton = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // tabNameTextBox - // - this.tabNameTextBox.Location = new System.Drawing.Point(33, 25); - this.tabNameTextBox.Name = "tabNameTextBox"; - this.tabNameTextBox.Size = new System.Drawing.Size(145, 20); - this.tabNameTextBox.TabIndex = 1; - // - // okButton - // - this.okButton.Location = new System.Drawing.Point(209, 18); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(85, 33); - this.okButton.TabIndex = 2; - this.okButton.Text = "OK"; - this.okButton.UseVisualStyleBackColor = true; - this.okButton.Click += new System.EventHandler(this.okButton_Click); - // - // TabNameDlg - // - this.AcceptButton = this.okButton; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(316, 69); - this.Controls.Add(this.okButton); - this.Controls.Add(this.tabNameTextBox); - this.Name = "TabNameDlg"; - this.Text = "TabName"; - this.Load += new System.EventHandler(this.TabNameDlg_Load); - this.ResumeLayout(false); - this.PerformLayout(); + this.tabNameTextBox = new System.Windows.Forms.TextBox(); + this.okButton = new System.Windows.Forms.Button(); + this.radioButton1 = new System.Windows.Forms.RadioButton(); + this.radioButton2 = new System.Windows.Forms.RadioButton(); + this.SuspendLayout(); + // + // tabNameTextBox + // + this.tabNameTextBox.Location = new System.Drawing.Point(33, 25); + this.tabNameTextBox.Name = "tabNameTextBox"; + this.tabNameTextBox.Size = new System.Drawing.Size(145, 20); + this.tabNameTextBox.TabIndex = 1; + // + // okButton + // + this.okButton.Location = new System.Drawing.Point(209, 18); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(85, 33); + this.okButton.TabIndex = 2; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // radioButton1 + // + this.radioButton1.AutoSize = true; + this.radioButton1.Checked = true; + this.radioButton1.Location = new System.Drawing.Point(37, 64); + this.radioButton1.Name = "radioButton1"; + this.radioButton1.Size = new System.Drawing.Size(121, 17); + this.radioButton1.TabIndex = 3; + this.radioButton1.TabStop = true; + this.radioButton1.Text = "Transition sequence"; + this.radioButton1.UseVisualStyleBackColor = true; + // + // radioButton2 + // + this.radioButton2.AutoSize = true; + this.radioButton2.Location = new System.Drawing.Point(37, 87); + this.radioButton2.Name = "radioButton2"; + this.radioButton2.Size = new System.Drawing.Size(137, 17); + this.radioButton2.TabIndex = 4; + this.radioButton2.Text = "Virtual bench sequence"; + this.radioButton2.UseVisualStyleBackColor = true; + // + // TabNameDlg + // + this.AcceptButton = this.okButton; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(316, 117); + this.Controls.Add(this.radioButton2); + this.Controls.Add(this.radioButton1); + this.Controls.Add(this.okButton); + this.Controls.Add(this.tabNameTextBox); + this.Name = "TabNameDlg"; + this.Text = "TabName"; + this.Load += new System.EventHandler(this.TabNameDlg_Load); + this.ResumeLayout(false); + this.PerformLayout(); } @@ -69,5 +95,7 @@ private System.Windows.Forms.TextBox tabNameTextBox; private System.Windows.Forms.Button okButton; + private System.Windows.Forms.RadioButton radioButton1; + private System.Windows.Forms.RadioButton radioButton2; } } \ No newline at end of file diff --git a/TestBenchFramework/Forms/TabNameDlg.cs b/TestBenchFramework/Forms/TabNameDlg.cs index a66332127..60232d433 100644 --- a/TestBenchFramework/Forms/TabNameDlg.cs +++ b/TestBenchFramework/Forms/TabNameDlg.cs @@ -8,6 +8,7 @@ namespace TBF.Forms { public string TabNameLabel; public string TabName; + public bool IsVirtualBenchSeq; public TabNameDlg() { @@ -18,12 +19,14 @@ namespace TBF.Forms { Text = TabNameLabel; tabNameTextBox.Text = TabName; + IsVirtualBenchSeq = false; okButton.Text = Strings.OkBtnText; } private void okButton_Click(object sender, EventArgs e) { TabName = tabNameTextBox.Text; + IsVirtualBenchSeq = radioButton2.Checked; DialogResult = DialogResult.OK; Close(); } diff --git a/TestBenchFramework/Mappings/VirtualBenchSequenceMap.cs b/TestBenchFramework/Mappings/VirtualBenchSequenceMap.cs new file mode 100644 index 000000000..d02223985 --- /dev/null +++ b/TestBenchFramework/Mappings/VirtualBenchSequenceMap.cs @@ -0,0 +1,19 @@ +using FluentNHibernate.Mapping; +using TBF.Entities; + +namespace TBF.Mappings +{ + class VirtualBenchSequenceMap : ClassMap + { + public VirtualBenchSequenceMap() + { + Id(x => x.Id); + Map(x => x.ItemNr); + Map(x => x.Name); + Map(x => x.Description); + HasMany(x => x.VirtualBenchSteps) + .OrderBy("ItemNr") + .Cascade.All(); + } + } +} diff --git a/TestBenchFramework/Mappings/VirtualBenchStepMap.cs b/TestBenchFramework/Mappings/VirtualBenchStepMap.cs new file mode 100644 index 000000000..d614e2cab --- /dev/null +++ b/TestBenchFramework/Mappings/VirtualBenchStepMap.cs @@ -0,0 +1,17 @@ +using FluentNHibernate.Mapping; +using TBF.Entities; + +namespace TBF.Mappings +{ + class VirtualBenchStepMap : ClassMap + { + public VirtualBenchStepMap() + { + Id(x => x.Id); + Map(x => x.ItemNr); + Map(x => x.Duration); + + References(x => x.VirtualBenchSequence); + } + } +} diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 5afe4cc97..113a57284 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -502,6 +502,8 @@ + + Form @@ -528,6 +530,8 @@ + + UserControl @@ -931,6 +935,9 @@ Component + + Component + ComponentCfgCtrl.cs diff --git a/TestBenchFramework/TransitionsDlg.cs b/TestBenchFramework/TransitionsDlg.cs index 4aa8a5ef8..9eed6d359 100644 --- a/TestBenchFramework/TransitionsDlg.cs +++ b/TestBenchFramework/TransitionsDlg.cs @@ -27,15 +27,16 @@ namespace TBF public ISession Session; /// - /// Procedure to be updated by this dialog. + /// Transition sequences to be updated by this dialog. /// Set by the constructor or updated by the parent after creation and before loading. /// - public IList LoadedSequences; + public IList TransitionSequences; - /// - /// A list of tests to be deleted after closing this dialog - /// - public IList ToBeDeletedSteps; + /// + /// Virtual bench sequences to be updated by this dialog. + /// Set by the constructor or updated by the parent after creation and before loading. + /// + public IList VirtualBenchSequences; /// Auxiliary public lists used also by user controls in tab pages @@ -44,7 +45,8 @@ namespace TBF public IList RegulValves; - IList transStepsCtrls; + IList transitionStepsCtrls; + IList virtualBenchStepsCtrls; bool unlocked; @@ -72,8 +74,11 @@ namespace TBF sharedButtons.RenameTabClicked += renameTabButton_Click; sharedButtons.RemoveTabClicked += removeTabButton_Click; - transStepsCtrls = new List(); - ToBeDeletedSteps = new List(); + transitionStepsCtrls = new List(); + virtualBenchStepsCtrls = new List(); + + TransitionSequences = new List(); + VirtualBenchSequences = new List(); } void Localize() @@ -89,60 +94,88 @@ namespace TBF Left = (ls.TransitionsDlgLeft != 0) ? ls.TransitionsDlgLeft : 150; Top = (ls.TransitionsDlgTop != 0) ? ls.TransitionsDlgTop : 150; - /// Load the procedures + /// Open the database Session = FluentCommon.CreateSession(Database.Procedures); - LoadedSequences = Session.CreateQuery("FROM TransitionSequence ORDER BY ItemNr") - .List(); - /// Prepare a list of components and a list of all valves in the test bench - TbfComponents = BenchControl.TbfComponents.LoadComponentsFromDB(Session); - Valves = BenchControl.GenericDevices.ValveBase.MasterValves(TbfComponents); - RegulValves = new List(); - foreach (var cmpnt in TbfComponents) - { - if (cmpnt is IRegulValve) RegulValves.Add(cmpnt as IRegulValve); - } + /// Prepare a list of components and a list of all valves in the test bench + TbfComponents = BenchControl.TbfComponents.LoadComponentsFromDB(Session); + Valves = BenchControl.GenericDevices.ValveBase.MasterValves(TbfComponents); + RegulValves = new List(); + foreach (var cmpnt in TbfComponents) + { + if (cmpnt is IRegulValve) RegulValves.Add(cmpnt as IRegulValve); + } - /// Create a tab with a TestParamsCtrl control for each used test method - foreach (var sequence in LoadedSequences) AddTab(sequence); + /// Load the sequences + TransitionSequences = Session.CreateQuery("FROM TransitionSequence ORDER BY ItemNr") + .List(); + + VirtualBenchSequences = Session.CreateQuery("FROM VirtualBenchSequence ORDER BY ItemNr") + .List(); + + /// Create a tab with sequence steps for each sequence + foreach (var sequence in TransitionSequences) AddTransitionSeqTab(sequence); + foreach (var sequence in VirtualBenchSequences) AddVirtualBenchSeqTab(sequence); /// Now refresh the content of the dialog RefreshAllTabs(); } - void AddTab(TransitionSequence sequence) + void AddTransitionSeqTab(TransitionSequence sequence) { TabPage nwTab = new TabPage(sequence.Name); TransitionStepsCtrl newCtrl = new TransitionStepsCtrl(); - transStepsCtrls.Add(newCtrl); + transitionStepsCtrls.Add(newCtrl); nwTab.Controls.Add(newCtrl); this.tabControl.TabPages.Add(nwTab); newCtrl.Initialize(sequence, this, this.tabControl.TabPages[this.tabControl.TabPages.Count - 1]); } + void AddVirtualBenchSeqTab(VirtualBenchSequence sequence) + { + TabPage nwTab = new TabPage(sequence.Name); + VirtualBenchStepsCtrl newCtrl = new VirtualBenchStepsCtrl(); + virtualBenchStepsCtrls.Add(newCtrl); + nwTab.Controls.Add(newCtrl); + this.tabControl.TabPages.Add(nwTab); + newCtrl.Initialize(sequence, this, this.tabControl.TabPages[this.tabControl.TabPages.Count - 1]); + } + void RefreshAllTabs() { - foreach (var ctrl in transStepsCtrls) ctrl.Refresh(); + foreach (var ctrl in transitionStepsCtrls) ctrl.Refresh(); + foreach (var ctrl in virtualBenchStepsCtrls) ctrl.Refresh(); } private void Unlocked(object sender, EventArgs e) { unlocked = true; - foreach (var ctrl in transStepsCtrls) ctrl.Unlock(); - } + foreach (var ctrl in transitionStepsCtrls) ctrl.Unlock(); + foreach (var ctrl in virtualBenchStepsCtrls) ctrl.Unlock(); + } private void newTabButton_Click(object sender, EventArgs e) { - int tabId = LoadedSequences.Count; + int tabId = TransitionSequences.Count + VirtualBenchSequences.Count; Forms.TabNameDlg dlg = new Forms.TabNameDlg(); dlg.TabNameLabel = Strings.New_transition_name; dlg.TabName = "Tr1"; dlg.ShowDialog(); - TransitionSequence sequence = new TransitionSequence(dlg.TabName, tabId); - LoadedSequences.Add(sequence); - AddTab(sequence); - transStepsCtrls[tabId].Unlock(); - tabControl.SelectTab(tabId); + if (dlg.IsVirtualBenchSeq) + { + VirtualBenchSequence sequence = new VirtualBenchSequence(dlg.TabName, tabId); + VirtualBenchSequences.Add(sequence); + AddVirtualBenchSeqTab(sequence); + virtualBenchStepsCtrls[tabId].Unlock(); + } + else + { + TransitionSequence sequence = new TransitionSequence(dlg.TabName, tabId); + TransitionSequences.Add(sequence); + AddTransitionSeqTab(sequence); + transitionStepsCtrls[tabId].Unlock(); + } + tabControl.SelectTab(tabId); } private void renameTabButton_Click(object sender, EventArgs e) @@ -155,16 +188,15 @@ namespace TBF private void okButton_Click(object sender, EventArgs e) { - if (transStepsCtrls.Count > slctdTab) transStepsCtrls[slctdTab].OkBtnClicked(); + if (transitionStepsCtrls.Count > slctdTab) transitionStepsCtrls[slctdTab].OkBtnClicked(); using (var transaction = Session.BeginTransaction()) { - foreach (var sequence in LoadedSequences) - { - Session.SaveOrUpdate(sequence); - } - try { transaction.Commit(); } - catch { } + foreach (var transSeq in TransitionSequences) Session.SaveOrUpdate(transSeq); + foreach (var vBnchSeq in VirtualBenchSequences) Session.SaveOrUpdate(vBnchSeq); + + try { transaction.Commit(); } + catch { log.Error("Update of sequences in the database failed"); } } Program.LocalSettings.TransitionsDlgLeft = Location.X; @@ -195,9 +227,9 @@ namespace TBF private void tabControl_SelectedIndexChanged(object sender, EventArgs e) { - if (transStepsCtrls.Count > slctdTab) + if (transitionStepsCtrls.Count > slctdTab) { - transStepsCtrls[slctdTab].OkBtnClicked(); + transitionStepsCtrls[slctdTab].OkBtnClicked(); } slctdTab = tabControl.SelectedIndex; sharedButtons.SetEnabled(SharedButtons.Buttons.Add, true); @@ -207,22 +239,22 @@ namespace TBF private void addButton_Click(object sender, EventArgs e) { - if (transStepsCtrls.Count > slctdTab) transStepsCtrls[slctdTab].AddOne(); + if (transitionStepsCtrls.Count > slctdTab) transitionStepsCtrls[slctdTab].AddOne(); } private void removeButton_Click(object sender, EventArgs e) { - if (transStepsCtrls.Count > slctdTab) transStepsCtrls[slctdTab].RemoveSelected(); + if (transitionStepsCtrls.Count > slctdTab) transitionStepsCtrls[slctdTab].RemoveSelected(); } private void upButton_Click(object sender, EventArgs e) { - if (transStepsCtrls.Count > slctdTab) transStepsCtrls[slctdTab].MoveUpSelected(); + if (transitionStepsCtrls.Count > slctdTab) transitionStepsCtrls[slctdTab].MoveUpSelected(); } private void downButton_Click(object sender, EventArgs e) { - if (transStepsCtrls.Count > slctdTab) transStepsCtrls[slctdTab].MoveDownSelected(); + if (transitionStepsCtrls.Count > slctdTab) transitionStepsCtrls[slctdTab].MoveDownSelected(); } public void UpdateButtonStates(SharedButtons.SelectedItemPos selectedItemPos) diff --git a/TestBenchFramework/UiControls/VirtualBenchStepsCtrl.cs b/TestBenchFramework/UiControls/VirtualBenchStepsCtrl.cs new file mode 100644 index 000000000..f7c2e57fc --- /dev/null +++ b/TestBenchFramework/UiControls/VirtualBenchStepsCtrl.cs @@ -0,0 +1,224 @@ +using System.Collections.Generic; +using System.Windows.Forms; +using log4net; +using TBF.BenchControl; +using TBF.BenchControl.GenericDevices; +using TBF.Resources; + +namespace TBF.UiControls +{ + public partial class VirtualBenchStepsCtrl : BaseWithListViewEx, ITabWithListViewEx + { + static readonly ILog log = LogManager.GetLogger(typeof(VirtualBenchStepsCtrl)); + + /// + /// Fixed ListViewEx columns + /// + enum Column + { + Duration, + FixedColumnsCount, + } + readonly int fixedCount = (int)Column.FixedColumnsCount; + + Entities.VirtualBenchSequence sequence; + + TransitionsDlg parent; + Control parentControl; + Control[] editors; + + int fmPumpCount; /// Number of pumps with FM control + int regvCount; /// Number of regulating valves + int vCount; /// Number of valves + + public VirtualBenchStepsCtrl() + : base() + { + } + + public void Initialize(Entities.VirtualBenchSequence sequence, TransitionsDlg parent, Control parentControl) + { + this.sequence = sequence; + this.parent = parent; + this.parentControl = parentControl; + Name = sequence.Name; + MyItems = sequence.VirtualBenchSteps; + + SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked); + SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing); + + vCount = 0; + fmPumpCount = 0; + regvCount = 0; + + /// + /// ListViewEx columns + /// + Columns.Add(Strings.Duration_s, 70 * parent.Dpi / PathsDlg.Dpi100pct); + //foreach (var vlv in parent.Valves) + //{ + // if (vlv is BenchControl.GenericDevices.IPumpFM) + // { + // Columns.Add(vlv.Cfg.Name + " [%]", 45 * parent.Dpi / PathsDlg.Dpi100pct); + // fmPumpCount++; + // } + //} + //foreach (var rvlv in parent.RegulValves) + //{ + // Columns.Add(rvlv.Cfg.Name + " [%]", 55 * parent.Dpi / PathsDlg.Dpi100pct); + //} + //foreach (var vlv in parent.Valves) + //{ + // if (!(vlv is BenchControl.GenericDevices.IPumpFM)) + // { + // Columns.Add(vlv.Cfg.Name, 40 * parent.Dpi / PathsDlg.Dpi100pct); + // vCount++; + // } + //} + + /// + /// Prepare valve combo-boxes + /// + editors = new Control[fixedCount + vCount + fmPumpCount + regvCount]; + + editors[0] = new TextBox(); /// Duration + parent.Controls.Add(editors[0]); + + //for (int i = fixedCount; i < fixedCount + fmPumpCount; i++) + //{ + // ComboBox cb = new ComboBox(); + // cb.Items.Add("---"); + // cb.Items.Add(Strings.dflt); + // cb.Items.Add("0"); + // cb.Items.Add("25"); + // cb.Items.Add("50"); + // cb.Items.Add("75"); + // cb.Items.Add("100"); + // editors[i] = cb; + // parent.Controls.Add(editors[i]); + //} + + //for (int i = fixedCount + fmPumpCount; i < fixedCount + fmPumpCount + regvCount; i++) + //{ + // ComboBox cb = new ComboBox(); + // cb.Items.Add("---"); + // cb.Items.Add("0"); + // cb.Items.Add("25"); + // cb.Items.Add("50"); + // cb.Items.Add("75"); + // cb.Items.Add("100"); + // editors[i] = cb; + // parent.Controls.Add(editors[i]); + //} + + //for (int i = fixedCount + fmPumpCount + regvCount; i < fixedCount + fmPumpCount + regvCount + vCount; i++) + //{ + // ComboBox cb = new ComboBox(); + // cb.Items.Add("---"); + // cb.Items.Add(Strings.open); + // cb.Items.Add(Strings.close); + // editors[i] = cb; + // parent.Controls.Add(cb); + //} + + base.RedrawAll(); + } + + void listViewEx_SubItemClicked(object sender, SubItemEventArgs e) + { + if (!Unlocked || e.SubItem >= editors.Length) return; + StartEditing(editors[e.SubItem], e.Item, e.SubItem); + } + + void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e) + { + if (e.SubItem == (int)Column.Duration) + { + int duration; + if (!int.TryParse(e.DisplayText, out duration) || duration <= 0) + { + e.DisplayText = e.Item.Text; + e.Cancel = true; + } + } + //else if ((e.SubItem >= fixedCount) && (e.SubItem < fixedCount + fmPumpCount)) + //{ + // float pct; + // if (!e.DisplayText.Equals("---") && + // !e.DisplayText.Equals(Strings.dflt) && + // !(Utils.TryParseUFloat(e.DisplayText, out pct) && (pct >= 0) && (pct <= 100.0f))) + // { + // e.DisplayText = e.Item.SubItems[e.SubItem].Text; + // e.Cancel = true; + // } + //} + //else if ((e.SubItem >= fixedCount + fmPumpCount) && (e.SubItem < fixedCount + fmPumpCount + regvCount)) + //{ + // float pct; + // if (!e.DisplayText.Equals("---") && + // !(Utils.TryParseUFloat(e.DisplayText, out pct) && (pct >= 0) && (pct <= 100.0f))) + // { + // e.DisplayText = e.Item.SubItems[e.SubItem].Text; + // e.Cancel = true; + // } + //} + //else if ((e.SubItem >= fixedCount + fmPumpCount + regvCount) && (e.SubItem < fixedCount + fmPumpCount + regvCount + vCount)) + //{ + // if ((e.DisplayText != Strings.open) && (e.DisplayText != Strings.close) && (e.DisplayText != "---")) + // { + // e.DisplayText = e.Item.SubItems[e.SubItem].Text; + // e.Cancel = true; + // } + //} + } + + public override void DrawOne(object myItem) + { + Entities.VirtualBenchStep step = (Entities.VirtualBenchStep)myItem; + + ListViewItem lvi = new ListViewItem(step.Duration.ToString()); + + /// TODO: All the rest + + lvi.Tag = step; + + Items.Add(lvi); + } + + public override void UpdateOne(ListViewItem lvi, object myItem) + { + Entities.VirtualBenchStep step = (Entities.VirtualBenchStep)myItem; + + /// Duration + try + { + step.Duration = int.Parse(lvi.Text); + if (step.Duration < 2) throw (new System.Exception()); + } + catch + { + lvi.Text = step.Duration.ToString(); + } + + // TODO: Replace the following: + //step.PumpWithFMPcts = fmPumpsPcts; + //step.RegulValvesPct = regulValvesPct; + //step.ValvesOpen = valvesOpen; + //step.ValvesClose = valvesClose; + } + + public void AddOne() + { + base.AddOne(new Entities.VirtualBenchStep(MyItems.Count, sequence)); + } + + public new void RemoveSelected() + { + bool lastItemRemoved = base.RemoveSelected(); + if (lastItemRemoved && parent != null) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.None); + } + } + } +}