| | |
| | | this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; |
| | | this.layoutControl1.SetupLayoutControl(); |
| | | this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent; |
| | | InitialLinkStatus(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | public event Action<List<Yw.Model.HydroPipeInfo>> ReloadDataEvent; |
| | | |
| | | //所有部件列表 |
| | | private List<Yw.Model.HydroPipeInfo> _allParterList = null; |
| | | private List<Yw.Model.HydroPipeInfo> _allVisualList = null; |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | public void SetBindingData(Yw.Model.HydroPipeInfo parter) |
| | | public void SetBindingData(Yw.Model.HydroPipeInfo visual) |
| | | { |
| | | var allParterList = parter == null ? null : new List<Yw.Model.HydroPipeInfo>() { parter }; |
| | | var allParterList = visual == null ? null : new List<Yw.Model.HydroPipeInfo>() { visual }; |
| | | this.SetBindingData(allParterList); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | public void SetBindingData(List<Yw.Model.HydroPipeInfo> allParterList) |
| | | public void SetBindingData(List<Yw.Model.HydroPipeInfo> allVisualList) |
| | | { |
| | | _allParterList = allParterList; |
| | | if (_allParterList != null && _allParterList.Count == 1) |
| | | _allVisualList = allVisualList; |
| | | if (_allVisualList != null && _allVisualList.Count == 1) |
| | | { |
| | | var parter = _allParterList.First(); |
| | | this.imgCmbLinkStatus.EditValue = parter.LinkStatus; |
| | | this.txtMaterial.EditValue = parter.Material; |
| | | this.txtDiameter.EditValue = parter.Diameter; |
| | | this.txtLength.EditValue = parter.Length; |
| | | this.txtRoughness.EditValue = parter.Roughness; |
| | | this.txtMinorLoss.EditValue = parter.MinorLoss; |
| | | 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 InitialLinkStatus() |
| | | { |
| | | this.imgCmbLinkStatus.Properties.BeginUpdate(); |
| | | this.imgCmbLinkStatus.Properties.Items.Clear(); |
| | | this.imgCmbLinkStatus.Properties.Items.Add(HydroLinkStatusHelper.GetStatusName(Yw.Hydro.LinkStatus.Open), Yw.Hydro.LinkStatus.Open, -1); |
| | | this.imgCmbLinkStatus.Properties.Items.Add(HydroLinkStatusHelper.GetStatusName(Yw.Hydro.LinkStatus.Closed), Yw.Hydro.LinkStatus.Closed, -1); |
| | | this.imgCmbLinkStatus.Properties.EndUpdate(); |
| | | } |
| | | |
| | | //验证 |
| | | private bool Valid() |
| | | { |
| | | this.dxErrorProvider1.ClearErrors(); |
| | | if (this.imgCmbLinkStatus.EditValue == null) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.imgCmbLinkStatus, "必选项"); |
| | | return false; |
| | | } |
| | | if (this.txtDiameter.EditValue == null) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.txtDiameter, "必填项"); |
| | | return false; |
| | | } |
| | | if (this.txtLength.EditValue == null) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.txtLength, "必填项"); |
| | | return false; |
| | | } |
| | | if (this.txtRoughness.EditValue == null) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.txtRoughness, "必填项"); |
| | | return false; |
| | | } |
| | | if (this.txtMinorLoss.EditValue == null) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.txtMinorLoss, "必填项"); |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | //确定 |
| | | private void GeneralOkAndCancelCtrl1_OkEvent() |
| | | { |
| | | if (_allParterList == null || _allParterList.Count < 1) |
| | | if (_allVisualList == null || _allVisualList.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | if (!Valid()) |
| | | { |
| | | return; |
| | | } |
| | | var linkStatus = this.imgCmbLinkStatus.EditValue.ToString(); |
| | | var material = this.txtMaterial.Text.Trim(); |
| | | var diameter = double.Parse(this.txtDiameter.EditValue.ToString()); |
| | | var length = double.Parse(this.txtLength.EditValue.ToString()); |
| | | var roughness = double.Parse(this.txtRoughness.EditValue.ToString()); |
| | | var minoroLoss = double.Parse(this.txtMinorLoss.EditValue.ToString()); |
| | | _allParterList.ForEach(x => |
| | | 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 => |
| | | { |
| | | x.LinkStatus = linkStatus; |
| | | x.Material = material; |
| | | x.Diameter = diameter; |
| | | x.Length = length; |
| | | x.Roughness = roughness; |
| | | x.MinorLoss = minoroLoss; |
| | | 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(_allParterList); |
| | | this.ReloadDataEvent?.Invoke(_allVisualList); |
| | | this.DialogResult = DialogResult.OK; |
| | | this.Close(); |
| | | } |