From c390474980cea47189c1fcc962315b9867c9e2ce Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期日, 17 十一月 2024 16:03:18 +0800 Subject: [PATCH] 颜色分级梳理 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs | 1114 +++++++++++----------------------------------------------- 1 files changed, 216 insertions(+), 898 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 9a1075e..71f3b2f 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 @@ -101,7 +101,6 @@ { return; } - ApplyGrading(); }; _bimfaceCtrl.HydroMouseLeftClickEvent += (obj) => {//榧犳爣宸﹂敭鐐瑰嚮浜嬩欢 @@ -238,31 +237,31 @@ } _bimfaceCtrl?.ZoomToComponent(parter.Code); }; - _propertyCtrl.PropertyValueChangedEvent += (parter) => + _propertyCtrl.PropertyValueChangedEvent += (visual) => { - if (parter == null) + if (visual == null) { return; } UpdateVisualListCtrl(); - AutoApplyGrading(); + ApplyGradingResultList(visual); }; - _propertyCtrl.MarkPropertyValueChangedEvent += (parter) => + _propertyCtrl.MarkPropertyValueChangedEvent += (visual) => { //鏍囨敞灞炴�у彂鐢熸敼鍙� //鍒ゆ柇褰撳墠鏄惁鏈夋爣娉ㄥ睍绀猴紝鑻ユ湁鍒欐洿鏂版爣娉紝鏈�濂芥槸鏇存柊鍗曚釜鏍囨敞 + UpdateMark(visual); }; _propertyCtrl.GradingPropertyValueChangedEvent += (parter) => { //鍒嗙骇灞炴�у彂鐢熸敼鍙� //鍒ゆ柇褰撳墠鏄惁鏈夊垎绾у睍绀猴紝鑻ユ湁鍒欐洿鏂板垎绾э紝鏈�濂芥槸鏇存柊鍗曚釜鍒嗙骇 }; - _propertyCtrl.FlowDirectionPropertyValueChangedEvent += async (parter) => + _propertyCtrl.FlowDirectionPropertyValueChangedEvent += (visual) => { //娴佸悜灞炴�у彂鐢熸敼鍙� //鍒ゆ柇娴佸悜鏄惁鍔犺浇锛屽鏋滃姞杞藉垯鏇存柊娴佸悜锛屾渶濂芥槸鏇存柊鍗曚釜娴佸悜 - UpdateFlowEffect(parter); - //await _bimfaceCtrl?.UnloadFlowEffectById(parter.Code); + UpdateFlowEffect(visual); }; } @@ -341,8 +340,6 @@ } #endregion - - #region 鑷姩鍖归厤 @@ -495,8 +492,6 @@ #endregion - - #region 淇濆瓨淇℃伅 //淇濆瓨 @@ -527,10 +522,6 @@ } #endregion - - - - #region 鎵归噺閰嶇疆 @@ -1022,8 +1013,6 @@ #endregion - - #region 鏋勪欢鏌ヨ //鏌ヨ缁勪欢 @@ -1154,14 +1143,23 @@ private List<HydroMarkResultViewModel> _allMarkResultList = null; //鑾峰彇鏍囨敞缁撴灉鍒楄〃 - private List<HydroMarkResultViewModel> GetMarkResultList() + //UseCache 鏄惁浣跨敤缂撳瓨 + private List<HydroMarkResultViewModel> GetMarkResultList(bool useCache = true) { if (_hydroInfo == null) { return default; } - var allSetList = GetMarkSetList(); - _allMarkResultList = HydroMarkHelper.GetResultList(_hydroInfo, allSetList); + if (!useCache) + { + var allSetList = GetMarkSetList(); + _allMarkResultList = HydroMarkHelper.GetResultList(_hydroInfo, allSetList); + } + if (_allMarkResultList == null) + { + var allSetList = GetMarkSetList(); + _allMarkResultList = HydroMarkHelper.GetResultList(_hydroInfo, allSetList); + } return _allMarkResultList; } @@ -1172,13 +1170,42 @@ //鏍囨敞鏄惁鏄剧ず private bool _isMarkVisible = false; + //鏇存柊鏍囨敞 + private async void UpdateMark(Yw.Model.HydroVisualInfo visual) + { + var allSetList = GetMarkSetList(); + var result = HydroMarkHelper.GetResult(visual, allSetList); + if (result == null) + { + return; + } + var allResultList = GetMarkResultList(true); + allResultList.Remove(x => x.Code == visual.Code); + allResultList.Add(result); + if (_isMarkVisible) + { + var leadLabel = new LogicMarkLeadLabel() { Id = result.Code, Text = result.Text, Distance = null }; + await _bimfaceCtrl?.UpdateLogicMarkLeadLabel(leadLabel); + } + } + + //鏇存柊鏍囨敞鍒楄〃 + private void UpdateMarkList(List<Yw.Model.HydroVisualInfo> visuals) + { + if (visuals == null || visuals.Count < 1) + { + visuals.ForEach(x => UpdateMark(x)); + } + } + //搴旂敤鏍囨敞鍒楄〃 - private async void ApplyMarkList() + //UseCache 鏄惁浣跨敤缂撳瓨 + private async void ApplyMarkList(bool useCache = true) { if (_isMarkVisible) { - var allResultList = GetMarkResultList(); - var leadLabels = allResultList?.Select(x => new LogicMarkLeadLabel(x.Code, x.Text, 100000)).ToList(); + var allResultList = GetMarkResultList(useCache); + var leadLabels = allResultList?.Select(x => new LogicMarkLeadLabel(x.Code, x.Text, null)).ToList(); await _bimfaceCtrl?.SetLogicMarkLeadLabels(leadLabels); } else @@ -1200,7 +1227,7 @@ dlg.ReloadDataEvent += (list) => { _allMarkSetList = list; - ApplyMarkList(); + ApplyMarkList(false); }; dlg.ShowDialog(); } @@ -1215,11 +1242,10 @@ private void barCkMark_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { _isMarkVisible = this.barCkMark.Checked; - ApplyMarkList(); + ApplyMarkList(true); } #endregion - #endregion @@ -1227,10 +1253,10 @@ #region 棰滆壊閰嶇疆 - //鎵�鏈夊垎绾у垪琛� + //鎵�鏈夐鑹插垎绾ч厤缃垪琛� private List<HydroGradingVmo> _allGradingList = null; - //鑾峰彇鍒嗙骇鍒楄〃 + //鑾峰彇棰滆壊鍒嗙骇閰嶇疆鍒楄〃 private async Task<List<HydroGradingVmo>> GetGradingList() { if (_hydroInfo == null) @@ -1239,36 +1265,13 @@ } if (_allGradingList == null) { - _allGradingList = await BLLFactory<Yw.BLL.HydroGrading>.Instance.GetByModelID(_hydroInfo.ID); - if (_allGradingList == null || _allGradingList.Count < 1) - { - var config = Yw.Settings.HydroParasHelper.Hydro.Grading; - if (config != null && config.Items != null && config.Items.Count > 0) - { - _allGradingList = new List<HydroGradingVmo>(); - config.Items.ForEach(x => - { - var vmo = new HydroGradingVmo() - { - ModelID = _hydroInfo.ID, - Catalog = x.Catalog, - PropName = x.PropName, - SetValue = x.SetValue, - MinValue = x.MinValue, - MaxValue = x.MaxValue, - Color = x.Color, - SortCode = config.Items.IndexOf(x) - }; - _allGradingList.Add(vmo); - }); - } - } + _allGradingList = await HydroGradingHelper.GetGradingList(_hydroInfo); } return _allGradingList; } - //鏄剧ず閰嶇疆棰滆壊鍒嗙骇绐椾綋 - private async void ShowSetGradingDlg() + //鏄剧ず棰滆壊鍒嗙骇绐椾綋 + private async void ShowGradingDlg() { if (_hydroInfo == null) { @@ -1280,10 +1283,12 @@ dlg.ReloadDataEvent += (list) => { _allGradingList = list; + ApplyGradingResultList(false); }; dlg.ApplyDataEvent += (catalog, propName) => { - ApplyGrading(catalog, propName); + UpdateGradingApplyList(catalog, propName); + ApplyGradingResultList(false); }; dlg.ShowDialog(); } @@ -1291,7 +1296,7 @@ //閰嶇疆棰滆壊鍒嗙骇 private void barBtnGradingSet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { - ShowSetGradingDlg(); + ShowGradingDlg(); } #endregion @@ -1304,818 +1309,35 @@ //鑾峰彇棰滆壊鍒嗙骇搴旂敤鍒楄〃 private List<HydroGradingApplyViewModel> GetGradingApplyList() { + if (_hydroInfo == null) + { + return default; + } if (_allGradingApplyList == null) { - _allGradingApplyList = new List<HydroGradingApplyViewModel>(); - - if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0) - { - _allGradingApplyList.Add(new HydroGradingApplyViewModel() - { - Code = Yw.Hydro.ParterCatalog.Pump, - Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pump), - PropName = Yw.Hydro.ParterProp.LinkStatus - }); - } - if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0) - { - _allGradingApplyList.Add(new HydroGradingApplyViewModel() - { - Code = Yw.Hydro.ParterCatalog.Valve, - Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Valve), - PropName = Yw.Hydro.ParterProp.LinkStatus - }); - } - if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0) - { - _allGradingApplyList.Add(new HydroGradingApplyViewModel() - { - Code = Yw.Hydro.ParterCatalog.Pipe, - Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pipe), - PropName = HydroVisualCalcuProp.CalcuFlow - }); - } + _allGradingApplyList = HydroGradingHelper.GetApplyList(_hydroInfo); } return _allGradingApplyList; } - //鑾峰彇棰滆壊鍒嗙骇搴旂敤缁撴灉鍒楄〃 - private async Task<List<HydroGradingApplyResultViewModel>> GetGradingApplyResultList() + //鏇存柊棰滆壊鍒嗙骇搴旂敤鍒楄〃 + private void UpdateGradingApplyList(string catalog, string propName) { - if (_hydroInfo == null) - { - return default; - } - - //鎵�鏈夊垎绾у垪琛� - var allGradingList = await GetGradingList(); - if (allGradingList == null || allGradingList.Count < 1) - { - return default; - } - - //鎵�鏈夊垎绾у簲鐢ㄥ垪琛� var allGradingApplyList = GetGradingApplyList(); if (allGradingApplyList == null || allGradingApplyList.Count < 1) { - return default; + return; } - - //鎵�鏈夎绠楃粨鏋滃垪琛� - var allCalcuResultList = GetCalcuResultList(); - - //鎵�鏈夊簲鐢ㄧ粨鏋滃垪琛� - var allGradingApplyResultList = new List<HydroGradingApplyResultViewModel>(); - allGradingApplyList.ForEach(x => - { - var allCatalogGradingList = allGradingList.Where(t => t.Catalog == x.Code).ToList(); - if (allCatalogGradingList != null || allCatalogGradingList.Count > 0) - { - switch (x.Code) - { - case Yw.Hydro.ParterCatalog.Pump: - { - if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0) - { - foreach (var pump in _hydroInfo.Pumps) - { - switch (x.PropName) - { - case Yw.Hydro.ParterProp.LinkStatus: - { - var gradingList = allCatalogGradingList.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 - }; - allGradingApplyResultList.Add(result); - } - } - } - break; - case HydroVisualCalcuProp.CalcuFlow: - { - var gradingList = allCatalogGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 - }; - allGradingApplyResultList.Add(result); - } - } - } - } - } - break; - case HydroVisualCalcuProp.CalcuVelocity: - { - var gradingList = allCatalogGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 - }; - allGradingApplyResultList.Add(result); - } - } - } - } - } - break; - case HydroVisualCalcuProp.CalcuHeadLoss: - { - var gradingList = allCatalogGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 - }; - allGradingApplyResultList.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 (x.PropName) - { - case Yw.Hydro.ParterProp.LinkStatus: - { - var gradingList = allCatalogGradingList.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 - }; - allGradingApplyResultList.Add(result); - } - } - } - break; - case HydroVisualCalcuProp.CalcuFlow: - { - var gradingList = allCatalogGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 - }; - allGradingApplyResultList.Add(result); - } - } - } - } - } - break; - case HydroVisualCalcuProp.CalcuVelocity: - { - var gradingList = allCatalogGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 - }; - allGradingApplyResultList.Add(result); - } - } - } - } - } - break; - case HydroVisualCalcuProp.CalcuHeadLoss: - { - var gradingList = allCatalogGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 - }; - allGradingApplyResultList.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 (x.PropName) - { - case HydroVisualCalcuProp.CalcuFlow: - { - var gradingList = allCatalogGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 - }; - allGradingApplyResultList.Add(result); - } - } - } - } - } - break; - case HydroVisualCalcuProp.CalcuVelocity: - { - var gradingList = allCatalogGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 - }; - allGradingApplyResultList.Add(result); - } - } - } - } - } - break; - case HydroVisualCalcuProp.CalcuHeadLoss: - { - var gradingList = allCatalogGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 - }; - allGradingApplyResultList.Add(result); - } - } - } - } - } - break; - default: break; - } - } - } - } - break; - default: break; - } - } - }); - - return allGradingApplyResultList; - } - - //鑾峰彇棰滆壊鍒嗙骇搴旂敤缁撴灉鍒楄〃 - 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 HydroVisualCalcuProp.CalcuFlow: - { - var gradingList = currentGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 HydroVisualCalcuProp.CalcuVelocity: - { - var gradingList = currentGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 HydroVisualCalcuProp.CalcuHeadLoss: - { - var gradingList = currentGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 HydroVisualCalcuProp.CalcuFlow: - { - var gradingList = currentGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 HydroVisualCalcuProp.CalcuVelocity: - { - var gradingList = currentGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 HydroVisualCalcuProp.CalcuHeadLoss: - { - var gradingList = currentGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 HydroVisualCalcuProp.CalcuFlow: - { - var gradingList = currentGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 HydroVisualCalcuProp.CalcuVelocity: - { - var gradingList = currentGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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 HydroVisualCalcuProp.CalcuHeadLoss: - { - var gradingList = currentGradingList.Where(x => x.PropName == HydroVisualCalcuProp.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() - { - if (_hydroInfo == null) + var apply = allGradingApplyList.Find(x => x.Catalog == catalog); + if (apply == null) { return; } - _isGradingApply = true; - var allGradingApplyResultList = await GetGradingApplyResultList(); - 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(); + apply.PropName = propName; } - //搴旂敤棰滆壊鍒嗙骇 - 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); - } - } - - //鏄剧ず搴旂敤棰滆壊鍒嗙骇绐椾綋 - private void ShowApplyGradingDlg() + //鏄剧ず棰滆壊鍒嗙骇搴旂敤绐椾綋 + private void ShowGradingApplyDlg() { if (_hydroInfo == null) { @@ -2131,7 +1353,7 @@ dlg.ReloadDataEvent += (obj) => { _allGradingApplyList = obj; - ApplyGrading(); + ApplyGradingResultList(false); }; dlg.ShowDialog(); } @@ -2139,13 +1361,122 @@ //搴旂敤棰滆壊鍒嗙骇 private void barBtnGradingApply_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { - ShowApplyGradingDlg(); + ShowGradingApplyDlg(); } - //鍙栨秷搴旂敤鍒嗙骇 - private void batBtnCancelGradingApply_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + #endregion + + #region 搴旂敤缁撴灉 + + //鎵�鏈夐鑹插垎绾х粨鏋滃垪琛� + private List<HydroGradingResultViewModel> _allGradingResultList = null; + + //鑾峰彇棰滆壊鍒嗙骇缁撴灉鍒楄〃 + //UseCache鏄惁浣跨敤缂撳瓨 + private async Task<List<HydroGradingResultViewModel>> GetGradingResultList(bool useCache = true) { - CancelApplyGrading(); + if (_hydroInfo == null) + { + return default; + } + var allGradingList = await GetGradingList(); + var allGradingApplyList = GetGradingApplyList(); + var allCalcuResultList = GetCalcuResultList(); + if (!useCache) + { + _allGradingResultList = HydroGradingHelper.GetResultList(_hydroInfo, allGradingList, allGradingApplyList, allCalcuResultList); + } + if (_allGradingResultList == null) + { + _allGradingResultList = HydroGradingHelper.GetResultList(_hydroInfo, allGradingList, allGradingApplyList, allCalcuResultList); + } + return _allGradingResultList; + } + + #endregion + + #region 缁撴灉灞曠ず + + //棰滆壊鍒嗙骇鏄惁鏄剧ず + private bool _isGradingVisible = false; + + //搴旂敤棰滆壊鍒嗙骇缁撴灉鍒楄〃 + //UseCache鏄惁浣跨敤缂撳瓨 + private async void ApplyGradingResultList(bool useCache = true) + { + if (_hydroInfo == null) + { + return; + } + var allGradingResultList = await GetGradingResultList(useCache); + if (allGradingResultList == null || allGradingResultList.Count < 1) + { + return; + } + if (_isGradingVisible) + { + var groupList = allGradingResultList.GroupBy(x => x.Color).ToList(); + groupList.ForEach(async x => await _bimfaceCtrl?.OverrideComponentsColor(x.Select(t => t.Code).Distinct().ToList(), x.Key, 1)); + } + else + { + var codes = allGradingResultList.Select(x => x.Code).Distinct().ToList(); + await _bimfaceCtrl?.RestoreComponentsColor(codes); + } + } + + //搴旂敤棰滆壊鍒嗙骇缁撴灉鍒楄〃 + private async void ApplyGradingResultList(Yw.Model.HydroVisualInfo visual) + { + if (visual == null) + { + return; + } + var allGradingList = await GetGradingList(); + var allGradingApplyList = GetGradingApplyList(); + var allGradingResultList = await GetGradingResultList(true); + var allCalcuResultList = GetCalcuResultList(true); + var oldResult = allGradingResultList?.Find(x => x.Code == visual.Code); + if (oldResult != null) + { + allGradingResultList.Remove(oldResult); + } + var newResult = HydroGradingHelper.GetResult(visual, allGradingList, allGradingApplyList, allCalcuResultList); + if (newResult != null) + { + allGradingResultList.Add(newResult); + } + if (_isGradingVisible) + { + if (newResult == null) + { + if (oldResult != null) + { + await _bimfaceCtrl?.RestoreComponentsColor(oldResult.Code); + } + } + else + { + await _bimfaceCtrl?.OverrideComponentsColor(newResult.Code, newResult.Color, 1); + } + } + } + + //搴旂敤棰滆壊鍒嗙骇缁撴灉鍒楄〃 + private void ApplyGradingResultList(List<Yw.Model.HydroVisualInfo> visualList) + { + if (visualList == null || visualList.Count < 1) + { + return; + } + visualList.ForEach(x => ApplyGradingResultList(x)); + } + + //棰滆壊鍒嗙骇灞曠ず + private void barCkGrading_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + _isGradingVisible = this.barCkGrading.Checked; + ApplyGradingResultList(true); } #endregion @@ -2252,12 +1583,10 @@ return _allFlowEffectList; } - /// <summary> - /// 鍔犺浇姘存祦鍔ㄧ敾 - /// </summary> + //鍔犺浇姘存祦鍔ㄧ敾 private async void LoadFlowEffect() { - if (_allFlowEffectList != null) + if (_hydroInfo == null) { return; } @@ -2265,48 +1594,38 @@ await _bimfaceCtrl?.LoadFlowEffect(allFlowEffectList); } - //鍗歌浇娴佸悜 + //鍗歌浇姘存祦鍔ㄧ敾 private async void UnloadFlowEffect() { - if (_allFlowEffectList == null) + if (_hydroInfo == null) { return; } - _allFlowEffectList = null; await _bimfaceCtrl?.UnloadFlowEffect(); } //璁剧疆姘村姏鍔ㄧ敾 - private async void SetFlowEffect() + private void SetFlowEffect() + { + if (_isFlowEffectVisible) + { + LoadFlowEffect(); + } + else + { + UnloadFlowEffect(); + } + } + + //鏇存柊姘存祦鍔ㄧ敾 + private async void UpdateFlowEffect(Yw.Model.HydroVisualInfo visual) { if (_hydroInfo == null) { return; } var allFlowEffectList = GetFlowEffectList(); - if (_isFlowEffectVisible) - { - await _bimfaceCtrl?.LoadFlowEffect(allFlowEffectList); - } - else - { - 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); + var flowEffect = _allFlowEffectList?.Find(x => x.Id == visual.Code); if (flowEffect == null) { return; @@ -2346,13 +1665,10 @@ flowEffect.SpeedX = -flowEffect.SpeedX; } } - await _bimfaceCtrl?.UpdateFlowEffect(flowEffect); - } - - //鍔犺浇娴佸悜 - private void barBtnLoadFlowDirection_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) - { - LoadFlowEffect(); + if (_isFlowEffectVisible) + { + await _bimfaceCtrl?.UpdateFlowEffect(flowEffect); + } } //姘存祦鍔ㄧ敾鏄惁鍙 @@ -2542,8 +1858,9 @@ }; _visualListCtrl.HydroChangedInfoEvent += (visualList) => { + UpdateMarkList(visualList); UpdateSelectedProperty(); - AutoApplyGrading(); + ApplyGradingResultList(); }; } return _visualListCtrl; @@ -3267,7 +2584,7 @@ ShowCalcuFailedCtrl(); TipFormHelper.ShowError("璁$畻澶辫触锛�"); } - AutoApplyGrading(); + ApplyGradingResultList(false); UpdateVisualListCtrl(); ShowSelectedProperty(); }; @@ -3467,5 +2784,6 @@ + } } \ No newline at end of file -- Gitblit v1.9.3