From b10f8e0a7cdd4fcfb92b011091ec39c1024eee33 Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期一, 11 十一月 2024 17:21:24 +0800 Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/HStation/XHS.V1.0 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs | 1063 ++++++++++++++++++++++++++++++++++------------------------ 1 files changed, 623 insertions(+), 440 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 c822e3b..5f4424f 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; @@ -226,15 +228,7 @@ await Task.Delay(5000); await _bimfaceCtrl?.ClearBlinkComponents(); }; - _propertyCtrl.PropertyValueChangedEvent += (parter) => - { - if (parter == null) - { - return; - } - UpdateParterListProperty(parter); - AutoApplyGrading(); - }; + _propertyCtrl.ViewParterEvent += (parter) => { if (parter == null) @@ -243,13 +237,63 @@ } _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); @@ -258,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 鑷姩鍖归厤 @@ -404,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) => { @@ -467,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; @@ -506,8 +460,11 @@ #region 涓�閿樉闅� + //鏄鹃殣缂栫爜鍒楄〃 + private List<string> _fastShowHiddenCodeList = null; + //涓�閿樉闅� - private async Task FastShowHidden() + private async void FastShowHidden() { if (_hydroInfo == null) { @@ -529,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)) - { - _selectedParter = null; - } - else - { - var allParterList = _hydroInfo.GetAllParters(); - _selectedParter = allParterList?.Find(x => x.Code == code); - if (_selectedParter != null) - { - elementIds.Add(_selectedParter.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 淇濆瓨淇℃伅 @@ -640,65 +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) => - { - _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瀵煎嚭 @@ -742,27 +571,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 @@ -773,52 +602,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 @@ -1204,7 +1033,7 @@ pump.SpeedRatio = Math.Round(x.CurrentHz / pump.RatedHz, 1); } }); - ShowProperty(); + ShowSelectedProperty(); return true; }; dlg.ShowDialog(); @@ -1215,66 +1044,8 @@ #region 姘村姏璁$畻 - #region 鍓嶆彁鏉′欢 + #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() @@ -1282,12 +1053,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) => { @@ -1311,12 +1082,15 @@ await Task.Delay(5000); var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo); - _calcuResult = netWork.Calcu(); + _calcuResult = netWork.CalcuMinorLoss(); WaitFormHelper.HideWaitForm(); if (_calcuResult.Succeed) { GetCalcuResultList(false); + UpdateVisualViewModelCalcuProperty(); + UpdateVisualListCtrl(); + UpdateSelectedProperty(); await _bimfaceCtrl?.SetLogicCalcuCustomLabels(_calcuResult); TipFormHelper.ShowSucceed("璁$畻鎴愬姛锛�"); var codes = _hydroInfo.Pumps.Select(x => x.Code).ToList(); @@ -1328,8 +1102,8 @@ TipFormHelper.ShowError("璁$畻澶辫触锛�"); } AutoApplyGrading(); - UpdateParterListProperty(); - ShowProperty(); + UpdateVisualListCtrl(); + ShowSelectedProperty(); }; dlg.SetBindingData(_hydroInfo); dlg.ShowDialog(); @@ -1563,49 +1337,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(); - _selectedParter = allParterList?.Find(x => x.Code == first.Code); + _selectedVisual = list.First(); list.ForEach(x => elementIds.Add(x.Code)); } else { - _selectedParter = 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; @@ -1613,10 +1407,30 @@ 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 @@ -1637,7 +1451,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 }); } @@ -1646,7 +1460,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 }); } @@ -1655,7 +1469,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 }); } @@ -1664,7 +1478,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 }); } @@ -1673,7 +1487,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 }); } @@ -2242,7 +2056,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 }); } @@ -2251,7 +2065,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 }); } @@ -2260,7 +2074,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 }); } @@ -3104,9 +2918,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("鏁版嵁宸插埛鏂�"); } } @@ -3115,31 +2929,400 @@ #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 + + #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 } -- Gitblit v1.9.3