tbf/TBF/UI/Bench/Metrology/MetrologyDlgBuoyancyTab.cs

117 lines
2.9 KiB
C#
Raw Normal View History

///
/// Copyright (c) 2013-2023 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.Metrology
{
public partial class MetrologyDlgBuoyancyTab : UserControl, IMetrologyDlgTab
{
static readonly ILog log = LogManager.GetLogger(typeof(MetrologyDlgBuoyancyTab));
/// <summary>
/// Component entity that has a list of 'measurement-correction' pairs
/// to be updated in the database on OK.
/// </summary>
public Component MeterEntity { get; set; }
/// <summary>
/// Buoyancy configuration
/// </summary>
2021-10-26 09:23:57 +00:00
public Rig.DataContainers.Buoyancy.ComponentCfg BuoyancyCfg;
/// <summary>
/// A list of 'measurement-correction' pairs to be deleted from the database on OK.
/// </summary>
public IList<MeasurementCorrection> ToBeRemoved { get; set; }
MetrologyDlg parent;
bool valuesModified;
public MetrologyDlgBuoyancyTab()
{
InitializeComponent();
ToBeRemoved = new List<MeasurementCorrection>();
valuesModified = false;
}
private void MetrologyDlgBuoyancyTab_Load(object sender, System.EventArgs e)
{
if (MeterEntity == null) return;
parent = ParentForm as MetrologyDlg;
/// Panel1
buoyancyLabel.Text = "Buoyancy";
/// Panel2
RefreshAll();
}
void RefreshAll()
{
buoyancyTextBox.Text = BuoyancyCfg.Buoyancy.ToString();
}
public void Unlock()
{
buoyancyTextBox.Enabled = true;
}
public void OkBtnClicked()
{
if (BuoyancyCfg != null)
{
try
{
if (valuesModified)
{
Config.Data.Buoyancy = BuoyancyCfg.Buoyancy = Utils.ParseUDouble(buoyancyTextBox.Text);
}
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<string, string> renmInfo)
{
return string.Empty;
}
public void UpdateRelatedItems(Dictionary<string, string> renameInfo)
{
}
private void buoyancyTextBox_TextChanged(object sender, EventArgs e)
{
valuesModified = true;
}
public void SaveEntityToDB(NHibernate.ISession session)
{
session.SaveOrUpdate(MeterEntity);
}
}
}