From adf7734a40dec76fc31590906eeadd02c782db90 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期五, 08 十一月 2024 21:29:59 +0800 Subject: [PATCH] 优化导入,优化水流动画 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs | 162 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 147 insertions(+), 15 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..813ad8e 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 @@ -254,10 +254,12 @@ //鍒嗙骇灞炴�у彂鐢熸敼鍙� //鍒ゆ柇褰撳墠鏄惁鏈夊垎绾у睍绀猴紝鑻ユ湁鍒欐洿鏂板垎绾э紝鏈�濂芥槸鏇存柊鍗曚釜鍒嗙骇 }; - _propertyCtrl.FlowDirectionPropertyValueChangedEvent += (parter) => + _propertyCtrl.FlowDirectionPropertyValueChangedEvent += async (parter) => { //娴佸悜灞炴�у彂鐢熸敼鍙� //鍒ゆ柇娴佸悜鏄惁鍔犺浇锛屽鏋滃姞杞藉垯鏇存柊娴佸悜锛屾渶濂芥槸鏇存柊鍗曚釜娴佸悜 + UpdateFlowEffect(parter); + //await _bimfaceCtrl?.UnloadFlowEffectById(parter.Code); }; } @@ -303,8 +305,6 @@ } } } - - #endregion @@ -3171,28 +3171,160 @@ #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 -- Gitblit v1.9.3