From 4ad79d54b05085b0ba734e0a7024e22752d23a2c Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Tue, 13 Jan 2015 05:00:59 +0100 Subject: [PATCH] Configuration of results: UI also for printer. Formatting float with given # of valid digits --- TestBenchFramework/Forms/ResultItemSpec.cs | 17 +++- .../Forms/ResultsConfig.Designer.cs | 91 ++++++++++++++++--- TestBenchFramework/Forms/ResultsConfig.cs | 73 +++++++++++---- TestBenchFramework/LocalSettings.cs | 26 ++++-- .../Resources/Strings.Designer.cs | 45 +++++++++ TestBenchFramework/Resources/Strings.resx | 15 +++ .../Screens/ResultsTabPageCtrl.cs | 41 ++++++--- TestBenchFramework/Utils.cs | 38 ++++++++ 8 files changed, 284 insertions(+), 62 deletions(-) diff --git a/TestBenchFramework/Forms/ResultItemSpec.cs b/TestBenchFramework/Forms/ResultItemSpec.cs index 82f459747..b629c3b5a 100644 --- a/TestBenchFramework/Forms/ResultItemSpec.cs +++ b/TestBenchFramework/Forms/ResultItemSpec.cs @@ -60,8 +60,8 @@ namespace TBF.Forms AllItems.Add(new ResultItemSpec("Test time", "T [s]", x => x.TestResult.TimeEnd.ToShortTimeString(), (x, y, z) => z.TestResult.TimeEnd.ToShortTimeString())); - AllItems.Add(new ResultItemSpec("Flow", Strings.Flow_m3h, x => x.TestResult.FlowVolume.ToString("F3"), - (x, y, z) => z.TestResult.FlowVolume.ToString("F3"))); + AllItems.Add(new ResultItemSpec("Flow", Strings.Flow_m3h, x => Utils.FloatToStr(x.TestResult.FlowVolume / 1000.0f, 4), + (x, y, z) => Utils.FloatToStr(z.TestResult.FlowVolume / 1000.0f, 4))); AllItems.Add(new ResultItemSpec("T in", Strings.T_in, x => x.TestResult.TempInAvrg.ToString("F2"), (x, y, z) => z.TestResult.TempInAvrg.ToString("F2"))); @@ -91,11 +91,20 @@ namespace TBF.Forms AllItems.Add(new ResultItemSpec("Passed", "Result", x => (x.Passed ? Strings.Passed : Strings.Failed), (x, y, z) => (z.Passed ? Strings.Passed : Strings.Failed))); + AllItems.Add(new ResultItemSpec("Serial Nr", "s/n", x => x.SerialNr, (x, y, z) => z.SerialNr)); + AllItems.Add(new ResultItemSpec("End state", "End state", x => x.EndState, (x, y, z) => z.EndState)); + /// Single water meters only results AllItems.Add(new ResultItemSpec("Pulses", "Pulses", x => x.PulsesMeter.ToString(), null)); AllItems.Add(new ResultItemSpec("Reference pulses", "Ref.pulses", x => x.PulsesMaster.ToString(), null)); - AllItems.Add(new ResultItemSpec("Serial Nr", "s/n", x => x.PulsesMeter.ToString(), null)); - AllItems.Add(new ResultItemSpec("End state", "End state", x => x.PulsesMeter.ToString(), null)); + + /// Combined water meters only results + AllItems.Add(new ResultItemSpec("Error large WM", "Error-L [%]", null, (x, y, z) => x.VolumeErrorPct.ToString("F2"))); + AllItems.Add(new ResultItemSpec("Error small WM", "Error-S [%]", null, (x, y, z) => y.VolumeErrorPct.ToString("F2"))); + AllItems.Add(new ResultItemSpec("Serial Nr large WM", "s/n", null, (x, y, z) => x.SerialNr)); + AllItems.Add(new ResultItemSpec("Serial Nr small WM", "s/n", null, (x, y, z) => y.SerialNr)); + AllItems.Add(new ResultItemSpec("End state large WM", "End state", null, (x, y, z) => x.EndState)); + AllItems.Add(new ResultItemSpec("End state small WM", "End state", null, (x, y, z) => y.EndState)); } public static ResultItemSpec GetItem(string name) diff --git a/TestBenchFramework/Forms/ResultsConfig.Designer.cs b/TestBenchFramework/Forms/ResultsConfig.Designer.cs index 6277810ea..ecdfd87b6 100644 --- a/TestBenchFramework/Forms/ResultsConfig.Designer.cs +++ b/TestBenchFramework/Forms/ResultsConfig.Designer.cs @@ -46,8 +46,14 @@ this.unlockButton = new System.Windows.Forms.Button(); this.singleRadioButton = new System.Windows.Forms.RadioButton(); this.combinedRadioButton = new System.Windows.Forms.RadioButton(); + this.screenRadioButton = new System.Windows.Forms.RadioButton(); + this.printerRadioButton = new System.Windows.Forms.RadioButton(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); this.testsArangementGroupBox.SuspendLayout(); this.metersArangementGroupBox.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // testsRowsRadioButton @@ -145,9 +151,9 @@ // this.availableResultsListBox.Enabled = false; this.availableResultsListBox.FormattingEnabled = true; - this.availableResultsListBox.Location = new System.Drawing.Point(12, 246); + this.availableResultsListBox.Location = new System.Drawing.Point(12, 272); this.availableResultsListBox.Name = "availableResultsListBox"; - this.availableResultsListBox.Size = new System.Drawing.Size(135, 160); + this.availableResultsListBox.Size = new System.Drawing.Size(135, 186); this.availableResultsListBox.TabIndex = 6; this.availableResultsListBox.DoubleClick += new System.EventHandler(this.availableResultsListBox_DoubleClick); // @@ -155,16 +161,16 @@ // this.selectedResultsListBox.Enabled = false; this.selectedResultsListBox.FormattingEnabled = true; - this.selectedResultsListBox.Location = new System.Drawing.Point(252, 246); + this.selectedResultsListBox.Location = new System.Drawing.Point(252, 272); this.selectedResultsListBox.Name = "selectedResultsListBox"; - this.selectedResultsListBox.Size = new System.Drawing.Size(135, 160); + this.selectedResultsListBox.Size = new System.Drawing.Size(135, 186); this.selectedResultsListBox.TabIndex = 7; this.selectedResultsListBox.DoubleClick += new System.EventHandler(this.selectedResultsListBox_DoubleClick); // // availableResultsLabel // this.availableResultsLabel.AutoSize = true; - this.availableResultsLabel.Location = new System.Drawing.Point(12, 224); + this.availableResultsLabel.Location = new System.Drawing.Point(12, 250); this.availableResultsLabel.Name = "availableResultsLabel"; this.availableResultsLabel.Size = new System.Drawing.Size(86, 13); this.availableResultsLabel.TabIndex = 8; @@ -173,7 +179,7 @@ // selectedResultsLabel // this.selectedResultsLabel.AutoSize = true; - this.selectedResultsLabel.Location = new System.Drawing.Point(249, 224); + this.selectedResultsLabel.Location = new System.Drawing.Point(249, 250); this.selectedResultsLabel.Name = "selectedResultsLabel"; this.selectedResultsLabel.Size = new System.Drawing.Size(85, 13); this.selectedResultsLabel.TabIndex = 9; @@ -183,7 +189,7 @@ // this.removeAllButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.removeAllButton.Enabled = false; - this.removeAllButton.Location = new System.Drawing.Point(153, 346); + this.removeAllButton.Location = new System.Drawing.Point(153, 385); this.removeAllButton.Name = "removeAllButton"; this.removeAllButton.Size = new System.Drawing.Size(94, 30); this.removeAllButton.TabIndex = 46; @@ -195,7 +201,7 @@ // this.removeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.removeButton.Enabled = false; - this.removeButton.Location = new System.Drawing.Point(153, 311); + this.removeButton.Location = new System.Drawing.Point(153, 350); this.removeButton.Name = "removeButton"; this.removeButton.Size = new System.Drawing.Size(93, 30); this.removeButton.TabIndex = 45; @@ -207,7 +213,7 @@ // this.addButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.addButton.Enabled = false; - this.addButton.Location = new System.Drawing.Point(153, 276); + this.addButton.Location = new System.Drawing.Point(153, 315); this.addButton.Name = "addButton"; this.addButton.Size = new System.Drawing.Size(93, 30); this.addButton.TabIndex = 44; @@ -230,7 +236,7 @@ this.singleRadioButton.Appearance = System.Windows.Forms.Appearance.Button; this.singleRadioButton.AutoSize = true; this.singleRadioButton.Checked = true; - this.singleRadioButton.Location = new System.Drawing.Point(11, 183); + this.singleRadioButton.Location = new System.Drawing.Point(19, 24); this.singleRadioButton.Name = "singleRadioButton"; this.singleRadioButton.Size = new System.Drawing.Size(46, 23); this.singleRadioButton.TabIndex = 48; @@ -243,24 +249,71 @@ // this.combinedRadioButton.Appearance = System.Windows.Forms.Appearance.Button; this.combinedRadioButton.AutoSize = true; - this.combinedRadioButton.Location = new System.Drawing.Point(63, 183); + this.combinedRadioButton.Location = new System.Drawing.Point(71, 24); this.combinedRadioButton.Name = "combinedRadioButton"; this.combinedRadioButton.Size = new System.Drawing.Size(64, 23); this.combinedRadioButton.TabIndex = 49; - this.combinedRadioButton.TabStop = true; this.combinedRadioButton.Text = "Combined"; this.combinedRadioButton.UseVisualStyleBackColor = true; this.combinedRadioButton.CheckedChanged += new System.EventHandler(this.combinedRadioButton_CheckedChanged); // + // screenRadioButton + // + this.screenRadioButton.Appearance = System.Windows.Forms.Appearance.Button; + this.screenRadioButton.AutoSize = true; + this.screenRadioButton.Checked = true; + this.screenRadioButton.Location = new System.Drawing.Point(29, 24); + this.screenRadioButton.Name = "screenRadioButton"; + this.screenRadioButton.Size = new System.Drawing.Size(51, 23); + this.screenRadioButton.TabIndex = 50; + this.screenRadioButton.TabStop = true; + this.screenRadioButton.Text = "Screen"; + this.screenRadioButton.UseVisualStyleBackColor = true; + this.screenRadioButton.CheckedChanged += new System.EventHandler(this.screenRadioButton_CheckedChanged); + // + // printerRadioButton + // + this.printerRadioButton.Appearance = System.Windows.Forms.Appearance.Button; + this.printerRadioButton.AutoSize = true; + this.printerRadioButton.Location = new System.Drawing.Point(86, 24); + this.printerRadioButton.Name = "printerRadioButton"; + this.printerRadioButton.Size = new System.Drawing.Size(47, 23); + this.printerRadioButton.TabIndex = 51; + this.printerRadioButton.Text = "Printer"; + this.printerRadioButton.UseVisualStyleBackColor = true; + this.printerRadioButton.CheckedChanged += new System.EventHandler(this.printerRadioButton_CheckedChanged); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.combinedRadioButton); + this.groupBox1.Controls.Add(this.singleRadioButton); + this.groupBox1.Location = new System.Drawing.Point(17, 176); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(153, 60); + this.groupBox1.TabIndex = 52; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Water Meter"; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.printerRadioButton); + this.groupBox2.Controls.Add(this.screenRadioButton); + this.groupBox2.Location = new System.Drawing.Point(220, 176); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(166, 60); + this.groupBox2.TabIndex = 0; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Device"; + // // ResultsConfig // this.AcceptButton = this.okButton; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(399, 419); - this.Controls.Add(this.combinedRadioButton); - this.Controls.Add(this.singleRadioButton); + this.ClientSize = new System.Drawing.Size(399, 468); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); this.Controls.Add(this.unlockButton); this.Controls.Add(this.removeAllButton); this.Controls.Add(this.removeButton); @@ -281,6 +334,10 @@ this.testsArangementGroupBox.PerformLayout(); this.metersArangementGroupBox.ResumeLayout(false); this.metersArangementGroupBox.PerformLayout(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -306,5 +363,9 @@ private System.Windows.Forms.Button unlockButton; private System.Windows.Forms.RadioButton singleRadioButton; private System.Windows.Forms.RadioButton combinedRadioButton; + private System.Windows.Forms.RadioButton screenRadioButton; + private System.Windows.Forms.RadioButton printerRadioButton; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.GroupBox groupBox2; } } \ No newline at end of file diff --git a/TestBenchFramework/Forms/ResultsConfig.cs b/TestBenchFramework/Forms/ResultsConfig.cs index 50cd45fa8..e79ab603b 100644 --- a/TestBenchFramework/Forms/ResultsConfig.cs +++ b/TestBenchFramework/Forms/ResultsConfig.cs @@ -34,10 +34,13 @@ namespace TBF.Forms public Meters MetersArrangement; public IList currentlyAvailableItems; - public IList SelectedItems_SingleWM; - public IList SelectedItems_CombinedWM; + public IList RsltItems_Screen_SingleWM; + public IList RsltItems_Screen_CombinedWM; + public IList RsltItems_Printer_SingleWM; + public IList RsltItems_Printer_CombinedWM; - bool combined; /// true = processing combined items + bool combined; /// false = single meter items, true = combined meter items + bool printer; /// false = screen items, true = printer items bool unlocked; /// true = changes enabled public ResultsConfig() @@ -45,6 +48,7 @@ namespace TBF.Forms InitializeComponent(); combined = false; + printer = false; unlocked = false; cancelButton.Visible = false; } @@ -58,6 +62,12 @@ namespace TBF.Forms testsColumnsRadioButton.Text = Strings.Tests_are_columns; horizontallyRadioButton.Text = Strings.Horizontally; verticallyRadioButton.Text = Strings.Vertically; + groupBox1.Text = Strings.Water_Meter; + singleRadioButton.Text = Strings.SingleBtnText; + combinedRadioButton.Text = Strings.CombinedBtnText; + groupBox2.Text = Strings.Device; + screenRadioButton.Text = Strings.ScreenBtnText; + printerRadioButton.Text = Strings.PrinterBtnText; availableResultsLabel.Text = Strings.Available_results; selectedResultsLabel.Text = Strings.Selected_results; addButton.Text = Strings.Add; @@ -87,7 +97,9 @@ namespace TBF.Forms /// void RedrawAvailable() { - IList selectedItems = combined ? SelectedItems_CombinedWM : SelectedItems_SingleWM; + IList selectedItems; + if (printer) selectedItems = combined ? RsltItems_Printer_CombinedWM : RsltItems_Printer_SingleWM; + else selectedItems = combined ? RsltItems_Screen_CombinedWM : RsltItems_Screen_SingleWM; availableResultsListBox.Items.Clear(); currentlyAvailableItems = new List(); @@ -96,8 +108,7 @@ namespace TBF.Forms if (!selectedItems.Contains(item) && (combined ? (item.PrintCombined != null) : (item.Print != null))) { currentlyAvailableItems.Add(item); - string displayName = item.Name.Substring(0, 1).Equals("_") ? item.Name.Substring(1) : item.Name; - availableResultsListBox.Items.Add(displayName); + availableResultsListBox.Items.Add(item.Name); } } } @@ -107,13 +118,14 @@ namespace TBF.Forms /// void RedrawSelected() { - IList selectedItems = combined ? SelectedItems_CombinedWM : SelectedItems_SingleWM; + IList selectedItems; + if (printer) selectedItems = combined ? RsltItems_Printer_CombinedWM : RsltItems_Printer_SingleWM; + else selectedItems = combined ? RsltItems_Screen_CombinedWM : RsltItems_Screen_SingleWM; selectedResultsListBox.Items.Clear(); foreach (var item in selectedItems) { - string displayName = item.Name.Substring(0, 1).Equals("_") ? item.Name.Substring(1) : item.Name; - selectedResultsListBox.Items.Add(displayName); + selectedResultsListBox.Items.Add(item.Name); } } @@ -171,11 +183,13 @@ namespace TBF.Forms var item = currentlyAvailableItems[availableResultsListBox.SelectedIndices[0]]; if (combined) { - SelectedItems_CombinedWM.Add(item); + if (printer) RsltItems_Printer_CombinedWM.Add(item); + else RsltItems_Screen_CombinedWM.Add(item); } else { - SelectedItems_SingleWM.Add(item); + if (printer) RsltItems_Printer_SingleWM.Add(item); + else RsltItems_Screen_SingleWM.Add(item); } RedrawAvailable(); RedrawSelected(); @@ -192,11 +206,13 @@ namespace TBF.Forms var item = currentlyAvailableItems[availableResultsListBox.SelectedIndices[i]]; if (combined) { - SelectedItems_CombinedWM.Add(item); + if (printer) RsltItems_Printer_CombinedWM.Add(item); + else RsltItems_Screen_CombinedWM.Add(item); } else { - SelectedItems_SingleWM.Add(item); + if (printer) RsltItems_Printer_SingleWM.Add(item); + else RsltItems_Screen_SingleWM.Add(item); } } RedrawAvailable(); @@ -211,11 +227,13 @@ namespace TBF.Forms { if (combined) { - SelectedItems_CombinedWM.RemoveAt(selectedResultsListBox.SelectedIndices[0]); + if (printer) RsltItems_Printer_CombinedWM.RemoveAt(selectedResultsListBox.SelectedIndices[0]); + else RsltItems_Screen_CombinedWM.RemoveAt(selectedResultsListBox.SelectedIndices[0]); } else { - SelectedItems_SingleWM.RemoveAt(selectedResultsListBox.SelectedIndices[0]); + if (printer) RsltItems_Printer_SingleWM.RemoveAt(selectedResultsListBox.SelectedIndices[0]); + else RsltItems_Screen_SingleWM.RemoveAt(selectedResultsListBox.SelectedIndices[0]); } RedrawAvailable(); RedrawSelected(); @@ -228,14 +246,16 @@ namespace TBF.Forms for (int i = selectedResultsListBox.SelectedIndices.Count - 1; i >= 0; i--) { - ResultItemSpec item = SelectedItems_SingleWM[selectedResultsListBox.SelectedIndices[i]]; + ResultItemSpec item = RsltItems_Screen_SingleWM[selectedResultsListBox.SelectedIndices[i]]; if (combined) { - SelectedItems_CombinedWM.Remove(item); + if (printer) RsltItems_Printer_CombinedWM.Remove(item); + else RsltItems_Screen_CombinedWM.Remove(item); } else { - SelectedItems_SingleWM.Remove(item); + if (printer) RsltItems_Printer_SingleWM.Remove(item); + else RsltItems_Screen_SingleWM.Remove(item); } } RedrawAvailable(); @@ -248,11 +268,13 @@ namespace TBF.Forms if (combined) { - SelectedItems_CombinedWM.Clear(); + if (printer) RsltItems_Printer_CombinedWM.Clear(); + else RsltItems_Screen_CombinedWM.Clear(); } else { - SelectedItems_SingleWM.Clear(); + if (printer) RsltItems_Printer_SingleWM.Clear(); + else RsltItems_Screen_SingleWM.Clear(); } RedrawAvailable(); RedrawSelected(); @@ -268,5 +290,16 @@ namespace TBF.Forms RedrawAvailable(); RedrawSelected(); } + + private void screenRadioButton_CheckedChanged(object sender, EventArgs e) + { + } + + private void printerRadioButton_CheckedChanged(object sender, EventArgs e) + { + printer = printerRadioButton.Checked; + RedrawAvailable(); + RedrawSelected(); + } } } diff --git a/TestBenchFramework/LocalSettings.cs b/TestBenchFramework/LocalSettings.cs index bb9f831ef..b8761102d 100644 --- a/TestBenchFramework/LocalSettings.cs +++ b/TestBenchFramework/LocalSettings.cs @@ -130,8 +130,10 @@ namespace TBF /// Configuration of results public Forms.ResultsConfig.Meters ResultsConfigMeters; public Forms.ResultsConfig.TestsAre ResultsConfigTests; - public string[] SelectedItems_SingleWM; - public string[] SelectedItems_CombinedWM; + public string[] RsltItems_Screen_SingleWM; + public string[] RsltItems_Screen_CombinedWM; + public string[] RsltItems_Printer_SingleWM; + public string[] RsltItems_Printer_CombinedWM; /// /// Copy public fields from a LocalSettings object to this object. @@ -207,13 +209,21 @@ namespace TBF ResultsConfigMeters = ls.ResultsConfigMeters; ResultsConfigTests = ls.ResultsConfigTests; - int count = (ls.SelectedItems_SingleWM != null) ? ls.SelectedItems_SingleWM.Length : 0; - SelectedItems_SingleWM = new string[count]; - for (int i = 0; i < count; i++) SelectedItems_SingleWM[i] = ls.SelectedItems_SingleWM[i]; + int count = (ls.RsltItems_Screen_SingleWM != null) ? ls.RsltItems_Screen_SingleWM.Length : 0; + RsltItems_Screen_SingleWM = new string[count]; + for (int i = 0; i < count; i++) RsltItems_Screen_SingleWM[i] = ls.RsltItems_Screen_SingleWM[i]; - count = (ls.SelectedItems_CombinedWM != null) ? ls.SelectedItems_CombinedWM.Length : 0; - SelectedItems_CombinedWM = new string[count]; - for (int i = 0; i < count; i++) SelectedItems_CombinedWM[i] = ls.SelectedItems_CombinedWM[i]; + count = (ls.RsltItems_Screen_CombinedWM != null) ? ls.RsltItems_Screen_CombinedWM.Length : 0; + RsltItems_Screen_CombinedWM = new string[count]; + for (int i = 0; i < count; i++) RsltItems_Screen_CombinedWM[i] = ls.RsltItems_Screen_CombinedWM[i]; + + count = (ls.RsltItems_Printer_SingleWM != null) ? ls.RsltItems_Printer_SingleWM.Length : 0; + RsltItems_Printer_SingleWM = new string[count]; + for (int i = 0; i < count; i++) RsltItems_Printer_SingleWM[i] = ls.RsltItems_Printer_SingleWM[i]; + + count = (ls.RsltItems_Printer_CombinedWM != null) ? ls.RsltItems_Printer_CombinedWM.Length : 0; + RsltItems_Printer_CombinedWM = new string[count]; + for (int i = 0; i < count; i++) RsltItems_Printer_CombinedWM[i] = ls.RsltItems_Printer_CombinedWM[i]; } } diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index 418eb8dee..efe5a151d 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -294,6 +294,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Combined. + /// + internal static string CombinedBtnText { + get { + return ResourceManager.GetString("CombinedBtnText", resourceCulture); + } + } + /// /// Looks up a localized string similar to Component. /// @@ -465,6 +474,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Device. + /// + internal static string Device { + get { + return ResourceManager.GetString("Device", resourceCulture); + } + } + /// /// Looks up a localized string similar to dflt. /// @@ -1311,6 +1329,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Printer. + /// + internal static string PrinterBtnText { + get { + return ResourceManager.GetString("PrinterBtnText", resourceCulture); + } + } + /// /// Looks up a localized string similar to Procedure. /// @@ -1626,6 +1653,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Screen. + /// + internal static string ScreenBtnText { + get { + return ResourceManager.GetString("ScreenBtnText", resourceCulture); + } + } + /// /// Looks up a localized string similar to s. /// @@ -1698,6 +1734,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Single. + /// + internal static string SingleBtnText { + get { + return ResourceManager.GetString("SingleBtnText", resourceCulture); + } + } + /// /// Looks up a localized string similar to Start the pump. /// diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index 814742fc3..f59b67db9 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -886,4 +886,19 @@ Timeout + + Combined + + + Device + + + Printer + + + Screen + + + Single + \ No newline at end of file diff --git a/TestBenchFramework/Screens/ResultsTabPageCtrl.cs b/TestBenchFramework/Screens/ResultsTabPageCtrl.cs index afbd7e1b5..7dd051f88 100644 --- a/TestBenchFramework/Screens/ResultsTabPageCtrl.cs +++ b/TestBenchFramework/Screens/ResultsTabPageCtrl.cs @@ -16,8 +16,10 @@ namespace TBF.Screens public TBF.Forms.ResultsConfig.Meters MetersArrangement; public TBF.Forms.ResultsConfig.TestsAre TestsArrangement; - public IList SelectedItems_SingleWM; - public IList SelectedItems_CombinedWM; + public IList RsltItems_Screen_SingleWM; + public IList RsltItems_Screen_CombinedWM; + public IList RsltItems_Printer_SingleWM; + public IList RsltItems_Printer_CombinedWM; IList tests; IList testResults; @@ -58,8 +60,10 @@ namespace TBF.Screens MetersArrangement = Program.LocalSettings.ResultsConfigMeters; TestsArrangement = Program.LocalSettings.ResultsConfigTests; - SelectedItems_SingleWM = Forms.ResultItemSpec.FromStrArray(Program.LocalSettings.SelectedItems_SingleWM); - SelectedItems_CombinedWM = Forms.ResultItemSpec.FromStrArray(Program.LocalSettings.SelectedItems_CombinedWM); + RsltItems_Screen_SingleWM = Forms.ResultItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_SingleWM); + RsltItems_Screen_CombinedWM = Forms.ResultItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_CombinedWM); + RsltItems_Printer_SingleWM = Forms.ResultItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_SingleWM); + RsltItems_Printer_CombinedWM = Forms.ResultItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_CombinedWM); RedrawAll(); } @@ -72,18 +76,25 @@ namespace TBF.Screens TBF.Forms.ResultsConfig dlg = new TBF.Forms.ResultsConfig(); dlg.TestsArrangement = TestsArrangement; dlg.MetersArrangement = MetersArrangement; - dlg.SelectedItems_SingleWM = SelectedItems_SingleWM; - dlg.SelectedItems_CombinedWM = SelectedItems_CombinedWM; + dlg.RsltItems_Screen_SingleWM = RsltItems_Screen_SingleWM; + dlg.RsltItems_Screen_CombinedWM = RsltItems_Screen_CombinedWM; + dlg.RsltItems_Printer_SingleWM = RsltItems_Printer_SingleWM; + dlg.RsltItems_Printer_CombinedWM = RsltItems_Printer_CombinedWM; if (DialogResult.OK == dlg.ShowDialog()) { MetersArrangement = dlg.MetersArrangement; TestsArrangement = dlg.TestsArrangement; - SelectedItems_SingleWM = dlg.SelectedItems_SingleWM; + RsltItems_Screen_SingleWM = dlg.RsltItems_Screen_SingleWM; + RsltItems_Screen_CombinedWM = dlg.RsltItems_Screen_CombinedWM; + RsltItems_Printer_SingleWM = dlg.RsltItems_Printer_SingleWM; + RsltItems_Printer_CombinedWM = dlg.RsltItems_Printer_CombinedWM; Program.LocalSettings.ResultsConfigMeters = MetersArrangement; Program.LocalSettings.ResultsConfigTests = TestsArrangement; - Program.LocalSettings.SelectedItems_SingleWM = Forms.ResultItemSpec.ToStrArray(SelectedItems_SingleWM); - Program.LocalSettings.SelectedItems_CombinedWM = Forms.ResultItemSpec.ToStrArray(SelectedItems_CombinedWM); + Program.LocalSettings.RsltItems_Screen_SingleWM = Forms.ResultItemSpec.ToStrArray(RsltItems_Screen_SingleWM); + Program.LocalSettings.RsltItems_Screen_CombinedWM = Forms.ResultItemSpec.ToStrArray(RsltItems_Screen_CombinedWM); + Program.LocalSettings.RsltItems_Printer_SingleWM = Forms.ResultItemSpec.ToStrArray(RsltItems_Printer_SingleWM); + Program.LocalSettings.RsltItems_Printer_CombinedWM = Forms.ResultItemSpec.ToStrArray(RsltItems_Printer_CombinedWM); Program.LocalSettings.Save(); } RedrawAll(); @@ -220,7 +231,7 @@ namespace TBF.Screens ListView GetResultsTestsAreRows(int mtr, bool combined) { if (tests == null) return null; - IList items = (combined ? SelectedItems_CombinedWM : SelectedItems_SingleWM); + IList items = (combined ? RsltItems_Screen_CombinedWM : RsltItems_Screen_SingleWM); ListView lview = GetListView(); // Header @@ -262,7 +273,7 @@ namespace TBF.Screens ListView GetResultsTestsAreColumns(int mtr, bool combined) { if (tests == null) return null; - IList items = (combined ? SelectedItems_CombinedWM : SelectedItems_SingleWM); + IList items = (combined ? RsltItems_Screen_CombinedWM : RsltItems_Screen_SingleWM); ListView lview = GetListView(); // Header @@ -278,16 +289,16 @@ namespace TBF.Screens { foreach (var tr in trs) { - lvi.SubItems.Add((item.PrintCombined == null) ? string.Empty : item.PrintCombined(tr.Meters[2 * mtr], - tr.Meters[2 * mtr + 1], - tr.CombinedMeters[mtr])); + lvi.SubItems.Add((item.PrintCombined == null || tr == null) ? string.Empty : item.PrintCombined(tr.Meters[2 * mtr], + tr.Meters[2 * mtr + 1], + tr.CombinedMeters[mtr])); } } else { foreach (var tr in trs) { - lvi.SubItems.Add((item.Print == null) ? string.Empty : item.Print(tr.Meters[mtr])); + lvi.SubItems.Add((item.Print == null || tr == null) ? string.Empty : item.Print(tr.Meters[mtr])); } } lview.Items.Add(lvi); diff --git a/TestBenchFramework/Utils.cs b/TestBenchFramework/Utils.cs index 370518eae..99987a880 100644 --- a/TestBenchFramework/Utils.cs +++ b/TestBenchFramework/Utils.cs @@ -164,5 +164,43 @@ namespace TBF return result; } + + /// + /// Converts a float number to a string with the specified number of valid digits + /// + /// Float value to be converted to a string + /// # of valid digits: 4, 3, or 2 (otherwise full precision number is printed) + /// String representation of the float number + public static string FloatToStr(float value, int validDigits) + { + if (validDigits == 4) + { + if (value >= 1000 || value <= -1000) return value.ToString("F0"); + else if (value >= 100 || value <= -100) return value.ToString("F1"); + else if (value >= 10 || value <= -10) return value.ToString("F2"); + else if (value >= 1 || value <= -1) return value.ToString("F3"); + else if (value >= 0.1 || value <= -0.1) return value.ToString("F4"); + else if (value >= 0.01 || value <= -0.01) return value.ToString("F5"); + else return value.ToString("F6"); + } + else if (validDigits == 3) + { + if (value >= 100 || value <= -100) return value.ToString("F0"); + else if (value >= 10 || value <= -10) return value.ToString("F1"); + else if (value >= 1 || value <= -1) return value.ToString("F2"); + else if (value >= 0.1 || value <= -0.1) return value.ToString("F3"); + else if (value >= 0.01 || value <= -0.01) return value.ToString("F4"); + else return value.ToString("F5"); + } + else if (validDigits == 2) + { + if (value >= 10 || value <= -10) return value.ToString("F0"); + else if (value >= 1 || value <= -1) return value.ToString("F1"); + else if (value >= 0.1 || value <= -0.1) return value.ToString("F2"); + else if (value >= 0.01 || value <= -0.01) return value.ToString("F3"); + else return value.ToString("F4"); + } + else return value.ToString(); + } } }