142 lines
3.3 KiB
C#
142 lines
3.3 KiB
C#
///
|
|
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Windows.Forms;
|
|
using log4net;
|
|
using Config.Entities;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.UiControls
|
|
{
|
|
public partial class MetrologyDlgDensityTab : UserControl, IMetrologyDlgTab
|
|
{
|
|
static readonly ILog log = LogManager.GetLogger(typeof(MetrologyDlgDensityTab));
|
|
|
|
/// <summary>
|
|
/// Component entity that has a list of 'measurement-correction' pairs
|
|
/// to be updated in the database on OK.
|
|
/// </summary>
|
|
public Component MeterEntity
|
|
{
|
|
get { return null; }
|
|
set { }
|
|
}
|
|
|
|
/// <summary>
|
|
/// A list of 'measurement-correction' pairs to be deleted from the database on OK.
|
|
/// </summary>
|
|
public IList<MeasurementCorrection> ToBeRemoved
|
|
{
|
|
get { return toBeRemoved; }
|
|
set { toBeRemoved = value; }
|
|
}
|
|
IList<MeasurementCorrection> toBeRemoved;
|
|
|
|
MetrologyDlg parent;
|
|
bool unlocked;
|
|
|
|
public MetrologyDlgDensityTab()
|
|
{
|
|
InitializeComponent();
|
|
toBeRemoved = new List<MeasurementCorrection>();
|
|
unlocked = false;
|
|
}
|
|
|
|
private void MetrologyDlgDensityTab_Load(object sender, System.EventArgs e)
|
|
{
|
|
parent = ParentForm as MetrologyDlg;
|
|
|
|
/// 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 = Program.LocalSettings.RealDensity.ToString();
|
|
temperatureTextBox.Text = Program.LocalSettings.AtTemperature.ToString();
|
|
densityCorrTextBox.Text = TBF.BenchControl.Formulas.DensityCorrection(Program.LocalSettings.RealDensity, Program.LocalSettings.AtTemperature).ToString();
|
|
}
|
|
|
|
public void Unlock()
|
|
{
|
|
unlocked = true;
|
|
|
|
densityTextBox.Enabled = true;
|
|
temperatureTextBox.Enabled = true;
|
|
}
|
|
|
|
public void OkBtnClicked()
|
|
{
|
|
double tmp;
|
|
if (Utils.TryParseUDouble(densityTextBox.Text, out tmp))
|
|
{
|
|
Program.LocalSettings.RealDensity = tmp;
|
|
}
|
|
if (Utils.TryParseUDouble(temperatureTextBox.Text, out tmp))
|
|
{
|
|
Program.LocalSettings.AtTemperature = tmp;
|
|
}
|
|
Program.LocalSettings.Save();
|
|
}
|
|
|
|
public void CancelBtnClicked()
|
|
{
|
|
}
|
|
|
|
public void AddOne()
|
|
{
|
|
}
|
|
|
|
public void RemoveSelected()
|
|
{
|
|
}
|
|
|
|
public void MoveUpSelected()
|
|
{
|
|
}
|
|
|
|
public void MoveDownSelected()
|
|
{
|
|
}
|
|
|
|
public string GetWarningsBeforeSaving(ref Dictionary<string, string> renmInfo)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
public void UpdateRelatedItems(Dictionary<string, string> 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 = TBF.BenchControl.Formulas.DensityCorrection(density, temp).ToString();
|
|
}
|
|
}
|
|
}
|
|
}
|