duheng
2025-03-14 a906f71640d9ba5cd9f8d689a51de3a557d8bbff
WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/16-translation/SetHydroTranslationDlg.cs
@@ -15,31 +15,44 @@
        /// </summary>
        public event Action<List<Yw.Model.HydroTranslationInfo>> ReloadDataEvent;
        //所有部件列表
        private List<Yw.Model.HydroTranslationInfo> _allVisualList = null;
        private List<Yw.Model.HydroTranslationInfo> _allVisualList = null;//所有部件列表
        private HydroChangeHelper _changeHelper = null;//改变辅助类
        private HydroPropStatusHelper _propStatusHelper = null;//属性状态辅助类
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(Yw.Model.HydroTranslationInfo parter)
        public void SetBindingData
            (
                Yw.Model.HydroTranslationInfo visual,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            var allParterList = parter == null ? null : new List<Yw.Model.HydroTranslationInfo>() { parter };
            this.SetBindingData(allParterList);
            var allVisualList = visual == null ? null : new List<Yw.Model.HydroTranslationInfo>() { visual };
            this.SetBindingData(allVisualList, changeHelper, propStatusHelper);
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<Yw.Model.HydroTranslationInfo> allVisualList)
        public void SetBindingData
            (
                List<Yw.Model.HydroTranslationInfo> 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.txtDiameter.EditValue = visual.Diameter;
                this.txtLength.EditValue = visual.Length;
                this.txtRoughness.EditValue = visual.Roughness;
                this.txtMinorLoss.EditValue = visual.MinorLoss;
            }
        }
@@ -52,31 +65,46 @@
            {
                return;
            }
            var beginGroup = this.txtBeginGroup.Text.Trim();
            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(beginGroup))
                {
                    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 (!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 (diameter.HasValue)
                {
                    x.Diameter = diameter.Value;
                }
                if (length.HasValue)
                {
                    if (x.Length != length)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.Length), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.Length = length.Value;
                }
                if (roughness.HasValue)
                {
                    x.Roughness = roughness.Value;
                }
                if (minorLoss.HasValue)
                {
                    if (x.MinorLoss != minorLoss)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.MinorLoss), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.MinorLoss = minorLoss.Value;
                }
            });