86 lines
1.9 KiB
C#
86 lines
1.9 KiB
C#
///
|
|
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.Windows.Forms;
|
|
using log4net;
|
|
using TBF.BenchControl.Generic;
|
|
|
|
namespace TBF.BenchControl.DataEntry.Combined
|
|
{
|
|
public partial class EntryFormCfgCtrl : UserControl, IComponentCfgCtrl
|
|
{
|
|
static readonly ILog log = LogManager.GetLogger(typeof(EntryFormCfgCtrl));
|
|
|
|
public bool ShowMore { get { return false; } }
|
|
|
|
EntryFormCfg config;
|
|
public IComponentCfg Config
|
|
{
|
|
get { return config as IComponentCfg; }
|
|
set
|
|
{
|
|
config = value as EntryFormCfg;
|
|
Redraw();
|
|
}
|
|
}
|
|
|
|
public EntryFormCfgCtrl()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void EntryFormCfgCtrl_Load(object sender, EventArgs e)
|
|
{
|
|
unitsComboBox.Items.Add("m3");
|
|
unitsComboBox.Items.Add("liter");
|
|
Redraw();
|
|
}
|
|
|
|
public void Closing()
|
|
{
|
|
}
|
|
|
|
void Redraw()
|
|
{
|
|
if (config == null) return; /// Control was not loaded, settings were not changed
|
|
classNameLabel.Text = config.Factory.ClassName;
|
|
nameTextBox.Text = config.Name;
|
|
unitsComboBox.Text = (config.Units == Entities.UnitsVolume.CubicMtr) ? "m3" : "liter";
|
|
}
|
|
|
|
public void Unlock()
|
|
{
|
|
nameTextBox.Enabled = true;
|
|
unitsComboBox.Enabled = true;
|
|
}
|
|
|
|
public CfgUpdateFlags VerifyCfg(ref string message)
|
|
{
|
|
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
|
if (unitsComboBox.Text != "m3" && unitsComboBox.Text != "liter")
|
|
{
|
|
message = "Units for volume should be liter or m3";
|
|
flags = CfgUpdateFlags.Error;
|
|
}
|
|
return flags;
|
|
}
|
|
|
|
public CfgUpdateFlags UpdateCfg()
|
|
{
|
|
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
|
|
|
|
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
|
|
|
config.Name = nameTextBox.Text;
|
|
|
|
if (unitsComboBox.Text == "m3")
|
|
config.Units = Entities.UnitsVolume.CubicMtr;
|
|
else
|
|
config.Units = Entities.UnitsVolume.Liter;
|
|
|
|
return flags;
|
|
}
|
|
}
|
|
}
|