lixiaojun
2024-12-20 94d10185010a7476021764f5b5cb59dc7d2b68f4
WinFrmUI/Yw.WinFrmUI.Hydro.Core/04-viewmodel/04-link/01-pipe/00-core/HydroPipeViewModel.cs
@@ -1,11 +1,9 @@
using Yw.Model;
namespace Yw.WinFrmUI
namespace Yw.WinFrmUI
{
    /// <summary>
    /// 管道视图
    /// </summary>
    public class HydroPipeViewModel : HydroLinkViewModel
    public class HydroPipeViewModel : HydroLinkViewModel, IHydroCalcuPipeResult
    {
        /// <summary>
        /// 
@@ -27,7 +25,6 @@
            this.UpdatePropStatus(nameof(this.Roughness), rhs, nameof(rhs.Roughness));
            this.MinorLoss = rhs.MinorLoss;
            this.UpdatePropStatus(nameof(this.MinorLoss), rhs, nameof(rhs.MinorLoss));
            this.Vmo = rhs;
        }
        /// <summary>
@@ -35,17 +32,18 @@
        /// </summary>
        [Category("数据")]
        [DisplayName("管道状态")]
        [PropertyOrder(13)]
        [PropertyOrder(1003)]
        [Browsable(true)]
        [TypeConverter(typeof(HydroPipeStatusConverter))]
        public override string LinkStatus { get; set; }
        /// <summary>
        /// 材料
        /// 材质
        /// </summary>
        [Category("数据")]
        [DisplayName("材料")]
        [PropertyOrder(100)]
        [Display(Name = "材质")]
        [DisplayName("材质")]
        [PropertyOrder(2001)]
        [Browsable(true)]
        public string Material { get; set; }
@@ -53,19 +51,21 @@
        /// 直径
        /// </summary>
        [Category("数据")]
        [Display(Name = "直径(mm)")]
        [DisplayName("直径")]
        [PropertyOrder(101)]
        [DisplayUnit("mm")]
        [PropertyOrder(2002)]
        [Browsable(true)]
        public double Diameter { get; set; }
        public virtual double Diameter { get; set; }
        /// <summary>
        /// 长度
        /// </summary>
        [Category("数据")]
        [Display(Name = "长度(m)")]
        [DisplayName("长度")]
        [PropertyOrder(102)]
        [DisplayUnit("m")]
        [PropertyOrder(2003)]
        [Browsable(true)]
        public double Length { get; set; }
@@ -73,8 +73,10 @@
        /// 粗糙系数
        /// </summary>
        [Category("数据")]
        [Display(Name = "粗糙系数")]
        [DisplayName("粗糙系数")]
        [PropertyOrder(103)]
        [Description("海森威廉公式系数")]
        [PropertyOrder(2004)]
        [Browsable(true)]
        public double Roughness { get; set; }
@@ -82,17 +84,62 @@
        /// 局阻系数
        /// </summary>
        [Category("数据")]
        [Display(Name = "局阻系数")]
        [DisplayName("局阻系数")]
        [PropertyOrder(104)]
        [Description("局部阻力系数")]
        [PropertyOrder(2005)]
        [Browsable(true)]
        public double MinorLoss { get; set; }
        /// <summary>
        /// 流量
        /// </summary>
        [Category("计算结果")]
        [DisplayName("流量")]
        [Display(Name = "流量(m³/h)")]
        [PropertyOrder(11001)]
        [Browsable(true)]
        [DisplayUnit("m³/h")]
        [HydroCalcuPro]
        [ShowEditor(false)]
        public virtual double? CalcuQ { get; set; }
        /// <summary>
        /// 进口压力
        /// </summary>
        [Category("计算结果")]
        [DisplayName("进口压力")]
        [Display(Name = "进口压力(m)")]
        [PropertyOrder(11002)]
        [Browsable(true)]
        [DisplayUnit("m")]
        [HydroCalcuPro]
        [ShowEditor(false)]
        public virtual double? CalcuPr1 { get; set; }
        /// <summary>
        /// 出口压力
        /// </summary>
        [Category("计算结果")]
        [DisplayName("出口压力")]
        [Display(Name = "出口压力(m)")]
        [PropertyOrder(11003)]
        [Browsable(true)]
        [DisplayUnit("m")]
        [HydroCalcuPro]
        [ShowEditor(false)]
        public virtual double? CalcuPr2 { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public new Yw.Model.HydroPipeInfo Vmo { get; set; }
        [Browsable(false)]
        public new Yw.Model.HydroPipeInfo Vmo
        {
            get { return _vmo as Yw.Model.HydroPipeInfo; }
            set { _vmo = value; }
        }
        /// <summary>
        /// 更新属性
@@ -104,7 +151,7 @@
            this.UpdatePropStatus(nameof(this.Material), this.Vmo, nameof(this.Vmo.Material));
            this.Diameter = this.Vmo.Diameter;
            this.UpdatePropStatus(nameof(this.Diameter), this.Vmo, nameof(this.Vmo.Diameter));
            this.Length = this.Vmo.Length;
            this.Length = Math.Round(this.Vmo.Length, 4);
            this.UpdatePropStatus(nameof(this.Length), this.Vmo, nameof(this.Vmo.Length));
            this.Roughness = this.Vmo.Roughness;
            this.UpdatePropStatus(nameof(this.Roughness), this.Vmo, nameof(this.Vmo.Roughness));
@@ -112,7 +159,37 @@
            this.UpdatePropStatus(nameof(this.MinorLoss), this.Vmo, nameof(this.Vmo.MinorLoss));
        }
        /// <summary>
        ///
        /// </summary>
        public override void UpdateVmoProperty()
        {
            base.UpdateVmoProperty();
            this.Vmo.Material = this.Material;
            this.Vmo.UpdatePropStatus(nameof(this.Vmo.Material), this, nameof(this.Material));
            this.Vmo.Diameter = this.Diameter;
            this.Vmo.UpdatePropStatus(nameof(this.Vmo.Diameter), this, nameof(this.Diameter));
            this.Vmo.Length = this.Length;
            this.Vmo.UpdatePropStatus(nameof(this.Vmo.Length), this, nameof(this.Length));
            this.Vmo.Roughness = this.Roughness;
            this.Vmo.UpdatePropStatus(nameof(this.Vmo.Roughness), this, nameof(this.Roughness));
            this.Vmo.MinorLoss = this.MinorLoss;
            this.Vmo.UpdatePropStatus(nameof(this.Vmo.MinorLoss), this, nameof(this.MinorLoss));
        }
        /// <summary>
        /// 更新计算属性
        /// </summary>
        public override void UpdateCalcuProperty(HydroCalcuVisualResult rhs)
        {
            base.UpdateCalcuProperty(rhs);
            if (rhs is HydroCalcuPipeResult calcuPipeProperty)
            {
                this.CalcuQ = calcuPipeProperty.CalcuQ.HasValue ? Math.Round(calcuPipeProperty.CalcuQ.Value, 1) : null;
                this.CalcuPr1 = calcuPipeProperty.CalcuPr1.HasValue ? Math.Round(calcuPipeProperty.CalcuPr1.Value, 2) : null;
                this.CalcuPr2 = calcuPipeProperty.CalcuPr2.HasValue ? Math.Round(calcuPipeProperty.CalcuPr2.Value, 2) : null;
            }
        }
    }
}