tbf/TBF/BenchControl/DataEntry/Combined/EntryFormCfgCtrl.cs

85 lines
1.9 KiB
C#

///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using Common;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.DataEntry.Combined
{
public partial class EntryFormCfgCtrl : UserControl, IComponentCfgCtrl
{
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)
{
Localize();
Redraw();
}
void Localize()
{
showCycleEndFormCheckBox.Text = Strings.Show_cycle_end_form;
remarkEnabledCheckBox.Text = Strings.Enable_Remark;
}
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;
showCycleEndFormCheckBox.Checked = config.ShowCycleEndForm;
remarkEnabledCheckBox.Checked = config.RemarkEnabled;
}
public void Unlock()
{
nameTextBox.Enabled = true;
showCycleEndFormCheckBox.Enabled = true;
remarkEnabledCheckBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
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;
config.ShowCycleEndForm = showCycleEndFormCheckBox.Checked;
config.RemarkEnabled = remarkEnabledCheckBox.Checked;
return flags;
}
}
}