From 26620f1fd1f54017c7e483c9491fdcd7b099b3f1 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Fri, 26 Sep 2014 15:01:46 +0200 Subject: [PATCH] First unfinished version with VirtualBenchSequences, requires DB upgrade --- Doc/Virtual-bench-components.ods | Bin 0 -> 11646 bytes .../Entities/VirtualBenchSequence.cs | 35 +++ .../Entities/VirtualBenchStep.cs | 36 +++ .../Forms/TabNameDlg.Designer.cs | 96 +++++--- TestBenchFramework/Forms/TabNameDlg.cs | 3 + .../Mappings/VirtualBenchSequenceMap.cs | 19 ++ .../Mappings/VirtualBenchStepMap.cs | 17 ++ TestBenchFramework/TBF.csproj | 7 + TestBenchFramework/TransitionsDlg.cs | 124 ++++++---- .../UiControls/VirtualBenchStepsCtrl.cs | 224 ++++++++++++++++++ 10 files changed, 481 insertions(+), 80 deletions(-) create mode 100644 Doc/Virtual-bench-components.ods create mode 100644 TestBenchFramework/Entities/VirtualBenchSequence.cs create mode 100644 TestBenchFramework/Entities/VirtualBenchStep.cs create mode 100644 TestBenchFramework/Mappings/VirtualBenchSequenceMap.cs create mode 100644 TestBenchFramework/Mappings/VirtualBenchStepMap.cs create mode 100644 TestBenchFramework/UiControls/VirtualBenchStepsCtrl.cs diff --git a/Doc/Virtual-bench-components.ods b/Doc/Virtual-bench-components.ods new file mode 100644 index 0000000000000000000000000000000000000000..070bf79fa930341aba9a06eeb76010dfacc0876e GIT binary patch literal 11646 zcmd^lbzD?i7w7;ANJt~nB8bE= z0i5idpm1*&sD+D*qaDNoZU=J)c{p2fz%1PD+&N$_P-iO`1mOgAhI6>PxIrzf+-;#y zxW-?2J{a5*;KKj_F0b!Ap>PWhFDFM4anujJ2h`0S#Z{Dni-VJa9_kE%S=l+;h%)GC z%K-%##Kmw#VAj@l5U9`(K|qv77W61mXLq4LxL&Cn zw$OJ$f3$cx+BrLjGT6f5E7@}Cl3eA%?89JC@2W}-plZ(C@aW+@LUjXj^DAY zARwqC^m6p>ATACr&=1^84gXiAE^&W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D)BjVcUvu97m5;=4`23m!|2v<{EchpQ(f?DQzvjgM z&gn9x{0SBG|K#*DNB&>Ato??|&z$)WE 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); + } + } + } +}