namespace Yw.WinFrmUI { public partial class SetHydroPipeDlg : DevExpress.XtraEditors.XtraForm { public SetHydroPipeDlg() { 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.HydroPipeInfo visual) { var allParterList = visual == null ? null : new List() { visual }; this.SetBindingData(allParterList); } /// /// 绑定数据 /// public void SetBindingData(List allVisualList) { _allVisualList = allVisualList; if (_allVisualList != null && _allVisualList.Count == 1) { var visual = _allVisualList.First(); this.txtMaterial.EditValue = visual.Material; this.txtDiameter.EditValue = visual.Diameter; this.txtLength.EditValue = visual.Length; this.txtRoughness.EditValue = visual.Roughness; this.txtMinorLoss.EditValue = visual.MinorLoss; } } //确定 private void GeneralOkAndCancelCtrl1_OkEvent() { if (_allVisualList == null || _allVisualList.Count < 1) { return; } var material = this.txtMaterial.Text.Trim(); double? diameter = this.txtDiameter.EditValue == null ? null : double.Parse(this.txtDiameter.EditValue.ToString()); double? length = this.txtLength.EditValue == null ? null : double.Parse(this.txtLength.EditValue.ToString()); double? roughness = this.txtRoughness.EditValue == null ? null : double.Parse(this.txtRoughness.EditValue.ToString()); double? minorLoss = this.txtMinorLoss.EditValue == null ? null : double.Parse(this.txtMinorLoss.EditValue.ToString()); _allVisualList.ForEach(x => { if (!string.IsNullOrEmpty(material)) { x.Material = material; } if (diameter.HasValue) { x.Diameter = diameter.Value; } if (length.HasValue) { x.Length = length.Value; } if (roughness.HasValue) { x.Roughness = roughness.Value; } if (minorLoss.HasValue) { x.MinorLoss = minorLoss.Value; } }); this.ReloadDataEvent?.Invoke(_allVisualList); this.DialogResult = DialogResult.OK; this.Close(); } } }