/// /// Copyright (c) 2018 Sensus Slovensko a.s. /// using System; using System.Windows.Forms; using Config.Entities; using TBF.BenchControl.Generic; using TBF.UI.Bench.Components; namespace TBF.BenchControl.RegisterReaders.KPackE.DataEntryForRadio { public partial class EntryFormCfgCtrl : UserControl, IComponentCfgCtrl { ComponentParametersDlg parent; 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(); parent = ParentForm as ComponentParametersDlg; if (parent == null) return; if (parent.CmpntEntities != null) { foreach (var cmpnt in parent.CmpntEntities) { if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Radio.Factory) { radioComboBox.Items.Add(cmpnt.Name); } } } Redraw(); } void Localize() { } 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; radioComboBox.Text = config.Radio; } public void Unlock() { nameTextBox.Enabled = true; radioComboBox.Enabled = true; } public CfgUpdateFlags VerifyCfg(ref string message) { CfgUpdateFlags flags = CfgUpdateFlags.None; if (!radioComboBox.Items.Contains(radioComboBox.Text)) { flags |= CfgUpdateFlags.Error; message += Environment.NewLine + "Invalid 'Radio'"; } 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.Radio = radioComboBox.Text; return flags; } } }