From 34d47fbe6f79897f79b381eb1f1b4cae89b6fe05 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期一, 14 十月 2024 00:07:42 +0800
Subject: [PATCH] 优化bimface 鼠标左键点击,尝试解决不能选中的问题,不一定解决,待测试

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs |   78 +++++++++++++++++++++++----------------
 1 files changed, 46 insertions(+), 32 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 92fe0c2..865c0e5 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
@@ -62,39 +62,53 @@
                 return;
             }
             this.PageTitle.Caption = $"{_project.Name}\r\n姘村姏妯℃嫙";
-            await this.xhsProjectSimulationBimfaceCtrl1.SetBindingData(_project, _projectSite, () => _hydroInfo);
+            var bimfaceCtrl = GetBimfaceCtrl();
+            this.tabPageBimface.Controls.Clear();
+            this.tabPageBimface.Controls.Add(bimfaceCtrl);
+            await bimfaceCtrl.InitialData(_project, _projectSite, () => _hydroInfo);
             this.xhsProjectSimulationQ3dCtrl1.SetBindingData(_hydroInfo);
             this.xhsProjectSimulationPropertyCtrl1.InitialData(() => _hydroInfo);
         }
 
         #region Bimface
 
-        //bimface 鍔犺浇瀹屾垚浜嬩欢
-        private async void xhsProjectSimulationBimfaceCtrl1_LoadCompletedEvent()
+        //鑾峰彇 bimface 鎺т欢
+        private XhsProjectSimulationBimfaceCtrl GetBimfaceCtrl()
         {
-            if (_hydroInfo == null)
+            if (_bimfaceCtrl == null)
             {
-                return;
+                _bimfaceCtrl = new XhsProjectSimulationBimfaceCtrl();
+                _bimfaceCtrl.Dock = DockStyle.Fill;
+                _bimfaceCtrl.LoadCompletedEvent += async () =>
+                {//view鍔犺浇瀹屾垚浜嬩欢
+                    if (_hydroInfo == null)
+                    {
+                        return;
+                    }
+                    var elementIds = new List<string>();
+                    var pumps = _hydroInfo.Pumps?.Where(x => x.LinkStatus == Yw.Hydro.PumpStatus.Open).ToList();
+                    pumps?.ForEach(x => elementIds.Add(x.Code));
+                    var valves = _hydroInfo.Valves?.Where(x => x.LinkStatus == Yw.Hydro.ValveStatus.Open).ToList();
+                    valves?.ForEach(x => elementIds.Add(x.Code));
+                    await _bimfaceCtrl?.SetOpenComponentsColor(elementIds);
+                };
+                _bimfaceCtrl.HydroMouseLeftClickEvent += (obj) =>
+                {//榧犳爣宸﹂敭鐐瑰嚮浜嬩欢
+                    if (_hydroInfo == null)
+                    {
+                        return;
+                    }
+                    _parter = obj;
+                    ShowProperty();
+                    SetBimfaceLinkColor();
+                };
             }
-            var elementIds = new List<string>();
-            var pumps = _hydroInfo.Pumps?.Where(x => x.LinkStatus == Yw.Hydro.PumpStatus.Open).ToList();
-            pumps?.ForEach(x => elementIds.Add(x.Code));
-            var valves = _hydroInfo.Valves?.Where(x => x.LinkStatus == Yw.Hydro.ValveStatus.Open).ToList();
-            valves?.ForEach(x => elementIds.Add(x.Code));
-            await this.xhsProjectSimulationBimfaceCtrl1.SetOpenComponentsColor(elementIds);
+            return _bimfaceCtrl;
         }
+        //bimface鎺т欢
+        private XhsProjectSimulationBimfaceCtrl _bimfaceCtrl = null;
 
-        //bimface 姘村姏鐐瑰嚮浜嬩欢
-        private void xhsProjectSimulationBimfaceCtrl1_HydroClickEvent(Yw.Model.HydroParterInfo obj)
-        {
-            if (_hydroInfo == null)
-            {
-                return;
-            }
-            _parter = obj;
-            ShowProperty();
-            SetBimfaceLinkColor();
-        }
+
 
         //璁剧疆Bimface杩炴帴棰滆壊
         private async void SetBimfaceLinkColor()
@@ -144,7 +158,7 @@
                     }
                 }
             }
-            await this.xhsProjectSimulationBimfaceCtrl1.SetLinkComponentsColor(elementIds);
+            await _bimfaceCtrl?.SetLinkComponentsColor(elementIds);
         }
 
         #endregion
@@ -193,7 +207,7 @@
                     {
                         elementIds.Add(_parter.Code);
                     }
-                    await this.xhsProjectSimulationBimfaceCtrl1.ZoomAndSelectComponents(elementIds);
+                    await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
                     ShowProperty();
                     SetBimfaceLinkColor();
                 };
@@ -253,14 +267,14 @@
                     var allParterList = _hydroInfo.GetAllParters();
                     _parter = allParterList?.Find(x => x.Code == parter.Code);
                     var elementIds = new List<string>() { parter.Code };
-                    await this.xhsProjectSimulationBimfaceCtrl1.ZoomAndSelectComponents(elementIds);
+                    await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
                     ShowProperty();
                     SetBimfaceLinkColor();
                 };
                 _unMatchingListCtrl.ViewModelEvent += async (parters) =>//鏌ョ湅妯″瀷
                 {
                     var codes = parters?.Select(x => x.Code).Distinct().ToList();
-                    await this.xhsProjectSimulationBimfaceCtrl1.ZoomAndSelectComponents(codes);
+                    await _bimfaceCtrl?.ZoomAndSelectComponents(codes);
                     _parter = null;
                     ShowProperty();
                 };
@@ -308,11 +322,11 @@
             if (_fastShowHideCodeList == null)
             {
                 _fastShowHideCodeList = _hydroInfo.Decorators.Select(x => x.Code).ToList();
-                await this.xhsProjectSimulationBimfaceCtrl1.HideComponents(_fastShowHideCodeList);
+                await _bimfaceCtrl?.HideComponents(_fastShowHideCodeList);
             }
             else
             {
-                await this.xhsProjectSimulationBimfaceCtrl1.ShowComponents(_fastShowHideCodeList);
+                await _bimfaceCtrl?.ShowComponents(_fastShowHideCodeList);
                 _fastShowHideCodeList = null;
             }
         }
@@ -348,7 +362,7 @@
                             elementIds.Add(_parter.Code);
                         }
                     }
-                    await this.xhsProjectSimulationBimfaceCtrl1.ZoomAndSelectComponents(elementIds);
+                    await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
                     ShowProperty();
                     SetBimfaceLinkColor();
                 };
@@ -415,7 +429,7 @@
                     }
                     var allParterList = _hydroInfo.GetAllParters();
                     _parter = allParterList?.Find(x => x.Code == parter.Code);
-                    await this.xhsProjectSimulationBimfaceCtrl1.ZoomAndSelectComponents(new List<string>() { _parter.Code });
+                    await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _parter.Code });
                     ShowProperty();
                     SetBimfaceLinkColor();
                 };
@@ -637,7 +651,7 @@
                             this.controlContainerBottom.Controls.Add(parterListCtrl);
                             this.docPnlBottom.Text = "璁$畻缁撴灉";
                             ShowProperty();
-                            await this.xhsProjectSimulationBimfaceCtrl1.ShowCalcuCustomLabels(_calcuResult);
+                            await _bimfaceCtrl?.ShowCalcuCustomLabels(_calcuResult);
                             TipFormHelper.ShowSucceed("璁$畻鎴愬姛锛�");
                         }
                         else
@@ -704,7 +718,7 @@
                     {
                         _parter = null;
                     }
-                    await this.xhsProjectSimulationBimfaceCtrl1.ZoomAndSelectComponents(elementIds);
+                    await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds);
                     ShowProperty();
                     SetBimfaceLinkColor();
                 };

--
Gitblit v1.9.3