/// /// Copyright (c) 2015-2017 Sensus Metering Systems /// using System; using System.Net; using System.Net.Sockets; using System.Windows.Forms; using log4net; using TBF.BenchControl.Generic; using TBF.Resources; using Config.Entities; namespace TBF.BenchControl.TestMethods.GenesisCommunication.GenesisHead { public partial class GenesisHeadCfgCtrl : UserControl, IComponentCfgCtrl { static readonly ILog log = LogManager.GetLogger(typeof(GenesisHeadCfgCtrl)); public bool ShowMore { get { return false; } } GenesisHeadCfg config; public IComponentCfg Config { get { return config as IComponentCfg; } set { config = value as GenesisHeadCfg; Redraw(); } } public GenesisHeadCfgCtrl() { InitializeComponent(); } private void WaterMeterCfgCtrl_Load(object sender, EventArgs e) { nameLabel.Text = Strings.Name; classNameLabel.Text = config.Factory.ClassName; Redraw(); } public void Closing() { } void Redraw() { if (config == null) return; /// Control was not loaded, settings were not changed nameTextBox.Text = config.Name; } public void Unlock() { nameTextBox.Enabled = true; slotNrTextBox.Enabled = true; } public CfgUpdateFlags VerifyCfg(ref string message) { CfgUpdateFlags flags = CfgUpdateFlags.None; int dummy; if (!int.TryParse(slotNrTextBox.Text, out dummy) || dummy < 1 || dummy > 7) { flags |= CfgUpdateFlags.Error; message += Environment.NewLine + string.Format(Strings.Invalid_0, muxBoardNrLabel.Text); } 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.SlotNr = int.Parse(slotNrTextBox.Text); return flags; } } }