From 1f590a71f526a50ddcd517af6a6b5b9f877cffbc Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Sat, 7 Feb 2015 21:42:32 +0100 Subject: [PATCH] Correct handling of up/down selection moves in TransitionStepsCtrl and VirtualBenchSteps Exception not used during updates (when duration is invalid) Minor resource change --- .../Resources/Strings.Designer.cs | 13 +++++-- TestBenchFramework/Resources/Strings.resx | 2 +- TestBenchFramework/TBF.csproj | 1 + TestBenchFramework/TransitionsDlg.cs | 5 ++- .../UiControls/BaseWithListViewEx.cs | 17 +++------ .../UiControls/TransitionStepsCtrl.cs | 35 +++++++++++++------ .../UiControls/VirtualBenchStepsCtrl.cs | 16 ++++----- 7 files changed, 54 insertions(+), 35 deletions(-) diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index cf8cc5017..cd1e10043 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.1026 +// Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -1348,7 +1348,7 @@ namespace TBF.Resources { } /// - /// Looks up a localized string similar to Please select a cycle, a_test or empty. + /// Looks up a localized string similar to Please select a cycle, a test or empty. /// internal static string Please_select_a_cycle_a_test_or_empty { get { @@ -2220,6 +2220,9 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap testFailedImage { get { object obj = ResourceManager.GetObject("testFailedImage", resourceCulture); @@ -2236,6 +2239,9 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap testNotDoneImage { get { object obj = ResourceManager.GetObject("testNotDoneImage", resourceCulture); @@ -2243,6 +2249,9 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap testPassedImage { get { object obj = ResourceManager.GetObject("testPassedImage", resourceCulture); diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index bdd9c5603..401814018 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -662,7 +662,7 @@ - Please select a cycle, a_test or empty + Please select a cycle, a test or empty Approval info. diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index eb2232825..3f312d707 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -1250,6 +1250,7 @@ ResXFileCodeGenerator Strings.Designer.cs + Designer ProcessTabPageCtrl.cs diff --git a/TestBenchFramework/TransitionsDlg.cs b/TestBenchFramework/TransitionsDlg.cs index 09d72241a..5d17392a2 100644 --- a/TestBenchFramework/TransitionsDlg.cs +++ b/TestBenchFramework/TransitionsDlg.cs @@ -149,6 +149,8 @@ namespace TBF nwTab.Controls.Add(newCtrl); this.tabControl.TabPages.Add(nwTab); newCtrl.Initialize(sequence, this, this.tabControl.TabPages[this.tabControl.TabPages.Count - 1]); + newCtrl.SelectedIndexChanged += new System.EventHandler(this.SelectedIndexChanged); + } void AddVirtualBenchSeqTab(VirtualBenchSequence sequence) @@ -159,7 +161,8 @@ namespace TBF nwTab.Controls.Add(newCtrl); this.tabControl.TabPages.Add(nwTab); newCtrl.Initialize(sequence, this, this.tabControl.TabPages[this.tabControl.TabPages.Count - 1]); - } + newCtrl.SelectedIndexChanged += new System.EventHandler(this.SelectedIndexChanged); + } void RefreshAllTabs() { diff --git a/TestBenchFramework/UiControls/BaseWithListViewEx.cs b/TestBenchFramework/UiControls/BaseWithListViewEx.cs index b3692a14b..64fda7315 100644 --- a/TestBenchFramework/UiControls/BaseWithListViewEx.cs +++ b/TestBenchFramework/UiControls/BaseWithListViewEx.cs @@ -66,10 +66,7 @@ namespace TBF.UiControls protected void RedrawAll() { Items.Clear(); - foreach (var myItem in MyItems) - { - DrawOne(myItem); - } + foreach (var myItem in MyItems) DrawOne(myItem); } public virtual void DrawOne(object myItem) @@ -152,10 +149,8 @@ namespace TBF.UiControls public void MoveUpSelected() { - if (SelectedItems.Count != 1) - { - return; - } + if (SelectedItems.Count != 1) return; + int ix = base.SelectedIndices[0]; if (ix <= FixedRowsCount || ix >= MyItems.Count) return; @@ -177,10 +172,8 @@ namespace TBF.UiControls public void MoveDownSelected() { - if (base.SelectedItems.Count != 1) - { - return; - } + if (base.SelectedItems.Count != 1) return; + int ix = base.SelectedIndices[0]; if (ix < FixedRowsCount || ix >= MyItems.Count - 1) return; diff --git a/TestBenchFramework/UiControls/TransitionStepsCtrl.cs b/TestBenchFramework/UiControls/TransitionStepsCtrl.cs index b21ce7389..a91ace150 100644 --- a/TestBenchFramework/UiControls/TransitionStepsCtrl.cs +++ b/TestBenchFramework/UiControls/TransitionStepsCtrl.cs @@ -91,20 +91,32 @@ namespace TBF.UiControls editors[1] = new TextBox(); parent.Controls.Add(editors[1]); + /// FM controlled pumps 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; + cb.Items.Add("0"); + cb.Items.Add("30"); + cb.Items.Add("40"); + cb.Items.Add("50"); + cb.Items.Add("60"); + cb.Items.Add("70"); + cb.Items.Add("75"); + cb.Items.Add("80"); + cb.Items.Add("85"); + cb.Items.Add("90"); + cb.Items.Add("92"); + cb.Items.Add("94"); + cb.Items.Add("96"); + cb.Items.Add("98"); + cb.Items.Add("100"); + editors[i] = cb; parent.Controls.Add(editors[i]); } + /// Regulation valves for (int i = fixedCount + fmPumpCount; i < fixedCount + fmPumpCount + regvCount; i++) { ComboBox cb = new ComboBox(); @@ -114,10 +126,11 @@ namespace TBF.UiControls cb.Items.Add("50"); cb.Items.Add("75"); cb.Items.Add("100"); - editors[i] = cb; + editors[i] = cb; parent.Controls.Add(editors[i]); } + /// Valves for (int i = fixedCount + fmPumpCount + regvCount; i < fixedCount + fmPumpCount + regvCount + vCount; i++) { ComboBox cb = new ComboBox(); @@ -252,12 +265,12 @@ namespace TBF.UiControls Entities.TransitionStep step = (Entities.TransitionStep)myItem; /// Duration - try + int duration; + if (int.TryParse(lvi.Text, out duration) && duration > 0) { - step.Duration = int.Parse(lvi.Text); - if (step.Duration < 2) throw (new System.Exception()); + step.Duration = duration; } - catch + else { lvi.Text = step.Duration.ToString(); } diff --git a/TestBenchFramework/UiControls/VirtualBenchStepsCtrl.cs b/TestBenchFramework/UiControls/VirtualBenchStepsCtrl.cs index f7c2e57fc..597eff7a1 100644 --- a/TestBenchFramework/UiControls/VirtualBenchStepsCtrl.cs +++ b/TestBenchFramework/UiControls/VirtualBenchStepsCtrl.cs @@ -189,16 +189,16 @@ namespace TBF.UiControls { Entities.VirtualBenchStep step = (Entities.VirtualBenchStep)myItem; - /// Duration - try + /// Duration + int duration; + if (int.TryParse(lvi.Text, out duration) && duration > 0) { - step.Duration = int.Parse(lvi.Text); - if (step.Duration < 2) throw (new System.Exception()); + step.Duration = duration; + } + else + { + lvi.Text = step.Duration.ToString(); } - catch - { - lvi.Text = step.Duration.ToString(); - } // TODO: Replace the following: //step.PumpWithFMPcts = fmPumpsPcts;