lixiaojun
2024-11-09 c9585ab171fb973d16792d7a290994bf8279da63
WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/07-threelink/SetHydroThreelinkDlg.cs
ÎļþÃû´Ó WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/07-threelink/SetHydroThreelinkDlg.cs ÐÞ¸Ä
@@ -7,6 +7,7 @@
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
            this.layoutControl1.SetupLayoutControl();
            this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent;
        }
        /// <summary>
@@ -15,32 +16,32 @@
        public event Action<List<Yw.Model.HydroThreelinkInfo>> ReloadDataEvent;
        //所有构件列表
        private List<Yw.Model.HydroThreelinkInfo> _allParterList = null;
        private List<Yw.Model.HydroThreelinkInfo> _allVisualList = null;
        /// <summary>
        /// ç»‘定数据
        /// </summary>
        public void SetBindingData(Yw.Model.HydroThreelinkInfo parter)
        public void SetBindingData(Yw.Model.HydroThreelinkInfo visual)
        {
            var allParterList = parter == null ? null : new List<Yw.Model.HydroThreelinkInfo>() { parter };
            SetBindingData(allParterList);
            var allVisualList = visual == null ? null : new List<Yw.Model.HydroThreelinkInfo>() { visual };
            SetBindingData(allVisualList);
        }
        /// <summary>
        /// ç»‘定数据
        /// </summary>
        public void SetBindingData(List<Yw.Model.HydroThreelinkInfo> allParterList)
        public void SetBindingData(List<Yw.Model.HydroThreelinkInfo> allVisualList)
        {
            _allParterList = allParterList;
            if (_allParterList != null && _allParterList.Count == 1)
            _allVisualList = allVisualList;
            if (_allVisualList != null && _allVisualList.Count == 1)
            {
                var parter = _allParterList.First();
                this.txtElev.EditValue = parter.Elev;
                this.txtMinorLoss.EditValue = parter.MinorLoss;
                this.txtMaterial.EditValue = parter.Material;
                this.txtCaliber.EditValue = parter.Caliber;
                this.txtRunningThroughLoss.EditValue = parter.RunningThroughLoss;
                this.txtBranchThroughLoss.EditValue = parter.BranchThroughLoss;
                var visual = _allVisualList.First();
                this.txtElev.EditValue = visual.Elev;
                this.txtMinorLoss.EditValue = visual.MinorLoss;
                this.txtMaterial.EditValue = visual.Material;
                this.txtCaliber.EditValue = visual.Caliber;
                this.txtRunningThroughLoss.EditValue = visual.RunningThroughLoss;
                this.txtBranchThroughLoss.EditValue = visual.BranchThroughLoss;
            }
        }
@@ -56,10 +57,11 @@
            return true;
        }
        //
        private void btnOk_Click(object sender, EventArgs e)
        //确定
        private void GeneralOkAndCancelCtrl1_OkEvent()
        {
            if (_allParterList == null || _allParterList.Count < 1)
            if (_allVisualList == null || _allVisualList.Count < 1)
            {
                return;
            }
@@ -73,7 +75,7 @@
            double? caliber = this.txtCaliber.EditValue == null ? null : double.Parse(this.txtCaliber.EditValue.ToString());
            double? runningThroughLoss = this.txtRunningThroughLoss.EditValue == null ? null : double.Parse(this.txtRunningThroughLoss.EditValue.ToString());
            double? branchThroughLoss = this.txtBranchThroughLoss.EditValue == null ? null : double.Parse(this.txtBranchThroughLoss.EditValue.ToString());
            _allParterList.ForEach(x =>
            _allVisualList.ForEach(x =>
            {
                x.Elev = elev;
                x.MinorLoss = minorLoss;
@@ -82,9 +84,10 @@
                x.RunningThroughLoss = runningThroughLoss;
                x.BranchThroughLoss = branchThroughLoss;
            });
            this.ReloadDataEvent?.Invoke(_allParterList);
            this.ReloadDataEvent?.Invoke(_allVisualList);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}