using System; using System.Collections.Generic; using System.Windows.Forms; using TBF.BenchControl; using TBF.BenchControl.Generic; using TBF.UiControls; using TBF.Resources; namespace TBF { public partial class ComponentParametersDlg : Form { public IComponentCfgCtrl ComponentCfgCtrl; public IComponentCfg Config { get { if (ComponentCfgCtrl == null) return null; return ComponentCfgCtrl.Config; } } /// /// List of components (=component configuration instances) /// public IList TbfComponents; public ComponentParametersDlg() { InitializeComponent(); /// SharedDlgButtons configuration sharedButtons.RequiredGroupMembership = Grp.GID.Metrologists; sharedButtons.OptionalButtons = SharedButtons.Buttons.None; sharedButtons.Unlocked += Unlock; sharedButtons.OKClicked += okButton_Click; sharedButtons.CancelClicked += cancelButton_Click; } private void ComponentCfgForm_Load(object sender, EventArgs e) { Text = Strings.Properties; if (ComponentCfgCtrl != null) { splitContainer.Panel1.Controls.Add((UserControl)ComponentCfgCtrl); } } private void Unlock(object sender, EventArgs e) { ComponentCfgCtrl.Unlock(); } public CfgVerifyFlags VerifyCfg(ref string message) { if (ComponentCfgCtrl == null) return CfgVerifyFlags.None; /// Nothing to verify -> OK return ComponentCfgCtrl.VerifyCfg(ref message); } private void okButton_Click(object sender, EventArgs e) { string message = string.Empty; CfgVerifyFlags flags = VerifyCfg(ref message); if ((flags & CfgVerifyFlags.Error) == CfgVerifyFlags.Error) { MessageBox.Show(Strings.Please_change_the_following_settings + message, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (ComponentCfgCtrl != null) ComponentCfgCtrl.UpdateCfg(); DialogResult = DialogResult.OK; Close(); return; } private void cancelButton_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; Close(); return; } } }