From cb3ec7cb8001317857087da706e51e6caa58f591 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期一, 21 十月 2024 12:01:20 +0800
Subject: [PATCH] 错误检查

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs |  670 +++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 470 insertions(+), 200 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs
index d58715b..367f20f 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs
@@ -1,4 +1,7 @@
 锘縢lobal using Yw.EPAnet;
+using DevExpress.Mvvm.Native;
+using DevExpress.Pdf.Native;
+using DevExpress.Utils.DirectXPaint;
 using Yw.WinFrmUI.Bimface;
 using Yw.WinFrmUI.Hydro;
 
@@ -11,7 +14,8 @@
             InitializeComponent();
             this.PageTitle.Caption = "姘村姏妯℃嫙";
             this.PageTitle.HeaderSvgImage = this.svgImg32[0];
-            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; 
+            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden;
+            this.docPnlRight.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden;
         }
 
         private HStation.Vmo.XhsProjectVmo _project = null;//椤圭洰
@@ -66,8 +70,10 @@
             this.tabPageBimface.Controls.Clear();
             this.tabPageBimface.Controls.Add(bimfaceCtrl);
             await bimfaceCtrl.InitialData(_project, _projectSite, () => _hydroInfo);
-            this.xhsProjectSimulationQ3dCtrl1.SetBindingData(_hydroInfo);
-            this.xhsProjectSimulationPropertyCtrl1.InitialData(() => _hydroInfo);
+            var q3dCtrl = GetQ3dCtrl();
+            this.tabPageQ3d.Controls.Clear();
+            this.tabPageQ3d.Controls.Add(q3dCtrl);
+            q3dCtrl.InitialData(() => _hydroInfo);
         }
 
         #region Bimface
@@ -105,6 +111,7 @@
             }
             return _bimfaceCtrl;
         }
+
         //bimface鎺т欢
         private XhsProjectSimulationBimfaceCtrl _bimfaceCtrl = null;
 
@@ -169,27 +176,174 @@
             }
         }
 
-        #endregion
+        #endregion Bimface
 
         #region Q3d
 
-        //鐐瑰嚮浜嬩欢
-        private void xhsProjectSimulationQ3dCtrl1_ClickParterEvent(string code)
+        //鑾峰彇Q3d鎺т欢
+        private XhsProjectSimulationQ3dCtrl GetQ3dCtrl()
+        {
+            if (_q3dCtrl == null)
+            {
+                _q3dCtrl = new XhsProjectSimulationQ3dCtrl();
+                _q3dCtrl.Dock = DockStyle.Fill;
+                _q3dCtrl.SelectedPartersChangedEvent += (obj) =>
+                {
+                    if (_hydroInfo == null)
+                    {
+                        return;
+                    }
+                    var allParterList = _hydroInfo.GetAllParters();
+                    _parter = allParterList?.Find(x => x.Code == obj?.FirstOrDefault());
+                    ShowProperty();
+                };
+            }
+            return _q3dCtrl;
+        }
+
+        //Q3d鎺т欢
+        private XhsProjectSimulationQ3dCtrl _q3dCtrl = null;
+
+        #endregion Q3d
+
+        #region 灞炴�ч潰鏉�
+
+        //灞炴�ф帶浠�
+        private XhsProjectSimulationPropertyCtrl _propertyCtrl = null;
+
+        //鑾峰彇灞炴�ф帶浠�
+        private XhsProjectSimulationPropertyCtrl GetPropertyCtrl()
+        {
+            if (_propertyCtrl == null)
+            {
+                _propertyCtrl = new XhsProjectSimulationPropertyCtrl();
+                _propertyCtrl.Dock = DockStyle.Fill;
+                _propertyCtrl.InitialData(() => _hydroInfo);
+                _propertyCtrl.BlinkLinkParterEvent += async (code, linkCode) =>
+                { //寮鸿皟杩炴帴缁勪欢
+                    if (string.IsNullOrEmpty(code))
+                    {
+                        return;
+                    }
+                    if (string.IsNullOrEmpty(linkCode))
+                    {
+                        return;
+                    }
+                    if (_hydroInfo == null)
+                    {
+                        return;
+                    }
+                    var allVisualList = _hydroInfo.GetAllVisuals();
+                    if (allVisualList == null || allVisualList.Count < 1)
+                    {
+                        return;
+                    }
+                    var linkParter = allVisualList.Find(x => x.Code == linkCode);
+                    if (linkParter == null)
+                    {
+                        return;
+                    }
+                    var blinkCodes = new List<string>();
+                    if (linkParter.GetType() == typeof(Yw.Model.HydroJunctionInfo))
+                    {
+                        var allLinkList = _hydroInfo.GetAllLinks();
+                        if (allLinkList == null || allLinkList.Count < 1)
+                        {
+                            return;
+                        }
+                        var linkList = allLinkList.Where(x => (x.StartCode == linkParter.Code || x.EndCode == linkParter.Code) && x.Code != code).ToList();
+                        if (linkList == null || linkList.Count < 1)
+                        {
+                            return;
+                        }
+                        blinkCodes.AddRange(linkList.Select(x => x.Code));
+                    }
+                    else
+                    {
+                        blinkCodes.Add(linkCode);
+                    }
+
+                    await _bimfaceCtrl?.SetBlinkComponents(blinkCodes);
+                    await Task.Delay(5000);
+                    await _bimfaceCtrl?.ClearBlinkComponents();
+                };
+            }
+            return _propertyCtrl;
+        }
+
+        //鏄剧ず灞炴�ч潰鏉�
+        private void ShowPropertyCtrl()
+        {
+            var propertyCtrl = GetPropertyCtrl();
+            this.controlContainerRight.Controls.Clear();
+            this.controlContainerRight.Controls.Add(propertyCtrl);
+            this.docPnlRight.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
+            this.docPnlRight.Text = "灞炴��";
+            this.docPnlRight.Width = 300;
+        }
+
+        //灞炴�ч潰鏉挎寜閽�
+        private void barBtnProperty_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            ShowPropertyCtrl();
+        }
+
+        //鏄剧ず灞炴��
+        private void ShowProperty()
         {
             if (_hydroInfo == null)
             {
                 return;
             }
-            var allParterList = _hydroInfo.GetAllParters();
-            _parter = allParterList?.Find(x => x.Code == code);
-            ShowProperty();
+            if (this.docPnlRight.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Hidden)
+            {
+                ShowPropertyCtrl();
+            }
+
+            if (_parter == null)
+            {
+                _propertyCtrl?.SelectParter(null);
+                return;
+            }
+
+            _propertyCtrl?.SelectParter(_parter.Code);
+            if (_calcuResult != null)
+            {
+                if (_calcuResult.Succeed)
+                {
+                    var allCalcuParterList = _calcuResult.GetParterList();
+                    var calcuParter = allCalcuParterList.Find(x => x.Id == _parter.Code);
+                    if (calcuParter != null)
+                    {
+                        IHydroCalcuResult calcuProperty = null;
+                        if (calcuParter is Yw.EPAnet.CalcuNode calcuNode)
+                        {
+                            var calcuNodeProperty = new Yw.WinFrmUI.HydroCalcuNodeResult();
+                            calcuNodeProperty.Code = _parter.Code;
+                            calcuNodeProperty.CalcuPress = calcuNode.Press;
+                            calcuNodeProperty.CalcuDemand = calcuNode.Demand;
+                            calcuNodeProperty.CalcuHead = calcuNode.Head;
+                            calcuProperty = calcuNodeProperty;
+                        }
+                        else if (calcuParter is Yw.EPAnet.CalcuLink calcuLink)
+                        {
+                            var calcuLinkProperty = new Yw.WinFrmUI.HydroCalcuLinkResult();
+                            calcuLinkProperty.Code = _parter.Code;
+                            calcuLinkProperty.CalcuHeadLoss = calcuLink.Headloss;
+                            calcuLinkProperty.CalcuFlow = calcuLink.Flow;
+                            calcuLinkProperty.CalcuVelocity = calcuLink.Velocity;
+                            calcuProperty = calcuLinkProperty;
+                        }
+
+                        if (calcuProperty != null)
+                        {
+                            _propertyCtrl?.UpdateCalcuProperty(calcuProperty);
+                        }
+                    }
+                }
+            }
+
         }
-
-        #endregion
-
-        #region 灞炴�ч潰鏉�
-
-
 
         #endregion
 
@@ -230,6 +384,7 @@
             }
             return _matchingListCtrl;
         }
+
         //鍖归厤鍒楄〃鎺т欢
         private XhsProjectSimulationMatchingListCtrl _matchingListCtrl = null;
 
@@ -250,8 +405,7 @@
             this.docPnlBottom.Height = 350;
         }
 
-
-        #endregion
+        #endregion 鑷姩鍖归厤
 
         #region 鏈尮閰嶅垪琛�
 
@@ -289,6 +443,7 @@
             }
             return _unMatchingListCtrl;
         }
+
         private XhsProjectSimulationUnMatchingListCtrl _unMatchingListCtrl = null;//鏈尮閰嶅垪琛�
 
         //鏈尮閰嶅垪琛�
@@ -307,17 +462,12 @@
             this.docPnlBottom.Height = 350;
         }
 
-
-
-        #endregion
+        #endregion 鏈尮閰嶅垪琛�
 
         #region 涓�閿樉闅�
 
-        //鏄鹃殣缂栫爜鍒楄〃
-        private List<string> _fastShowHideCodeList = null;
-
-        //瑙﹀彂涓�閿樉闅�
-        private async void barBtnShowHide_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        //涓�閿樉闅�
+        private async Task FastShowHidden()
         {
             if (_hydroInfo == null)
             {
@@ -327,30 +477,42 @@
             {
                 return;
             }
-            if (_fastShowHideCodeList == null)
+            if (_fastShowHiddenCodeList == null)
             {
-                _fastShowHideCodeList = _hydroInfo.Decorators.Select(x => x.Code).ToList();
-                await _bimfaceCtrl?.HideComponents(_fastShowHideCodeList);
+                _fastShowHiddenCodeList = _hydroInfo.Decorators.Select(x => x.Code).ToList();
+                await _bimfaceCtrl?.HideComponents(_fastShowHiddenCodeList);
             }
             else
             {
-                await _bimfaceCtrl?.ShowComponents(_fastShowHideCodeList);
-                _fastShowHideCodeList = null;
+                await _bimfaceCtrl?.ShowComponents(_fastShowHiddenCodeList);
+                _fastShowHiddenCodeList = null;
             }
+        }
+
+        //鏄鹃殣缂栫爜鍒楄〃
+        private List<string> _fastShowHiddenCodeList = null;
+
+        //瑙﹀彂涓�閿樉闅�
+        private async void barBtnFastShowHidden_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            await FastShowHidden();
         }
 
         #endregion
 
         #region 姘村姏鏍¢獙
 
-        //鑾峰彇鏍¢獙缁撴灉鎺т欢
-        private XhsProjectSimulationHydroCheckResultCtrl GetCheckResultCtrl()
+        //鏍¢獙鎺т欢
+        private XhsProjectSimulationHydroCheckResultCtrl _checkCtrl = null;
+
+        //鑾峰彇鏍¢獙鎺т欢
+        private XhsProjectSimulationHydroCheckResultCtrl GetCheckCtrl()
         {
-            if (_checkResultCtrl == null)
+            if (_checkCtrl == null)
             {
-                _checkResultCtrl = new XhsProjectSimulationHydroCheckResultCtrl();
-                _checkResultCtrl.Dock = DockStyle.Fill;
-                _checkResultCtrl.HydroClickEvent += async (code) =>
+                _checkCtrl = new XhsProjectSimulationHydroCheckResultCtrl();
+                _checkCtrl.Dock = DockStyle.Fill;
+                _checkCtrl.HydroClickEvent += async (code) =>
                 {
                     if (_hydroInfo == null)
                     {
@@ -375,10 +537,25 @@
                     SetBimfaceLinkColor();
                 };
             }
-            return _checkResultCtrl;
+            return _checkCtrl;
         }
-        //鏍¢獙缁撴灉鎺т欢
-        private XhsProjectSimulationHydroCheckResultCtrl _checkResultCtrl = null;
+
+        //鏄剧ず鏍¢獙鎺т欢
+        private void ShowCheckCtrl()
+        {
+            if (_checkResult == null)
+            {
+                return;
+            }
+            var checkCtrl = GetCheckCtrl();
+            checkCtrl.SetBindingData(_checkResult);
+            this.controlContainerBottom.Controls.Clear();
+            this.controlContainerBottom.Controls.Add(checkCtrl);
+            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
+            this.docPnlBottom.Text = "鏍¢獙缁撴灉";
+            this.docPnlBottom.Height = 350;
+
+        }
 
         //姘村姏楠岃瘉
         private void barBtnHydroCheck_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
@@ -388,16 +565,10 @@
                 return;
             }
             _checkResult = _hydroInfo.Check();
-            this.controlContainerBottom.Controls.Clear();
-            var checkResultCtrl = GetCheckResultCtrl();
-            checkResultCtrl.SetBindingData(_checkResult);
-            this.controlContainerBottom.Controls.Add(checkResultCtrl);
-            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
-            this.docPnlBottom.Text = "鏍¢獙缁撴灉";
-            this.docPnlBottom.Height = 350;
+            ShowCheckCtrl();
         }
 
-        #endregion
+        #endregion 姘村姏鏍¢獙
 
         #region 淇濆瓨姘村姏淇℃伅
 
@@ -418,9 +589,12 @@
             TipFormHelper.ShowSucceed("淇濆瓨鎴愬姛锛�");
         }
 
-        #endregion
+        #endregion 淇濆瓨姘村姏淇℃伅
 
         #region 鏋勪欢鏄庣粏
+
+        //鏋勪欢鏄庣粏鎺т欢
+        private Yw.WinFrmUI.HydroParterListCtrl _parterListCtrl = null;
 
         //鑾峰彇鏋勪欢鏄庣粏鎺т欢
         private Yw.WinFrmUI.HydroParterListCtrl GetParterListCtrl()
@@ -444,8 +618,8 @@
             }
             return _parterListCtrl;
         }
-        //鏋勪欢鏄庣粏鎺т欢
-        private Yw.WinFrmUI.HydroParterListCtrl _parterListCtrl = null;
+
+
 
         //姘村姏鏋勪欢鍒楄〃
         private void barBtnHydroParterList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
@@ -463,8 +637,7 @@
             this.docPnlBottom.Height = 350;
         }
 
-
-        #endregion
+        #endregion 鏋勪欢鏄庣粏
 
         #region INP瀵煎嚭
 
@@ -486,64 +659,7 @@
             TipFormHelper.ShowSucceed("瀵煎嚭鎴愬姛");
         }
 
-        #endregion
-
-        #region 涓氬姟鏂规硶
-
-        //鏄剧ず灞炴��
-        private void ShowProperty()
-        {
-            if (_hydroInfo == null)
-            {
-                return;
-            }
-
-            if (_parter == null)
-            {
-                this.xhsProjectSimulationPropertyCtrl1.SelectParter(null);
-                return;
-            }
-
-            this.xhsProjectSimulationPropertyCtrl1.SelectParter(_parter.Code);
-            if (_calcuResult != null)
-            {
-                if (_calcuResult.Succeed)
-                {
-                    var allCalcuParterList = _calcuResult.GetParterList();
-                    var calcuParter = allCalcuParterList.Find(x => x.Id == _parter.Code);
-                    if (calcuParter != null)
-                    {
-                        IHydroCalcuResult calcuProperty = null;
-                        if (calcuParter is Yw.EPAnet.CalcuNode calcuNode)
-                        {
-                            var calcuNodeProperty = new Yw.WinFrmUI.HydroCalcuNodeResult();
-                            calcuNodeProperty.Code = _parter.Code;
-                            calcuNodeProperty.CalcuPress = calcuNode.Press;
-                            calcuNodeProperty.CalcuDemand = calcuNode.Demand;
-                            calcuNodeProperty.CalcuHead = calcuNode.Head;
-                            calcuProperty = calcuNodeProperty;
-                        }
-                        else if (calcuParter is Yw.EPAnet.CalcuLink calcuLink)
-                        {
-                            var calcuLinkProperty = new Yw.WinFrmUI.HydroCalcuLinkResult();
-                            calcuLinkProperty.Code = _parter.Code;
-                            calcuLinkProperty.CalcuHeadLoss = calcuLink.Headloss;
-                            calcuLinkProperty.CalcuFlow = calcuLink.Flow;
-                            calcuLinkProperty.CalcuVelocity = calcuLink.Velocity;
-                            calcuProperty = calcuLinkProperty;
-                        }
-
-                        if (calcuProperty != null)
-                        {
-                            this.xhsProjectSimulationPropertyCtrl1.UpdateCalcuProperty(calcuProperty);
-                        }
-                    }
-                }
-            }
-
-        }
-
-        #endregion
+        #endregion INP瀵煎嚭
 
         #region 閰嶇疆
 
@@ -553,7 +669,7 @@
             this.rmSet.ShowPopup(MousePosition, true);
         }
 
-        #endregion
+        #endregion 閰嶇疆
 
         #region 鎬ц兘鏇茬嚎
 
@@ -595,7 +711,7 @@
                 }
 
                 var rated_speed = x.RatedN.Value;
-                var speed_ratio = x.SpeedRatio ?? 1;
+                var speed_ratio = x.SpeedRatio;
 
                 var qh_pt_list = qh.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                 var qe_pt_list = qe?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
@@ -620,88 +736,132 @@
             dlg.ShowDialog();
         }
 
-        #endregion
+        #endregion 鎬ц兘鏇茬嚎
 
         #region 姘村姏璁$畻
 
+        //璁$畻鎺т欢
+        private SetHydroCalcuPrefixCtrl _calcuCtrl = null;
 
         //鑾峰彇璁$畻鎺т欢
-        private XhsProjectSimulationCalcuCtrl GetCalcuCtrl()
+        private SetHydroCalcuPrefixCtrl GetCalcuCtrl()
         {
             if (_calcuCtrl == null)
             {
-                _calcuCtrl = new XhsProjectSimulationCalcuCtrl();
+                _calcuCtrl = new SetHydroCalcuPrefixCtrl();
                 _calcuCtrl.Dock = DockStyle.Fill;
-                _calcuCtrl.CancelEvent += () =>
+                _calcuCtrl.InitialData(() => _hydroInfo);
+                _calcuCtrl.HydroViewEvent += async (parter) =>
+                {//姘村姏鏌ョ湅浜嬩欢
+                    if (parter == null)
                     {
-                        this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden;
-                    };
-                _calcuCtrl.OkEvent += async () =>
+                        return;
+                    }
+                    await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { parter.Code });
+                };
+                _calcuCtrl.HydroCalcuEvent += async () =>
+                {//姘村姏璁$畻浜嬩欢
+                    if (_hydroInfo == null)
                     {
-                        if (_hydroInfo == null)
-                        {
-                            return;
-                        }
-                        _checkResult = _hydroInfo.Check();
-                        if (!_checkResult.Succeed)
-                        {
-                            this.controlContainerBottom.Controls.Clear();
-                            var checkResultCtrl = GetCheckResultCtrl();
-                            checkResultCtrl.SetBindingData(_checkResult);
-                            this.controlContainerBottom.Controls.Add(checkResultCtrl);
-                            TipFormHelper.ShowWarn("鏍¢獙澶辫触锛岃妫�鏌ュ悗閲嶈瘯");
-                            return;
-                        }
+                        return;
+                    }
 
-                        var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo);
-                        _calcuResult = netWork.Calcu();
-                        if (_calcuResult.Succeed)
-                        {
-                            this.controlContainerBottom.Controls.Clear();
-                            var parterListCtrl = GetParterListCtrl();
-                            var calcuResultList = new List<IHydroCalcuResult>();
-                            _calcuResult.NodeList?.ForEach(x =>
-                            {
-                                calcuResultList.Add(new HydroCalcuNodeResult()
-                                {
-                                    Code = x.Id,
-                                    CalcuPress = x.Press,
-                                    CalcuHead = x.Head,
-                                    CalcuDemand = x.Demand,
-                                });
-                            });
-                            _calcuResult.LinkList?.ForEach(x =>
-                            {
-                                calcuResultList.Add(new HydroCalcuLinkResult()
-                                {
-                                    Code = x.Id,
-                                    CalcuFlow = x.Flow,
-                                    CalcuVelocity = x.Velocity,
-                                    CalcuHeadLoss = x.Headloss
-                                });
-                            });
-                            parterListCtrl.SetBindingData(_hydroInfo, calcuResultList);
-                            parterListCtrl.SetCalcuView();
-                            this.controlContainerBottom.Controls.Add(parterListCtrl);
-                            this.docPnlBottom.Text = "璁$畻缁撴灉";
-                            ShowProperty();
-                            await _bimfaceCtrl?.ShowCalcuCustomLabels(_calcuResult);
-                            TipFormHelper.ShowSucceed("璁$畻鎴愬姛锛�");
-                        }
-                        else
-                        {
-                            _calcuCtrl.SetBindingData(_calcuResult.FailedList);
-                            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
-                            this.docPnlBottom.Text = "璁$畻澶辫触鍘熷洜";
-                            this.docPnlBottom.Height = 350;
-                            TipFormHelper.ShowError("璁$畻澶辫触");
-                        }
+                    //鏍¢獙
+                    _checkResult = _hydroInfo.Check();
+                    if (!_checkResult.Succeed)
+                    {
+                        ShowCheckCtrl();
+                        TipFormHelper.ShowWarn("鏍¢獙澶辫触锛岃妫�鏌ュ悗閲嶈瘯");
+                        return;
+                    }
 
-                    };
+                    var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo);
+                    _calcuResult = netWork.Calcu();
+                    if (_calcuResult.Succeed)
+                    {
+                        this.docPnlRight.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden;
+                        await _bimfaceCtrl?.SetLogicCalcuCustomLabels(_calcuResult);
+                        TipFormHelper.ShowSucceed("璁$畻鎴愬姛锛�");
+                    }
+                    else
+                    {
+                        _calcuCtrl.SetFailedList(_calcuResult.FailedList);
+                        this.docPnlRight.Text = "澶辫触鍘熷洜";
+                        this.docPnlRight.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
+                        TipFormHelper.ShowError("璁$畻澶辫触");
+                    }
+                };
             }
             return _calcuCtrl;
         }
-        private XhsProjectSimulationCalcuCtrl _calcuCtrl = null;//璁$畻鎺т欢
+
+        //鑾峰彇璁$畻缁撴灉
+        private List<IHydroCalcuResult> GetAllCalcuResult()
+        {
+            if (_hydroInfo == null)
+            {
+                return default;
+            }
+            if (_calcuResult == null)
+            {
+                return default;
+            }
+            if (!_calcuResult.Succeed)
+            {
+                return default;
+            }
+            var list = new List<IHydroCalcuResult>();
+
+            var allNodeList = _hydroInfo.GetAllNodes();
+            if (allNodeList != null && allNodeList.Count > 0)
+            {
+                var allCalcuNodeList = _calcuResult.NodeList;
+                if (allCalcuNodeList != null && allCalcuNodeList.Count > 0)
+                {
+                    foreach (var node in allNodeList)
+                    {
+                        var calcuNode = allCalcuNodeList.Find(x => x.Id == node.Code);
+                        if (calcuNode != null)
+                        {
+                            var calcuResult = new HydroCalcuNodeResult()
+                            {
+                                Code = node.Code,
+                                CalcuPress = calcuNode.Press,
+                                CalcuHead = calcuNode.Head,
+                                CalcuDemand = calcuNode.Demand
+                            };
+                            list.Add(calcuResult);
+                        }
+                    }
+                }
+            }
+
+            var allListList = _hydroInfo.GetAllLinks();
+            if (allListList != null && allListList.Count > 0)
+            {
+                var allCalcuLinkList = _calcuResult.LinkList;
+                if (allCalcuLinkList != null && allCalcuLinkList.Count > 0)
+                {
+                    foreach (var link in allListList)
+                    {
+                        var calcuLink = allCalcuLinkList.Find(x => x.Id == link.Code);
+                        if (calcuLink != null)
+                        {
+                            var calcuResult = new HydroCalcuLinkResult()
+                            {
+                                Code = link.Code,
+                                CalcuFlow = calcuLink.Flow,
+                                CalcuVelocity = calcuLink.Velocity,
+                                CalcuHeadLoss = calcuLink.Headloss
+                            };
+                            list.Add(calcuResult);
+                        }
+                    }
+                }
+            }
+
+            return list;
+        }
 
         //姘村姏璁$畻
         private void barBtnHydroCalcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
@@ -710,21 +870,21 @@
             {
                 return;
             }
-
-            this.controlContainerBottom.Controls.Clear();
-            var calcuCtrl = GetCalcuCtrl();
-            calcuCtrl.SetBindingData(_hydroInfo);
-            this.controlContainerBottom.Controls.Add(calcuCtrl);
-            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
-            this.docPnlBottom.Text = "璁$畻鍓嶆彁鏉′欢";
-            this.docPnlBottom.Height = 350;
+            var calcuPrefixCtrl = GetCalcuCtrl();
+            calcuPrefixCtrl.SetBindingData();
+            this.controlContainerRight.Controls.Clear();
+            this.controlContainerRight.Controls.Add(calcuPrefixCtrl);
+            this.docPnlRight.Text = "鍓嶆彁鏉′欢";
+            this.docPnlRight.Width = SetHydroCalcuPrefixCtrl.ControlMinWidth;
+            this.docPnlRight.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
         }
-
-
 
         #endregion
 
         #region 鏋勪欢鏌ヨ
+
+        //鏌ヨ缁勪欢
+        private XhsProjectSimulationSearchCtrl _searchCtrl = null;
 
         //鑾峰彇鏌ヨ缁勪欢
         private XhsProjectSimulationSearchCtrl GetSearchCtrl()
@@ -759,34 +919,36 @@
             }
             return _searchCtrl;
         }
-        private XhsProjectSimulationSearchCtrl _searchCtrl = null;//鏌ヨ缁勪欢
 
-        //鏌ヨ
-        private void barBtnSearch_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        //鏄剧ず鏌ヨ鎺т欢
+        private void ShowSearchCtrl()
         {
             if (_hydroInfo == null)
             {
                 return;
             }
-
-            this.controlContainerBottom.Controls.Clear();
             var searchCtrl = GetSearchCtrl();
+            this.controlContainerBottom.Controls.Clear();
             this.controlContainerBottom.Controls.Add(searchCtrl);
             this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
-            this.docPnlBottom.Text = "妯″瀷鏋勪欢鏌ヨ";
+            this.docPnlBottom.Text = "鏋勪欢鏌ヨ";
             this.docPnlBottom.Height = 350;
         }
 
+        //鏌ヨ
+        private void barBtnSearch_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            ShowSearchCtrl();
+        }
+
         #endregion
-
-
 
         #region 鏍囨敞
 
         private List<HydroMarkSetViewModel> _allMarkList = null;
 
-        //鏍囨敞
-        private void barBtnMark_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        //璁剧疆鏍囨敞
+        private void barBtnMarkSet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
             if (_hydroInfo == null)
             {
@@ -845,12 +1007,120 @@
             dlg.SetBindingData(() => _hydroInfo, _allMarkList);
             dlg.ReloadDataEvent += async (obj) =>
             {
-                var leadLabels = obj?.Select(x => new LeadLabel() { Id = x.Code, Text = x.Text }).ToList();
-                await _bimfaceCtrl?.SetLeadLabels(leadLabels);
+                var leadLabels = obj?.Select(x => new LogicMarkLeadLabel() { Id = x.Code, Text = x.Text }).ToList();
+                await _bimfaceCtrl?.SetLogicMarkLeadLabels(leadLabels);
             };
             dlg.ShowDialog();
         }
 
+        //鍙栨秷鏍囨敞
+        private async void barBtnMarkCancel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            await _bimfaceCtrl?.ClearLogicMarkLeadLabels();
+        }
+
         #endregion
+
+        #region 棰滆壊鍒嗙骇
+
+        private List<HydroGradingApplyViewModel> _allGradingApplyList = null;
+        private List<string> _allGradingCodeList = null;
+
+        //璁剧疆
+        private void barBtnGradingSet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            var dlg = new SetHydroGradingModelDlg();
+            dlg.SetBindingData(_hydroInfo.ID);
+            dlg.ShowDialog();
+        }
+
+        //搴旂敤
+        private void barBtnGradingApply_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            if (_allGradingApplyList == null)
+            {
+                _allGradingApplyList = new List<HydroGradingApplyViewModel>();
+                if (_hydroInfo.Waterboxs != null && _hydroInfo.Waterboxs.Count > 0)
+                {
+                    _allGradingApplyList.Add(new HydroGradingApplyViewModel()
+                    {
+                        Code = Yw.Hydro.ParterCatalog.Waterbox,
+                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Waterbox),
+                        PropName = string.Empty
+                    });
+                }
+                if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0)
+                {
+                    _allGradingApplyList.Add(new HydroGradingApplyViewModel()
+                    {
+                        Code = Yw.Hydro.ParterCatalog.Pump,
+                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pump),
+                        PropName = string.Empty
+                    });
+                }
+                if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0)
+                {
+                    _allGradingApplyList.Add(new HydroGradingApplyViewModel()
+                    {
+                        Code = Yw.Hydro.ParterCatalog.Valve,
+                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Valve),
+                        PropName = string.Empty
+                    });
+                }
+                if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0)
+                {
+                    _allGradingApplyList.Add(new HydroGradingApplyViewModel()
+                    {
+                        Code = Yw.Hydro.ParterCatalog.Pipe,
+                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pipe),
+                        PropName = string.Empty
+                    });
+                }
+                if (_hydroInfo.Nozzles != null && _hydroInfo.Nozzles.Count > 0)
+                {
+                    _allGradingApplyList.Add(new HydroGradingApplyViewModel()
+                    {
+                        Code = Yw.Hydro.ParterCatalog.Nozzle,
+                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Nozzle),
+                        PropName = string.Empty
+                    });
+                }
+            }
+            var dlg = new ApplyHydroGradingDlg();
+            dlg.SetBindingData(() => _hydroInfo, _allGradingApplyList, GetAllCalcuResult());
+            dlg.ReloadDataEvent += (obj) =>
+            {
+                _allGradingCodeList = obj?.Select(x => x.Code).Distinct().ToList();
+                var objGroupList = obj?.GroupBy(x => x.Color).ToList();
+                objGroupList.ForEach(async x =>
+                {
+                    await _bimfaceCtrl?.OverrideComponentsColor(x.Select(t => t.Code).Distinct().ToList(), x.Key, 1);
+                });
+            };
+            dlg.ShowDialog();
+        }
+
+        //鍙栨秷
+        private async void barBtnGradingCancel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            await _bimfaceCtrl?.RestoreComponentsColor(_allGradingCodeList);
+        }
+
+        #endregion
+
+
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3