From c0a8df94a97281d7ed5a38550dd6fcf73e9cf0c8 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期六, 09 十一月 2024 13:53:43 +0800
Subject: [PATCH] 核心修改

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs | 1902 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 1,606 insertions(+), 296 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 4279474..0a32a23 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,8 +1,11 @@
 锘縢lobal using Yw.EPAnet;
 using DevExpress.Mvvm.Native;
+using DevExpress.Xpo.Helpers;
 using DevExpress.XtraRichEdit.Layout;
 using DevExpress.XtraSpreadsheet.Commands;
 using HStation.WinFrmUI.PhartRelation;
+using System.Diagnostics;
+using System.Windows.Media;
 using System.Windows.Media.Media3D;
 using Yw.Pump;
 using Yw.Vmo;
@@ -26,9 +29,10 @@
         private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;//椤圭洰绔�
         private Yw.Model.HydroModelInfo _hydroInfo = null;//姘村姏淇℃伅
 
-        private Yw.Model.HydroParterInfo _parter = null;
-        private Yw.WinFrmUI.HydroCheckResult _checkResult = null;
-        private Yw.EPAnet.CalcuResult _calcuResult = null;
+
+        private Yw.WinFrmUI.HydroCheckResult _checkResult = null;//妫�鏌ョ粨鏋�
+        private Yw.EPAnet.CalcuResult _calcuResult = null;//璁$畻缁撴灉
+
 
         /// <summary>
         /// 缁戝畾鏁版嵁
@@ -76,6 +80,7 @@
 
         }
 
+
         #region Bimface
 
         //bimface鎺т欢
@@ -95,6 +100,7 @@
                     {
                         return;
                     }
+                    ApplyGrading();
                 };
                 _bimfaceCtrl.HydroMouseLeftClickEvent += (obj) =>
                 {//榧犳爣宸﹂敭鐐瑰嚮浜嬩欢
@@ -102,8 +108,8 @@
                     {
                         return;
                     }
-                    _parter = obj;
-                    ShowProperty();
+                    _selectedVisual = obj;
+                    ShowSelectedProperty();
                 };
             }
             return _bimfaceCtrl;
@@ -115,6 +121,11 @@
             var bimfaceCtrl = await GetBimfaceCtrl();
             this.tabPageBimface.Controls.Clear();
             this.tabPageBimface.Controls.Add(bimfaceCtrl);
+        }
+
+        private void SelectBimfaceParter()
+        {
+
         }
 
         #endregion
@@ -138,9 +149,9 @@
                     {
                         return;
                     }
-                    var allParterList = _hydroInfo.GetAllParters();
-                    _parter = allParterList?.Find(x => x.Code == obj?.FirstOrDefault());
-                    ShowProperty();
+                    var allParterList = _hydroInfo.GetAllVisuals();
+                    _selectedVisual = allParterList?.Find(x => x.Code == obj?.FirstOrDefault());
+                    ShowSelectedProperty();
                 };
             }
             return _q3dCtrl;
@@ -156,7 +167,7 @@
 
         #endregion
 
-        #region 鏋勪欢灞炴��
+        #region 灞炴�ф帶浠�
 
         //灞炴�ф帶浠�
         private XhsProjectSimulationPropertyCtrl _propertyCtrl = null;
@@ -217,13 +228,72 @@
                     await Task.Delay(5000);
                     await _bimfaceCtrl?.ClearBlinkComponents();
                 };
+
+                _propertyCtrl.ViewParterEvent += (parter) =>
+                {
+                    if (parter == null)
+                    {
+                        return;
+                    }
+                    _bimfaceCtrl?.ZoomToComponent(parter.Code);
+                };
+                _propertyCtrl.PropertyValueChangedEvent += (parter) =>
+                {
+                    if (parter == null)
+                    {
+                        return;
+                    }
+                    UpdateVisualListCtrl();
+                    AutoApplyGrading();
+                };
+                _propertyCtrl.MarkPropertyValueChangedEvent += (parter) =>
+                {
+                    //鏍囨敞灞炴�у彂鐢熸敼鍙�
+                    //鍒ゆ柇褰撳墠鏄惁鏈夋爣娉ㄥ睍绀猴紝鑻ユ湁鍒欐洿鏂版爣娉紝鏈�濂芥槸鏇存柊鍗曚釜鏍囨敞
+                };
+                _propertyCtrl.GradingPropertyValueChangedEvent += (parter) =>
+                {
+                    //鍒嗙骇灞炴�у彂鐢熸敼鍙�
+                    //鍒ゆ柇褰撳墠鏄惁鏈夊垎绾у睍绀猴紝鑻ユ湁鍒欐洿鏂板垎绾э紝鏈�濂芥槸鏇存柊鍗曚釜鍒嗙骇
+                };
+                _propertyCtrl.FlowDirectionPropertyValueChangedEvent += async (parter) =>
+                {
+                    //娴佸悜灞炴�у彂鐢熸敼鍙�
+                    //鍒ゆ柇娴佸悜鏄惁鍔犺浇锛屽鏋滃姞杞藉垯鏇存柊娴佸悜锛屾渶濂芥槸鏇存柊鍗曚釜娴佸悜
+                    UpdateFlowEffect(parter);
+                    //await _bimfaceCtrl?.UnloadFlowEffectById(parter.Code);
+                };
+
             }
             return _propertyCtrl;
         }
 
-        //鏄剧ず灞炴�ч潰鏉�
+        //灞炴�ф帶浠舵槸鍚﹀彲瑙�
+        private bool IsPropertyCtrlVisible
+        {
+            get
+            {
+                if (this.docPnlRight.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible)
+                {
+                    if (this.controlContainerRight.Controls.Count > 0)
+                    {
+                        if (this.controlContainerRight.Controls[0] is XhsProjectSimulationPropertyCtrl)
+                        {
+                            return true;
+                        }
+                    }
+                }
+                return false;
+            }
+        }
+
+        //鏄剧ず灞炴�ф帶浠�
         private void ShowPropertyCtrl()
         {
+            if (IsPropertyCtrlVisible)
+            {
+                return;
+            }
             var propertyCtrl = GetPropertyCtrl();
             this.controlContainerRight.Controls.Clear();
             this.controlContainerRight.Controls.Add(propertyCtrl);
@@ -232,42 +302,46 @@
             this.docPnlRight.Width = 300;
         }
 
-        //灞炴�ч潰鏉挎寜閽�
-        private void barBtnProperty_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        //鏄剧ず閫夋嫨灞炴��
+        private void ShowSelectedProperty()
         {
-            ShowPropertyCtrl();
+            ShowSelectedProperty(_selectedVisual);
         }
 
-        //鏄剧ず灞炴��
-        private void ShowProperty()
+        //鏄剧ず閫夋嫨灞炴��
+        private void ShowSelectedProperty(Yw.Model.HydroVisualInfo visual)
         {
             if (_hydroInfo == null)
             {
                 return;
             }
-            if (this.docPnlRight.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Hidden)
+            ShowPropertyCtrl();
+            _selectedVisual = visual;
+            if (_selectedVisual == null)
             {
-                ShowPropertyCtrl();
-            }
-            if (_parter == null)
-            {
-                _propertyCtrl?.SelectParter(null);
+                _propertyCtrl.SelectedObject = null;
                 return;
             }
-            _propertyCtrl?.SelectParter(_parter.Code);
+            _propertyCtrl.SelectedObject = GetVisualViewModel(_selectedVisual);
+        }
 
-            var allCalcuResultList = GetCalcuResultList();
-            if (allCalcuResultList != null && allCalcuResultList.Count > 0)
+        //鏇存柊閫夋嫨灞炴��
+        private void UpdateSelectedProperty()
+        {
+            if (!IsPropertyCtrlVisible)
             {
-                var calcuResult = allCalcuResultList.Find(x => x.Code == _parter.Code);
-                if (calcuResult != null)
-                {
-                    _propertyCtrl?.UpdateCalcuProperty(calcuResult);
-                }
+                return;
             }
+            if (_selectedVisual == null)
+            {
+                return;
+            }
+            _propertyCtrl?.UpdateRows();
         }
 
         #endregion
+
+
 
         #region 鑷姩鍖归厤
 
@@ -284,15 +358,15 @@
                     {
                         return;
                     }
-                    var allParterList = _hydroInfo.GetAllParters();
-                    _parter = allParterList?.Find(x => x.Code == code);
+                    var allParterList = _hydroInfo.GetAllVisuals();
+                    _selectedVisual = allParterList?.Find(x => x.Code == code);
                     var elementIds = new List<string>();
-                    if (_parter != null)
+                    if (_selectedVisual != null)
                     {
-                        elementIds.Add(_parter.Code);
+                        elementIds.Add(_selectedVisual.Code);
                     }
                     await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
-                    ShowProperty();
+                    ShowSelectedProperty();
                 };
                 _matchingListCtrl.ApplyMatchingEvent += (output) =>
                 {
@@ -347,18 +421,18 @@
                     {
                         return;
                     }
-                    var allParterList = _hydroInfo.GetAllParters();
-                    _parter = allParterList?.Find(x => x.Code == parter.Code);
+                    var allParterList = _hydroInfo.GetAllVisuals();
+                    _selectedVisual = allParterList?.Find(x => x.Code == parter.Code);
                     var elementIds = new List<string>() { parter.Code };
                     await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
-                    ShowProperty();
+                    ShowSelectedProperty();
                 };
                 _unMatchingListCtrl.ViewModelEvent += async (parters) =>//鏌ョ湅妯″瀷
                 {
                     var codes = parters?.Select(x => x.Code).Distinct().ToList();
                     await _bimfaceCtrl?.ZoomAndSelectComponents(codes);
-                    _parter = null;
-                    ShowProperty();
+                    _selectedVisual = null;
+                    ShowSelectedProperty();
                 };
             }
             return _unMatchingListCtrl;
@@ -386,8 +460,11 @@
 
         #region 涓�閿樉闅�
 
+        //鏄鹃殣缂栫爜鍒楄〃
+        private List<string> _fastShowHiddenCodeList = null;
+
         //涓�閿樉闅�
-        private async Task FastShowHidden()
+        private async void FastShowHidden()
         {
             if (_hydroInfo == null)
             {
@@ -409,85 +486,15 @@
             }
         }
 
-        //鏄鹃殣缂栫爜鍒楄〃
-        private List<string> _fastShowHiddenCodeList = null;
-
         //瑙﹀彂涓�閿樉闅�
-        private async void barBtnFastShowHidden_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        private void barBtnFastShowHidden_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            await FastShowHidden();
+            FastShowHidden();
         }
 
         #endregion
 
-        #region 姘村姏鏍¢獙
 
-        //鏍¢獙鎺т欢
-        private XhsProjectSimulationHydroCheckResultCtrl _checkCtrl = null;
-
-        //鑾峰彇鏍¢獙鎺т欢
-        private XhsProjectSimulationHydroCheckResultCtrl GetCheckCtrl()
-        {
-            if (_checkCtrl == null)
-            {
-                _checkCtrl = new XhsProjectSimulationHydroCheckResultCtrl();
-                _checkCtrl.Dock = DockStyle.Fill;
-                _checkCtrl.HydroClickEvent += async (code) =>
-                {
-                    if (_hydroInfo == null)
-                    {
-                        return;
-                    }
-                    var elementIds = new List<string>();
-                    if (string.IsNullOrEmpty(code))
-                    {
-                        _parter = null;
-                    }
-                    else
-                    {
-                        var allParterList = _hydroInfo.GetAllParters();
-                        _parter = allParterList?.Find(x => x.Code == code);
-                        if (_parter != null)
-                        {
-                            elementIds.Add(_parter.Code);
-                        }
-                    }
-                    await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
-                    ShowProperty();
-                };
-            }
-            return _checkCtrl;
-        }
-
-        //鏄剧ず妫�鏌ユ帶浠�
-        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)
-        {
-            if (_hydroInfo == null)
-            {
-                return;
-            }
-            _checkResult = _hydroInfo.Check();
-            ShowCheckCtrl();
-        }
-
-        #endregion
 
         #region 淇濆瓨淇℃伅
 
@@ -498,7 +505,17 @@
             {
                 return;
             }
+            Stopwatch sw = new Stopwatch();
+            sw.Start();
+
+
             var id = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(_hydroInfo);
+
+            //鑰楁椂宸ㄥぇ鐨勪唬鐮�  
+
+            sw.Stop();
+            TimeSpan ts2 = sw.Elapsed;
+            Console.WriteLine("Stopwatch鎬诲叡鑺辫垂{0}ms.", ts2.TotalMilliseconds);
             if (id < 1)
             {
                 TipFormHelper.ShowError("淇濆瓨澶辫触锛�");
@@ -510,56 +527,7 @@
 
         #endregion
 
-        #region 鏋勪欢鏄庣粏
 
-        //鏋勪欢鏄庣粏鎺т欢
-        private Yw.WinFrmUI.HydroParterListCtrl _parterListCtrl = null;
-
-        //鑾峰彇鏋勪欢鏄庣粏鎺т欢
-        private Yw.WinFrmUI.HydroParterListCtrl GetParterListCtrl()
-        {
-            if (_parterListCtrl == null)
-            {
-                _parterListCtrl = new HydroParterListCtrl();
-                _parterListCtrl.Dock = DockStyle.Fill;
-                _parterListCtrl.HydroClickEvent += async (parter) =>
-                {
-                    if (_hydroInfo == null)
-                    {
-                        return;
-                    }
-                    var allParterList = _hydroInfo.GetAllParters();
-                    _parter = allParterList?.Find(x => x.Code == parter.Code);
-                    await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _parter.Code });
-                    ShowProperty();
-                };
-            }
-            return _parterListCtrl;
-        }
-
-        //鏄剧ず鏋勪欢鏄庣粏鎺т欢
-        private void ShowParterListCtrl()
-        {
-            if (_hydroInfo == null)
-            {
-                return;
-            }
-            var parterListCtrl = GetParterListCtrl();
-            parterListCtrl.SetBindingData(_hydroInfo, GetCalcuResultList());
-            this.controlContainerBottom.Controls.Clear();
-            this.controlContainerBottom.Controls.Add(parterListCtrl);
-            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
-            this.docPnlBottom.Text = "鏋勪欢鏄庣粏";
-            this.docPnlBottom.Height = 350;
-        }
-
-        //鏋勪欢鏄庣粏
-        private void barBtnHydroParterList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
-        {
-            ShowParterListCtrl();
-        }
-
-        #endregion
 
         #region INP瀵煎嚭
 
@@ -591,52 +559,95 @@
             //姘村簱
             this.barBtnSetReservoirList.ItemClick += delegate
             {
-                var dlg = new HydroReservoirBulkSetListDlg();
-                dlg.ShowDialog();
+                //var dlg = new HydroReservoirBulkSetListDlg();
+                //dlg.ShowDialog();
             };
             //姘存睜
             this.barBtnSetTankList.ItemClick += delegate
             {
-                var dlg = new HydroTankBulkSetListDlg();
-                dlg.ShowDialog();
+                //var dlg = new HydroTankBulkSetListDlg();
+                //dlg.ShowDialog();
             };
             //姘寸
             this.barBtnSetWaterboxList.ItemClick += delegate
             {
-                if (_hydroInfo == null)
-                {
-                    return;
-                }
-                var dlg = new HydroWaterboxBulkSetListDlg();
-                dlg.SetBindingData(_hydroInfo);
-                dlg.ShowDialog();
+                //if (_hydroInfo == null)
+                //{
+                //    return;
+                //}
+                //var dlg = new SetHydroWaterboxListDlg();
+                //dlg.SetBindingData(_hydroInfo);
+                //dlg.HydroClickEvent += async (obj) =>
+                //{
+                //    if (obj == null)
+                //    {
+                //        return;
+                //    }
+                //    _selectedParter = obj;
+                //    await _bimfaceCtrl?.ZoomAndSelectComponent(obj.Code);
+                //    ShowProperty();
+                //};
+                //dlg.HydroChangedEvent += (obj) =>
+                //{
+
+                //};
+                //dlg.ShowDialog();
             };
             //杩炴帴鑺傜偣
             this.barBtnSetJunctionList.ItemClick += delegate
             {
-                var dlg = new HydroJunctionBulkSetListDlg();
-                dlg.ShowDialog();
+                //var dlg = new HydroJunctionBulkSetListDlg();
+                //dlg.ShowDialog();
             };
             //闂峰ご
             this.barBtnSetBluntheadList.ItemClick += delegate
             {
-                if (_hydroInfo == null)
-                {
-                    return;
-                }
-                var dlg = new HydroBluntheadBulkSetListDlg();
-                dlg.ShowDialog();
+                //if (_hydroInfo == null)
+                //{
+                //    return;
+                //}
+                //var dlg = new SetHydroBluntheadListDlg();
+                //dlg.SetBindingData(_hydroInfo);
+                //dlg.HydroClickEvent += async (obj) =>
+                //{
+                //    if (obj == null)
+                //    {
+                //        return;
+                //    }
+                //    _selectedParter = obj;
+                //    await _bimfaceCtrl?.ZoomAndSelectComponent(obj.Code);
+                //    ShowProperty();
+                //};
+                //dlg.HydroChangedEvent += (obj) =>
+                //{
+
+                //};
+                //dlg.ShowDialog();
             };
             //寮ご
             this.barBtnSetElbowsList.ItemClick += delegate
             {
-                if (_hydroInfo == null)
-                {
-                    return;
-                }
-                var dlg = new HydroElbowBulkSetListDlg();
-                dlg.SetBindingData(_hydroInfo);
-                dlg.ShowDialog();
+                //if (_hydroInfo == null)
+                //{
+                //    return;
+                //}
+                //var dlg = new SetHydroElbowListDlg();
+                //dlg.SetBindingData(_hydroInfo);
+                //dlg.HydroClickEvent += async (obj) =>
+                //{
+                //    if (obj == null)
+                //    {
+                //        return;
+                //    }
+                //    _selectedParter = obj;
+                //    await _bimfaceCtrl?.ZoomAndSelectComponent(obj.Code);
+                //    ShowProperty();
+                //};
+                //dlg.HydroChangedEvent += (obj) =>
+                //{
+
+                //};
+                //dlg.ShowDialog();
             };
             //涓夐��
             this.barBtnSetThreelinkList.ItemClick += delegate
@@ -645,7 +656,7 @@
                 {
                     return;
                 }
-                var dlg = new HydroThreelinkBulkSetListDlg();
+                var dlg = new SetHydroThreelinkListDlg();
                 dlg.SetBindingData(_hydroInfo);
                 dlg.ShowDialog();
             };
@@ -656,7 +667,7 @@
                 {
                     return;
                 }
-                var dlg = new HydroFourlinkBulkSetListDlg();
+                var dlg = new SetHydroFourlinkListDlg();
                 dlg.SetBindingData(_hydroInfo);
                 dlg.ShowDialog();
             };
@@ -667,7 +678,7 @@
                 {
                     return;
                 }
-                var dlg = new HydroMeterBulkSetListDlg();
+                var dlg = new SetHydroMeterListDlg();
                 dlg.SetBindingData(_hydroInfo);
                 dlg.ShowDialog();
             };
@@ -678,7 +689,7 @@
                 {
                     return;
                 }
-                var dlg = new HydroFlowmeterBulkSetListDlg();
+                var dlg = new SetHydroFlowmeterListDlg();
                 dlg.SetBindingData(_hydroInfo);
                 dlg.ShowDialog();
             };
@@ -689,7 +700,7 @@
                 {
                     return;
                 }
-                var dlg = new HydroPressmeterBulkSetListDlg();
+                var dlg = new SetHydroPressmeterListDlg();
                 dlg.SetBindingData(_hydroInfo);
                 dlg.ShowDialog();
             };
@@ -700,7 +711,7 @@
                 {
                     return;
                 }
-                var dlg = new HydroPipeBulkSetListDlg();
+                var dlg = new SetHydroPipeListDlg();
                 dlg.SetBindingData(_hydroInfo);
                 dlg.ShowDialog();
             };
@@ -711,7 +722,7 @@
                 {
                     return;
                 }
-                var dlg = new HydroPumpBulkSetListDlg();
+                var dlg = new SetHydroPumpListDlg();
                 dlg.SetBindingData(_hydroInfo);
                 dlg.ShowDialog();
             };
@@ -722,7 +733,7 @@
                 {
                     return;
                 }
-                var dlg = new HydroValveBulkSetListDlg();
+                var dlg = new SetHydroValveListDlg();
                 dlg.SetBindingData(_hydroInfo);
                 dlg.ShowDialog();
             };
@@ -1022,7 +1033,7 @@
                         pump.SpeedRatio = Math.Round(x.CurrentHz / pump.RatedHz, 1);
                     }
                 });
-                ShowProperty();
+                ShowSelectedProperty();
                 return true;
             };
             dlg.ShowDialog();
@@ -1035,31 +1046,27 @@
 
         #region 鍓嶆彁鏉′欢
 
-        //鏄剧ず璁$畻鍓嶆彁鏉′欢绐椾綋
-        private void ShowCalcuPrefixDlg()
+
+        //鏄剧ず宸ュ喌璁$畻绐椾綋
+        private void ShowWorkingCalcuDlg()
         {
-            if (_hydroInfo == null)
-            {
-                return;
-            }
-            var dlg = new HStation.WinFrmUI.SetHydroCalcuPrefixDlg1();
-            dlg.SetBindingData(_hydroInfo);
+            var dlg = new SetHydroWorkingInfoDlg();
             dlg.HydroViewEvent += async (parter) =>
             {
-                _parter = parter;
-                if (_parter != null)
+                _selectedVisual = parter as Yw.Model.HydroVisualInfo;
+                if (_selectedVisual != null)
                 {
-                    await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _parter.Code });
+                    await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _selectedVisual.Code });
                 }
-                ShowProperty();
+                ShowSelectedProperty();
             };
-            dlg.HydroCalcuEvent += async () =>
+            dlg.HydroCalcuEvent += async (hydroInfo, workingInfo) =>
             {
                 if (_hydroInfo == null)
                 {
                     return;
                 }
-
+                _hydroInfo.UpdateWorkingInfo(workingInfo);
                 //鏍¢獙
                 _checkResult = _hydroInfo.Check();
                 if (!_checkResult.Succeed)
@@ -1070,6 +1077,7 @@
                 }
 
                 WaitFormHelper.ShowWaitForm(this, "姝e湪璁$畻鍒嗘瀽涓紝璇风◢鍊�...");
+
 
                 await Task.Delay(5000);
 
@@ -1082,14 +1090,19 @@
                     GetCalcuResultList(false);
                     await _bimfaceCtrl?.SetLogicCalcuCustomLabels(_calcuResult);
                     TipFormHelper.ShowSucceed("璁$畻鎴愬姛锛�");
+                    var codes = _hydroInfo.Pumps.Select(x => x.Code).ToList();
+                    await _bimfaceCtrl?.ZoomAndSelectComponents(codes);
                 }
                 else
                 {
                     ShowCalcuFailedCtrl();
                     TipFormHelper.ShowError("璁$畻澶辫触锛�");
                 }
-
+                AutoApplyGrading();
+                UpdateVisualListCtrl();
+                ShowSelectedProperty();
             };
+            dlg.SetBindingData(_hydroInfo);
             dlg.ShowDialog();
         }
 
@@ -1312,7 +1325,8 @@
         //姘村姏璁$畻
         private void barBtnHydroCalcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            ShowCalcuPrefixDlg();
+            //ShowCalcuPrefixDlg();
+            ShowWorkingCalcuDlg();
         }
 
         #endregion
@@ -1320,49 +1334,69 @@
         #region 鏋勪欢鏌ヨ
 
         //鏌ヨ缁勪欢
-        private XhsProjectSimulationSearchCtrl _searchCtrl = null;
+        private HydroVisualSearchListCtrl _searchCtrl = null;
 
         //鑾峰彇鏌ヨ缁勪欢
-        private XhsProjectSimulationSearchCtrl GetSearchCtrl()
+        private HydroVisualSearchListCtrl GetSearchCtrl()
         {
             if (_searchCtrl == null)
             {
-                _searchCtrl = new XhsProjectSimulationSearchCtrl();
+                _searchCtrl = new HydroVisualSearchListCtrl();
                 _searchCtrl.Dock = DockStyle.Fill;
-                _searchCtrl.InitialData(() => _hydroInfo);
-                _searchCtrl.ApplySearchEvent += async (list) =>
+                var allVisualViewModelList = GetVisualViewModelList();
+                _searchCtrl.InitialData(allVisualViewModelList);
+                _searchCtrl.HydroClickInfoEvent += async (visual) =>
                 {
-                    if (_hydroInfo == null)
-                    {
-                        return;
-                    }
+                    ShowSelectedProperty(visual);
+                    await _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
+                };
+                _searchCtrl.HydroSearchInfoEvent += async (list) =>
+                {
                     var elementIds = new List<string>();
                     if (list != null && list.Count > 0)
                     {
-                        var first = list.First();
-                        var allParterList = _hydroInfo.GetAllParters();
-                        _parter = allParterList?.Find(x => x.Code == first.Code);
+                        _selectedVisual = list.First();
                         list.ForEach(x => elementIds.Add(x.Code));
                     }
                     else
                     {
-                        _parter = null;
+                        _selectedVisual = null;
                     }
+                    ShowSelectedProperty();
                     await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
-                    ShowProperty();
                 };
             }
             return _searchCtrl;
         }
 
-        //鏄剧ず鏌ヨ鎺т欢
-        private void ShowSearchCtrl()
+        //鏌ヨ鎺т欢鏄惁鍙
+        private bool IsSearchCtrlVisible
         {
-            if (_hydroInfo == null)
+            get
+            {
+                if (this.docPnlBottom.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible)
+                {
+                    if (this.controlContainerBottom.Controls.Count > 0)
+                    {
+                        if (this.controlContainerBottom.Controls[0] is HydroVisualSearchListCtrl)
+                        {
+                            return true;
+                        }
+                    }
+                }
+                return false;
+            }
+        }
+
+        //鏄剧ず鏌ヨ鎺т欢
+        private void ShowSearchCtrl(string content)
+        {
+            if (IsSearchCtrlVisible)
             {
                 return;
             }
             var searchCtrl = GetSearchCtrl();
+            searchCtrl.SetBindingData(content);
             this.controlContainerBottom.Controls.Clear();
             this.controlContainerBottom.Controls.Add(searchCtrl);
             this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
@@ -1370,81 +1404,547 @@
             this.docPnlBottom.Height = 350;
         }
 
+        //鏄剧ず鏌ヨ绐椾綋
+        private void ShowSearchDlg()
+        {
+            if (IsSearchCtrlVisible)
+            {
+                return;
+            }
+            var dlg = new InputHydroVisualSearchListDlg();
+            dlg.SearchEvent += (content) =>
+            {
+                if (string.IsNullOrEmpty(content))
+                {
+                    return;
+                }
+                ShowSearchCtrl(content);
+            };
+            dlg.SetBindingData();
+            dlg.ShowDialog();
+        }
+
         //鏌ヨ
         private void barBtnSearch_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            ShowSearchCtrl();
+            ShowSearchDlg();
         }
 
         #endregion
 
         #region 妯″瀷鏍囨敞
 
-        //鎵�鏈夋爣娉ㄥ垪琛�
-        private List<HydroMarkSetViewModel> _allMarkList = null;
+        //鎵�鏈夋爣娉ㄨ缃垪琛�
+        private List<HydroMarkSetViewModel> _allMarkSetList = null;
 
-        //鏄剧ず鏍囨敞绐椾綋
-        private void ShowMarkDlg()
+        //鑾峰彇鏍囨敞璁剧疆鍒楄〃
+        private List<HydroMarkSetViewModel> GetMarkSetList()
         {
-            if (_hydroInfo == null)
+            if (_allMarkSetList == null)
             {
-                return;
-            }
-            if (_allMarkList == null)
-            {
-                _allMarkList = new List<HydroMarkSetViewModel>();
+                _allMarkSetList = new List<HydroMarkSetViewModel>();
                 if (_hydroInfo.Waterboxs != null && _hydroInfo.Waterboxs.Count > 0)
                 {
-                    _allMarkList.Add(new HydroMarkSetViewModel()
+                    _allMarkSetList.Add(new HydroMarkSetViewModel()
                     {
                         Code = Yw.Hydro.ParterCatalog.Waterbox,
-                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Waterbox),
+                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Waterbox),
                         MarkType = (int)eWaterboxMarkType.None
                     });
                 }
                 if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0)
                 {
-                    _allMarkList.Add(new HydroMarkSetViewModel()
+                    _allMarkSetList.Add(new HydroMarkSetViewModel()
                     {
                         Code = Yw.Hydro.ParterCatalog.Pump,
-                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pump),
+                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pump),
                         MarkType = (int)eWaterboxMarkType.None
                     });
                 }
                 if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0)
                 {
-                    _allMarkList.Add(new HydroMarkSetViewModel()
+                    _allMarkSetList.Add(new HydroMarkSetViewModel()
                     {
                         Code = Yw.Hydro.ParterCatalog.Valve,
-                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Valve),
+                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Valve),
                         MarkType = (int)eWaterboxMarkType.None
                     });
                 }
                 if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0)
                 {
-                    _allMarkList.Add(new HydroMarkSetViewModel()
+                    _allMarkSetList.Add(new HydroMarkSetViewModel()
                     {
                         Code = Yw.Hydro.ParterCatalog.Pipe,
-                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pipe),
+                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pipe),
                         MarkType = (int)eWaterboxMarkType.None
                     });
                 }
                 if (_hydroInfo.Nozzles != null && _hydroInfo.Nozzles.Count > 0)
                 {
-                    _allMarkList.Add(new HydroMarkSetViewModel()
+                    _allMarkSetList.Add(new HydroMarkSetViewModel()
                     {
                         Code = Yw.Hydro.ParterCatalog.Nozzle,
-                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Nozzle),
+                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Nozzle),
                         MarkType = (int)eWaterboxMarkType.None
                     });
                 }
             }
-            var dlg = new SetHydroMarkDlg();
-            dlg.SetBindingData(_hydroInfo, _allMarkList);
-            dlg.ReloadDataEvent += async (allResultList) =>
+            return _allMarkSetList;
+        }
+
+        //鎵�鏈夋爣娉ㄧ粨鏋滃垪琛�
+        private List<HydroMarkResultViewModel> _allMarkResultList = null;
+
+        //鑾峰彇鏍囨敞缁撴灉鍒楄〃
+        private List<HydroMarkResultViewModel> GetMarkResultList()
+        {
+            if (_hydroInfo == null)
             {
-                var leadLabels = allResultList?.Select(x => new LogicMarkLeadLabel(x.Code, x.Text, 100000)).ToList();
-                await _bimfaceCtrl?.SetLogicMarkLeadLabels(leadLabels);
+                return default;
+            }
+            _allMarkResultList = new List<HydroMarkResultViewModel>();
+            var allMarkSetList = GetMarkSetList();
+            foreach (var markSet in allMarkSetList)
+            {
+                switch (markSet.Code)
+                {
+                    case Yw.Hydro.ParterCatalog.Waterbox:
+                        {
+                            if (_hydroInfo.Waterboxs != null && _hydroInfo.Waterboxs.Count > 0)
+                            {
+                                switch ((eWaterboxMarkType)markSet.MarkType)
+                                {
+                                    case eWaterboxMarkType.None:
+                                        {
+
+                                        }
+                                        break;
+                                    case eWaterboxMarkType.PoolElev:
+                                        {
+                                            _hydroInfo.Waterboxs.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"姹犲簳鏍囬珮:{Math.Round(t.PoolElev, 4)}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eWaterboxMarkType.InitLevel:
+                                        {
+                                            _hydroInfo.Waterboxs.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鍒濆姘翠綅:{Math.Round(t.InitLevel, 4)}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eWaterboxMarkType.MinLevel:
+                                        {
+                                            _hydroInfo.Waterboxs.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鏈�灏忔按浣�:{Math.Round(t.MinLevel, 4)}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eWaterboxMarkType.MaxLevel:
+                                        {
+                                            _hydroInfo.Waterboxs.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鏈�楂樻按浣�:{Math.Round(t.MaxLevel, 4)}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eWaterboxMarkType.DN:
+                                        {
+                                            _hydroInfo.Waterboxs.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鐩村緞:{Math.Round(t.DN, 4)}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eWaterboxMarkType.MinVol:
+                                        {
+                                            _hydroInfo.Waterboxs.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鏈�灏忓绉�:{Math.Round(t.MinVol, 1)}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                        break;
+                    case Yw.Hydro.ParterCatalog.Pump:
+                        {
+                            if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0)
+                            {
+                                switch ((ePumpMarkType)markSet.MarkType)
+                                {
+                                    case ePumpMarkType.None:
+                                        {
+
+                                        }
+                                        break;
+                                    case ePumpMarkType.PumpStatus:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"寮�鏈虹姸鎬�:{Yw.WinFrmUI.HydroLinkStatusHelper.GetStatusName(t.LinkStatus)}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePumpMarkType.RatedP:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"棰濆畾鍔熺巼:{t.RatedP}kW"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePumpMarkType.RatedQ:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"棰濆畾娴侀噺:{t.RatedQ}m鲁/h"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePumpMarkType.RatedH:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"棰濆畾鎵▼:{t.RatedH}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePumpMarkType.RatedN:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"棰濆畾杞��:{t.RatedN}r/min"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePumpMarkType.RatedHz:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"棰濆畾棰戠巼:{t.RatedHz}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePumpMarkType.CurrentN:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                if (t.RatedN.HasValue)
+                                                {
+                                                    _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                    {
+                                                        Code = t.Code,
+                                                        Text = $"璁惧畾杞��:{Math.Round(t.RatedN.Value * t.SpeedRatio, 1)}r/min"
+                                                    });
+                                                }
+                                            });
+                                        }
+                                        break;
+                                    case ePumpMarkType.CurrentHz:
+                                        {
+                                            _hydroInfo.Pumps.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"璁惧畾棰戠巼:{Math.Round(t.RatedHz * t.SpeedRatio, 1)}hz"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                        break;
+                    case Yw.Hydro.ParterCatalog.Valve:
+                        {
+                            if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0)
+                            {
+                                switch ((eValveMarkType)markSet.MarkType)
+                                {
+                                    case eValveMarkType.None:
+                                        {
+
+                                        }
+                                        break;
+                                    case eValveMarkType.ValveStatus:
+                                        {
+                                            _hydroInfo.Valves.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"闃�闂ㄧ姸鎬�:{HydroLinkStatusHelper.GetStatusName(t.LinkStatus)}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eValveMarkType.ValveType:
+                                        {
+                                            _hydroInfo.Valves.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"闃�闂ㄧ被鍨�:{HydroValveTypeHelper.GetTypeName(t.ValveType)}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eValveMarkType.Diameter:
+                                        {
+                                            _hydroInfo.Valves.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鐩村緞:{t.Diameter}mm"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eValveMarkType.MinorLoss:
+                                        {
+                                            _hydroInfo.Valves.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"灞�闃荤郴鏁�:{t.MinorLoss}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                        break;
+                    case Yw.Hydro.ParterCatalog.Pipe:
+                        {
+                            if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0)
+                            {
+                                switch ((ePipeMarkType)markSet.MarkType)
+                                {
+                                    case ePipeMarkType.None:
+                                        {
+
+                                        }
+                                        break;
+                                    case ePipeMarkType.PipeStatus:
+                                        {
+                                            _hydroInfo.Pipes.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鐘舵��:{Yw.WinFrmUI.HydroLinkStatusHelper.GetStatusName(t.LinkStatus)}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePipeMarkType.Diameter:
+                                        {
+                                            _hydroInfo.Pipes.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鐩村緞:{t.Diameter}mm"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePipeMarkType.Length:
+                                        {
+                                            _hydroInfo.Pipes.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"闀垮害:{t.Length}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePipeMarkType.Roughness:
+                                        {
+                                            _hydroInfo.Pipes.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"绮楃硻绯绘暟:{t.Roughness}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case ePipeMarkType.MinorLoss:
+                                        {
+                                            _hydroInfo.Pipes.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"灞�闃荤郴鏁�:{t.MinorLoss}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                        break;
+                    case Yw.Hydro.ParterCatalog.Nozzle:
+                        {
+                            if (_hydroInfo.Nozzles != null && _hydroInfo.Nozzles.Count > 0)
+                            {
+                                switch ((eNozzleMarkType)markSet.MarkType)
+                                {
+                                    case eNozzleMarkType.None:
+                                        {
+
+                                        }
+                                        break;
+                                    case eNozzleMarkType.Elev:
+                                        {
+                                            _hydroInfo.Nozzles.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鏍囬珮:{Math.Round(t.Elev, 4)}m"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eNozzleMarkType.Demand:
+                                        {
+                                            _hydroInfo.Nozzles.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"闇�姘撮噺:{t.Demand}m鲁/h"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    case eNozzleMarkType.Coefficient:
+                                        {
+                                            _hydroInfo.Nozzles.ForEach(t =>
+                                            {
+                                                _allMarkResultList.Add(new HydroMarkResultViewModel()
+                                                {
+                                                    Code = t.Code,
+                                                    Text = $"鍠峰皠绯绘暟:{t.Coefficient}"
+                                                });
+                                            });
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                        break;
+                    default: break;
+                }
+            }
+            return _allMarkResultList;
+        }
+
+        //搴旂敤鏍囨敞缁撴灉鍒楄〃
+        private async Task ApplyMarkResultList()
+        {
+            var allMarkResultList = GetMarkResultList();
+            var leadLabels = allMarkResultList?.Select(x => new LogicMarkLeadLabel(x.Code, x.Text, 100000)).ToList();
+            await _bimfaceCtrl?.SetLogicMarkLeadLabels(leadLabels);
+            TipFormHelper.ShowSucceed("鏍囨敞淇℃伅宸茶缃�");
+        }
+
+        //娓呴櫎鏍囨敞缁撴灉鍒楄〃
+        private async Task ClearMarkResultList()
+        {
+            if (_allMarkResultList == null || _allMarkResultList.Count < 1)
+            {
+                TipFormHelper.ShowWarn("灏氭湭璁剧疆鏍囨敞淇℃伅");
+                return;
+            }
+            _allMarkResultList = null;
+            await _bimfaceCtrl?.ClearLogicMarkLeadLabels();
+            TipFormHelper.ShowSucceed("鏍囨敞淇℃伅宸叉竻闄�");
+        }
+
+        //鏄剧ず鏍囨敞璁剧疆绐椾綋
+        private void ShowMarkSetDlg()
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            var allMarkSetList = GetMarkSetList();
+            var dlg = new SetHydroMarkDlg();
+            dlg.SetBindingData(allMarkSetList);
+            dlg.ReloadDataEvent += async (list) =>
+            {
+                _allMarkSetList = list;
+                await ApplyMarkResultList();
             };
             dlg.ShowDialog();
         }
@@ -1452,7 +1952,13 @@
         //璁剧疆鏍囨敞
         private void barBtnSetMark_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            ShowMarkDlg();
+            ShowMarkSetDlg();
+        }
+
+        //娓呴櫎鏍囨敞
+        private async void barBtnClearMark_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            await ClearMarkResultList();
         }
 
         #endregion
@@ -1515,9 +2021,9 @@
             {
                 _allGradingList = list;
             };
-            dlg.ApplyDataEvent += () =>
+            dlg.ApplyDataEvent += (catalog, propName) =>
             {
-                ShowApplyGradingDlg();
+                ApplyGrading(catalog, propName);
             };
             dlg.ShowDialog();
         }
@@ -1547,7 +2053,7 @@
                     _allGradingApplyList.Add(new HydroGradingApplyViewModel()
                     {
                         Code = Yw.Hydro.ParterCatalog.Pump,
-                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pump),
+                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pump),
                         PropName = Yw.Hydro.ParterProp.LinkStatus
                     });
                 }
@@ -1556,7 +2062,7 @@
                     _allGradingApplyList.Add(new HydroGradingApplyViewModel()
                     {
                         Code = Yw.Hydro.ParterCatalog.Valve,
-                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Valve),
+                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Valve),
                         PropName = Yw.Hydro.ParterProp.LinkStatus
                     });
                 }
@@ -1565,16 +2071,13 @@
                     _allGradingApplyList.Add(new HydroGradingApplyViewModel()
                     {
                         Code = Yw.Hydro.ParterCatalog.Pipe,
-                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pipe),
+                        Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pipe),
                         PropName = Yw.Hydro.ParterProp.CalcuFlow
                     });
                 }
             }
             return _allGradingApplyList;
         }
-
-        //棰滆壊鍒嗙骇搴旂敤缁撴灉鍒楄〃
-        private List<HydroGradingApplyResultViewModel> _allGradingApplyResultList = null;
 
         //鑾峰彇棰滆壊鍒嗙骇搴旂敤缁撴灉鍒楄〃
         private async Task<List<HydroGradingApplyResultViewModel>> GetGradingApplyResultList()
@@ -1598,9 +2101,11 @@
                 return default;
             }
 
+            //鎵�鏈夎绠楃粨鏋滃垪琛�
             var allCalcuResultList = GetCalcuResultList();
 
-            _allGradingApplyResultList = new List<HydroGradingApplyResultViewModel>();
+            //鎵�鏈夊簲鐢ㄧ粨鏋滃垪琛�
+            var allGradingApplyResultList = new List<HydroGradingApplyResultViewModel>();
             allGradingApplyList.ForEach(x =>
             {
                 var allCatalogGradingList = allGradingList.Where(t => t.Catalog == x.Code).ToList();
@@ -1629,7 +2134,7 @@
                                                                 Code = pump.Code,
                                                                 Color = grading.Color
                                                             };
-                                                            _allGradingApplyResultList.Add(result);
+                                                            allGradingApplyResultList.Add(result);
                                                         }
                                                     }
                                                 }
@@ -1652,7 +2157,7 @@
                                                                         Code = pump.Code,
                                                                         Color = grading.Color
                                                                     };
-                                                                    _allGradingApplyResultList.Add(result);
+                                                                    allGradingApplyResultList.Add(result);
                                                                 }
                                                             }
                                                         }
@@ -1677,7 +2182,7 @@
                                                                         Code = pump.Code,
                                                                         Color = grading.Color
                                                                     };
-                                                                    _allGradingApplyResultList.Add(result);
+                                                                    allGradingApplyResultList.Add(result);
                                                                 }
                                                             }
                                                         }
@@ -1702,7 +2207,7 @@
                                                                         Code = pump.Code,
                                                                         Color = grading.Color
                                                                     };
-                                                                    _allGradingApplyResultList.Add(result);
+                                                                    allGradingApplyResultList.Add(result);
                                                                 }
                                                             }
                                                         }
@@ -1736,7 +2241,7 @@
                                                                 Code = valve.Code,
                                                                 Color = grading.Color
                                                             };
-                                                            _allGradingApplyResultList.Add(result);
+                                                            allGradingApplyResultList.Add(result);
                                                         }
                                                     }
                                                 }
@@ -1759,7 +2264,7 @@
                                                                         Code = valve.Code,
                                                                         Color = grading.Color
                                                                     };
-                                                                    _allGradingApplyResultList.Add(result);
+                                                                    allGradingApplyResultList.Add(result);
                                                                 }
                                                             }
                                                         }
@@ -1784,7 +2289,7 @@
                                                                         Code = valve.Code,
                                                                         Color = grading.Color
                                                                     };
-                                                                    _allGradingApplyResultList.Add(result);
+                                                                    allGradingApplyResultList.Add(result);
                                                                 }
                                                             }
                                                         }
@@ -1809,7 +2314,7 @@
                                                                         Code = valve.Code,
                                                                         Color = grading.Color
                                                                     };
-                                                                    _allGradingApplyResultList.Add(result);
+                                                                    allGradingApplyResultList.Add(result);
                                                                 }
                                                             }
                                                         }
@@ -1848,7 +2353,7 @@
                                                                         Code = pipe.Code,
                                                                         Color = grading.Color
                                                                     };
-                                                                    _allGradingApplyResultList.Add(result);
+                                                                    allGradingApplyResultList.Add(result);
                                                                 }
                                                             }
                                                         }
@@ -1873,7 +2378,7 @@
                                                                         Code = pipe.Code,
                                                                         Color = grading.Color
                                                                     };
-                                                                    _allGradingApplyResultList.Add(result);
+                                                                    allGradingApplyResultList.Add(result);
                                                                 }
                                                             }
                                                         }
@@ -1898,7 +2403,7 @@
                                                                         Code = pipe.Code,
                                                                         Color = grading.Color
                                                                     };
-                                                                    _allGradingApplyResultList.Add(result);
+                                                                    allGradingApplyResultList.Add(result);
                                                                 }
                                                             }
                                                         }
@@ -1916,11 +2421,365 @@
                 }
             });
 
-            return _allGradingApplyResultList;
+            return allGradingApplyResultList;
         }
 
-        //棰滆壊鍒嗙骇缂栫爜鍒楄〃
-        private List<string> _allGradingCodeList = null;
+        //鑾峰彇棰滆壊鍒嗙骇搴旂敤缁撴灉鍒楄〃
+        private async Task<List<HydroGradingApplyResultViewModel>> GetGradingApplyResultList(string catalog, string propName)
+        {
+            if (_hydroInfo == null)
+            {
+                return default;
+            }
+
+            //鎵�鏈夊垎绾у垪琛�
+            var allGradingList = await GetGradingList();
+            if (allGradingList == null || allGradingList.Count < 1)
+            {
+                return default;
+            }
+            var currentGradingList = allGradingList.Where(x => x.Catalog == catalog).ToList();
+            if (currentGradingList.Count < 1)
+            {
+                return default;
+            }
+
+            //鎵�鏈夊垎绾у簲鐢ㄥ垪琛�
+            var allGradingApplyList = GetGradingApplyList();
+            if (allGradingApplyList == null || allGradingApplyList.Count < 1)
+            {
+                return default;
+            }
+
+            //褰撳墠鍒嗙骇搴旂敤
+            var gradingApply = allGradingApplyList.Find(x => x.Code == catalog);
+            if (gradingApply == null)
+            {
+                return default;
+            }
+            gradingApply.PropName = propName;
+
+            //鎵�鏈夎绠楃粨鏋�
+            var allCalcuResultList = GetCalcuResultList();
+
+            //搴旂敤缁撴灉鍒楄〃
+            var gradingApplyResultList = new List<HydroGradingApplyResultViewModel>();
+
+            switch (catalog)
+            {
+                case Yw.Hydro.ParterCatalog.Pump:
+                    {
+                        if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0)
+                        {
+                            foreach (var pump in _hydroInfo.Pumps)
+                            {
+                                switch (propName)
+                                {
+                                    case Yw.Hydro.ParterProp.LinkStatus:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.LinkStatus).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var grading = gradingList.Meet(pump.LinkStatus);
+                                                if (grading != null)
+                                                {
+                                                    var result = new HydroGradingApplyResultViewModel()
+                                                    {
+                                                        Code = pump.Code,
+                                                        Color = grading.Color
+                                                    };
+                                                    gradingApplyResultList.Add(result);
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuFlow:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuFlow.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = pump.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuVelocity:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuVelocity.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = pump.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuHeadLoss:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuHeadLoss.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = pump.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                    }
+                    break;
+                case Yw.Hydro.ParterCatalog.Valve:
+                    {
+                        if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0)
+                        {
+                            foreach (var valve in _hydroInfo.Valves)
+                            {
+                                switch (propName)
+                                {
+                                    case Yw.Hydro.ParterProp.LinkStatus:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.LinkStatus).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var grading = gradingList.Meet(valve.LinkStatus);
+                                                if (grading != null)
+                                                {
+                                                    var result = new HydroGradingApplyResultViewModel()
+                                                    {
+                                                        Code = valve.Code,
+                                                        Color = grading.Color
+                                                    };
+                                                    gradingApplyResultList.Add(result);
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuFlow:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuFlow.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = valve.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuVelocity:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuVelocity.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = valve.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuHeadLoss:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuHeadLoss.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = valve.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                    }
+                    break;
+                case Yw.Hydro.ParterCatalog.Pipe:
+                    {
+                        if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0)
+                        {
+                            foreach (var pipe in _hydroInfo.Pipes)
+                            {
+                                switch (propName)
+                                {
+                                    case Yw.Hydro.ParterProp.CalcuFlow:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuFlow.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = pipe.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuVelocity:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuVelocity.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = pipe.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    case Yw.Hydro.ParterProp.CalcuHeadLoss:
+                                        {
+                                            var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList();
+                                            if (gradingList != null && gradingList.Count > 0)
+                                            {
+                                                var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code);
+                                                if (calcuResult is HydroCalcuLinkResult calcuLinkResult)
+                                                {
+                                                    if (calcuLinkResult.CalcuHeadLoss.HasValue)
+                                                    {
+                                                        var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value));
+                                                        if (grading != null)
+                                                        {
+                                                            var result = new HydroGradingApplyResultViewModel()
+                                                            {
+                                                                Code = pipe.Code,
+                                                                Color = grading.Color
+                                                            };
+                                                            gradingApplyResultList.Add(result);
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                        break;
+                                    default: break;
+                                }
+                            }
+                        }
+                    }
+                    break;
+                default: break;
+            }
+
+            return gradingApplyResultList;
+        }
+
+        //棰滆壊鍒嗙骇鏄惁搴旂敤浜�
+        private bool _isGradingApply = false;
+        //棰滆壊鍒嗙骇搴旂敤缂栫爜鍒楄〃
+        private List<string> _allGradingApplyCodeList = null;
 
         //搴旂敤棰滆壊鍒嗙骇
         private async void ApplyGrading()
@@ -1929,13 +2788,70 @@
             {
                 return;
             }
+            _isGradingApply = true;
             var allGradingApplyResultList = await GetGradingApplyResultList();
-            _allGradingCodeList = allGradingApplyResultList?.Select(x => x.Code).Distinct().ToList();
-            var objGroupList = allGradingApplyResultList?.GroupBy(x => x.Color).ToList();
-            objGroupList?.ForEach(async x =>
+            if (allGradingApplyResultList == null || allGradingApplyResultList.Count < 1)
+            {
+                CancelApplyGrading();
+                return;
+            }
+            var objGroupList = allGradingApplyResultList.GroupBy(x => x.Color).ToList();
+            objGroupList.ForEach(async x =>
             {
                 await _bimfaceCtrl?.OverrideComponentsColor(x.Select(t => t.Code).Distinct().ToList(), x.Key, 1);
             });
+            _allGradingApplyCodeList = allGradingApplyResultList.Select(x => x.Code).Distinct().ToList();
+        }
+
+        //搴旂敤棰滆壊鍒嗙骇
+        private async void ApplyGrading(string catalog, string propName)
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            _isGradingApply = true;
+            var allGradingApplyResultList = await GetGradingApplyResultList(catalog, propName);
+            if (allGradingApplyResultList == null || allGradingApplyResultList.Count < 1)
+            {
+                return;
+            }
+            var objGroupList = allGradingApplyResultList.GroupBy(x => x.Color).ToList();
+            objGroupList.ForEach(async x =>
+            {
+                await _bimfaceCtrl?.OverrideComponentsColor(x.Select(t => t.Code).Distinct().ToList(), x.Key, 1);
+            });
+            var codeList = allGradingApplyResultList.Select(x => x.Code);
+            if (_allGradingApplyCodeList == null)
+            {
+                _allGradingApplyCodeList = new List<string>();
+            }
+            _allGradingApplyCodeList.AddRange(codeList);
+            _allGradingApplyCodeList = _allGradingApplyCodeList.Distinct().ToList();
+        }
+
+        //鑷姩搴旂敤棰滆壊鍒嗙骇
+        private void AutoApplyGrading()
+        {
+            if (!_isGradingApply)
+            {
+                return;
+            }
+            ApplyGrading();
+        }
+
+        //鍙栨秷搴旂敤棰滆壊鍒嗙骇
+        private async void CancelApplyGrading()
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            _isGradingApply = false;
+            if (_allGradingApplyCodeList != null && _allGradingApplyCodeList.Count > 0)
+            {
+                await _bimfaceCtrl?.RestoreComponentsColor(_allGradingApplyCodeList);
+            }
         }
 
         //鏄剧ず搴旂敤棰滆壊鍒嗙骇绐椾綋
@@ -1952,7 +2868,7 @@
             }
             var dlg = new ApplyHydroGradingDlg();
             dlg.SetBindingData(allGradingApplyList);
-            dlg.ReloadDataEvent += async (obj) =>
+            dlg.ReloadDataEvent += (obj) =>
             {
                 _allGradingApplyList = obj;
                 ApplyGrading();
@@ -1964,6 +2880,12 @@
         private void barBtnGradingApply_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
             ShowApplyGradingDlg();
+        }
+
+        //鍙栨秷搴旂敤鍒嗙骇
+        private void batBtnCancelGradingApply_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            CancelApplyGrading();
         }
 
         #endregion
@@ -1987,30 +2909,418 @@
                 }
                 var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance
                     .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation);
+                Stopwatch sw = new Stopwatch();
+                sw.Start();
                 _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID);
-                _parter = null;
+                sw.Stop();
+                TimeSpan ts2 = sw.Elapsed;
+                Console.WriteLine("Stopwatch鎬诲叡鑺辫垂{0}ms.", ts2.TotalMilliseconds);
+                _selectedVisual = null;
                 await _bimfaceCtrl?.ZoomAndSelectComponents(null);
-                ShowProperty();
+                ShowSelectedProperty();
                 TipFormHelper.ShowSucceed("鏁版嵁宸插埛鏂�");
             }
         }
 
         #endregion
 
-        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        #region 姘存祦鍔ㄧ敾
+
+        //鎵�鏈夋祦鍚戝垪琛�
+        private List<Yw.WinFrmUI.Bimface.LogicFlowEffect> _allFlowEffectList = null;
+
+        //鑾峰彇娴佸悜鍒楄〃
+        private List<Yw.WinFrmUI.Bimface.LogicFlowEffect> GetFlowEffectList()
         {
-            var pipes = _hydroInfo.GetAllPipes();
-            var list = pipes.Select(x =>
+            if (_allFlowEffectList == null)
             {
-                return new Yw.WinFrmUI.Bimface.LogicFlowEffect()
+                if (_hydroInfo == null)
                 {
-                    Id = x.Code,
-                    Rotation = 90,
-                    Direction = true,
-                    Speed = 0.1d
-                };
-            }).ToList();
-            _bimfaceCtrl?.LoadAllFlowMaterialList(list);
+                    return default;
+                }
+                _allFlowEffectList = new List<LogicFlowEffect>();
+                var allCalcuResultList = GetCalcuResultList();
+                if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0)
+                {
+                    foreach (var parter in _hydroInfo.Pipes)
+                    {
+                        var flowEffect = new LogicFlowEffect();
+                        _allFlowEffectList.Add(flowEffect);
+                        flowEffect.Id = parter.Code;
+                        flowEffect.Rotation = 90;
+                        flowEffect.SpeedX = 0.1;
+                        if (parter.FlowDirectionX == Yw.Hydro.FlowDirection.None)
+                        {
+                            flowEffect.SpeedX = 0;
+                        }
+                        else if (parter.FlowDirectionX == Yw.Hydro.FlowDirection.Positive)
+                        {
+                            flowEffect.SpeedX = 0.1;
+                        }
+                        else
+                        {
+                            flowEffect.SpeedX = -0.1;
+                        }
+
+                        if (parter.FlowDirectionY == Yw.Hydro.FlowDirection.None)
+                        {
+                            flowEffect.SpeedY = 0;
+                        }
+                        else if (parter.FlowDirectionY == Yw.Hydro.FlowDirection.Positive)
+                        {
+                            flowEffect.SpeedY = 0.1;
+                        }
+                        else
+                        {
+                            flowEffect.SpeedY = -0.1;
+                        }
+
+                        var calcuResult = allCalcuResultList?.Find(x => x.Code == parter.Code) as HydroCalcuLinkResult;
+                        if (calcuResult != null)
+                        {
+                            if (calcuResult.CalcuVelocity < 0)
+                            {
+                                flowEffect.SpeedX = -flowEffect.SpeedX;
+                            }
+                        }
+                    }
+                }
+            }
+            return _allFlowEffectList;
         }
+
+        /// <summary>
+        /// 鍔犺浇姘存祦鍔ㄧ敾
+        /// </summary>
+        private async void LoadFlowEffect()
+        {
+            if (_allFlowEffectList != null)
+            {
+                return;
+            }
+            var allFlowEffectList = GetFlowEffectList();
+            await _bimfaceCtrl?.LoadFlowEffect(allFlowEffectList);
+        }
+
+        //鍗歌浇娴佸悜
+        private async void UnloadFlowEffect()
+        {
+            if (_allFlowEffectList == null)
+            {
+                return;
+            }
+            _allFlowEffectList = null;
+            await _bimfaceCtrl?.UnloadFlowEffect();
+        }
+
+        //鏇存柊姘存祦鍔ㄧ敾
+        private async void UpdateFlowEffect(Yw.Model.HydroParterInfo parter)
+        {
+            if (_allFlowEffectList == null)
+            {
+                return;
+            }
+            var visual = parter as Yw.Model.HydroVisualInfo;
+            if (visual == null)
+            {
+                return;
+            }
+            var flowEffect = _allFlowEffectList.Find(x => x.Id == parter.Code);
+            if (flowEffect == null)
+            {
+                return;
+            }
+            if (visual.FlowDirectionX == Yw.Hydro.FlowDirection.None)
+            {
+                flowEffect.SpeedX = 0;
+            }
+            else if (visual.FlowDirectionX == Yw.Hydro.FlowDirection.Positive)
+            {
+                flowEffect.SpeedX = 0.1;
+            }
+            else
+            {
+                flowEffect.SpeedX = -0.1;
+            }
+
+            if (visual.FlowDirectionY == Yw.Hydro.FlowDirection.None)
+            {
+                flowEffect.SpeedY = 0;
+            }
+            else if (visual.FlowDirectionY == Yw.Hydro.FlowDirection.Positive)
+            {
+                flowEffect.SpeedY = 0.1;
+            }
+            else
+            {
+                flowEffect.SpeedY = -0.1;
+            }
+
+            var allCalcuResultList = GetCalcuResultList();
+            var calcuResult = allCalcuResultList?.Find(x => x.Code == visual.Code) as HydroCalcuLinkResult;
+            if (calcuResult != null)
+            {
+                if (calcuResult.CalcuVelocity < 0)
+                {
+                    flowEffect.SpeedX = -flowEffect.SpeedX;
+                }
+            }
+            await _bimfaceCtrl?.UpdateFlowEffect(flowEffect);
+        }
+
+        //鍔犺浇娴佸悜
+        private void barBtnLoadFlowDirection_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            LoadFlowEffect();
+        }
+
+        //鍗歌浇娴佸悜
+        private void barBtnUnloadFlowDirection_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            UnloadFlowEffect();
+        }
+
+        #endregion
+
+        #region 鍙瑙嗗浘
+
+        //鎵�鏈夊彲瑙佽鍥惧垪琛�
+        private List<HydroVisualViewModel> _allVisualViewModelList = null;
+
+        //鑾峰彇鍙瑙嗗浘鍒楄〃
+        private List<HydroVisualViewModel> GetVisualViewModelList()
+        {
+            if (_hydroInfo == null)
+            {
+                return default;
+            }
+            if (_allVisualViewModelList == null)
+            {
+                _allVisualViewModelList = new List<HydroVisualViewModel>();
+                var allVisualList = _hydroInfo.GetAllVisuals();
+                if (allVisualList != null && allVisualList.Count > 0)
+                {
+                    var allCalcuResultList = GetCalcuResultList();
+                    allVisualList.ForEach(x =>
+                    {
+                        var vm = HydroVisualViewModelBuilder.CreateVisualViewModel(x, _hydroInfo);
+                        var calcuResult = allCalcuResultList?.Find(x => x.Code == x.Code);
+                        if (calcuResult != null)
+                        {
+                            vm.UpdateCalcuProperty(calcuResult);
+                        }
+                        _allVisualViewModelList.Add(vm);
+                    });
+                }
+            }
+            return _allVisualViewModelList;
+        }
+
+        //鏇存柊鍙瑙嗗浘璁$畻灞炴��
+        private void UpdateVisualViewModelCalcuProperty()
+        {
+            var allVisualViewModelList = GetVisualViewModelList();
+            if (allVisualViewModelList != null && allVisualViewModelList.Count > 0)
+            {
+                var allCalcuResultList = GetCalcuResultList();
+                if (allCalcuResultList != null && allCalcuResultList.Count > 0)
+                {
+                    allVisualViewModelList.ForEach(x =>
+                    {
+                        var calcuResult = allCalcuResultList.Find(t => t.Code == x.Code);
+                        if (calcuResult != null)
+                        {
+                            x.UpdateCalcuProperty(calcuResult);
+                        }
+                    });
+                }
+            }
+        }
+
+        //鑾峰彇鍙瑙嗗浘
+        private HydroVisualViewModel GetVisualViewModel(Yw.Model.HydroVisualInfo visual)
+        {
+            if (visual == null)
+            {
+                return default;
+            }
+            var allVisualViewModelList = GetVisualViewModelList();
+            return allVisualViewModelList?.Find(x => x.Code == visual.Code);
+        }
+
+        #endregion
+
+        #region 閫夋嫨鏋勪欢
+
+        //閫夋嫨鏋勪欢
+        private Yw.Model.HydroVisualInfo _selectedVisual = null;
+
+
+        #endregion
+
+        #region 鏋勪欢鏄庣粏
+
+        //鏋勪欢鏄庣粏鎺т欢
+        private Yw.WinFrmUI.HydroVisualListCtrl _visualListCtrl = null;
+
+        //鑾峰彇鏋勪欢鏄庣粏鎺т欢
+        private Yw.WinFrmUI.HydroVisualListCtrl GetVisualListCtrl()
+        {
+            if (_visualListCtrl == null)
+            {
+                _visualListCtrl = new HydroVisualListCtrl();
+                _visualListCtrl.Dock = DockStyle.Fill;
+                _visualListCtrl.HydroClickInfoEvent += async (visual) =>
+                {
+                    ShowSelectedProperty(visual);
+                    await _bimfaceCtrl?.ZoomAndSelectComponent(_selectedVisual?.Code);
+                };
+                _visualListCtrl.HydroChangedInfoEvent += (visualList) =>
+                {
+                    UpdateSelectedProperty();
+                    AutoApplyGrading();
+                };
+            }
+            return _visualListCtrl;
+        }
+
+        //鏋勪欢鏄庣粏鎺т欢鏄惁鍙
+        private bool IsVisualListCtrlVisible
+        {
+            get
+            {
+                if (this.docPnlBottom.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible)
+                {
+                    if (this.controlContainerBottom.Controls.Count > 0)
+                    {
+                        if (this.controlContainerBottom.Controls[0] is HydroVisualListCtrl)
+                        {
+                            return true;
+                        }
+                    }
+                }
+                return false;
+            }
+        }
+
+        //鏄剧ず鏋勪欢鏄庣粏鎺т欢
+        private void ShowVisualListCtrl()
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            if (IsVisualListCtrlVisible)
+            {
+                return;
+            }
+
+            var visualListCtrl = GetVisualListCtrl();
+            var allVisualViewModelList = GetVisualViewModelList();
+            visualListCtrl.SetBindingData(allVisualViewModelList);
+            var allCalcuResultList = GetCalcuResultList();
+            if (allCalcuResultList == null || allCalcuResultList.Count < 1)
+            {
+                visualListCtrl.SetNormalView();
+            }
+            else
+            {
+                visualListCtrl.SetCalcuView();
+            }
+            this.controlContainerBottom.Controls.Clear();
+            this.controlContainerBottom.Controls.Add(visualListCtrl);
+            this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
+            this.docPnlBottom.Text = "鏋勪欢鏄庣粏";
+            this.docPnlBottom.Height = 350;
+        }
+
+        //鏇存柊鏋勪欢鏄庣粏鎺т欢
+        private void UpdateVisualListCtrl()
+        {
+            if (!IsVisualListCtrlVisible)
+            {
+                return;
+            }
+            _visualListCtrl?.UpdateBindingData();
+        }
+
+        //鏋勪欢鏄庣粏
+        private void barBtnHydroVisualList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            ShowVisualListCtrl();
+        }
+
+        #endregion
+
+        #region 姘村姏鏍¢獙
+
+        //鏍¢獙鎺т欢
+        private XhsProjectSimulationHydroCheckResultCtrl _checkCtrl = null;
+
+        //鑾峰彇鏍¢獙鎺т欢
+        private XhsProjectSimulationHydroCheckResultCtrl GetCheckCtrl()
+        {
+            if (_checkCtrl == null)
+            {
+                _checkCtrl = new XhsProjectSimulationHydroCheckResultCtrl();
+                _checkCtrl.Dock = DockStyle.Fill;
+                _checkCtrl.HydroClickEvent += async (code) =>
+                {
+                    if (_hydroInfo == null)
+                    {
+                        return;
+                    }
+                    var elementIds = new List<string>();
+                    if (string.IsNullOrEmpty(code))
+                    {
+                        _selectedVisual = null;
+                    }
+                    else
+                    {
+                        var allParterList = _hydroInfo.GetAllVisuals();
+                        _selectedVisual = allParterList?.Find(x => x.Code == code);
+                        if (_selectedVisual != null)
+                        {
+                            elementIds.Add(_selectedVisual.Code);
+                        }
+                    }
+                    await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
+                    ShowSelectedProperty();
+                };
+            }
+            return _checkCtrl;
+        }
+
+        //鏄剧ず妫�鏌ユ帶浠�
+        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)
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            _checkResult = _hydroInfo.Check();
+            ShowCheckCtrl();
+        }
+
+        #endregion
+
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3