/// /// Copyright (c) 2017 Sensus Metering Systems /// using System; using System.Windows.Forms; using Config.Entities; using TBF.BenchControl.Generic; namespace TBF.BenchControl.Dummy.RegulValve { public partial class RegulValveCfgCtrl : UserControl, IComponentCfgCtrl { ComponentParametersDlg parent; public bool ShowMore { get { return true; } } RegulValveCfg config; public IComponentCfg Config { get { return config as IComponentCfg; } set { config = value as RegulValveCfg; Redraw(); } } public RegulValveCfgCtrl() { InitializeComponent(); } private void RegulationValveCfgCtrl_Load(object sender, EventArgs e) { categoryComboBox.Items.Add(ValveCategory.All.ToString()); categoryComboBox.Items.Add(ValveCategory.Feeding.ToString()); categoryComboBox.Items.Add(ValveCategory.Output.ToString()); 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; categoryComboBox.Text = config.Category.ToString(); } public void Unlock() { nameTextBox.Enabled = true; categoryComboBox.Enabled = true; } public CfgUpdateFlags VerifyCfg(ref string message) { CfgUpdateFlags flags = CfgUpdateFlags.None; if (!categoryComboBox.Text.Equals(ValveCategory.All.ToString()) && !categoryComboBox.Text.Equals(ValveCategory.Feeding.ToString()) && !categoryComboBox.Text.Equals(ValveCategory.Output.ToString())) { flags |= CfgUpdateFlags.Error; message += Environment.NewLine + "Invalid 'Category'"; } return flags; } public CfgUpdateFlags UpdateCfg() { CfgUpdateFlags flags = CfgUpdateFlags.None; if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed /// if (!config.Name.Equals(nameTextBox.Text)) { config.Name = nameTextBox.Text; flags |= CfgUpdateFlags.RestartRqrd; } ValveCategory newCategory; if (categoryComboBox.Text.Equals(ValveCategory.All.ToString())) newCategory = ValveCategory.All; else if (categoryComboBox.Text.Equals(ValveCategory.Feeding.ToString())) newCategory = ValveCategory.Feeding; else if (categoryComboBox.Text.Equals(ValveCategory.Bench.ToString())) newCategory = ValveCategory.Bench; else if (categoryComboBox.Text.Equals(ValveCategory.Output.ToString())) newCategory = ValveCategory.Output; else newCategory = ValveCategory.None; if (newCategory != config.Category) { config.Category = newCategory; flags |= CfgUpdateFlags.RestartRqrd; } return flags; } } }