From 90b760075cd1b26c16525af66bcb5eb9c39e133c Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 18 Sep 2019 14:44:31 +0200 Subject: [PATCH] TBF.UI.Bench.Uncertainties : Modifications, 3 tab pages completed, 2 in preparation. --- TBF/Resources/Strings.Designer.cs | 36 +++ TBF/Resources/Strings.cs.resx | 12 + TBF/Resources/Strings.resx | 12 + TBF/TBF.csproj | 46 +++ .../Uncertainties/IUncetaintiesDlgTab.cs | 22 ++ .../Bench/Uncertainties/UncertaintiesDlg.cs | 213 +++++++------- .../UncertaintiesDlg.designer.cs | 30 +- .../Uncertainties/UncertntDlgBuoyancyTab.cs | 132 +++++++++ .../UncertntDlgBuoyancyTab.designer.cs | 97 +++++++ .../Uncertainties/UncertntDlgBuoyancyTab.resx | 120 ++++++++ .../Uncertainties/UncertntDlgDensityTab.cs | 162 +++++++++++ .../UncertntDlgDensityTab.designer.cs | 145 ++++++++++ .../Uncertainties/UncertntDlgDensityTab.resx | 120 ++++++++ .../Uncertainties/UncertntDlgPressMeterTab.cs | 264 +++++++++++++++++ .../UncertntDlgPressMeterTab.designer.cs | 122 ++++++++ .../UncertntDlgPressMeterTab.resx | 120 ++++++++ .../Uncertainties/UncertntDlgScaleTab.cs | 269 ++++++++++++++++++ .../UncertntDlgScaleTab.designer.cs | 121 ++++++++ .../Uncertainties/UncertntDlgScaleTab.resx | 120 ++++++++ .../Uncertainties/UncertntDlgTempMeterTab.cs | 264 +++++++++++++++++ .../UncertntDlgTempMeterTab.designer.cs | 122 ++++++++ .../UncertntDlgTempMeterTab.resx | 120 ++++++++ 22 files changed, 2549 insertions(+), 120 deletions(-) create mode 100644 TBF/UI/Bench/Uncertainties/IUncetaintiesDlgTab.cs create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgBuoyancyTab.cs create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgBuoyancyTab.designer.cs create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgBuoyancyTab.resx create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgDensityTab.cs create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgDensityTab.designer.cs create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgDensityTab.resx create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgPressMeterTab.cs create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgPressMeterTab.designer.cs create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgPressMeterTab.resx create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgScaleTab.cs create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgScaleTab.designer.cs create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgScaleTab.resx create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgTempMeterTab.cs create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgTempMeterTab.designer.cs create mode 100644 TBF/UI/Bench/Uncertainties/UncertntDlgTempMeterTab.resx diff --git a/TBF/Resources/Strings.Designer.cs b/TBF/Resources/Strings.Designer.cs index 72b730725..c3cce2444 100644 --- a/TBF/Resources/Strings.Designer.cs +++ b/TBF/Resources/Strings.Designer.cs @@ -1356,6 +1356,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Drift per year. + /// + internal static string Drift_per_year { + get { + return ResourceManager.GetString("Drift_per_year", resourceCulture); + } + } + /// /// Looks up a localized string similar to Leak duration [s]. /// @@ -2319,6 +2328,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Main uncertainty. + /// + internal static string Main_uncertainty { + get { + return ResourceManager.GetString("Main_uncertainty", resourceCulture); + } + } + /// /// Looks up a localized string similar to Main Water Meter. /// @@ -4092,6 +4110,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Resolution. + /// + internal static string Resolution { + get { + return ResourceManager.GetString("Resolution", resourceCulture); + } + } + /// /// Looks up a localized string similar to You must restart to apply these changes. /// @@ -5517,6 +5544,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Uncertainty of correction. + /// + internal static string Uncertainty_of_correction { + get { + return ResourceManager.GetString("Uncertainty_of_correction", resourceCulture); + } + } + /// /// Looks up a localized string similar to Uncertainty [%]. /// diff --git a/TBF/Resources/Strings.cs.resx b/TBF/Resources/Strings.cs.resx index 874fd9766..cc6b34ab2 100644 --- a/TBF/Resources/Strings.cs.resx +++ b/TBF/Resources/Strings.cs.resx @@ -1488,4 +1488,16 @@ Program musí být uzavřen. + + Drift za rok + + + Hlavní neurčitost + + + Rozlišení + + + Neurčitost korekce + \ No newline at end of file diff --git a/TBF/Resources/Strings.resx b/TBF/Resources/Strings.resx index 7ec5826dc..630ec04a9 100644 --- a/TBF/Resources/Strings.resx +++ b/TBF/Resources/Strings.resx @@ -2065,4 +2065,16 @@ Invalid density parameters.\r\nCorrect them please. + + Drift per year + + + Main uncertainty + + + Resolution + + + Uncertainty of correction + \ No newline at end of file diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index 83753ce39..cc2485f4f 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -2089,6 +2089,37 @@ Component + + + UserControl + + + UncertntDlgBuoyancyTab.cs + + + UserControl + + + UncertntDlgDensityTab.cs + + + UserControl + + + UncertntDlgScaleTab.cs + + + UserControl + + + UncertntDlgPressMeterTab.cs + + + UserControl + + + UncertntDlgTempMeterTab.cs + Form @@ -3063,6 +3094,21 @@ TransitionsDlg.cs + + UncertntDlgBuoyancyTab.cs + + + UncertntDlgDensityTab.cs + + + UncertntDlgScaleTab.cs + + + UncertntDlgPressMeterTab.cs + + + UncertntDlgTempMeterTab.cs + UncertaintiesDlg.cs diff --git a/TBF/UI/Bench/Uncertainties/IUncetaintiesDlgTab.cs b/TBF/UI/Bench/Uncertainties/IUncetaintiesDlgTab.cs new file mode 100644 index 000000000..47931e9b0 --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/IUncetaintiesDlgTab.cs @@ -0,0 +1,22 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using Config.Entities; + +namespace TBF.UI.Bench.Uncertainties +{ + interface IUncetaintiesDlgTab : TBF.UI.Shared.ITabWithListViewEx + { + /// + /// Component entity that has a list of 'measurement-correction' pairs + /// to be updated in the database on OK. + /// + Component MeterEntity { get; set; } + + /// + /// A list of 'measurement-correction' pairs to be deleted from the database on OK. + /// + IList ToBeRemoved { get; set; } + } +} diff --git a/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.cs b/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.cs index a4753b658..6fa8bb7bb 100644 --- a/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.cs +++ b/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.cs @@ -10,7 +10,6 @@ using Config.Entities; using TBF.BenchControl; using TBF.Resources; using TBF.UI.Shared; -using TBF.UI.Bench.Metrology; /// TODO: Remove namespace TBF.UI.Bench.Uncertainties { @@ -40,7 +39,7 @@ namespace TBF.UI.Bench.Uncertainties sharedButtons.RemoveClicked += removeButton_Click; } - private void MetrologyDlg_Load(object sender, EventArgs e) + private void UncertaintiesDlg_Load(object sender, EventArgs e) { LoadUISettings(); @@ -53,7 +52,6 @@ namespace TBF.UI.Bench.Uncertainties int flowMetersCount = 0; int pressMetersCount = 0; int tempMetersCount = 0; - int platinumTempMetersCount = 0; int evaporationsCount = 0; session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config); @@ -61,19 +59,38 @@ namespace TBF.UI.Bench.Uncertainties .OrderBy(x => x. ItemNr).Asc .List(); - // Density tab-page - fixedCount++; - TabPage dstyTabPage = new TabPage(" " + Strings.Density + " "); - MetrologyDlgDensityTab uiCtl = new MetrologyDlgDensityTab(); - uiCtl.Dock = DockStyle.Fill; - dstyTabPage.Tag = uiCtl; - dstyTabPage.Controls.Add(uiCtl); - metrologyTabControl.TabPages.Add(dstyTabPage); - foreach (var cmpnt in cmpntEntities) { BenchControl.Generic.IComponentFactory factory = TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName); + /// Tab-page density + if (factory is BenchControl.DataContainers.Density.ComponentFactory) + { + fixedCount++; + TabPage tabPage = new TabPage(" " + Strings.Density + " "); + UncertntDlgDensityTab uiControl = new UncertntDlgDensityTab(); + uiControl.MeterEntity = cmpnt; + uiControl.DensityCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.DataContainers.Density.ComponentCfg; + uiControl.Dock = DockStyle.Fill; + tabPage.Tag = uiControl; + tabPage.Controls.Add(uiControl); + uncertaintiesTabControl.TabPages.Add(tabPage); + } + + /// Tab-page buoyancy + if (factory is BenchControl.DataContainers.Buoyancy.ComponentFactory) + { + fixedCount++; + TabPage tabPage = new TabPage(" Buoyancy "); + UncertntDlgBuoyancyTab uiControl = new UncertntDlgBuoyancyTab(); + uiControl.MeterEntity = cmpnt; + uiControl.BuoyancyCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.DataContainers.Buoyancy.ComponentCfg; + uiControl.Dock = DockStyle.Fill; + tabPage.Tag = uiControl; + tabPage.Controls.Add(uiControl); + uncertaintiesTabControl.TabPages.Add(tabPage); + } + /// Tab-pages for scales if (factory is BenchControl.MettlerToledo.Standard.BalanceFactory || factory is BenchControl.MettlerToledo.Standard.BalanceOldFactory || @@ -82,36 +99,36 @@ namespace TBF.UI.Bench.Uncertainties { balancesCount++; TabPage tabPage = new TabPage(" " + cmpnt.Name + " "); - MetrologyDlgBalanceTab uiControl = new MetrologyDlgBalanceTab(); + UncertntDlgScaleTab uiControl = new UncertntDlgScaleTab(); uiControl.MeterEntity = cmpnt; - uiControl.BalanceCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.IScaleCfg; + uiControl.ScaleCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.IScaleCfg; uiControl.Dock = DockStyle.Fill; tabPage.Tag = uiControl; tabPage.Controls.Add(uiControl); - metrologyTabControl.TabPages.Add(tabPage); + uncertaintiesTabControl.TabPages.Add(tabPage); } - /// Tab-pages for flowmeters - if (factory is BenchControl.Elde.FlowMeter.FlowMeterFactory) - { - BenchControl.Elde.FlowMeter.FlowMeterCfg flowMeterCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.Elde.FlowMeter.FlowMeterCfg; + ///// Tab-pages for flowmeters + //if (factory is BenchControl.Elde.FlowMeter.FlowMeterFactory) + //{ + // BenchControl.Elde.FlowMeter.FlowMeterCfg flowMeterCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.Elde.FlowMeter.FlowMeterCfg; - for (int r = 0; r <= 5; r++) - { - if (flowMeterCfg.RangeEnabled(r)) - { - flowMetersCount++; - TabPage tabPage = new TabPage(string.Format(((r == 0) ? " {0} " : " {0} r{1} "), cmpnt.Name, r)); - MetrologyDlgFlowMeterTab uiControl = new MetrologyDlgFlowMeterTab(r); - uiControl.MeterEntity = cmpnt; - uiControl.CalibInfoCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.ICalibRangesCfg; - uiControl.Dock = DockStyle.Fill; - tabPage.Tag = uiControl; - tabPage.Controls.Add(uiControl); - metrologyTabControl.TabPages.Add(tabPage); - } - } - } + // for (int r = 0; r <= 5; r++) + // { + // if (flowMeterCfg.RangeEnabled(r)) + // { + // flowMetersCount++; + // TabPage tabPage = new TabPage(string.Format(((r == 0) ? " {0} " : " {0} r{1} "), cmpnt.Name, r)); + // MetrologyDlgFlowMeterTab uiControl = new MetrologyDlgFlowMeterTab(r); + // uiControl.MeterEntity = cmpnt; + // uiControl.CalibInfoCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.ICalibRangesCfg; + // uiControl.Dock = DockStyle.Fill; + // tabPage.Tag = uiControl; + // tabPage.Controls.Add(uiControl); + // metrologyTabControl.TabPages.Add(tabPage); + // } + // } + //} /// Tab-pages for pressure meters if (factory is BenchControl.Elde.PressureMeter.PressureMeterFactory || @@ -120,91 +137,78 @@ namespace TBF.UI.Bench.Uncertainties { pressMetersCount++; TabPage tabPage = new TabPage(" " + cmpnt.Name + " "); - MetrologyDlgPressMeterTab uiControl = new MetrologyDlgPressMeterTab(); + UncertntDlgPressMeterTab uiControl = new UncertntDlgPressMeterTab(); uiControl.MeterEntity = cmpnt; uiControl.Dock = DockStyle.Fill; tabPage.Tag = uiControl; tabPage.Controls.Add(uiControl); - metrologyTabControl.TabPages.Add(tabPage); + uncertaintiesTabControl.TabPages.Add(tabPage); } - /// Tab-pages for temperature meters + /// Tab-pages for temperature meters (incl. platinum temp. meter with Keithley) if (factory is BenchControl.Elde.TempMeter.TempMeterFactory || - factory is BenchControl.Elde.TempMeterInternal.TempMeterFactory) + factory is BenchControl.Elde.TempMeterInternal.TempMeterFactory || + factory is BenchControl.Keithley.TempMeter.Factory) { tempMetersCount++; TabPage tabPage = new TabPage(" " + cmpnt.Name + " "); - MetrologyDlgTempMeterTab uiControl = new MetrologyDlgTempMeterTab(); + UncertntDlgTempMeterTab uiControl = new UncertntDlgTempMeterTab(); uiControl.MeterEntity = cmpnt; uiControl.Dock = DockStyle.Fill; tabPage.Tag = uiControl; tabPage.Controls.Add(uiControl); - metrologyTabControl.TabPages.Add(tabPage); + uncertaintiesTabControl.TabPages.Add(tabPage); } - /// Tab-pages for platinum resistance temperature meters - if (factory is BenchControl.Keithley.TempMeter.Factory) - { - platinumTempMetersCount++; - TabPage tabPage = new TabPage(" " + cmpnt.Name + " "); - MetrologyDlgPlatinumResistanceTMeterTab uiControl = new MetrologyDlgPlatinumResistanceTMeterTab(); - uiControl.MeterEntity = cmpnt; - uiControl.TempMeterCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.Keithley.TempMeter.TempMeterCfg; - uiControl.Dock = DockStyle.Fill; - tabPage.Tag = uiControl; - tabPage.Controls.Add(uiControl); - metrologyTabControl.TabPages.Add(tabPage); - } + ///// Tab-pages for diverters + //if (factory is BenchControl.Elde.Diverter.DiverterFactory) + //{ + // divertersCount++; + // TabPage tabPage = new TabPage(" " + cmpnt.Name + " "); + // MetrologyDlgDiverterTab uiControl = new MetrologyDlgDiverterTab(); + // uiControl.MeterEntity = cmpnt; + // uiControl.CalibInfoCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.ICalibInfoCfg; + // uiControl.Dock = DockStyle.Fill; + // tabPage.Tag = uiControl; + // tabPage.Controls.Add(uiControl); + // metrologyTabControl.TabPages.Add(tabPage); + //} - /// Tab-pages for diverters - if (factory is BenchControl.Elde.Diverter.DiverterFactory) - { - divertersCount++; - TabPage tabPage = new TabPage(" " + cmpnt.Name + " "); - MetrologyDlgDiverterTab uiControl = new MetrologyDlgDiverterTab(); - uiControl.MeterEntity = cmpnt; - uiControl.CalibInfoCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.ICalibInfoCfg; - uiControl.Dock = DockStyle.Fill; - tabPage.Tag = uiControl; - tabPage.Controls.Add(uiControl); - metrologyTabControl.TabPages.Add(tabPage); - } + ///// Tab-pages for level meters inside water tanks + //if (factory is BenchControl.Hart.Nivotrack.Factory) + //{ + // levelMetersCount++; + // TabPage tabPage = new TabPage(" " + cmpnt.Name + " "); + // MetrologyDlgLevelMeterTab uiControl = new MetrologyDlgLevelMeterTab(); + // uiControl.MeterEntity = cmpnt; + // uiControl.CalibInfoCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.ICalibInfoCfg; + // uiControl.Dock = DockStyle.Fill; + // tabPage.Tag = uiControl; + // tabPage.Controls.Add(uiControl); + // metrologyTabControl.TabPages.Add(tabPage); + //} - /// Tab-pages for level meters inside water tanks - if (factory is BenchControl.Hart.Nivotrack.Factory) - { - levelMetersCount++; - TabPage tabPage = new TabPage(" " + cmpnt.Name + " "); - MetrologyDlgLevelMeterTab uiControl = new MetrologyDlgLevelMeterTab(); - uiControl.MeterEntity = cmpnt; - uiControl.CalibInfoCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.ICalibInfoCfg; - uiControl.Dock = DockStyle.Fill; - tabPage.Tag = uiControl; - tabPage.Controls.Add(uiControl); - metrologyTabControl.TabPages.Add(tabPage); - } - - /// Tab-pages for water tank evaporation rates - if (factory is BenchControl.Various.Evaporation.Factory) - { - evaporationsCount++; - TabPage tabPage = new TabPage(" " + cmpnt.Name + " "); - MetrologyDlgEvaporationTab uiControl = new MetrologyDlgEvaporationTab(); - uiControl.MeterEntity = cmpnt; - uiControl.CalibInfoCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.ICalibInfoCfg; - uiControl.Dock = DockStyle.Fill; - tabPage.Tag = uiControl; - tabPage.Controls.Add(uiControl); - metrologyTabControl.TabPages.Add(tabPage); - } + ///// Tab-pages for water tank evaporation rates + //if (factory is BenchControl.Various.Evaporation.Factory) + //{ + // evaporationsCount++; + // TabPage tabPage = new TabPage(" " + cmpnt.Name + " "); + // MetrologyDlgEvaporationTab uiControl = new MetrologyDlgEvaporationTab(); + // uiControl.MeterEntity = cmpnt; + // uiControl.CalibInfoCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.ICalibInfoCfg; + // uiControl.Dock = DockStyle.Fill; + // tabPage.Tag = uiControl; + // tabPage.Controls.Add(uiControl); + // metrologyTabControl.TabPages.Add(tabPage); + //} } } private void unlockButton_Click(object sender, EventArgs e) { - foreach (TabPage tabPage in metrologyTabControl.TabPages) + foreach (TabPage tabPage in uncertaintiesTabControl.TabPages) { - (tabPage.Tag as IMetrologyDlgTab).Unlock(); + (tabPage.Tag as IUncetaintiesDlgTab).Unlock(); } } @@ -214,13 +218,12 @@ namespace TBF.UI.Bench.Uncertainties { try { - foreach (TabPage tabPage in metrologyTabControl.TabPages) + foreach (TabPage tabPage in uncertaintiesTabControl.TabPages) { - IMetrologyDlgTab tab = tabPage.Tag as IMetrologyDlgTab; - tab.OkBtnClicked(); - - if (!(tabPage.Tag is MetrologyDlgDensityTab)) + IUncetaintiesDlgTab tab = tabPage.Tag as IUncetaintiesDlgTab; + if (tab != null) { + tab.OkBtnClicked(); session.SaveOrUpdate(tab.MeterEntity); foreach (var entity in tab.ToBeRemoved) session.Delete(entity); } @@ -243,9 +246,9 @@ namespace TBF.UI.Bench.Uncertainties private void cancelButton_Click(object sender, EventArgs e) { - foreach (TabPage tabPage in metrologyTabControl.TabPages) + foreach (TabPage tabPage in uncertaintiesTabControl.TabPages) { - (tabPage.Tag as IMetrologyDlgTab).CancelBtnClicked(); + (tabPage.Tag as IUncetaintiesDlgTab).CancelBtnClicked(); } SaveUISettings(); @@ -292,12 +295,12 @@ namespace TBF.UI.Bench.Uncertainties private void addButton_Click(object sender, EventArgs e) { - (metrologyTabControl.SelectedTab.Tag as IMetrologyDlgTab).AddOne(); + (uncertaintiesTabControl.SelectedTab.Tag as IUncetaintiesDlgTab).AddOne(); } private void removeButton_Click(object sender, EventArgs e) { - (metrologyTabControl.SelectedTab.Tag as IMetrologyDlgTab).RemoveSelected(); + (uncertaintiesTabControl.SelectedTab.Tag as IUncetaintiesDlgTab).RemoveSelected(); } public void UpdateButtonStates(SharedButtons.SelectedItemPos selectedItemPos) diff --git a/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.designer.cs b/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.designer.cs index 1e79fc24b..5271641a5 100644 --- a/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.designer.cs +++ b/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.designer.cs @@ -32,7 +32,7 @@ namespace TBF.UI.Bench.Uncertainties private void InitializeComponent() { this.splitContainer = new System.Windows.Forms.SplitContainer(); - this.metrologyTabControl = new System.Windows.Forms.TabControl(); + this.uncertaintiesTabControl = new System.Windows.Forms.TabControl(); this.sharedButtons = new TBF.UI.Shared.SharedButtons(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); this.splitContainer.Panel1.SuspendLayout(); @@ -49,7 +49,7 @@ namespace TBF.UI.Bench.Uncertainties // // splitContainer.Panel1 // - this.splitContainer.Panel1.Controls.Add(this.metrologyTabControl); + this.splitContainer.Panel1.Controls.Add(this.uncertaintiesTabControl); // // splitContainer.Panel2 // @@ -58,16 +58,16 @@ namespace TBF.UI.Bench.Uncertainties this.splitContainer.SplitterDistance = 863; this.splitContainer.TabIndex = 0; // - // metrologyTabControl + // uncertaintiesTabControl // - this.metrologyTabControl.Dock = System.Windows.Forms.DockStyle.Fill; - this.metrologyTabControl.ItemSize = new System.Drawing.Size(60, 30); - this.metrologyTabControl.Location = new System.Drawing.Point(0, 0); - this.metrologyTabControl.Name = "metrologyTabControl"; - this.metrologyTabControl.SelectedIndex = 0; - this.metrologyTabControl.Size = new System.Drawing.Size(863, 344); - this.metrologyTabControl.TabIndex = 0; - this.metrologyTabControl.SelectedIndexChanged += new System.EventHandler(this.metrologyTabControl_SelectedIndexChanged); + this.uncertaintiesTabControl.Dock = System.Windows.Forms.DockStyle.Fill; + this.uncertaintiesTabControl.ItemSize = new System.Drawing.Size(60, 30); + this.uncertaintiesTabControl.Location = new System.Drawing.Point(0, 0); + this.uncertaintiesTabControl.Name = "uncertaintiesTabControl"; + this.uncertaintiesTabControl.SelectedIndex = 0; + this.uncertaintiesTabControl.Size = new System.Drawing.Size(863, 344); + this.uncertaintiesTabControl.TabIndex = 0; + this.uncertaintiesTabControl.SelectedIndexChanged += new System.EventHandler(this.metrologyTabControl_SelectedIndexChanged); // // sharedButtons // @@ -76,16 +76,16 @@ namespace TBF.UI.Bench.Uncertainties this.sharedButtons.Size = new System.Drawing.Size(100, 400); this.sharedButtons.TabIndex = 0; // - // UncertaintyDlg + // UncertaintiesDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(965, 344); this.Controls.Add(this.splitContainer); - this.Name = "UncertaintyDlg"; + this.Name = "UncertaintiesDlg"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Uncertainty"; - this.Load += new System.EventHandler(this.MetrologyDlg_Load); + this.Load += new System.EventHandler(this.UncertaintiesDlg_Load); this.splitContainer.Panel1.ResumeLayout(false); this.splitContainer.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit(); @@ -97,7 +97,7 @@ namespace TBF.UI.Bench.Uncertainties #endregion private System.Windows.Forms.SplitContainer splitContainer; - private System.Windows.Forms.TabControl metrologyTabControl; + private System.Windows.Forms.TabControl uncertaintiesTabControl; private TBF.UI.Shared.SharedButtons sharedButtons; } } \ No newline at end of file diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgBuoyancyTab.cs b/TBF/UI/Bench/Uncertainties/UncertntDlgBuoyancyTab.cs new file mode 100644 index 000000000..edd674127 --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgBuoyancyTab.cs @@ -0,0 +1,132 @@ +/// +/// Copyright (c) 2019 Senus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using log4net; +using Config.Entities; +using TBF.Resources; + +namespace TBF.UI.Bench.Uncertainties +{ + public partial class UncertntDlgBuoyancyTab : UserControl, IUncetaintiesDlgTab + { + static readonly ILog log = LogManager.GetLogger(typeof(UncertntDlgBuoyancyTab)); + + /// + /// Component entity that has a list of 'measurement-correction' pairs + /// to be updated in the database on OK. + /// + public Component MeterEntity + { + get { return meterEntity; } + set { meterEntity = value; } + } + Component meterEntity; + + /// + /// Buoyancy configuration + /// + public BenchControl.DataContainers.Buoyancy.ComponentCfg BuoyancyCfg; + + /// + /// A list of 'measurement-correction' pairs to be deleted from the database on OK. + /// + public IList ToBeRemoved + { + get { return toBeRemoved; } + set { toBeRemoved = value; } + } + IList toBeRemoved; + + UncertaintiesDlg parent; + bool unlocked; + + public UncertntDlgBuoyancyTab() + { + InitializeComponent(); + toBeRemoved = new List(); + unlocked = false; + } + + private void MetrologyDlgBuoyancyTab_Load(object sender, System.EventArgs e) + { + if (meterEntity == null) return; + + parent = ParentForm as UncertaintiesDlg; + + /// Panel1 + buoyancyLabel.Text = "Buoyancy"; + + /// Panel2 + + RefreshAll(); + } + + void RefreshAll() + { + buoyancyTextBox.Text = Config.Data.Buoyancy.ToString("F5"); + } + + public void Unlock() + { + unlocked = true; + + buoyancyTextBox.Enabled = true; + } + + public void OkBtnClicked() + { + if (BuoyancyCfg != null) + { + try + { + double buoyancy = Utils.ParseUDouble(buoyancyTextBox.Text); + + global::Results.WMeterRsltItemSpec.Buoyancy = + Config.Data.Buoyancy = BuoyancyCfg.Buoyancy = buoyancy; + + Component modified = BuoyancyCfg.CreateDbEntity(); + MeterEntity.Parameters = modified.Parameters; + } + catch + { + MessageBox.Show(Strings.Invalid_buoyancy_parameter_Correct_pls, + Strings.Error, + MessageBoxButtons.OK, + MessageBoxIcon.Exclamation); + } + } + } + + public void CancelBtnClicked() + { + } + + public void AddOne() + { + } + + public void RemoveSelected() + { + } + + public void MoveUpSelected() + { + } + + public void MoveDownSelected() + { + } + + public string GetWarningsBeforeSaving(ref Dictionary renmInfo) + { + return string.Empty; + } + + public void UpdateRelatedItems(Dictionary renameInfo) + { + } + } +} diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgBuoyancyTab.designer.cs b/TBF/UI/Bench/Uncertainties/UncertntDlgBuoyancyTab.designer.cs new file mode 100644 index 000000000..d99abb518 --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgBuoyancyTab.designer.cs @@ -0,0 +1,97 @@ +/// +/// Copyright (c) 2019 Senus Slovensko a.s. +/// +namespace TBF.UI.Bench.Uncertainties +{ + partial class UncertntDlgBuoyancyTab + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.buoyancyTextBox = new System.Windows.Forms.TextBox(); + this.buoyancyLabel = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.buoyancyTextBox); + this.splitContainer1.Panel1.Controls.Add(this.buoyancyLabel); + this.splitContainer1.Size = new System.Drawing.Size(420, 300); + this.splitContainer1.SplitterDistance = 120; + this.splitContainer1.TabIndex = 1; + // + // buoyancyTextBox + // + this.buoyancyTextBox.Enabled = false; + this.buoyancyTextBox.Location = new System.Drawing.Point(189, 51); + this.buoyancyTextBox.Name = "buoyancyTextBox"; + this.buoyancyTextBox.Size = new System.Drawing.Size(110, 20); + this.buoyancyTextBox.TabIndex = 1; + // + // buoyancyLabel + // + this.buoyancyLabel.AutoSize = true; + this.buoyancyLabel.Location = new System.Drawing.Point(41, 54); + this.buoyancyLabel.Name = "buoyancyLabel"; + this.buoyancyLabel.Size = new System.Drawing.Size(54, 13); + this.buoyancyLabel.TabIndex = 0; + this.buoyancyLabel.Text = "Buoyancy"; + // + // MetrologyDlgBuoyancyTab + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.splitContainer1); + this.Name = "MetrologyDlgBuoyancyTab"; + this.Size = new System.Drawing.Size(420, 300); + this.Load += new System.EventHandler(this.MetrologyDlgBuoyancyTab_Load); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.TextBox buoyancyTextBox; + private System.Windows.Forms.Label buoyancyLabel; + } +} diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgBuoyancyTab.resx b/TBF/UI/Bench/Uncertainties/UncertntDlgBuoyancyTab.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgBuoyancyTab.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgDensityTab.cs b/TBF/UI/Bench/Uncertainties/UncertntDlgDensityTab.cs new file mode 100644 index 000000000..00dda201a --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgDensityTab.cs @@ -0,0 +1,162 @@ +/// +/// Copyright (c) 2019 Senus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using log4net; +using Config.Entities; +using TBF.Resources; + +namespace TBF.UI.Bench.Uncertainties +{ + public partial class UncertntDlgDensityTab : UserControl, IUncetaintiesDlgTab + { + static readonly ILog log = LogManager.GetLogger(typeof(UncertntDlgDensityTab)); + + /// + /// Component entity that has a list of 'measurement-correction' pairs + /// to be updated in the database on OK. + /// + public Component MeterEntity + { + get { return meterEntity; } + set { meterEntity = value; } + } + Component meterEntity; + + /// + /// Density configuration + /// + public BenchControl.DataContainers.Density.ComponentCfg DensityCfg; + + /// + /// A list of 'measurement-correction' pairs to be deleted from the database on OK. + /// + public IList ToBeRemoved + { + get { return toBeRemoved; } + set { toBeRemoved = value; } + } + IList toBeRemoved; + + UncertaintiesDlg parent; + bool unlocked; + + public UncertntDlgDensityTab() + { + InitializeComponent(); + toBeRemoved = new List(); + unlocked = false; + } + + private void MetrologyDlgDensityTab_Load(object sender, System.EventArgs e) + { + if (meterEntity == null) return; + + parent = ParentForm as UncertaintiesDlg; + + /// Panel1 + densityLabel.Text = string.Format("{0} [{1}]", Strings.Density, Config.Unit.kgpm3.ToDescription()); + temperatureLabel.Text = string.Format("{0} [{1}]", Strings.At_temperature, Config.Unit.C.ToDescription()); + densityCorrLabel.Text = string.Format("{0} [{1}]", Strings.Density_correction, Config.Unit.kgpm3.ToDescription()); + + /// Panel2 + + RefreshAll(); + } + + void RefreshAll() + { + densityTextBox.Text = Config.Data.RealDensity.ToString("F4"); + temperatureTextBox.Text = Config.Data.AtTemperature.ToString("F2"); + densityCorrTextBox.Text = Config.Formulas.DensityCorrection(Config.Data.RealDensity, Config.Data.AtTemperature).ToString("F5"); + } + + public void Unlock() + { + unlocked = true; + + densityTextBox.Enabled = true; + temperatureTextBox.Enabled = true; + } + + public void OkBtnClicked() + { + if (DensityCfg != null) + { + try + { + double realDensity = Utils.ParseUDouble(densityTextBox.Text); + double atTemperature = Utils.ParseUDouble(temperatureTextBox.Text); + + global::Results.WMeterRsltItemSpec.RealDensity = + Config.Data.RealDensity = DensityCfg.RealDensity = realDensity; + + global::Results.WMeterRsltItemSpec.AtTemperature = + Config.Data.AtTemperature = DensityCfg.AtTemperature = atTemperature; + + Component modified = DensityCfg.CreateDbEntity(); + MeterEntity.Parameters = modified.Parameters; + } + catch + { + MessageBox.Show(Strings.Invalid_density_parameter_Correct_pls, + Strings.Error, + MessageBoxButtons.OK, + MessageBoxIcon.Exclamation); + } + } + } + + public void CancelBtnClicked() + { + } + + public void AddOne() + { + } + + public void RemoveSelected() + { + } + + public void MoveUpSelected() + { + } + + public void MoveDownSelected() + { + } + + public string GetWarningsBeforeSaving(ref Dictionary renmInfo) + { + return string.Empty; + } + + public void UpdateRelatedItems(Dictionary renameInfo) + { + } + + private void densityTextBox_TextChanged(object sender, EventArgs e) + { + UpdateDensityCorrectionDisplay(); + } + + private void temperatureTextBox_TextChanged(object sender, EventArgs e) + { + UpdateDensityCorrectionDisplay(); + } + + void UpdateDensityCorrectionDisplay() + { + double density; + double temp; + if (Utils.TryParseUDouble(densityTextBox.Text, out density) && + Utils.TryParseUDouble(temperatureTextBox.Text, out temp)) + { + densityCorrTextBox.Text = Config.Formulas.DensityCorrection(density, temp).ToString(); + } + } + } +} diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgDensityTab.designer.cs b/TBF/UI/Bench/Uncertainties/UncertntDlgDensityTab.designer.cs new file mode 100644 index 000000000..657204973 --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgDensityTab.designer.cs @@ -0,0 +1,145 @@ +/// +/// Copyright (c) 2019 Senus Slovensko a.s. +/// +namespace TBF.UI.Bench.Uncertainties +{ + partial class UncertntDlgDensityTab + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.densityCorrTextBox = new System.Windows.Forms.TextBox(); + this.densityCorrLabel = new System.Windows.Forms.Label(); + this.temperatureTextBox = new System.Windows.Forms.TextBox(); + this.temperatureLabel = new System.Windows.Forms.Label(); + this.densityTextBox = new System.Windows.Forms.TextBox(); + this.densityLabel = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.densityCorrTextBox); + this.splitContainer1.Panel1.Controls.Add(this.densityCorrLabel); + this.splitContainer1.Panel1.Controls.Add(this.temperatureTextBox); + this.splitContainer1.Panel1.Controls.Add(this.temperatureLabel); + this.splitContainer1.Panel1.Controls.Add(this.densityTextBox); + this.splitContainer1.Panel1.Controls.Add(this.densityLabel); + this.splitContainer1.Size = new System.Drawing.Size(420, 300); + this.splitContainer1.SplitterDistance = 120; + this.splitContainer1.TabIndex = 1; + // + // densityCorrTextBox + // + this.densityCorrTextBox.Enabled = false; + this.densityCorrTextBox.Location = new System.Drawing.Point(185, 86); + this.densityCorrTextBox.Name = "densityCorrTextBox"; + this.densityCorrTextBox.Size = new System.Drawing.Size(110, 20); + this.densityCorrTextBox.TabIndex = 5; + // + // densityCorrLabel + // + this.densityCorrLabel.AutoSize = true; + this.densityCorrLabel.Location = new System.Drawing.Point(37, 89); + this.densityCorrLabel.Name = "densityCorrLabel"; + this.densityCorrLabel.Size = new System.Drawing.Size(132, 13); + this.densityCorrLabel.TabIndex = 4; + this.densityCorrLabel.Text = "Density correction [kg/m3]"; + // + // temperatureTextBox + // + this.temperatureTextBox.Enabled = false; + this.temperatureTextBox.Location = new System.Drawing.Point(185, 43); + this.temperatureTextBox.Name = "temperatureTextBox"; + this.temperatureTextBox.Size = new System.Drawing.Size(110, 20); + this.temperatureTextBox.TabIndex = 3; + this.temperatureTextBox.TextChanged += new System.EventHandler(this.temperatureTextBox_TextChanged); + // + // temperatureLabel + // + this.temperatureLabel.AutoSize = true; + this.temperatureLabel.Location = new System.Drawing.Point(37, 46); + this.temperatureLabel.Name = "temperatureLabel"; + this.temperatureLabel.Size = new System.Drawing.Size(112, 13); + this.temperatureLabel.TabIndex = 2; + this.temperatureLabel.Text = "@Temperature [degC]"; + // + // densityTextBox + // + this.densityTextBox.Enabled = false; + this.densityTextBox.Location = new System.Drawing.Point(185, 17); + this.densityTextBox.Name = "densityTextBox"; + this.densityTextBox.Size = new System.Drawing.Size(110, 20); + this.densityTextBox.TabIndex = 1; + this.densityTextBox.TextChanged += new System.EventHandler(this.densityTextBox_TextChanged); + // + // densityLabel + // + this.densityLabel.AutoSize = true; + this.densityLabel.Location = new System.Drawing.Point(37, 20); + this.densityLabel.Name = "densityLabel"; + this.densityLabel.Size = new System.Drawing.Size(82, 13); + this.densityLabel.TabIndex = 0; + this.densityLabel.Text = "Density [kg/m3]"; + // + // MetrologyDlgDensityTab + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.splitContainer1); + this.Name = "MetrologyDlgDensityTab"; + this.Size = new System.Drawing.Size(420, 300); + this.Load += new System.EventHandler(this.MetrologyDlgDensityTab_Load); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.TextBox temperatureTextBox; + private System.Windows.Forms.Label temperatureLabel; + private System.Windows.Forms.TextBox densityTextBox; + private System.Windows.Forms.Label densityLabel; + private System.Windows.Forms.TextBox densityCorrTextBox; + private System.Windows.Forms.Label densityCorrLabel; + } +} diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgDensityTab.resx b/TBF/UI/Bench/Uncertainties/UncertntDlgDensityTab.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgDensityTab.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgPressMeterTab.cs b/TBF/UI/Bench/Uncertainties/UncertntDlgPressMeterTab.cs new file mode 100644 index 000000000..53d8f5e78 --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgPressMeterTab.cs @@ -0,0 +1,264 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Windows.Forms; +using log4net; +using Config.Entities; +using Results.Forms; +using TBF.Resources; +using TBF.UI.Shared; + +namespace TBF.UI.Bench.Uncertainties +{ + public partial class UncertntDlgPressMeterTab : UserControl, IUncetaintiesDlgTab + { + static readonly ILog log = LogManager.GetLogger(typeof(UncertntDlgPressMeterTab)); + + /// + /// Component entity that has a list of 'measurement-correction' pairs + /// to be updated in the database on OK. + /// + Component meterEntity; + public Component MeterEntity + { + get { return meterEntity; } + set { meterEntity = value; } + } + + /// + /// A list of 'measurement-correction' pairs to be deleted from the database on OK. + /// + public IList ToBeRemoved + { + get { return toBeRemoved; } + set { toBeRemoved = value; } + } + IList toBeRemoved; + + UncertaintiesDlg parent; + bool unlocked; + Control[] textBoxes; + + public UncertntDlgPressMeterTab() + { + InitializeComponent(); + toBeRemoved = new List(); + } + + private void UncertntDlgPressMeterTab_Load(object sender, System.EventArgs e) + { + if (meterEntity == null) return; + + parent = ParentForm as UncertaintiesDlg; + + /// Panel1 + cmpntLabel.Text = Strings.Component; + cmpntNameLabel.Text = meterEntity.Name; + + /// Panel2 + listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked); + listViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing); + + listViewEx.Columns.Add(new ColumnHeader() { Text = Strings.Nr, Width = 40 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [bar]", Strings.Pressure), Width = 100 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [mbar]", Strings.Main_uncertainty), Width = 120 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [mbar]", Strings.Resolution), Width = 100 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [mbar/year]", Strings.Drift_per_year), Width = 120 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [mbar]", Strings.Conditions), Width = 100 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [mbar]", Strings.Uncertainty_of_correction), Width = 160 }); + + textBoxes = new TextBox[listViewEx.Columns.Count]; + for (int i = 1; i < textBoxes.Length; i++) + { + this.Controls.Add(textBoxes[i] = new TextBox()); + } + + RefreshAll(); + } + + void RefreshAll() + { + listViewEx.Items.Clear(); + foreach (var uncrtnty in MeterEntity.Uncertainties) AddOneLVI(uncrtnty); + } + + void AddOneLVI(Uncertainty corr) + { + int nr = listViewEx.Items.Count + 1; + ListViewItem lvi = new ListViewItem(nr.ToString()); + lvi.Tag = corr; + lvi.SubItems.Add(corr.Measurement.ToString()); + lvi.SubItems.Add((1000 * corr.MainUncertainty).ToString()); + lvi.SubItems.Add((1000 * corr.Resolution).ToString()); + lvi.SubItems.Add((1000 * corr.DriftPerYr).ToString()); + lvi.SubItems.Add((1000 * corr.Conditions).ToString()); + lvi.SubItems.Add((1000 * corr.UncertaintyOfCorrection).ToString()); + + listViewEx.Items.Add(lvi); + } + + void listViewEx_SubItemClicked(object sender, SubItemEventArgs e) + { + if (unlocked && (e.SubItem >= 1) && (e.SubItem < listViewEx.Columns.Count)) + { + /// This is not the first column + listViewEx.StartEditing(textBoxes[e.SubItem], e.Item, e.SubItem); + } + } + + void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e) + { + if (ParseItem(e.Item, e.SubItem, e.DisplayText)) return; + + /// New value is NOK, revert the original text + e.DisplayText = e.Item.Text; + e.Cancel = true; + } + + /// + /// Parse text of a ListViewItem + /// + /// true = value parsed OK + bool ParseItem(ListViewItem item, int subItem, string strValue) + { + Uncertainty uncrtnty = item.Tag as Uncertainty; + double dblValue = 0; + if ((uncrtnty != null) && Utils.TryParseEDouble(strValue, out dblValue) && (dblValue >= 0)) + { + double inDefaultUnits = dblValue / 1000; + switch (subItem) + { + case 1: + uncrtnty.Measurement = (float)dblValue; + return true; + case 2: + uncrtnty.MainUncertainty = (float)inDefaultUnits; + return true; + case 3: + uncrtnty.Resolution = (float)inDefaultUnits; + return true; + case 4: + uncrtnty.DriftPerYr = (float)inDefaultUnits; + return true; + case 5: + uncrtnty.Conditions = (float)inDefaultUnits; + return true; + case 6: + uncrtnty.UncertaintyOfCorrection = (float)inDefaultUnits; + return true; + default: + return false; + } + } + else + { + return false; + } + } + + public void Unlock() + { + unlocked = true; + + if (listViewEx.SelectedItems.Count == 1) + { + int ix = listViewEx.SelectedIndices[0]; + listViewEx.Focus(); + listViewEx.Items[ix].Selected = true; + listViewEx.Items[ix].EnsureVisible(); + } + } + + public void OkBtnClicked() + { + } + + public void CancelBtnClicked() + { + } + + public void AddOne() + { + Uncertainty uncrtnty = new Uncertainty(); + MeterEntity.Uncertainties.Add(uncrtnty); + AddOneLVI(uncrtnty); + + listViewEx.Focus(); + listViewEx.SelectedItems.Clear(); + listViewEx.Items[listViewEx.Items.Count - 1].Selected = true; + listViewEx.Items[listViewEx.Items.Count - 1].EnsureVisible(); + } + + public void RemoveSelected() + { + if (listViewEx.SelectedItems.Count != 1) return; + + int removeItemNr = listViewEx.SelectedIndices[0]; + + Uncertainty selected = + (Uncertainty)listViewEx.SelectedItems[0].Tag; + if (selected.Id != 0) toBeRemoved.Add(selected); + MeterEntity.Corrections.RemoveAt(removeItemNr); + RefreshAll(); + + if (removeItemNr < listViewEx.Items.Count) + { + listViewEx.Focus(); + listViewEx.Items[removeItemNr].Selected = true; + listViewEx.Items[removeItemNr].EnsureVisible(); + } + else + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.None); + } + } + + public void MoveUpSelected() + { + } + + public void MoveDownSelected() + { + } + + /// + /// Event handler that indicates the selected item position + /// and updates 'Remove', 'Up' and 'Down' buttons in the parent dialog. + /// + private void listViewEx_SelectedIndexChanged(object sender, EventArgs e) + { + if (listViewEx.SelectedItems.Count != 1) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.None); + } + else if (listViewEx.Items.Count == 1) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.FirstAndLast); + } + else if (listViewEx.SelectedIndices[0] == 0) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.First); + } + else if (listViewEx.SelectedIndices[0] == (listViewEx.Items.Count - 1)) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.Last); + } + else + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.Middle); + } + } + + public string GetWarningsBeforeSaving(ref Dictionary renmInfo) + { + return string.Empty; + } + + public void UpdateRelatedItems(Dictionary renameInfo) + { + } + } +} diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgPressMeterTab.designer.cs b/TBF/UI/Bench/Uncertainties/UncertntDlgPressMeterTab.designer.cs new file mode 100644 index 000000000..cf3b0e69b --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgPressMeterTab.designer.cs @@ -0,0 +1,122 @@ +/// +/// Copyright (c) 2019 Senus Slovensko a.s. +/// +namespace TBF.UI.Bench.Uncertainties +{ + partial class UncertntDlgPressMeterTab + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.cmpntLabel = new System.Windows.Forms.Label(); + this.cmpntNameLabel = new System.Windows.Forms.Label(); + this.listViewEx = new global::Results.Forms.ListViewEx(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.cmpntLabel); + this.splitContainer1.Panel1.Controls.Add(this.cmpntNameLabel); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.listViewEx); + this.splitContainer1.Size = new System.Drawing.Size(420, 300); + this.splitContainer1.SplitterDistance = 40; + this.splitContainer1.TabIndex = 2; + // + // componentLabel + // + this.cmpntLabel.AutoSize = true; + this.cmpntLabel.Location = new System.Drawing.Point(14, 12); + this.cmpntLabel.Name = "componentLabel"; + this.cmpntLabel.Size = new System.Drawing.Size(64, 13); + this.cmpntLabel.TabIndex = 1; + this.cmpntLabel.Text = "Component:"; + // + // cmpntNameLabel + // + this.cmpntNameLabel.AutoSize = true; + this.cmpntNameLabel.Location = new System.Drawing.Point(97, 12); + this.cmpntNameLabel.Name = "cmpntNameLabel"; + this.cmpntNameLabel.Size = new System.Drawing.Size(88, 13); + this.cmpntNameLabel.TabIndex = 0; + this.cmpntNameLabel.Text = "componentName"; + // + // listViewEx + // + this.listViewEx.AllowColumnReorder = true; + this.listViewEx.Dock = System.Windows.Forms.DockStyle.Fill; + this.listViewEx.DoubleClickActivation = false; + this.listViewEx.FullRowSelect = true; + this.listViewEx.GridLines = true; + this.listViewEx.Location = new System.Drawing.Point(0, 0); + this.listViewEx.Name = "listViewEx"; + this.listViewEx.Size = new System.Drawing.Size(420, 256); + this.listViewEx.TabIndex = 0; + this.listViewEx.UseCompatibleStateImageBehavior = false; + this.listViewEx.View = System.Windows.Forms.View.Details; + this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged); + // + // UncertntDlgPressMeterTab + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.splitContainer1); + this.Name = "UncertntDlgPressMeterTab"; + this.Size = new System.Drawing.Size(420, 300); + this.Load += new System.EventHandler(this.UncertntDlgPressMeterTab_Load); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel1.PerformLayout(); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.Label cmpntLabel; + private System.Windows.Forms.Label cmpntNameLabel; + private global::Results.Forms.ListViewEx listViewEx; + + } +} diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgPressMeterTab.resx b/TBF/UI/Bench/Uncertainties/UncertntDlgPressMeterTab.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgPressMeterTab.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgScaleTab.cs b/TBF/UI/Bench/Uncertainties/UncertntDlgScaleTab.cs new file mode 100644 index 000000000..9ab096b78 --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgScaleTab.cs @@ -0,0 +1,269 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Windows.Forms; +using log4net; +using Config.Entities; +using Results.Forms; +using TBF.Resources; +using TBF.UI.Shared; + +namespace TBF.UI.Bench.Uncertainties +{ + public partial class UncertntDlgScaleTab : UserControl, IUncetaintiesDlgTab + { + static readonly ILog log = LogManager.GetLogger(typeof(UncertntDlgScaleTab)); + + /// + /// Component entity that has a list of 'measurement-correction' pairs + /// to be updated in the database on OK. + /// + public Component MeterEntity + { + get { return meterEntity; } + set { meterEntity = value; } + } + Component meterEntity; + + /// + /// Balance configuration (with buoyancy parameters) + /// + public BenchControl.GenericDevices.IScaleCfg ScaleCfg; + + /// + /// A list of 'measurement-correction' pairs to be deleted from the database on OK. + /// + public IList ToBeRemoved + { + get { return toBeRemoved; } + set { toBeRemoved = value; } + } + IList toBeRemoved; + + UncertaintiesDlg parent; + bool unlocked; + Control[] textBoxes; + + public UncertntDlgScaleTab() + { + InitializeComponent(); + toBeRemoved = new List(); + unlocked = false; + } + + private void UncertntDlgScaleTab_Load(object sender, System.EventArgs e) + { + if (meterEntity == null) return; + + parent = ParentForm as UncertaintiesDlg; + + /// Panel1 + cmpntLabel.Text = Strings.Component; + cmpntNameLabel.Text = meterEntity.Name; + + /// Panel2 + listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked); + listViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing); + + listViewEx.Columns.Add(new ColumnHeader() { Text = Strings.Nr, Width = 40 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [kg]", Strings.Mass), Width = 100 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [g]", Strings.Main_uncertainty), Width = 120 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [g]", Strings.Resolution), Width = 100 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [g/year]", Strings.Drift_per_year), Width = 120 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [g]", Strings.Conditions), Width = 100 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [g]", Strings.Uncertainty_of_correction), Width = 160 }); + + textBoxes = new TextBox[listViewEx.Columns.Count]; + for (int i = 1; i < textBoxes.Length; i++) + { + this.Controls.Add(textBoxes[i] = new TextBox()); + } + + RefreshAll(); + } + + void RefreshAll() + { + listViewEx.Items.Clear(); + foreach (var uncrtnty in MeterEntity.Uncertainties) AddOneLVI(uncrtnty); + } + + void AddOneLVI(Uncertainty corr) + { + int nr = listViewEx.Items.Count + 1; + ListViewItem lvi = new ListViewItem(nr.ToString()); + lvi.Tag = corr; + lvi.SubItems.Add(corr.Measurement.ToString()); + lvi.SubItems.Add((1000 * corr.MainUncertainty).ToString()); + lvi.SubItems.Add((1000 * corr.Resolution).ToString()); + lvi.SubItems.Add((1000 * corr.DriftPerYr).ToString()); + lvi.SubItems.Add((1000 * corr.Conditions).ToString()); + lvi.SubItems.Add((1000 * corr.UncertaintyOfCorrection).ToString()); + + listViewEx.Items.Add(lvi); + } + + void listViewEx_SubItemClicked(object sender, SubItemEventArgs e) + { + if (unlocked && (e.SubItem >= 1) && (e.SubItem < listViewEx.Columns.Count)) + { + /// This is not the first column + listViewEx.StartEditing(textBoxes[e.SubItem], e.Item, e.SubItem); + } + } + + void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e) + { + if (ParseItem(e.Item, e.SubItem, e.DisplayText)) return; + + /// New value is NOK, revert the original text + e.DisplayText = e.Item.Text; + e.Cancel = true; + } + + /// + /// Parse text of a ListViewItem + /// + /// true = value parsed OK + bool ParseItem(ListViewItem item, int subItem, string strValue) + { + Uncertainty uncrtnty = item.Tag as Uncertainty; + double dblValue = 0; + if ((uncrtnty != null) && Utils.TryParseEDouble(strValue, out dblValue) && (dblValue >= 0)) + { + double inDefaultUnits = dblValue / 1000; + switch (subItem) + { + case 1: + uncrtnty.Measurement = (float)dblValue; + return true; + case 2: + uncrtnty.MainUncertainty = (float)inDefaultUnits; + return true; + case 3: + uncrtnty.Resolution = (float)inDefaultUnits; + return true; + case 4: + uncrtnty.DriftPerYr = (float)inDefaultUnits; + return true; + case 5: + uncrtnty.Conditions = (float)inDefaultUnits; + return true; + case 6: + uncrtnty.UncertaintyOfCorrection = (float)inDefaultUnits; + return true; + default: + return false; + } + } + else + { + return false; + } + } + + public void Unlock() + { + unlocked = true; + + if (listViewEx.SelectedItems.Count == 1) + { + int ix = listViewEx.SelectedIndices[0]; + listViewEx.Focus(); + listViewEx.Items[ix].Selected = true; + listViewEx.Items[ix].EnsureVisible(); + } + } + + public void OkBtnClicked() + { + } + + public void CancelBtnClicked() + { + } + + public void AddOne() + { + Uncertainty uncrtnty = new Uncertainty(); + MeterEntity.Uncertainties.Add(uncrtnty); + AddOneLVI(uncrtnty); + + listViewEx.Focus(); + listViewEx.SelectedItems.Clear(); + listViewEx.Items[listViewEx.Items.Count - 1].Selected = true; + listViewEx.Items[listViewEx.Items.Count - 1].EnsureVisible(); + } + + public void RemoveSelected() + { + if (listViewEx.SelectedItems.Count != 1) return; + + int removeItemNr = listViewEx.SelectedIndices[0]; + + Uncertainty selected = listViewEx.SelectedItems[0].Tag as Uncertainty; + if ((selected != null) && (selected.Id != 0)) toBeRemoved.Add(selected); + MeterEntity.Uncertainties.RemoveAt(removeItemNr); + RefreshAll(); + + if (removeItemNr < listViewEx.Items.Count) + { + listViewEx.Focus(); + listViewEx.Items[removeItemNr].Selected = true; + listViewEx.Items[removeItemNr].EnsureVisible(); + } + else + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.None); + } + } + + public void MoveUpSelected() + { + } + + public void MoveDownSelected() + { + } + + /// + /// Event handler that indicates the selected item position + /// and updates 'Remove', 'Up' and 'Down' buttons in the parent dialog. + /// + private void listViewEx_SelectedIndexChanged(object sender, EventArgs e) + { + if (listViewEx.SelectedItems.Count != 1) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.None); + } + else if (listViewEx.Items.Count == 1) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.FirstAndLast); + } + else if (listViewEx.SelectedIndices[0] == 0) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.First); + } + else if (listViewEx.SelectedIndices[0] == (listViewEx.Items.Count - 1)) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.Last); + } + else + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.Middle); + } + } + + public string GetWarningsBeforeSaving(ref Dictionary renmInfo) + { + return string.Empty; + } + + public void UpdateRelatedItems(Dictionary renameInfo) + { + } + } +} diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgScaleTab.designer.cs b/TBF/UI/Bench/Uncertainties/UncertntDlgScaleTab.designer.cs new file mode 100644 index 000000000..6cf60c138 --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgScaleTab.designer.cs @@ -0,0 +1,121 @@ +/// +/// Copyright (c) 2019 Senus Slovensko a.s. +/// +namespace TBF.UI.Bench.Uncertainties +{ + partial class UncertntDlgScaleTab + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.listViewEx = new global::Results.Forms.ListViewEx(); + this.cmpntLabel = new System.Windows.Forms.Label(); + this.cmpntNameLabel = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.cmpntLabel); + this.splitContainer1.Panel1.Controls.Add(this.cmpntNameLabel); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.listViewEx); + this.splitContainer1.Size = new System.Drawing.Size(668, 400); + this.splitContainer1.SplitterDistance = 40; + this.splitContainer1.TabIndex = 1; + // + // listViewEx + // + this.listViewEx.AllowColumnReorder = true; + this.listViewEx.Dock = System.Windows.Forms.DockStyle.Fill; + this.listViewEx.DoubleClickActivation = false; + this.listViewEx.FullRowSelect = true; + this.listViewEx.GridLines = true; + this.listViewEx.Location = new System.Drawing.Point(0, 0); + this.listViewEx.Name = "listViewEx"; + this.listViewEx.Size = new System.Drawing.Size(668, 356); + this.listViewEx.TabIndex = 0; + this.listViewEx.UseCompatibleStateImageBehavior = false; + this.listViewEx.View = System.Windows.Forms.View.Details; + this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged); + // + // componentLabel + // + this.cmpntLabel.AutoSize = true; + this.cmpntLabel.Location = new System.Drawing.Point(14, 12); + this.cmpntLabel.Name = "componentLabel"; + this.cmpntLabel.Size = new System.Drawing.Size(64, 13); + this.cmpntLabel.TabIndex = 3; + this.cmpntLabel.Text = "Component:"; + // + // cmpntNameLabel + // + this.cmpntNameLabel.AutoSize = true; + this.cmpntNameLabel.Location = new System.Drawing.Point(97, 12); + this.cmpntNameLabel.Name = "cmpntNameLabel"; + this.cmpntNameLabel.Size = new System.Drawing.Size(88, 13); + this.cmpntNameLabel.TabIndex = 2; + this.cmpntNameLabel.Text = "componentName"; + // + // UncertntDlgScaleTab + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.splitContainer1); + this.Name = "UncertntDlgScaleTab"; + this.Size = new System.Drawing.Size(668, 400); + this.Load += new System.EventHandler(this.UncertntDlgScaleTab_Load); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel1.PerformLayout(); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainer1; + private global::Results.Forms.ListViewEx listViewEx; + private System.Windows.Forms.Label cmpntLabel; + private System.Windows.Forms.Label cmpntNameLabel; + } +} diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgScaleTab.resx b/TBF/UI/Bench/Uncertainties/UncertntDlgScaleTab.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgScaleTab.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgTempMeterTab.cs b/TBF/UI/Bench/Uncertainties/UncertntDlgTempMeterTab.cs new file mode 100644 index 000000000..e638f15b3 --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgTempMeterTab.cs @@ -0,0 +1,264 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Windows.Forms; +using log4net; +using Config.Entities; +using Results.Forms; +using TBF.Resources; +using TBF.UI.Shared; + +namespace TBF.UI.Bench.Uncertainties +{ + public partial class UncertntDlgTempMeterTab : UserControl, IUncetaintiesDlgTab + { + static readonly ILog log = LogManager.GetLogger(typeof(UncertntDlgTempMeterTab)); + + /// + /// Component entity that has a list of 'measurement-correction' pairs + /// to be updated in the database on OK. + /// + Component meterEntity; + public Component MeterEntity + { + get { return meterEntity; } + set { meterEntity = value; } + } + + /// + /// A list of 'measurement-correction' pairs to be deleted from the database on OK. + /// + public IList ToBeRemoved + { + get { return toBeRemoved; } + set { toBeRemoved = value; } + } + IList toBeRemoved; + + UncertaintiesDlg parent; + bool unlocked; + Control[] textBoxes; + + public UncertntDlgTempMeterTab() + { + InitializeComponent(); + toBeRemoved = new List(); + } + + private void UncertntDlgTempMeterTab_Load(object sender, System.EventArgs e) + { + if (meterEntity == null) return; + + parent = ParentForm as UncertaintiesDlg; + + /// Panel1 + cmpntLabel.Text = Strings.Component; + cmpntNameLabel.Text = meterEntity.Name; + + /// Panel2 + listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked); + listViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing); + + listViewEx.Columns.Add(new ColumnHeader() { Text = Strings.Nr, Width = 40 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [°C]", Strings.Temperature), Width = 100 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [1/1000 °C]", Strings.Main_uncertainty), Width = 120 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [1/1000 °C]", Strings.Resolution), Width = 100 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [1/1000 °C/year]", Strings.Drift_per_year), Width = 120 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [1/1000 °C]", Strings.Conditions), Width = 100 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [1/1000 °C]", Strings.Uncertainty_of_correction), Width = 160 }); + + textBoxes = new TextBox[listViewEx.Columns.Count]; + for (int i = 1; i < textBoxes.Length; i++) + { + this.Controls.Add(textBoxes[i] = new TextBox()); + } + + RefreshAll(); + } + + void RefreshAll() + { + listViewEx.Items.Clear(); + foreach (var uncrtnty in MeterEntity.Uncertainties) AddOneLVI(uncrtnty); + } + + void AddOneLVI(Uncertainty corr) + { + int nr = listViewEx.Items.Count + 1; + ListViewItem lvi = new ListViewItem(nr.ToString()); + lvi.Tag = corr; + lvi.SubItems.Add(corr.Measurement.ToString()); + lvi.SubItems.Add((1000 * corr.MainUncertainty).ToString()); + lvi.SubItems.Add((1000 * corr.Resolution).ToString()); + lvi.SubItems.Add((1000 * corr.DriftPerYr).ToString()); + lvi.SubItems.Add((1000 * corr.Conditions).ToString()); + lvi.SubItems.Add((1000 * corr.UncertaintyOfCorrection).ToString()); + + listViewEx.Items.Add(lvi); + } + + void listViewEx_SubItemClicked(object sender, SubItemEventArgs e) + { + if (unlocked && (e.SubItem >= 1) && (e.SubItem < listViewEx.Columns.Count)) + { + /// This is not the first column + listViewEx.StartEditing(textBoxes[e.SubItem], e.Item, e.SubItem); + } + } + + void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e) + { + if (ParseItem(e.Item, e.SubItem, e.DisplayText)) return; + + /// New value is NOK, revert the original text + e.DisplayText = e.Item.Text; + e.Cancel = true; + } + + /// + /// Parse text of a ListViewItem + /// + /// true = value parsed OK + bool ParseItem(ListViewItem item, int subItem, string strValue) + { + Uncertainty uncrtnty = item.Tag as Uncertainty; + double dblValue = 0; + if ((uncrtnty != null) && Utils.TryParseEDouble(strValue, out dblValue) && (dblValue >= 0)) + { + double inDefaultUnits = dblValue / 1000; + switch (subItem) + { + case 1: + uncrtnty.Measurement = (float)dblValue; + return true; + case 2: + uncrtnty.MainUncertainty = (float)inDefaultUnits; + return true; + case 3: + uncrtnty.Resolution = (float)inDefaultUnits; + return true; + case 4: + uncrtnty.DriftPerYr = (float)inDefaultUnits; + return true; + case 5: + uncrtnty.Conditions = (float)inDefaultUnits; + return true; + case 6: + uncrtnty.UncertaintyOfCorrection = (float)inDefaultUnits; + return true; + default: + return false; + } + } + else + { + return false; + } + } + + public void Unlock() + { + unlocked = true; + + if (listViewEx.SelectedItems.Count == 1) + { + int ix = listViewEx.SelectedIndices[0]; + listViewEx.Focus(); + listViewEx.Items[ix].Selected = true; + listViewEx.Items[ix].EnsureVisible(); + } + } + + public void OkBtnClicked() + { + } + + public void CancelBtnClicked() + { + } + + public void AddOne() + { + Uncertainty uncrtnty = new Uncertainty(); + MeterEntity.Uncertainties.Add(uncrtnty); + AddOneLVI(uncrtnty); + + listViewEx.Focus(); + listViewEx.SelectedItems.Clear(); + listViewEx.Items[listViewEx.Items.Count - 1].Selected = true; + listViewEx.Items[listViewEx.Items.Count - 1].EnsureVisible(); + } + + public void RemoveSelected() + { + if (listViewEx.SelectedItems.Count != 1) return; + + int removeItemNr = listViewEx.SelectedIndices[0]; + + Uncertainty selected = + (Uncertainty)listViewEx.SelectedItems[0].Tag; + if (selected.Id != 0) toBeRemoved.Add(selected); + MeterEntity.Corrections.RemoveAt(removeItemNr); + RefreshAll(); + + if (removeItemNr < listViewEx.Items.Count) + { + listViewEx.Focus(); + listViewEx.Items[removeItemNr].Selected = true; + listViewEx.Items[removeItemNr].EnsureVisible(); + } + else + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.None); + } + } + + public void MoveUpSelected() + { + } + + public void MoveDownSelected() + { + } + + /// + /// Event handler that indicates the selected item position + /// and updates 'Remove', 'Up' and 'Down' buttons in the parent dialog. + /// + private void listViewEx_SelectedIndexChanged(object sender, EventArgs e) + { + if (listViewEx.SelectedItems.Count != 1) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.None); + } + else if (listViewEx.Items.Count == 1) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.FirstAndLast); + } + else if (listViewEx.SelectedIndices[0] == 0) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.First); + } + else if (listViewEx.SelectedIndices[0] == (listViewEx.Items.Count - 1)) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.Last); + } + else + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.Middle); + } + } + + public string GetWarningsBeforeSaving(ref Dictionary renmInfo) + { + return string.Empty; + } + + public void UpdateRelatedItems(Dictionary renameInfo) + { + } + } +} diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgTempMeterTab.designer.cs b/TBF/UI/Bench/Uncertainties/UncertntDlgTempMeterTab.designer.cs new file mode 100644 index 000000000..a79bd8a60 --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgTempMeterTab.designer.cs @@ -0,0 +1,122 @@ +/// +/// Copyright (c) 2019 Senus Slovensko a.s. +/// +namespace TBF.UI.Bench.Uncertainties +{ + partial class UncertntDlgTempMeterTab + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.cmpntLabel = new System.Windows.Forms.Label(); + this.cmpntNameLabel = new System.Windows.Forms.Label(); + this.listViewEx = new global::Results.Forms.ListViewEx(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.cmpntLabel); + this.splitContainer1.Panel1.Controls.Add(this.cmpntNameLabel); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.listViewEx); + this.splitContainer1.Size = new System.Drawing.Size(420, 300); + this.splitContainer1.SplitterDistance = 40; + this.splitContainer1.TabIndex = 2; + // + // componentLabel + // + this.cmpntLabel.AutoSize = true; + this.cmpntLabel.Location = new System.Drawing.Point(14, 12); + this.cmpntLabel.Name = "componentLabel"; + this.cmpntLabel.Size = new System.Drawing.Size(64, 13); + this.cmpntLabel.TabIndex = 1; + this.cmpntLabel.Text = "Component:"; + // + // cmpntNameLabel + // + this.cmpntNameLabel.AutoSize = true; + this.cmpntNameLabel.Location = new System.Drawing.Point(97, 12); + this.cmpntNameLabel.Name = "cmpntNameLabel"; + this.cmpntNameLabel.Size = new System.Drawing.Size(88, 13); + this.cmpntNameLabel.TabIndex = 0; + this.cmpntNameLabel.Text = "componentName"; + // + // listViewEx + // + this.listViewEx.AllowColumnReorder = true; + this.listViewEx.Dock = System.Windows.Forms.DockStyle.Fill; + this.listViewEx.DoubleClickActivation = false; + this.listViewEx.FullRowSelect = true; + this.listViewEx.GridLines = true; + this.listViewEx.Location = new System.Drawing.Point(0, 0); + this.listViewEx.Name = "listViewEx"; + this.listViewEx.Size = new System.Drawing.Size(420, 256); + this.listViewEx.TabIndex = 0; + this.listViewEx.UseCompatibleStateImageBehavior = false; + this.listViewEx.View = System.Windows.Forms.View.Details; + this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged); + // + // UncertntDlgTempMeterTab + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.splitContainer1); + this.Name = "UncertntDlgTempMeterTab"; + this.Size = new System.Drawing.Size(420, 300); + this.Load += new System.EventHandler(this.UncertntDlgTempMeterTab_Load); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel1.PerformLayout(); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.Label cmpntLabel; + private System.Windows.Forms.Label cmpntNameLabel; + private global::Results.Forms.ListViewEx listViewEx; + + } +} diff --git a/TBF/UI/Bench/Uncertainties/UncertntDlgTempMeterTab.resx b/TBF/UI/Bench/Uncertainties/UncertntDlgTempMeterTab.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TBF/UI/Bench/Uncertainties/UncertntDlgTempMeterTab.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file