From ad6ccae53244330399fe871d78209faa988219c3 Mon Sep 17 00:00:00 2001
From: duheng <2784771470@qq.com>
Date: 星期三, 23 十月 2024 16:00:00 +0800
Subject: [PATCH] 增加MatchingViewModel字段

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/01-property/XhsProjectSimulationPropertyCtrl.cs |  175 ++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 122 insertions(+), 53 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/01-property/XhsProjectSimulationPropertyCtrl.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/01-property/XhsProjectSimulationPropertyCtrl.cs
index f61ed97..46c7174 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/01-property/XhsProjectSimulationPropertyCtrl.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/01-property/XhsProjectSimulationPropertyCtrl.cs
@@ -1,4 +1,5 @@
-锘縰sing HStation.WinFrmUI.Xhs;
+锘縰sing HStation.WinFrmUI.PhartRelation;
+using HStation.WinFrmUI.Xhs;
 
 namespace HStation.WinFrmUI
 {
@@ -11,22 +12,31 @@
         {
             InitializeComponent();
 
-            this.hydroParterPropertyCtrl1.SetCurveEvent += HydroParterPropertyCtrl1_SetCurveEvent;
-            this.hydroParterPropertyCtrl1.SetPatternEvent += HydroParterPropertyCtrl1_SetPatternEvent;
             this.hydroParterPropertyCtrl1.PropertyValueChangedEvent += HydroParterPropertyCtrl1_PropertyValueChangedEvent;
             this.hydroParterPropertyCtrl1.PropertyValueChangingEvent += HydroParterPropertyCtrl1_PropertyValueChangingEvent;
             this.hydroParterPropertyCtrl1.MatchingDbEvent += HydroParterPropertyCtrl1_MatchingDbEvent;
+            this.hydroParterPropertyCtrl1.BlinkLinkParterEvent += HydroParterPropertyCtrl1_BlinkLinkParterEvent;
         }
+
+        /// <summary>
+        /// 寮鸿皟杩炴帴缁勪欢浜嬩欢
+        /// 绗竴涓弬鏁颁负缁勪欢Code
+        /// 绗簩涓弬鏁颁负杩炴帴缁勪欢Code
+        /// </summary>
+        public event Action<string, string> BlinkLinkParterEvent;
 
         //姘村姏淇℃伅鏂规硶
         private Func<Yw.Model.HydroModelInfo> _hydroInfoFunc = null;
+        private Func<List<IHydroCalcuResult>> _allHydroCalcuResultListFunc = null;
 
         /// <summary>
         /// 鍒濆鍖栨暟鎹�
         /// </summary>
-        public void InitialData(Func<Yw.Model.HydroModelInfo> hydroInfoFunc)
+        public void InitialData(Func<Yw.Model.HydroModelInfo> hydroInfoFunc, Func<List<IHydroCalcuResult>> allHydroCalcuResultListFunc)
         {
             _hydroInfoFunc = hydroInfoFunc;
+            _allHydroCalcuResultListFunc = allHydroCalcuResultListFunc;
+            this.hydroParterPropertyCtrl1.InitialData(hydroInfoFunc);
         }
 
         /// <summary>
@@ -86,6 +96,42 @@
             this.hydroParterPropertyCtrl1.UpdateRows();
         }
 
+        //鏌ョ湅鏇茬嚎
+        private void HydroParterPropertyCtrl1_ViewCurveEvent(Yw.Model.HydroParterInfo parterInfo, string curveType)
+        {
+            var hydroInfo = _hydroInfoFunc?.Invoke();
+            if (hydroInfo == null)
+            {
+                return;
+            }
+            switch (curveType)
+            {
+                case Yw.WinFrmUI.HydroCurve.Pump:
+                    {
+                        var pumpInfo = parterInfo as Yw.Model.HydroPumpInfo;
+                        var curveqh = hydroInfo.Curves?.Find(x => x.Code == pumpInfo.CurveQH);
+                        if (curveqh == null)
+                        {
+                            return;
+                        }
+                        var pumpId = string.IsNullOrEmpty(pumpInfo.DbId) ? 0 : Convert.ToInt64(pumpInfo.DbId);
+                        var curveId = string.IsNullOrEmpty(curveqh.DbId) ? 0 : Convert.ToInt64(curveqh.DbId);
+                        var speedRatio = pumpInfo.SpeedRatio;
+                        var dlg = new PumpPerform2dViewDlg();
+                        dlg.SetBindingData(pumpId, curveId, speedRatio);
+                        dlg.ShowDialog();
+                    }
+                    break;
+
+                case Yw.WinFrmUI.HydroCurve.Valve:
+                    {
+                    }
+                    break;
+
+                default: break;
+            }
+        }
+
         //閫夋嫨鏇茬嚎
         private bool HydroParterPropertyCtrl1_SetCurveEvent(HydroParterPropertyViewModel propViewModel, string curveType)
         {
@@ -100,7 +146,7 @@
                         }
                         var pumpInfo = hydroInfo.Pumps?.Find(x => x.Code == propViewModel.Code);
 
-                        var input = AssetsMatchingParasHelper.Create(hydroInfo, pumpInfo);
+                        var input = AssetsMatchingParasHelper.Create(hydroInfo, pumpInfo, _allHydroCalcuResultListFunc?.Invoke());
                         var dlg = new PumpSingleMatchingDlg();
                         dlg.SetBindingData(input);
                         dlg.ReloadDataEvent += (rhs) =>
@@ -175,101 +221,124 @@
             return false;
         }
 
-        //鍖归厤Db浜嬩欢
-        private void HydroParterPropertyCtrl1_MatchingDbEvent(Yw.Model.HydroParterInfo parter)
+        //鍖归厤Db
+        private bool HydroParterPropertyCtrl1_MatchingDbEvent(HydroParterPropertyViewModel propertyViewModel)
         {
-            if (parter == null)
+            var bol = false;
+            if (propertyViewModel == null)
             {
-                return;
+                return bol;
             }
             var hydroInfo = _hydroInfoFunc?.Invoke();
             if (hydroInfo == null)
             {
-                return;
+                return bol;
             }
-            switch (parter.Catalog)
+            var catalog = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogCode(propertyViewModel.Catalog);
+            switch (catalog)
             {
                 case Yw.Hydro.ParterCatalog.Pump://姘存车
                     {
-                        var pumpInfo = hydroInfo.Pumps?.Find(x => x.Code == parter.Code);
-                        var input = AssetsMatchingParasHelper.Create(hydroInfo, pumpInfo);
-                        var dlg = new PumpSingleMatchingDlg();
-                        dlg.SetBindingData(input);
-                        dlg.ReloadDataEvent += (rhs) =>
+                        var pumpInfo = hydroInfo.Pumps?.Find(x => x.Code == propertyViewModel.Code);
+                        if (pumpInfo == null)
                         {
-                            var bol = AssetsMatchingParasHelper.Apply(hydroInfo, rhs);
-                            if (bol)
+                            break;
+                        }
+
+                        var input = AssetsMatchingParasHelper.Create(hydroInfo, pumpInfo, _allHydroCalcuResultListFunc?.Invoke());
+                        if (string.IsNullOrEmpty(pumpInfo.DbId))
+                        {
+                            var dlg = new PumpSingleMatchingDlg();
+                            dlg.SetBindingData(input);
+                            dlg.ReloadDataEvent += (output) =>
                             {
-                                TipFormHelper.ShowSucceed("鍖归厤鎴愬姛");
-                            }
-                            else
+                                bol = AssetsMatchingParasHelper.Apply(hydroInfo, output);
+                                if (bol)
+                                {
+                                    propertyViewModel.UpdateProperty(pumpInfo, hydroInfo.GetAllParters());
+                                }
+                            };
+                            dlg.ShowDialog();
+                        }
+                        else
+                        {
+                            var dlg = new PumpFullInfoViewDlg();
+                            dlg.SetBindindData(input);
+                            dlg.ReloadDataEvent += (output) =>
                             {
-                                TipFormHelper.ShowWarn("鍖归厤澶辫触");
-                            }
-                        };
-                        dlg.ShowDialog();
+                                bol = AssetsMatchingParasHelper.Apply(hydroInfo, output);
+                                if (bol)
+                                {
+                                    propertyViewModel.UpdateProperty(pumpInfo, hydroInfo.GetAllParters());
+                                }
+                            };
+                            dlg.ShowDialog();
+                        }
                     }
                     break;
-
                 case Yw.Hydro.ParterCatalog.Valve://闃�闂�
                     {
-                        var valveInfo = hydroInfo.Valves?.Find(x => x.Code == parter.Code);
-                        var input = AssetsMatchingParasHelper.Create(hydroInfo, valveInfo);
+                        var valveInfo = hydroInfo.Valves?.Find(x => x.Code == propertyViewModel.Code);
+                        if (valveInfo == null)
+                        {
+                            break;
+                        }
+                        var input = AssetsMatchingParasHelper.Create(hydroInfo, valveInfo, _allHydroCalcuResultListFunc?.Invoke());
                         var dlg = new ValveSingleMatchingDlg();
                         dlg.SetBindingData(input);
                         dlg.ReloadDataEvent += (rhs) =>
                         {
-                            var bol = AssetsMatchingParasHelper.Apply(hydroInfo, rhs);
-                            if (bol)
-                            {
-                                TipFormHelper.ShowSucceed("鍖归厤鎴愬姛");
-                            }
-                            else
-                            {
-                                TipFormHelper.ShowWarn("鍖归厤澶辫触");
-                            }
+                            bol = AssetsMatchingParasHelper.Apply(hydroInfo, rhs);
                         };
                         dlg.ShowDialog();
                     }
                     break;
-
                 case Yw.Hydro.ParterCatalog.Pipe://绠¢亾
                     {
                     }
                     break;
-
                 case Yw.Hydro.ParterCatalog.Elbow://寮ご
                     {
-                        var elbowInfo = hydroInfo.Elbows?.Find(x => x.Code == parter.Code);
-                        var input = AssetsMatchingParasHelper.Create(hydroInfo, elbowInfo);
+                        var elbowInfo = hydroInfo.Elbows?.Find(x => x.Code == propertyViewModel.Code);
+                        if (elbowInfo == null)
+                        {
+                            break;
+                        }
+                        var input = AssetsMatchingParasHelper.Create(hydroInfo, elbowInfo, _allHydroCalcuResultListFunc?.Invoke());
                         var dlg = new ElbowSingMatchingDlg();
                         dlg.SetBindingData(input);
-                        dlg.ReloadDataEvent += (rhs) =>
+                        dlg.ReloadDataEvent += (output) =>
                         {
-                            var bol = AssetsMatchingParasHelper.Apply(hydroInfo, rhs);
-                            if (bol)
-                            {
-                                TipFormHelper.ShowSucceed("鍖归厤鎴愬姛");
-                            }
-                            else
-                            {
-                                TipFormHelper.ShowWarn("鍖归厤澶辫触");
-                            }
+                            bol = AssetsMatchingParasHelper.Apply(hydroInfo, output);
                         };
                         dlg.ShowDialog();
                     }
                     break;
-
                 case Yw.Hydro.ParterCatalog.Threelink://涓夐��
                     {
                     }
                     break;
-
                 case Yw.Hydro.ParterCatalog.Fourlink://鍥涢��
                     {
                     }
                     break;
+                default: break;
             }
+            return bol;
+        }
+
+        //寮鸿皟杩炴帴缁勪欢
+        private void HydroParterPropertyCtrl1_BlinkLinkParterEvent(string code, string linkCode)
+        {
+            if (string.IsNullOrEmpty(code))
+            {
+                return;
+            }
+            if (string.IsNullOrEmpty(linkCode))
+            {
+                return;
+            }
+            this.BlinkLinkParterEvent?.Invoke(code, linkCode);
         }
 
 

--
Gitblit v1.9.3