ningshuxia
2025-03-20 d1807075581920a8c94a409b11a9c88dd869be1e
WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/06-elbow/SetHydroElbowDlg.cs
@@ -15,33 +15,45 @@
        /// </summary>
        public event Action<List<Yw.Model.HydroElbowInfo>> ReloadDataEvent;
        //所有构件列表
        private List<Yw.Model.HydroElbowInfo> _allVisualList = null;
        private List<Yw.Model.HydroElbowInfo> _allVisualList = null; //所有构件列表
        private HydroChangeHelper _changeHelper = null;//改变辅助类
        private HydroPropStatusHelper _propStatusHelper = null;//属性状态辅助类
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(Yw.Model.HydroElbowInfo visual)
        public void SetBindingData
            (
                Yw.Model.HydroElbowInfo visual,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            var allVisualList = visual == null ? null : new List<Yw.Model.HydroElbowInfo>() { visual };
            SetBindingData(allVisualList);
            SetBindingData(allVisualList, changeHelper, propStatusHelper);
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<Yw.Model.HydroElbowInfo> allVisualList)
        public void SetBindingData
            (
                List<Yw.Model.HydroElbowInfo> allVisualList,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            _allVisualList = allVisualList;
            _changeHelper = changeHelper;
            _propStatusHelper = propStatusHelper;
            if (_allVisualList != null && _allVisualList.Count == 1)
            {
                var visual = _allVisualList.First();
                this.txtBeginGroup.EditValue = visual.BeginGroup;
                this.txtMaterial.EditValue = visual.Material;
                this.txtCaliber.EditValue = visual.Caliber;
                this.txtBendingAngle.EditValue = visual.BendingAngle;
                this.txtElbowType.EditValue = visual.ElbowType;
                this.txtElev.EditValue = visual.Elev;
                this.txtMinorLoss.EditValue = visual.MinorLoss;
            }
        }
@@ -53,7 +65,7 @@
            {
                return;
            }
            double? elev = this.txtElev.EditValue == null ? null : double.Parse(this.txtElev.EditValue.ToString());
            var beginGroup = this.txtBeginGroup.Text.Trim();
            double? minorLoss = this.txtMinorLoss.EditValue == null ? null : double.Parse(this.txtMinorLoss.EditValue.ToString());
            var material = this.txtMaterial.Text.Trim();
            double? caliber = this.txtCaliber.EditValue == null ? null : double.Parse(this.txtCaliber.EditValue.ToString());
@@ -61,28 +73,58 @@
            var elbowType = this.txtElbowType.Text.Trim();
            _allVisualList.ForEach(x =>
            {
                if (elev.HasValue)
                if (!string.IsNullOrEmpty(beginGroup))
                {
                    x.Elev = elev.Value;
                    if (x.BeginGroup != beginGroup)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.BeginGroup), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.BeginGroup = beginGroup;
                }
                if (minorLoss.HasValue)
                {
                    if (x.MinorLoss != minorLoss.Value)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.MinorLoss), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.MinorLoss = minorLoss.Value;
                }
                if (!string.IsNullOrEmpty(material))
                {
                    if (x.Material != material)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.Material), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.Material = material;
                }
                if (caliber.HasValue)
                {
                    if (x.Caliber != caliber.Value)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.Caliber), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.Caliber = caliber.Value;
                }
                if (blendingAngle.HasValue)
                {
                    if (x.BendingAngle != blendingAngle.Value)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.BendingAngle), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.BendingAngle = blendingAngle.Value;
                }
                if (!string.IsNullOrEmpty(elbowType))
                {
                    if (x.ElbowType != elbowType)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.ElbowType), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.ElbowType = elbowType;
                }
            });