From 4cdf471c689babf5e86b4bd50ecfe0d6a84def9c Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Thu, 21 May 2015 12:44:48 +0200 Subject: [PATCH] CycleEndForm in DataEntry.Standard24 can be disabled. --- .../DataEntry/Standard24/EntryForm.cs | 45 +++++++++++-------- .../DataEntry/Standard24/EntryFormCfg.cs | 4 +- .../DataEntry/Standard24/EntryFormCfgCtrl.cs | 10 +++++ .../Standard24/EntryFormCfgCtrl.designer.cs | 20 +++++++-- .../Resources/Strings.Designer.cs | 9 ++++ TestBenchFramework/Resources/Strings.resx | 3 ++ 6 files changed, 68 insertions(+), 23 deletions(-) diff --git a/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryForm.cs b/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryForm.cs index e0f178dc0..5cef70c1a 100644 --- a/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryForm.cs +++ b/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryForm.cs @@ -150,7 +150,10 @@ namespace TBF.BenchControl.DataEntry.Standard24 Program.MainWnd.Invoke(new EntryFormDlgt(OpenBeginningDlg), this); break; case CurrentOp.ShowFormAtCycleEnd: - Program.MainWnd.Invoke(new EntryFormDlgt(OpenEndDlg), this); + if (entryFormCfg.ShowCycleEndForm) + { + Program.MainWnd.Invoke(new EntryFormDlgt(OpenEndDlg), this); + } break; case CurrentOp.EnterTestStartStates: Program.MainWnd.Invoke(new EntryFormDlgt(OpenTestStartStatesDlg), this); @@ -172,22 +175,25 @@ namespace TBF.BenchControl.DataEntry.Standard24 if (!resultSaved) /// This is to save the result only once { - if (modelessDlg is CycleBeginningForm) + if (currentOp == CurrentOp.ShowFormAtCycleBeginning) { CycleBeginningForm dlg = (modelessDlg as CycleBeginningForm); - purchaseOrder = dlg.PurchaseOrder; - - for (int i = 0; i < Math.Min(dlg.WaterMetersCount, waterMeters.Count); i++) + if (dlg != null) { - if (waterMeters[i] != null) + purchaseOrder = dlg.PurchaseOrder; + + for (int i = 0; i < Math.Min(dlg.WaterMetersCount, waterMeters.Count); i++) { - serialNr[i] = waterMeters[i].SerialNr = dlg.SNText[i]; - disabled[i] = waterMeters[i].Disabled = dlg.Disabled[i]; + if (waterMeters[i] != null) + { + serialNr[i] = waterMeters[i].SerialNr = dlg.SNText[i]; + disabled[i] = waterMeters[i].Disabled = dlg.Disabled[i]; + } } } } - else if (modelessDlg is CycleEndForm) + else if (currentOp == CurrentOp.ShowFormAtCycleEnd) { CycleEndForm dlg = (modelessDlg as CycleEndForm); @@ -195,7 +201,8 @@ namespace TBF.BenchControl.DataEntry.Standard24 { if (waterMeters[i] != null) { - wmCycleEndState[i] = waterMeters[i].EndState = dlg.EndStateText[i]; + /// In case entryFormCfg.ShowCycleEndForm == false dlg would be null, values would be string.Empty + wmCycleEndState[i] = waterMeters[i].EndState = (dlg != null) ? dlg.EndStateText[i] : string.Empty; } } } @@ -210,16 +217,16 @@ namespace TBF.BenchControl.DataEntry.Standard24 wmStartStateStr[i] = dlg.WMStartStateStr[i]; } } - else if (modelessDlg is TestStartEndForm && currentOp == CurrentOp.EnterTestEndStates) - { - /// Fixed start test - end - TestStartEndForm dlg = (modelessDlg as TestStartEndForm); + else if (modelessDlg is TestStartEndForm && currentOp == CurrentOp.EnterTestEndStates) + { + /// Fixed start test - end + TestStartEndForm dlg = (modelessDlg as TestStartEndForm); - for (int i = 0; i < dlg.WaterMetersCount; i++) - { - wmEndState[i] = dlg.WMEndState[i]; - } - } + for (int i = 0; i < dlg.WaterMetersCount; i++) + { + wmEndState[i] = dlg.WMEndState[i]; + } + } resultSaved = true; modelessDlg = null; } diff --git a/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryFormCfg.cs b/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryFormCfg.cs index 9610b5f8a..a7f5a9b92 100644 --- a/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryFormCfg.cs +++ b/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryFormCfg.cs @@ -17,12 +17,14 @@ namespace TBF.BenchControl.DataEntry.Standard24 /// /// Serialized parameters /// + public bool ShowCycleEndForm; /// Private parameterless constructor invoked by all other (public) constructors EntryFormCfg() { Name = "DataEntry-Standard-24"; ParentName = string.Empty; + ShowCycleEndForm = false; } public EntryFormCfg(IComponentFactory factory) @@ -33,7 +35,7 @@ namespace TBF.BenchControl.DataEntry.Standard24 public string ToString(int i) { - return string.Format("Name={0}", Name); + return string.Format("Name={0}, ShowEndForm={1}", Name, ShowCycleEndForm); } } } diff --git a/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryFormCfgCtrl.cs b/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryFormCfgCtrl.cs index 2b7798f01..2fd8925eb 100644 --- a/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryFormCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryFormCfgCtrl.cs @@ -5,6 +5,7 @@ using System; using System.Windows.Forms; using log4net; using TBF.BenchControl.Generic; +using TBF.Resources; namespace TBF.BenchControl.DataEntry.Standard24 { @@ -32,9 +33,15 @@ namespace TBF.BenchControl.DataEntry.Standard24 private void EntryFormCfgCtrl_Load(object sender, EventArgs e) { + Localize(); Redraw(); } + void Localize() + { + showCycleEndFormCheckBox.Text = Strings.Show_cycle_end_form; + } + public void Closing() { } @@ -44,11 +51,13 @@ namespace TBF.BenchControl.DataEntry.Standard24 if (config == null) return; /// Control was not loaded, settings were not changed classNameLabel.Text = config.Factory.ClassName; nameTextBox.Text = config.Name; + showCycleEndFormCheckBox.Checked = config.ShowCycleEndForm; } public void Unlock() { nameTextBox.Enabled = true; + showCycleEndFormCheckBox.Enabled = true; } public CfgUpdateFlags VerifyCfg(ref string message) @@ -64,6 +73,7 @@ namespace TBF.BenchControl.DataEntry.Standard24 if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed config.Name = nameTextBox.Text; + config.ShowCycleEndForm = showCycleEndFormCheckBox.Checked; return flags; } diff --git a/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryFormCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryFormCfgCtrl.designer.cs index 8494416f3..2ae781c22 100644 --- a/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryFormCfgCtrl.designer.cs +++ b/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryFormCfgCtrl.designer.cs @@ -34,12 +34,13 @@ namespace TBF.BenchControl.DataEntry.Standard24 this.nameTextBox = new System.Windows.Forms.TextBox(); this.nameLabel = new System.Windows.Forms.Label(); this.classNameLabel = new System.Windows.Forms.Label(); + this.showCycleEndFormCheckBox = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // nameTextBox // this.nameTextBox.Enabled = false; - this.nameTextBox.Location = new System.Drawing.Point(137, 57); + this.nameTextBox.Location = new System.Drawing.Point(131, 57); this.nameTextBox.Name = "nameTextBox"; this.nameTextBox.Size = new System.Drawing.Size(130, 20); this.nameTextBox.TabIndex = 5; @@ -47,7 +48,7 @@ namespace TBF.BenchControl.DataEntry.Standard24 // nameLabel // this.nameLabel.AutoSize = true; - this.nameLabel.Location = new System.Drawing.Point(27, 60); + this.nameLabel.Location = new System.Drawing.Point(32, 60); this.nameLabel.Name = "nameLabel"; this.nameLabel.Size = new System.Drawing.Size(35, 13); this.nameLabel.TabIndex = 4; @@ -56,16 +57,28 @@ namespace TBF.BenchControl.DataEntry.Standard24 // classNameLabel // this.classNameLabel.AutoSize = true; - this.classNameLabel.Location = new System.Drawing.Point(134, 33); + this.classNameLabel.Location = new System.Drawing.Point(128, 32); this.classNameLabel.Name = "classNameLabel"; this.classNameLabel.Size = new System.Drawing.Size(83, 13); this.classNameLabel.TabIndex = 3; this.classNameLabel.Text = "ComonentName"; // + // showCycleEndFormCheckBox + // + this.showCycleEndFormCheckBox.AutoSize = true; + this.showCycleEndFormCheckBox.Enabled = false; + this.showCycleEndFormCheckBox.Location = new System.Drawing.Point(131, 90); + this.showCycleEndFormCheckBox.Name = "showCycleEndFormCheckBox"; + this.showCycleEndFormCheckBox.Size = new System.Drawing.Size(125, 17); + this.showCycleEndFormCheckBox.TabIndex = 13; + this.showCycleEndFormCheckBox.Text = "Show cycle end form"; + this.showCycleEndFormCheckBox.UseVisualStyleBackColor = true; + // // EntryFormCfgCtrl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.showCycleEndFormCheckBox); this.Controls.Add(this.nameTextBox); this.Controls.Add(this.nameLabel); this.Controls.Add(this.classNameLabel); @@ -82,5 +95,6 @@ namespace TBF.BenchControl.DataEntry.Standard24 private System.Windows.Forms.TextBox nameTextBox; private System.Windows.Forms.Label nameLabel; private System.Windows.Forms.Label classNameLabel; + private System.Windows.Forms.CheckBox showCycleEndFormCheckBox; } } diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index 3cb098e49..da3850879 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -2112,6 +2112,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Show cycle end form. + /// + internal static string Show_cycle_end_form { + get { + return ResourceManager.GetString("Show_cycle_end_form", resourceCulture); + } + } + /// /// Looks up a localized string similar to Single. /// diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index 44ea04b8c..dfd0c707d 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -1045,4 +1045,7 @@ Nr. meters in a group: + + Show cycle end form + \ No newline at end of file