From c9585ab171fb973d16792d7a290994bf8279da63 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期六, 09 十一月 2024 09:56:41 +0800
Subject: [PATCH] 属性视图调整

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs |  882 +++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 502 insertions(+), 380 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 b08352f..9d867ed 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
@@ -5,6 +5,7 @@
 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;
@@ -31,6 +32,7 @@
 
         private Yw.WinFrmUI.HydroCheckResult _checkResult = null;//妫�鏌ョ粨鏋�
         private Yw.EPAnet.CalcuResult _calcuResult = null;//璁$畻缁撴灉
+
 
         /// <summary>
         /// 缁戝畾鏁版嵁
@@ -106,8 +108,8 @@
                     {
                         return;
                     }
-                    _selectedParter = obj;
-                    ShowProperty();
+                    _selectedVisual = obj;
+                    ShowSelectedProperty();
                 };
             }
             return _bimfaceCtrl;
@@ -147,9 +149,9 @@
                     {
                         return;
                     }
-                    var allParterList = _hydroInfo.GetAllParters();
-                    _selectedParter = allParterList?.Find(x => x.Code == obj?.FirstOrDefault());
-                    ShowProperty();
+                    var allParterList = _hydroInfo.GetAllVisuals();
+                    _selectedVisual = allParterList?.Find(x => x.Code == obj?.FirstOrDefault());
+                    ShowSelectedProperty();
                 };
             }
             return _q3dCtrl;
@@ -165,7 +167,7 @@
 
         #endregion
 
-        #region 鏋勪欢灞炴��
+        #region 灞炴�ф帶浠�
 
         //灞炴�ф帶浠�
         private XhsProjectSimulationPropertyCtrl _propertyCtrl = null;
@@ -241,7 +243,7 @@
                     {
                         return;
                     }
-                    UpdateParterListProperty(parter);
+                    UpdateVisualListCtrl();
                     AutoApplyGrading();
                 };
                 _propertyCtrl.MarkPropertyValueChangedEvent += (parter) =>
@@ -254,19 +256,44 @@
                     //鍒嗙骇灞炴�у彂鐢熸敼鍙�
                     //鍒ゆ柇褰撳墠鏄惁鏈夊垎绾у睍绀猴紝鑻ユ湁鍒欐洿鏂板垎绾э紝鏈�濂芥槸鏇存柊鍗曚釜鍒嗙骇
                 };
-                _propertyCtrl.FlowDirectionPropertyValueChangedEvent += (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);
@@ -275,136 +302,46 @@
             this.docPnlRight.Width = 300;
         }
 
-        //鏄剧ず灞炴��
-        private void ShowProperty()
+        //鏄剧ず閫夋嫨灞炴��
+        private void ShowSelectedProperty()
+        {
+            ShowSelectedProperty(_selectedVisual);
+        }
+
+        //鏄剧ず閫夋嫨灞炴��
+        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 (_selectedParter == null)
-            {
-                _propertyCtrl?.CancelSelectParter();
+                _propertyCtrl.SelectedObject = null;
                 return;
             }
-            _propertyCtrl?.SelectParter(_selectedParter.Code);
-
-            var allCalcuResultList = GetCalcuResultList();
-            if (allCalcuResultList != null && allCalcuResultList.Count > 0)
-            {
-                var calcuResult = allCalcuResultList.Find(x => x.Code == _selectedParter.Code);
-                if (calcuResult != null)
-                {
-                    _propertyCtrl?.UpdateCalcuProperty(calcuResult);
-                }
-            }
+            _propertyCtrl.SelectedObject = GetVisualViewModel(_selectedVisual);
         }
 
-
+        //鏇存柊閫夋嫨灞炴��
+        private void UpdateSelectedProperty()
+        {
+            if (!IsPropertyCtrlVisible)
+            {
+                return;
+            }
+            if (_selectedVisual == null)
+            {
+                return;
+            }
+            _propertyCtrl?.UpdateRows();
+        }
 
         #endregion
 
-        #region 閫夋嫨鏋勪欢
 
-        //閫夋嫨鏋勪欢
-        private Yw.Model.HydroParterInfo _selectedParter = null;
-
-        //鏇存柊閫夋嫨缁勪欢灞炴��
-        private void UpdateSelectedParterProperty()
-        {
-            if (_selectedParter == null)
-            {
-                return;
-            }
-            _propertyCtrl?.UpdateProperty();
-        }
-
-        //鏇存柊閫夋嫨缁勪欢璁$畻灞炴��
-        private void UpdateSelectedParterCalcuProperty()
-        {
-            if (_selectedParter == null)
-            {
-                return;
-            }
-            var allCalcuResultList = GetCalcuResultList();
-            if (allCalcuResultList == null || allCalcuResultList.Count < 1)
-            {
-                return;
-            }
-            var calcuResult = allCalcuResultList.Find(x => x.Code == _selectedParter.Code);
-            if (calcuResult == null)
-            {
-                return;
-            }
-            _propertyCtrl?.UpdateCalcuProperty(calcuResult);
-        }
-
-        //鏇存柊鏋勪欢鍒楄〃灞炴��
-        private void UpdateParterListProperty()
-        {
-            if (this.docPnlBottom.Visibility != DevExpress.XtraBars.Docking.DockVisibility.Visible)
-            {
-                return;
-            }
-            var parterListCtrl = this.controlContainerBottom.Controls[0] as Yw.WinFrmUI.HydroParterListCtrl;
-            if (parterListCtrl == null)
-            {
-                return;
-            }
-            parterListCtrl.UpdateProperty();
-        }
-
-        //鏇存柊鏋勪欢鍒楄〃灞炴��
-        private void UpdateParterListProperty(Yw.Model.HydroParterInfo parter)
-        {
-            if (this.docPnlBottom.Visibility != DevExpress.XtraBars.Docking.DockVisibility.Visible)
-            {
-                return;
-            }
-            var parterListCtrl = this.controlContainerBottom.Controls[0] as Yw.WinFrmUI.HydroParterListCtrl;
-            if (parterListCtrl == null)
-            {
-                return;
-            }
-            parterListCtrl.UpdateProperty(parter);
-        }
-
-        //鏇存柊鏋勪欢鍒楄〃灞炴��
-        private void UpdateParterListProperty(List<Yw.Model.HydroParterInfo> parterList)
-        {
-            if (this.docPnlBottom.Visibility != DevExpress.XtraBars.Docking.DockVisibility.Visible)
-            {
-                return;
-            }
-            var parterListCtrl = this.controlContainerBottom.Controls[0] as Yw.WinFrmUI.HydroParterListCtrl;
-            if (parterListCtrl == null)
-            {
-                return;
-            }
-            parterListCtrl.UpdateProperty(parterList);
-        }
-
-        //鏇存柊鏋勪欢鍒楄〃璁$畻灞炴��
-        private void UpdateParterListCalcuProperty()
-        {
-            if (this.docPnlBottom.Visibility != DevExpress.XtraBars.Docking.DockVisibility.Visible)
-            {
-                return;
-            }
-            var parterListCtrl = this.controlContainerBottom.Controls[0] as Yw.WinFrmUI.HydroParterListCtrl;
-            if (parterListCtrl == null)
-            {
-                return;
-            }
-            var allCalcuResultList = GetCalcuResultList();
-            parterListCtrl.UpdateCalcuProperty(allCalcuResultList);
-        }
-
-        #endregion
 
         #region 鑷姩鍖归厤
 
@@ -421,15 +358,15 @@
                     {
                         return;
                     }
-                    var allParterList = _hydroInfo.GetAllParters();
-                    _selectedParter = allParterList?.Find(x => x.Code == code);
+                    var allParterList = _hydroInfo.GetAllVisuals();
+                    _selectedVisual = allParterList?.Find(x => x.Code == code);
                     var elementIds = new List<string>();
-                    if (_selectedParter != null)
+                    if (_selectedVisual != null)
                     {
-                        elementIds.Add(_selectedParter.Code);
+                        elementIds.Add(_selectedVisual.Code);
                     }
                     await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
-                    ShowProperty();
+                    ShowSelectedProperty();
                 };
                 _matchingListCtrl.ApplyMatchingEvent += (output) =>
                 {
@@ -484,18 +421,18 @@
                     {
                         return;
                     }
-                    var allParterList = _hydroInfo.GetAllParters();
-                    _selectedParter = 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);
-                    _selectedParter = null;
-                    ShowProperty();
+                    _selectedVisual = null;
+                    ShowSelectedProperty();
                 };
             }
             return _unMatchingListCtrl;
@@ -578,19 +515,19 @@
                     var elementIds = new List<string>();
                     if (string.IsNullOrEmpty(code))
                     {
-                        _selectedParter = null;
+                        _selectedVisual = null;
                     }
                     else
                     {
-                        var allParterList = _hydroInfo.GetAllParters();
-                        _selectedParter = allParterList?.Find(x => x.Code == code);
-                        if (_selectedParter != null)
+                        var allParterList = _hydroInfo.GetAllVisuals();
+                        _selectedVisual = allParterList?.Find(x => x.Code == code);
+                        if (_selectedVisual != null)
                         {
-                            elementIds.Add(_selectedParter.Code);
+                            elementIds.Add(_selectedVisual.Code);
                         }
                     }
                     await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
-                    ShowProperty();
+                    ShowSelectedProperty();
                 };
             }
             return _checkCtrl;
@@ -657,65 +594,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) =>
-                {
-                    _selectedParter = parter;
-                    await _bimfaceCtrl?.ZoomAndSelectComponent(_selectedParter.Code);
-                    ShowProperty();
-                };
-                _parterListCtrl.HydroChangedEvent += (parterList) =>
-                {
-                    UpdateSelectedParterProperty();
-                    AutoApplyGrading();
-                };
-            }
-            return _parterListCtrl;
-        }
-
-        //鏄剧ず鏋勪欢鏄庣粏鎺т欢
-        private void ShowParterListCtrl()
-        {
-            if (_hydroInfo == null)
-            {
-                return;
-            }
-            var allCalcuResultList = GetCalcuResultList();
-            var parterListCtrl = GetParterListCtrl();
-            parterListCtrl.SetBindingData(_hydroInfo, allCalcuResultList);
-            if (allCalcuResultList == null || allCalcuResultList.Count < 1)
-            {
-                parterListCtrl.SetNormalView();
-            }
-            else
-            {
-                parterListCtrl.SetCalcuView();
-            }
-            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瀵煎嚭
 
@@ -759,27 +638,27 @@
             //姘寸
             this.barBtnSetWaterboxList.ItemClick += delegate
             {
-                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) =>
-                {
+                //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();
+                //};
+                //dlg.ShowDialog();
             };
             //杩炴帴鑺傜偣
             this.barBtnSetJunctionList.ItemClick += delegate
@@ -790,52 +669,52 @@
             //闂峰ご
             this.barBtnSetBluntheadList.ItemClick += delegate
             {
-                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) =>
-                {
+                //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();
+                //};
+                //dlg.ShowDialog();
             };
             //寮ご
             this.barBtnSetElbowsList.ItemClick += delegate
             {
-                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) =>
-                {
+                //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();
+                //};
+                //dlg.ShowDialog();
             };
             //涓夐��
             this.barBtnSetThreelinkList.ItemClick += delegate
@@ -1221,7 +1100,7 @@
                         pump.SpeedRatio = Math.Round(x.CurrentHz / pump.RatedHz, 1);
                     }
                 });
-                ShowProperty();
+                ShowSelectedProperty();
                 return true;
             };
             dlg.ShowDialog();
@@ -1234,64 +1113,6 @@
 
         #region 鍓嶆彁鏉′欢
 
-        //鏄剧ず璁$畻鍓嶆彁鏉′欢绐椾綋
-        private void ShowCalcuPrefixDlg()
-        {
-            if (_hydroInfo == null)
-            {
-                return;
-            }
-            var dlg = new HStation.WinFrmUI.SetHydroCalcuPrefixDlg1();
-            dlg.SetBindingData(_hydroInfo);
-            dlg.HydroViewEvent += async (parter) =>
-            {
-                _selectedParter = parter;
-                if (_selectedParter != null)
-                {
-                    await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _selectedParter.Code });
-                }
-                ShowProperty();
-            };
-            dlg.HydroCalcuEvent += async () =>
-            {
-                if (_hydroInfo == null)
-                {
-                    return;
-                }
-
-                //鏍¢獙
-                _checkResult = _hydroInfo.Check();
-                if (!_checkResult.Succeed)
-                {
-                    ShowCheckCtrl();
-                    TipFormHelper.ShowWarn("鏍¢獙澶辫触锛岃妫�鏌ュ悗閲嶈瘯");
-                    return;
-                }
-
-                WaitFormHelper.ShowWaitForm(this, "姝e湪璁$畻鍒嗘瀽涓紝璇风◢鍊�...");
-
-
-                //await Task.Delay(5000);
-
-                var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo);
-                _calcuResult = netWork.Calcu();
-
-                WaitFormHelper.HideWaitForm();
-                if (_calcuResult.Succeed)
-                {
-                    GetCalcuResultList(false);
-                    await _bimfaceCtrl?.SetLogicCalcuCustomLabels(_calcuResult);
-                    TipFormHelper.ShowSucceed("璁$畻鎴愬姛锛�");
-                }
-                else
-                {
-                    ShowCalcuFailedCtrl();
-                    TipFormHelper.ShowError("璁$畻澶辫触锛�");
-                }
-
-            };
-            dlg.ShowDialog();
-        }
 
         //鏄剧ず宸ュ喌璁$畻绐椾綋
         private void ShowWorkingCalcuDlg()
@@ -1299,12 +1120,12 @@
             var dlg = new SetHydroWorkingInfoDlg();
             dlg.HydroViewEvent += async (parter) =>
             {
-                _selectedParter = parter;
-                if (_selectedParter != null)
+                _selectedVisual = parter as Yw.Model.HydroVisualInfo;
+                if (_selectedVisual != null)
                 {
-                    await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _selectedParter.Code });
+                    await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _selectedVisual.Code });
                 }
-                ShowProperty();
+                ShowSelectedProperty();
             };
             dlg.HydroCalcuEvent += async (hydroInfo, workingInfo) =>
             {
@@ -1345,8 +1166,8 @@
                     TipFormHelper.ShowError("璁$畻澶辫触锛�");
                 }
                 AutoApplyGrading();
-                UpdateParterListProperty();
-                ShowProperty();
+                UpdateVisualListCtrl();
+                ShowSelectedProperty();
             };
             dlg.SetBindingData(_hydroInfo);
             dlg.ShowDialog();
@@ -1580,57 +1401,64 @@
         #region 鏋勪欢鏌ヨ
 
         //鏌ヨ缁勪欢
-        private HydroParterSearchListCtrl _searchCtrl = null;
+        private HydroVisualSearchListCtrl _searchCtrl = null;
 
         //鑾峰彇鏌ヨ缁勪欢
-        private HydroParterSearchListCtrl GetSearchCtrl()
+        private HydroVisualSearchListCtrl GetSearchCtrl()
         {
             if (_searchCtrl == null)
             {
-                _searchCtrl = new HydroParterSearchListCtrl();
+                _searchCtrl = new HydroVisualSearchListCtrl();
                 _searchCtrl.Dock = DockStyle.Fill;
-                _searchCtrl.InitialData(() => _hydroInfo);
-                _searchCtrl.HydroClickEvent += async (parter) =>
+                var allVisualViewModelList = GetVisualViewModelList();
+                _searchCtrl.InitialData(allVisualViewModelList);
+                _searchCtrl.HydroClickInfoEvent += async (visual) =>
                 {
-                    if (_hydroInfo == null)
-                    {
-                        return;
-                    }
-                    if (parter == null)
-                    {
-                        return;
-                    }
-                    _selectedParter = parter;
-                    await _bimfaceCtrl?.ZoomAndSelectComponent(parter.Code);
-                    ShowProperty();
+                    ShowSelectedProperty(visual);
+                    await _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                 };
-                _searchCtrl.HydroSearchEvent += async (list) =>
+                _searchCtrl.HydroSearchInfoEvent += async (list) =>
                 {
-                    if (_hydroInfo == null)
-                    {
-                        return;
-                    }
                     var elementIds = new List<string>();
                     if (list != null && list.Count > 0)
                     {
-                        _selectedParter = list.First();
+                        _selectedVisual = list.First();
                         list.ForEach(x => elementIds.Add(x.Code));
                     }
                     else
                     {
-                        _selectedParter = null;
+                        _selectedVisual = null;
                     }
+                    ShowSelectedProperty();
                     await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
-                    ShowProperty();
                 };
             }
             return _searchCtrl;
         }
 
+        //鏌ヨ鎺т欢鏄惁鍙
+        private bool IsSearchCtrlVisible
+        {
+            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 (_hydroInfo == null)
+            if (IsSearchCtrlVisible)
             {
                 return;
             }
@@ -1646,17 +1474,11 @@
         //鏄剧ず鏌ヨ绐椾綋
         private void ShowSearchDlg()
         {
-            if (this.docPnlBottom.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible)
+            if (IsSearchCtrlVisible)
             {
-                if (this.controlContainerBottom.Controls.Count > 0)
-                {
-                    if (this.controlContainerBottom.Controls[0] is HydroParterSearchListCtrl)
-                    {
-                        return;
-                    }
-                }
+                return;
             }
-            var dlg = new InputHydroParterSearchListDlg();
+            var dlg = new InputHydroVisualSearchListDlg();
             dlg.SearchEvent += (content) =>
             {
                 if (string.IsNullOrEmpty(content))
@@ -1693,7 +1515,7 @@
                     _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
                     });
                 }
@@ -1702,7 +1524,7 @@
                     _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
                     });
                 }
@@ -1711,7 +1533,7 @@
                     _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
                     });
                 }
@@ -1720,7 +1542,7 @@
                     _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
                     });
                 }
@@ -1729,7 +1551,7 @@
                     _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
                     });
                 }
@@ -2298,7 +2120,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
                     });
                 }
@@ -2307,7 +2129,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
                     });
                 }
@@ -2316,7 +2138,7 @@
                     _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
                     });
                 }
@@ -3160,9 +2982,9 @@
                 sw.Stop();
                 TimeSpan ts2 = sw.Elapsed;
                 Console.WriteLine("Stopwatch鎬诲叡鑺辫垂{0}ms.", ts2.TotalMilliseconds);
-                _selectedParter = null;
+                _selectedVisual = null;
                 await _bimfaceCtrl?.ZoomAndSelectComponents(null);
-                ShowProperty();
+                ShowSelectedProperty();
                 TipFormHelper.ShowSucceed("鏁版嵁宸插埛鏂�");
             }
         }
@@ -3171,31 +2993,331 @@
 
         #region 姘存祦鍔ㄧ敾
 
-        //鍔犺浇娴佸悜
-        private async void barBtnLoadFlowDirection_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        //鎵�鏈夋祦鍚戝垪琛�
+        private List<Yw.WinFrmUI.Bimface.LogicFlowEffect> _allFlowEffectList = null;
+
+        //鑾峰彇娴佸悜鍒楄〃
+        private List<Yw.WinFrmUI.Bimface.LogicFlowEffect> GetFlowEffectList()
         {
-            var pipes = _hydroInfo.Pipes;
-            var list = pipes.Select(x =>
+            if (_allFlowEffectList == null)
             {
-                return new Yw.WinFrmUI.Bimface.LogicFlowEffect()
+                if (_hydroInfo == null)
                 {
-                    Id = x.Code,
-                    Rotation = 90,
-                    Speed = 0.1d
-                };
-            }).ToList();
-            await _bimfaceCtrl?.LoadFlowEffect(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 barBtnUnloadFlowDirection_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        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
 
 
     }

--
Gitblit v1.9.3