namespace Yw.WinFrmUI { public partial class SetHydroValveDlg : DevExpress.XtraEditors.XtraForm { public SetHydroValveDlg() { InitializeComponent(); this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; this.layoutControl1.SetupLayoutControl(); this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent; } /// /// 重载数据事件 /// public event Action> ReloadDataEvent; //所有构件列表 private List _allVisualList = null; /// /// 绑定数据 /// public void SetBindingData(Yw.Model.HydroValveInfo visial) { var allParterList = visial == null ? null : new List() { visial }; this.SetBindingData(allParterList); } /// /// 绑定数据 /// public void SetBindingData(List allParterList) { _allVisualList = allParterList; if (_allVisualList != null && _allVisualList.Count == 1) { var parter = _allVisualList.First(); this.imgCmbLinkStatus.EditValue = parter.LinkStatus; this.txtMaterial.EditValue = parter.Material; this.txtDiameter.EditValue = parter.Diameter; this.txtMinorLoss.EditValue = parter.MinorLoss; } } //确定 private void GeneralOkAndCancelCtrl1_OkEvent() { if (_allVisualList == null || _allVisualList.Count < 1) { return; } var linkStatus = this.imgCmbLinkStatus.EditValue == null ? null : this.imgCmbLinkStatus.EditValue.ToString(); var material = string.IsNullOrEmpty(this.txtMaterial.Text.Trim()) ? null : this.txtMaterial.Text.Trim(); double? diameter = this.txtDiameter.EditValue == null ? null : double.Parse(this.txtDiameter.EditValue.ToString()); double? minorLoss = this.txtMinorLoss.EditValue == null ? null : double.Parse(this.txtMinorLoss.EditValue.ToString()); _allVisualList.ForEach(x => { if (!string.IsNullOrEmpty(linkStatus)) { x.LinkStatus = linkStatus; } if (!string.IsNullOrEmpty(material)) { x.Material = material; } if (diameter.HasValue) { x.Diameter = diameter.Value; } if (minorLoss.HasValue) { x.MinorLoss = minorLoss.Value; } if (x.LinkStatus == Yw.Hydro.ValveStatus.Closed) { x.OpeningDegree = 0; } }); this.ReloadDataEvent?.Invoke(_allVisualList); this.DialogResult = DialogResult.OK; this.Close(); } } }