using DevExpress.XtraEditors; using System; using System.Threading.Tasks; using System.Windows.Forms; namespace IStation.WinFrmUI { /// /// 设置使用状态 /// public partial class SetUseStatusDlg : XtraForm { public SetUseStatusDlg() { InitializeComponent(); this.IconOptions.Icon = Properties.Resources.App; this.layoutControl1.SetupLayoutControl(); } /// /// 回调函数 /// public event Func> ReloadDataEvent; /// /// 绑定数据 /// public void SetBindingData(Model.eUseStatus UseStatus) { switch (UseStatus) { case Model.eUseStatus.Enable: this.radioGroup1.SelectedIndex = 1; break; case Model.eUseStatus.Disable: this.radioGroup1.SelectedIndex = 0; break; default: break; } } //确定 private async void btnOk_Click(object sender, EventArgs e) { var status = Model.eUseStatus.Enable; if (this.radioGroup1.SelectedIndex == 0) status = Model.eUseStatus.Disable; else if (this.radioGroup1.SelectedIndex == 1) status = Model.eUseStatus.Enable; if (this.ReloadDataEvent != null) { var result = this.ReloadDataEvent.Invoke(status); if (await result) { XtraMessageBox.Show("更新成功!"); } else { XtraMessageBox.Show("更新失败!"); return; } } this.DialogResult = DialogResult.OK; this.Close(); } } }