| | |
| | | global using Yw.EPAnet; |
| | | using DevExpress.Mvvm.Native; |
| | | using DevExpress.Office.Utils; |
| | | using DevExpress.Utils.Extensions; |
| | | using DevExpress.Xpo.Helpers; |
| | | using DevExpress.XtraBars.Ribbon; |
| | | using DevExpress.XtraRichEdit.Layout; |
| | | using DevExpress.XtraSpreadsheet.Commands; |
| | | using HStation.WinFrmUI.PhartRelation; |
| | | using System.Diagnostics; |
| | | using System.Windows.Media; |
| | | using System.Windows.Media.Media3D; |
| | | using Yw.Hydro; |
| | | using Yw.Pump; |
| | | using Yw.Vmo; |
| | | using Yw.WinFrmUI.Bimface; |
| | | using Yw.WinFrmUI.Hydro; |
| | | |
| | |
| | | private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;//项目站 |
| | | private Yw.Model.HydroModelInfo _hydroInfo = null;//水力信息 |
| | | |
| | | private Yw.Model.HydroParterInfo _parter = null; |
| | | private Yw.WinFrmUI.HydroCheckResult _checkResult = null; |
| | | private Yw.EPAnet.CalcuResult _calcuResult = null; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | #region Bimface |
| | | |
| | | //bimface控件 |
| | |
| | | { |
| | | return; |
| | | } |
| | | _parter = obj; |
| | | ShowProperty(); |
| | | _selectedVisual = obj; |
| | | ShowSelectedProperty(); |
| | | }; |
| | | } |
| | | return _bimfaceCtrl; |
| | |
| | | var bimfaceCtrl = await GetBimfaceCtrl(); |
| | | this.tabPageBimface.Controls.Clear(); |
| | | this.tabPageBimface.Controls.Add(bimfaceCtrl); |
| | | } |
| | | |
| | | private void SelectBimfaceParter() |
| | | { |
| | | |
| | | } |
| | | |
| | | #endregion |
| | |
| | | { |
| | | return; |
| | | } |
| | | var allParterList = _hydroInfo.GetAllParters(); |
| | | _parter = allParterList?.Find(x => x.Code == obj?.FirstOrDefault()); |
| | | ShowProperty(); |
| | | var allParterList = _hydroInfo.GetAllVisuals(); |
| | | _selectedVisual = allParterList?.Find(x => x.Code == obj?.FirstOrDefault()); |
| | | ShowSelectedProperty(); |
| | | }; |
| | | } |
| | | return _q3dCtrl; |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region 构件属性 |
| | | #region 属性控件 |
| | | |
| | | //属性控件 |
| | | private XhsProjectSimulationPropertyCtrl _propertyCtrl = null; |
| | |
| | | { |
| | | _propertyCtrl = new XhsProjectSimulationPropertyCtrl(); |
| | | _propertyCtrl.Dock = DockStyle.Fill; |
| | | _propertyCtrl.InitialData(() => _hydroInfo, () => GetAllCalcuResultList()); |
| | | _propertyCtrl.InitialData(() => _hydroInfo, () => GetCalcuResultList()); |
| | | _propertyCtrl.BlinkLinkParterEvent += async (code, linkCode) => |
| | | { //强调连接组件 |
| | | if (string.IsNullOrEmpty(code)) |
| | |
| | | await Task.Delay(5000); |
| | | await _bimfaceCtrl?.ClearBlinkComponents(); |
| | | }; |
| | | |
| | | _propertyCtrl.ViewParterEvent += (parter) => |
| | | { |
| | | if (parter == null) |
| | | { |
| | | return; |
| | | } |
| | | _bimfaceCtrl?.ZoomToComponent(parter.Code); |
| | | }; |
| | | _propertyCtrl.PropertyValueChangedEvent += (visual) => |
| | | { |
| | | if (visual == null) |
| | | { |
| | | return; |
| | | } |
| | | UpdateVisualListCtrl(); |
| | | ApplyGradingResultList(visual); |
| | | }; |
| | | _propertyCtrl.MarkPropertyValueChangedEvent += (visual) => |
| | | { |
| | | //标注属性发生改变 |
| | | //判断当前是否有标注展示,若有则更新标注,最好是更新单个标注 |
| | | UpdateMark(visual); |
| | | }; |
| | | _propertyCtrl.GradingPropertyValueChangedEvent += (parter) => |
| | | { |
| | | //分级属性发生改变 |
| | | //判断当前是否有分级展示,若有则更新分级,最好是更新单个分级 |
| | | }; |
| | | _propertyCtrl.FlowDirectionPropertyValueChangedEvent += (visual) => |
| | | { |
| | | //流向属性发生改变 |
| | | //判断流向是否加载,如果加载则更新流向,最好是更新单个流向 |
| | | UpdateFlowEffect(visual); |
| | | }; |
| | | |
| | | } |
| | | 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); |
| | |
| | | this.docPnlRight.Width = 300; |
| | | } |
| | | |
| | | //属性面板按钮 |
| | | private void barBtnProperty_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | //显示选择属性 |
| | | private void ShowSelectedProperty() |
| | | { |
| | | ShowPropertyCtrl(); |
| | | ShowSelectedProperty(_selectedVisual); |
| | | } |
| | | |
| | | //显示属性 |
| | | private void ShowProperty() |
| | | //显示选择属性 |
| | | 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 (_parter == null) |
| | | { |
| | | _propertyCtrl?.SelectParter(null); |
| | | _propertyCtrl.SelectedObject = null; |
| | | return; |
| | | } |
| | | _propertyCtrl?.SelectParter(_parter.Code); |
| | | _propertyCtrl.SelectedObject = GetVisualViewModel(_selectedVisual); |
| | | } |
| | | |
| | | var allCalcuResultList = GetAllCalcuResultList(); |
| | | if (allCalcuResultList != null && allCalcuResultList.Count > 0) |
| | | //更新选择属性 |
| | | private void UpdateSelectedProperty() |
| | | { |
| | | if (!IsPropertyCtrlVisible) |
| | | { |
| | | var calcuResult = allCalcuResultList.Find(x => x.Code == _parter.Code); |
| | | if (calcuResult != null) |
| | | { |
| | | _propertyCtrl?.UpdateCalcuProperty(calcuResult); |
| | | } |
| | | return; |
| | | } |
| | | if (_selectedVisual == null) |
| | | { |
| | | return; |
| | | } |
| | | _propertyCtrl?.UpdateRows(); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | { |
| | | return; |
| | | } |
| | | var allParterList = _hydroInfo.GetAllParters(); |
| | | _parter = allParterList?.Find(x => x.Code == code); |
| | | var allParterList = _hydroInfo.GetAllVisuals(); |
| | | _selectedVisual = allParterList?.Find(x => x.Code == code); |
| | | var elementIds = new List<string>(); |
| | | if (_parter != null) |
| | | if (_selectedVisual != null) |
| | | { |
| | | elementIds.Add(_parter.Code); |
| | | elementIds.Add(_selectedVisual.Code); |
| | | } |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds); |
| | | ShowProperty(); |
| | | ShowSelectedProperty(); |
| | | }; |
| | | _matchingListCtrl.ApplyMatchingEvent += (output) => |
| | | { |
| | |
| | | } |
| | | this.controlContainerBottom.Controls.Clear(); |
| | | var matchingListCtrl = GetMatchingListCtrl(); |
| | | var input = AssetsMatchingParasHelper.Create(_hydroInfo, GetAllCalcuResultList()); |
| | | var input = AssetsMatchingParasHelper.Create(_hydroInfo, GetCalcuResultList()); |
| | | matchingListCtrl.SetBindingData(input); |
| | | this.controlContainerBottom.Controls.Add(matchingListCtrl); |
| | | this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; |
| | |
| | | { |
| | | return; |
| | | } |
| | | var allParterList = _hydroInfo.GetAllParters(); |
| | | _parter = 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); |
| | | _parter = null; |
| | | ShowProperty(); |
| | | _selectedVisual = null; |
| | | ShowSelectedProperty(); |
| | | }; |
| | | } |
| | | return _unMatchingListCtrl; |
| | |
| | | |
| | | #region 一键显隐 |
| | | |
| | | //显隐编码列表 |
| | | private List<string> _fastShowHiddenCodeList = null; |
| | | |
| | | //一键显隐 |
| | | private async Task FastShowHidden() |
| | | private async void FastShowHidden() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | //显隐编码列表 |
| | | 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(); |
| | | } |
| | | |
| | | #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)) |
| | | { |
| | | _parter = null; |
| | | } |
| | | else |
| | | { |
| | | var allParterList = _hydroInfo.GetAllParters(); |
| | | _parter = allParterList?.Find(x => x.Code == code); |
| | | if (_parter != null) |
| | | { |
| | | elementIds.Add(_parter.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(); |
| | | FastShowHidden(); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | { |
| | | return; |
| | | } |
| | | Stopwatch sw = new Stopwatch(); |
| | | sw.Start(); |
| | | |
| | | |
| | | var id = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(_hydroInfo); |
| | | |
| | | //耗时巨大的代码 |
| | | |
| | | sw.Stop(); |
| | | TimeSpan ts2 = sw.Elapsed; |
| | | Console.WriteLine("Stopwatch总共花费{0}ms.", ts2.TotalMilliseconds); |
| | | if (id < 1) |
| | | { |
| | | TipFormHelper.ShowError("保存失败!"); |
| | |
| | | |
| | | #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) => |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var allParterList = _hydroInfo.GetAllParters(); |
| | | _parter = allParterList?.Find(x => x.Code == parter.Code); |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _parter.Code }); |
| | | ShowProperty(); |
| | | }; |
| | | } |
| | | return _parterListCtrl; |
| | | } |
| | | |
| | | //显示构件明细控件 |
| | | private void ShowParterListCtrl() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var parterListCtrl = GetParterListCtrl(); |
| | | parterListCtrl.SetBindingData(_hydroInfo, GetAllCalcuResultList()); |
| | | 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导出 |
| | | |
| | | //导出水力INP文件 |
| | | private void barBtnHydroExportInp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var fileName = Yw.WinFrmUI.FileDialogHelper.SaveInp("导出Inp文件"); |
| | | if (string.IsNullOrEmpty(fileName)) |
| | | { |
| | | return; |
| | | } |
| | | var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo); |
| | | var result = netWork.ToInpString(); |
| | | File.WriteAllText(fileName, result); |
| | | TipFormHelper.ShowSucceed("导出成功"); |
| | | } |
| | | |
| | | #endregion INP导出 |
| | | |
| | | #region 批量配置 |
| | | |
| | | //注册批量配置事件 |
| | |
| | | //水库 |
| | | this.barBtnSetReservoirList.ItemClick += delegate |
| | | { |
| | | var dlg = new HydroReservoirBulkSetListDlg(); |
| | | dlg.ShowDialog(); |
| | | //var dlg = new HydroReservoirBulkSetListDlg(); |
| | | //dlg.ShowDialog(); |
| | | }; |
| | | //水池 |
| | | this.barBtnSetTankList.ItemClick += delegate |
| | | { |
| | | var dlg = new HydroTankBulkSetListDlg(); |
| | | dlg.ShowDialog(); |
| | | //var dlg = new HydroTankBulkSetListDlg(); |
| | | //dlg.ShowDialog(); |
| | | }; |
| | | //水箱 |
| | | this.barBtnSetWaterboxList.ItemClick += delegate |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroWaterboxBulkSetListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | //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(); |
| | | }; |
| | | //连接节点 |
| | | this.barBtnSetJunctionList.ItemClick += delegate |
| | | { |
| | | var dlg = new HydroJunctionBulkSetListDlg(); |
| | | dlg.ShowDialog(); |
| | | //var dlg = new HydroJunctionBulkSetListDlg(); |
| | | //dlg.ShowDialog(); |
| | | }; |
| | | //闷头 |
| | | this.barBtnSetBluntheadList.ItemClick += delegate |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroBluntheadBulkSetListDlg(); |
| | | dlg.ShowDialog(); |
| | | //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(); |
| | | }; |
| | | //弯头 |
| | | this.barBtnSetElbowsList.ItemClick += delegate |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroElbowBulkSetListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | //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(); |
| | | }; |
| | | //三通 |
| | | this.barBtnSetThreelinkList.ItemClick += delegate |
| | |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroThreelinkBulkSetListDlg(); |
| | | var dlg = new SetHydroThreelinkListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroFourlinkBulkSetListDlg(); |
| | | var dlg = new SetHydroFourlinkListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroMeterBulkSetListDlg(); |
| | | var dlg = new SetHydroMeterListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroFlowmeterBulkSetListDlg(); |
| | | var dlg = new SetHydroFlowmeterListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroPressmeterBulkSetListDlg(); |
| | | var dlg = new SetHydroPressmeterListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroPipeBulkSetListDlg(); |
| | | var dlg = new SetHydroPipeListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroPumpBulkSetListDlg(); |
| | | var dlg = new SetHydroPumpListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HydroValveBulkSetListDlg(); |
| | | var dlg = new SetHydroValveListDlg(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | }; |
| | |
| | | { |
| | | return; |
| | | } |
| | | var allCalcuResultList = GetAllCalcuResultList(); |
| | | var allCalcuResultList = GetCalcuResultList(); |
| | | var vmList = new List<XhsSinglePumpViewModel>(); |
| | | foreach (var pump in _hydroInfo.Pumps) |
| | | { |
| | |
| | | pump.SpeedRatio = Math.Round(x.CurrentHz / pump.RatedHz, 1); |
| | | } |
| | | }); |
| | | ShowProperty(); |
| | | ShowSelectedProperty(); |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region 水力计算 |
| | | #region 构件查询 |
| | | |
| | | //查询组件 |
| | | private HydroVisualSearchListCtrl _searchCtrl = null; |
| | | |
| | | #region 前提条件 |
| | | //获取查询组件 |
| | | private HydroVisualSearchListCtrl GetSearchCtrl() |
| | | { |
| | | if (_searchCtrl == null) |
| | | { |
| | | _searchCtrl = new HydroVisualSearchListCtrl(); |
| | | _searchCtrl.Dock = DockStyle.Fill; |
| | | var allVisualViewModelList = GetVisualViewModelList(); |
| | | _searchCtrl.InitialData(allVisualViewModelList); |
| | | _searchCtrl.HydroClickInfoEvent += async (visual) => |
| | | { |
| | | ShowSelectedProperty(visual); |
| | | await _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code); |
| | | }; |
| | | _searchCtrl.HydroSearchInfoEvent += async (list) => |
| | | { |
| | | var elementIds = new List<string>(); |
| | | if (list != null && list.Count > 0) |
| | | { |
| | | _selectedVisual = list.First(); |
| | | list.ForEach(x => elementIds.Add(x.Code)); |
| | | } |
| | | else |
| | | { |
| | | _selectedVisual = null; |
| | | } |
| | | ShowSelectedProperty(); |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds); |
| | | }; |
| | | } |
| | | return _searchCtrl; |
| | | } |
| | | |
| | | //显示计算前提条件窗体 |
| | | private async void ShowCalcuPrefixDlg() |
| | | //查询控件是否可见 |
| | | 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 (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; |
| | | this.docPnlBottom.Text = "构件查询"; |
| | | 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) |
| | | { |
| | | ShowSearchDlg(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 模型标注 |
| | | |
| | | #region 标注设置 |
| | | |
| | | //所有标注设置列表 |
| | | private List<HydroMarkSetViewModel> _allMarkSetList = null; |
| | | |
| | | //获取标注设置列表 |
| | | private List<HydroMarkSetViewModel> GetMarkSetList() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return default; |
| | | } |
| | | if (_allMarkSetList == null) |
| | | { |
| | | _allMarkSetList = HydroMarkHelper.GetSetList(_hydroInfo); |
| | | } |
| | | return _allMarkSetList; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 标注结果 |
| | | |
| | | //所有标注结果列表 |
| | | private List<HydroMarkResultViewModel> _allMarkResultList = null; |
| | | |
| | | //获取标注结果列表 |
| | | //UseCache 是否使用缓存 |
| | | private List<HydroMarkResultViewModel> GetMarkResultList(bool useCache = true) |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return default; |
| | | } |
| | | if (!useCache) |
| | | { |
| | | var allSetList = GetMarkSetList(); |
| | | _allMarkResultList = HydroMarkHelper.GetResultList(_hydroInfo, allSetList); |
| | | } |
| | | if (_allMarkResultList == null) |
| | | { |
| | | var allSetList = GetMarkSetList(); |
| | | _allMarkResultList = HydroMarkHelper.GetResultList(_hydroInfo, allSetList); |
| | | } |
| | | return _allMarkResultList; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 标注显示 |
| | | |
| | | //标注是否显示 |
| | | 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)); |
| | | } |
| | | } |
| | | |
| | | //应用标注列表 |
| | | //UseCache 是否使用缓存 |
| | | private async void ApplyMarkList(bool useCache = true) |
| | | { |
| | | if (_isMarkVisible) |
| | | { |
| | | var allResultList = GetMarkResultList(useCache); |
| | | var leadLabels = allResultList?.Select(x => new LogicMarkLeadLabel(x.Code, x.Text, null)).ToList(); |
| | | await _bimfaceCtrl?.SetLogicMarkLeadLabels(leadLabels); |
| | | } |
| | | else |
| | | { |
| | | await _bimfaceCtrl?.ClearLogicMarkLeadLabels(); |
| | | } |
| | | } |
| | | |
| | | //显示标注设置窗体 |
| | | private void ShowSetMarkDlg() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new HStation.WinFrmUI.SetHydroCalcuPrefixDlg1(); |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.HydroViewEvent += async (parter) => |
| | | var allMarkSetList = GetMarkSetList(); |
| | | var dlg = new SetHydroMarkDlg(); |
| | | dlg.SetBindingData(allMarkSetList); |
| | | dlg.ReloadDataEvent += (list) => |
| | | { |
| | | _parter = parter; |
| | | if (_parter != null) |
| | | { |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _parter.Code }); |
| | | } |
| | | ShowProperty(); |
| | | _allMarkSetList = list; |
| | | ApplyMarkList(false); |
| | | }; |
| | | dlg.HydroCalcuEvent += async () => |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //设置标注 |
| | | private void barBtnSetMark_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | ShowSetMarkDlg(); |
| | | } |
| | | |
| | | //是否显示 |
| | | private void barCkMark_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | _isMarkVisible = this.barCkMark.Checked; |
| | | ApplyMarkList(true); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | #region 颜色分级 |
| | | |
| | | #region 颜色配置 |
| | | |
| | | //所有颜色分级配置列表 |
| | | private List<HydroGradingVmo> _allGradingList = null; |
| | | |
| | | //获取颜色分级配置列表 |
| | | private async Task<List<HydroGradingVmo>> GetGradingList() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | return default; |
| | | } |
| | | if (_allGradingList == null) |
| | | { |
| | | _allGradingList = await HydroGradingHelper.GetGradingList(_hydroInfo); |
| | | } |
| | | return _allGradingList; |
| | | } |
| | | |
| | | //校验 |
| | | _checkResult = _hydroInfo.Check(); |
| | | if (!_checkResult.Succeed) |
| | | { |
| | | ShowCheckCtrl(); |
| | | TipFormHelper.ShowWarn("校验失败,请检查后重试"); |
| | | return; |
| | | } |
| | | //显示颜色分级窗体 |
| | | private async void ShowGradingDlg() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var allGradingList = await GetGradingList(); |
| | | var dlg = new SetHydroGradingTreeDlg(); |
| | | dlg.SetBindingData(_hydroInfo, allGradingList); |
| | | dlg.ReloadDataEvent += (list) => |
| | | { |
| | | _allGradingList = list; |
| | | ApplyGradingResultList(false); |
| | | }; |
| | | dlg.ApplyDataEvent += (catalog, propName) => |
| | | { |
| | | UpdateGradingApplyList(catalog, propName); |
| | | ApplyGradingResultList(false); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo); |
| | | _calcuResult = netWork.Calcu(); |
| | | if (_calcuResult.Succeed) |
| | | //配置颜色分级 |
| | | private void barBtnGradingSet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | ShowGradingDlg(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 应用分级 |
| | | |
| | | //颜色分级应用列表 |
| | | private List<HydroGradingApplyViewModel> _allGradingApplyList = null; |
| | | |
| | | //获取颜色分级应用列表 |
| | | private List<HydroGradingApplyViewModel> GetGradingApplyList() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return default; |
| | | } |
| | | if (_allGradingApplyList == null) |
| | | { |
| | | _allGradingApplyList = HydroGradingHelper.GetApplyList(_hydroInfo); |
| | | } |
| | | return _allGradingApplyList; |
| | | } |
| | | |
| | | //更新颜色分级应用列表 |
| | | private void UpdateGradingApplyList(string catalog, string propName) |
| | | { |
| | | var allGradingApplyList = GetGradingApplyList(); |
| | | if (allGradingApplyList == null || allGradingApplyList.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | var apply = allGradingApplyList.Find(x => x.Catalog == catalog); |
| | | if (apply == null) |
| | | { |
| | | return; |
| | | } |
| | | apply.PropName = propName; |
| | | } |
| | | |
| | | //显示颜色分级应用窗体 |
| | | private void ShowGradingApplyDlg() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var allGradingApplyList = GetGradingApplyList(); |
| | | if (allGradingApplyList == null || allGradingApplyList.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new ApplyHydroGradingDlg(); |
| | | dlg.SetBindingData(allGradingApplyList); |
| | | dlg.ReloadDataEvent += (obj) => |
| | | { |
| | | _allGradingApplyList = obj; |
| | | ApplyGradingResultList(false); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //应用颜色分级 |
| | | private void barBtnGradingApply_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | ShowGradingApplyDlg(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 应用结果 |
| | | |
| | | //所有颜色分级结果列表 |
| | | private List<HydroGradingResultViewModel> _allGradingResultList = null; |
| | | |
| | | //获取颜色分级结果列表 |
| | | //UseCache是否使用缓存 |
| | | private async Task<List<HydroGradingResultViewModel>> GetGradingResultList(bool useCache = true) |
| | | { |
| | | 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) |
| | | { |
| | | GetAllCalcuResultList(false); |
| | | await _bimfaceCtrl?.SetLogicCalcuCustomLabels(_calcuResult); |
| | | TipFormHelper.ShowSucceed("计算成功!"); |
| | | if (oldResult != null) |
| | | { |
| | | await _bimfaceCtrl?.RestoreComponentsColor(oldResult.Code); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ShowCalcuFailedCtrl(); |
| | | TipFormHelper.ShowError("计算失败!"); |
| | | 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 |
| | | |
| | | #endregion |
| | | |
| | | #region 人工刷新 |
| | | |
| | | //刷新 |
| | | private async void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (XtraMessageBox.Show("刷新后将丢失当前水力信息更改,是否继续刷新?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes) |
| | | { |
| | | if (_project == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_projectSite == null) |
| | | { |
| | | return; |
| | | } |
| | | var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance |
| | | .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation); |
| | | Stopwatch sw = new Stopwatch(); |
| | | sw.Start(); |
| | | _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID); |
| | | sw.Stop(); |
| | | TimeSpan ts2 = sw.Elapsed; |
| | | Console.WriteLine("Stopwatch总共花费{0}ms.", ts2.TotalMilliseconds); |
| | | _selectedVisual = null; |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(null); |
| | | ShowSelectedProperty(); |
| | | TipFormHelper.ShowSucceed("数据已刷新"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 水流动画 |
| | | |
| | | //水流动画是否可见 |
| | | private bool _isFlowEffectVisible = false; |
| | | |
| | | //所有水流动画列表 |
| | | private List<LogicFlowEffect> _allFlowEffectList = null; |
| | | |
| | | //获取流向列表 |
| | | private List<LogicFlowEffect> GetFlowEffectList() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return default; |
| | | } |
| | | if (_allFlowEffectList == null) |
| | | { |
| | | _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; |
| | | } |
| | | |
| | | //加载水流动画 |
| | | private async void LoadFlowEffect() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var allFlowEffectList = GetFlowEffectList(); |
| | | await _bimfaceCtrl?.LoadFlowEffect(allFlowEffectList); |
| | | } |
| | | |
| | | //卸载水流动画 |
| | | private async void UnloadFlowEffect() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | await _bimfaceCtrl?.UnloadFlowEffect(); |
| | | } |
| | | |
| | | //设置水力动画 |
| | | private void SetFlowEffect() |
| | | { |
| | | if (_isFlowEffectVisible) |
| | | { |
| | | LoadFlowEffect(); |
| | | } |
| | | else |
| | | { |
| | | UnloadFlowEffect(); |
| | | } |
| | | } |
| | | |
| | | //更新水流动画 |
| | | private async void UpdateFlowEffect(Yw.Model.HydroVisualInfo visual) |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var allFlowEffectList = GetFlowEffectList(); |
| | | var flowEffect = _allFlowEffectList?.Find(x => x.Id == visual.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; |
| | | } |
| | | } |
| | | if (_isFlowEffectVisible) |
| | | { |
| | | await _bimfaceCtrl?.UpdateFlowEffect(flowEffect); |
| | | } |
| | | } |
| | | |
| | | //水流动画是否可见 |
| | | private void barCkFlowEffect_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | _isFlowEffectVisible = this.barCkFlowEffect.Checked; |
| | | SetFlowEffect(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 选择构件 |
| | | |
| | | //选择构件 |
| | | private Yw.Model.HydroVisualInfo _selectedVisual = null; |
| | | |
| | | //选择构件 |
| | | private Yw.Model.HydroVisualInfo SelectedVisual |
| | | { |
| | | get { return _selectedVisual; } |
| | | set |
| | | { |
| | | _selectedVisual = value; |
| | | if (_selectedVisual == null) |
| | | { |
| | | this.barBtnSetMonitor.Enabled = false; |
| | | } |
| | | else |
| | | { |
| | | this.barBtnSetMonitor.Enabled = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 构件明细 |
| | | |
| | | #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 UpdateVisualViewModelProperty() |
| | | { |
| | | var allVisualViewModelList = GetVisualViewModelList(); |
| | | if (allVisualViewModelList != null && allVisualViewModelList.Count > 0) |
| | | { |
| | | allVisualViewModelList.ForEach(x => |
| | | { |
| | | x.UpdateProperty(); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | //更新可见视图属性 |
| | | private void UpdateVisualViewModelProperty(List<string> codes) |
| | | { |
| | | if (codes == null || codes.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | var allVisualViewModelList = GetVisualViewModelList(); |
| | | if (allVisualViewModelList != null && allVisualViewModelList.Count > 0) |
| | | { |
| | | allVisualViewModelList.ForEach(x => |
| | | { |
| | | if (codes.Contains(x.Code)) |
| | | { |
| | | x.UpdateProperty(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | //更新可见视图属性 |
| | | private void UpdateVisualViewModelProperty(List<Yw.Model.HydroVisualInfo> visualList) |
| | | { |
| | | if (visualList == null || visualList.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | var allVisualViewModelList = GetVisualViewModelList(); |
| | | if (allVisualViewModelList != null && allVisualViewModelList.Count > 0) |
| | | { |
| | | allVisualViewModelList.ForEach(x => |
| | | { |
| | | if (visualList.Exists(t => t.Code == x.Code)) |
| | | { |
| | | x.UpdateProperty(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | //更新可见视图计算属性 |
| | | 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(string code) |
| | | { |
| | | if (string.IsNullOrEmpty(code)) |
| | | { |
| | | return default; |
| | | } |
| | | var allVisualViewModelList = GetVisualViewModelList(); |
| | | return allVisualViewModelList?.Find(x => x.Code == code); |
| | | } |
| | | |
| | | //获取可见视图 |
| | | 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.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) => |
| | | { |
| | | UpdateMarkList(visualList); |
| | | UpdateSelectedProperty(); |
| | | ApplyGradingResultList(); |
| | | }; |
| | | } |
| | | 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 |
| | | |
| | | #endregion |
| | | |
| | | #region 监测列表 |
| | | |
| | | #region 测点列表 |
| | | |
| | | //所有监测点列表 |
| | | private List<HydroMonitorVmo> _allMonitorList = null; |
| | | |
| | | //获取监测点列表 |
| | | private async Task<List<HydroMonitorVmo>> GetMonitorList() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return default; |
| | | } |
| | | if (_allMonitorList == null) |
| | | { |
| | | _allMonitorList = await BLLFactory<Yw.BLL.HydroMonitor>.Instance.GetByModelID(_hydroInfo.ID); |
| | | if (_allMonitorList == null) |
| | | { |
| | | _allMonitorList = new List<HydroMonitorVmo>(); |
| | | } |
| | | } |
| | | return _allMonitorList; |
| | | } |
| | | |
| | | //更新监测点列表 |
| | | private async void UpdateMonitorList(string code) |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(code)) |
| | | { |
| | | return; |
| | | } |
| | | var allMonitorList = await GetMonitorList(); |
| | | allMonitorList.RemoveAll(x => x.Relation == code); |
| | | var monitorList = await BLLFactory<Yw.BLL.HydroMonitor>.Instance.GetByRelation(_hydroInfo.ID, code); |
| | | if (monitorList != null && monitorList.Count > 0) |
| | | { |
| | | allMonitorList.AddRange(monitorList); |
| | | } |
| | | UpdateMonitorValueList(code, monitorList); |
| | | SetLogicMonitorList(); |
| | | } |
| | | |
| | | //设置选择构件监测点列表 |
| | | private async void SetSelectVisualMonitorList() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_selectedVisual == null) |
| | | { |
| | | return; |
| | | } |
| | | var allMonitorList = await GetMonitorList(); |
| | | var dlg = new SetHydroVisualMonitorDlg(); |
| | | dlg.SetBindingData(_hydroInfo, _selectedVisual, allMonitorList); |
| | | dlg.ReloadDataEvent += async (hydroInfo, visual, list) => |
| | | { |
| | | if (hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | if (visual == null) |
| | | { |
| | | return; |
| | | } |
| | | var bol = await BLLFactory<Yw.BLL.HydroMonitor>.Instance.Save(hydroInfo.ID, visual.Code, list); |
| | | if (!bol) |
| | | { |
| | | TipFormHelper.ShowError("设置失败"); |
| | | return; |
| | | } |
| | | TipFormHelper.ShowSucceed("设置成功"); |
| | | UpdateMonitorList(visual.Code); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //设置监测点 |
| | | private void barBtnSetMonitor_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | SetSelectVisualMonitorList(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 监测值列表 |
| | | |
| | | //所有监测值列表 |
| | | private List<HydroVisualMonitorValueViewModel> _allMonitorValueList = null; |
| | | |
| | | //获取监测值列表 |
| | | private async Task<List<HydroVisualMonitorValueViewModel>> GetMonitorValueList() |
| | | { |
| | | if (_allMonitorValueList == null) |
| | | { |
| | | _allMonitorValueList = new List<HydroVisualMonitorValueViewModel>(); |
| | | var allMonitorList = await GetMonitorList(); |
| | | var allVisualViewModelList = GetVisualViewModelList(); |
| | | allMonitorList.ForEach(x => |
| | | { |
| | | var visual = allVisualViewModelList.Find(t => t.Code == x.Relation); |
| | | if (visual != null) |
| | | { |
| | | var vm = new HydroVisualMonitorValueViewModel(visual.Vmo, x); |
| | | _allMonitorValueList.Add(vm); |
| | | } |
| | | }); |
| | | } |
| | | return _allMonitorValueList; |
| | | } |
| | | |
| | | //更新监测值列表 |
| | | private async void UpdateMonitorValueList(string code, List<HydroMonitorVmo> monitorList) |
| | | { |
| | | if (string.IsNullOrEmpty(code)) |
| | | { |
| | | return; |
| | | } |
| | | var visual = GetVisualViewModel(code)?.Vmo; |
| | | if (visual == null) |
| | | { |
| | | return; |
| | | } |
| | | var allMonitorValueList = await GetMonitorValueList(); |
| | | var monitorValueList = allMonitorValueList.Where(x => x.Vmo.Relation == code).ToList(); |
| | | monitorValueList?.ForEach(x => |
| | | { |
| | | var result = monitorList?.Exists(t => t.Relation == x.Vmo.Relation && t.PropName == x.Vmo.PropName); |
| | | if (!(result.HasValue && result.Value)) |
| | | { |
| | | allMonitorValueList.Remove(x); |
| | | } |
| | | }); |
| | | monitorList?.ForEach(x => |
| | | { |
| | | var result = monitorValueList?.Exists(t => t.Vmo.Relation == x.Relation && t.Vmo.PropName == x.PropName); |
| | | if (!(result.HasValue && result.Value)) |
| | | { |
| | | var vm = new HydroVisualMonitorValueViewModel(visual, x); |
| | | allMonitorValueList.Add(vm); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 监测值列表控件 |
| | | |
| | | //监测值列表控件 |
| | | private HydroVisualMonitorValueListCtrl _monitorValueListCtrl = null; |
| | | |
| | | //获取监测值列表控件 |
| | | private HydroVisualMonitorValueListCtrl GetMonitorValueListCtrl() |
| | | { |
| | | if (_monitorValueListCtrl == null) |
| | | { |
| | | _monitorValueListCtrl = new HydroVisualMonitorValueListCtrl(); |
| | | _monitorValueListCtrl.Dock = DockStyle.Fill; |
| | | _monitorValueListCtrl.HydroViewEvent += (code) => |
| | | { |
| | | _bimfaceCtrl?.ZoomToComponent(code); |
| | | }; |
| | | } |
| | | return _monitorValueListCtrl; |
| | | } |
| | | |
| | | //显示监测值列表控件 |
| | | private async void ShowMonitorValueListCtrl() |
| | | { |
| | | var monitorValueListCtrl = GetMonitorValueListCtrl(); |
| | | var allMonitorValueList = await GetMonitorValueList(); |
| | | monitorValueListCtrl.SetBindingData(allMonitorValueList); |
| | | this.controlContainerBottom.Controls.Clear(); |
| | | this.controlContainerBottom.Controls.Add(monitorValueListCtrl); |
| | | this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; |
| | | this.docPnlBottom.Text = "监测值"; |
| | | this.docPnlBottom.Height = 350; |
| | | } |
| | | |
| | | //设置监测值 |
| | | private void barBtnSetMonitorValue_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | ShowMonitorValueListCtrl(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 监测列表显示 |
| | | |
| | | //监测是否显示 |
| | | private bool _isMonitorVisible = false; |
| | | |
| | | //获取业务监测列表 |
| | | private async Task<List<LogicMonitor>> GetLogicMonitorList() |
| | | { |
| | | var allMonitorList = await GetMonitorList(); |
| | | var allLogicMonitorList = allMonitorList.Select(x => |
| | | { |
| | | var logicMonitor = new LogicMonitor(); |
| | | logicMonitor.Id = x.Relation; |
| | | logicMonitor.PropName = x.PropName; |
| | | logicMonitor.Description = x.Description; |
| | | return logicMonitor; |
| | | }).ToList(); |
| | | return allLogicMonitorList; |
| | | } |
| | | |
| | | //设置业务监测列表 |
| | | private async void SetLogicMonitorList() |
| | | { |
| | | if (_isMonitorVisible) |
| | | { |
| | | var allLogicMonitorList = await GetLogicMonitorList(); |
| | | await _bimfaceCtrl?.SetLogicMonitors(allLogicMonitorList); |
| | | } |
| | | else |
| | | { |
| | | await _bimfaceCtrl?.ClearLogicMonitors(); |
| | | } |
| | | } |
| | | |
| | | //显示状态改变 |
| | | private void barCkMonitor_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | _isMonitorVisible = this.barCkMonitor.Checked; |
| | | SetLogicMonitorList(); |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | #region 水力检查 |
| | | |
| | | #region 检查结果 |
| | | |
| | | //检查结果缓存 |
| | | private HydroCheckResult _checkResult = null; |
| | | |
| | | //获取检查结果 |
| | | //needCheckAgain 用于确定是否需要重新检查 |
| | | private HydroCheckResult GetCheckResult(bool needCheckAgain = false) |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return default; |
| | | } |
| | | if (needCheckAgain) |
| | | { |
| | | _checkResult = _hydroInfo.Check(); |
| | | } |
| | | if (_checkResult == null) |
| | | { |
| | | _checkResult = _hydroInfo.Check(); |
| | | } |
| | | return _checkResult; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 检查控件 |
| | | |
| | | //检查控件 |
| | | private HydroCheckResultCtrl _checkCtrl = null; |
| | | |
| | | //获取检查控件 |
| | | private HydroCheckResultCtrl GetCheckCtrl() |
| | | { |
| | | if (_checkCtrl == null) |
| | | { |
| | | _checkCtrl = new HydroCheckResultCtrl(); |
| | | _checkCtrl.Dock = DockStyle.Fill; |
| | | _checkCtrl.HydroClickEvent += async (code) => |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var elementIds = new List<string>(); |
| | | if (string.IsNullOrEmpty(code)) |
| | | { |
| | | this.SelectedVisual = null; |
| | | } |
| | | else |
| | | { |
| | | var allVisualViewModelList = GetVisualViewModelList(); |
| | | this.SelectedVisual = allVisualViewModelList?.Find(x => x.Code == code)?.Vmo; |
| | | if (this.SelectedVisual != null) |
| | | { |
| | | elementIds.Add(this.SelectedVisual.Code); |
| | | } |
| | | } |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds); |
| | | ShowSelectedProperty(); |
| | | }; |
| | | } |
| | | return _checkCtrl; |
| | | } |
| | | |
| | | //显示检查控件 |
| | | //needCheckAgain 用于确定是否需要重新检查 |
| | | private void ShowCheckCtrl(bool needCheckAgain = false) |
| | | { |
| | | var checkResult = GetCheckResult(needCheckAgain); |
| | | 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; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | //检查 |
| | | private void barBtnCheck_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | ShowCheckCtrl(true); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region EPA计算结果 |
| | | |
| | | //EPA计算结果 |
| | | private Yw.EPAnet.CalcuResult _epaCalcuResult = null; |
| | | |
| | | //获取EPA计算结果 |
| | | //CalcuMode 在 Yw.EPANet.Calcu.Core 中定义 |
| | | //NeedCalcuAgain 是否需要重新计算 |
| | | private Yw.EPAnet.CalcuResult GetEpaCalcuResult(string calcuMode, bool needCalcuAgain = false) |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return default; |
| | | } |
| | | if (needCalcuAgain) |
| | | { |
| | | var network = _hydroInfo.ToNetwork(); |
| | | _epaCalcuResult = network.Calcu(calcuMode); |
| | | } |
| | | if (_epaCalcuResult == null) |
| | | { |
| | | var network = _hydroInfo.ToNetwork(); |
| | | _epaCalcuResult = network.Calcu(calcuMode); |
| | | } |
| | | return _epaCalcuResult; |
| | | } |
| | | |
| | | #endregion |
| | |
| | | } |
| | | |
| | | //显示计算失败控件 |
| | | private void ShowCalcuFailedCtrl() |
| | | private void ShowCalcuFailedCtrl(Yw.EPAnet.CalcuResult calcuResult) |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_calcuResult == null) |
| | | if (calcuResult == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_calcuResult.Succeed) |
| | | if (calcuResult.Succeed) |
| | | { |
| | | return; |
| | | } |
| | | var calcuFailedCtrl = GetCalcuFailedCtrl(); |
| | | calcuFailedCtrl.SetBindingData(_calcuResult.FailedList); |
| | | calcuFailedCtrl.SetBindingData(calcuResult.FailedList); |
| | | this.controlContainerBottom.Controls.Clear(); |
| | | this.controlContainerBottom.Controls.Add(calcuFailedCtrl); |
| | | this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; |
| | |
| | | this.docPnlBottom.Height = 350; |
| | | } |
| | | |
| | | //显示计算失败控件 |
| | | private void ShowCalcuFailedCtrl() |
| | | { |
| | | ShowCalcuFailedCtrl(_epaCalcuResult); |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #region 管网修复 |
| | | |
| | | //修复管网 |
| | | private void Repair() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var checkResult = GetCheckResult(true); |
| | | if (checkResult == null) |
| | | { |
| | | return; |
| | | } |
| | | if (!checkResult.Succeed) |
| | | { |
| | | ShowCheckCtrl(false); |
| | | TipFormHelper.ShowWarn("检查失败导致无法进行试算,停止修复!"); |
| | | return; |
| | | } |
| | | var calcuResult = GetEpaCalcuResult(Yw.EPAnet.CalcuMode.Simple, true); |
| | | if (calcuResult == null || !calcuResult.Succeed) |
| | | { |
| | | ShowCalcuFailedCtrl(calcuResult); |
| | | TipFormHelper.ShowWarn("试算失败,停止修复!"); |
| | | return; |
| | | } |
| | | |
| | | var allLinks = _hydroInfo.GetAllLinks(); |
| | | if (allLinks != null && allLinks.Count < 1) |
| | | { |
| | | TipFormHelper.ShowError("模型中未包含管段信息,停止修复!"); |
| | | return; |
| | | } |
| | | int count = 0; |
| | | foreach (var link in allLinks) |
| | | { |
| | | var calcuLink = calcuResult.LinkList?.Find(x => x.Id == link.Code); |
| | | if (calcuLink == null) |
| | | { |
| | | continue; |
| | | } |
| | | if (calcuLink.Flow < 0) |
| | | { |
| | | var tempCode = link.StartCode; |
| | | link.StartCode = link.EndCode; |
| | | link.EndCode = tempCode; |
| | | count++; |
| | | } |
| | | } |
| | | UpdateVisualViewModelProperty(); |
| | | UpdateVisualListCtrl(); |
| | | UpdateSelectedProperty(); |
| | | TipFormHelper.ShowSucceed($"修复完成,共修复管段({count})个!"); |
| | | } |
| | | |
| | | //管网修复 |
| | | private void barBtnRepair_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | Repair(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 导出INP文件 |
| | | |
| | | //导出INP文件 |
| | | private void barBtnExportInp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var fileName = FileDialogHelper.SaveInp("导出Inp文件"); |
| | | if (string.IsNullOrEmpty(fileName)) |
| | | { |
| | | return; |
| | | } |
| | | var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo); |
| | | var result = netWork.ToInpString(); |
| | | File.WriteAllText(fileName, result); |
| | | TipFormHelper.ShowSucceed("导出成功"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 并联分析 |
| | | |
| | | //并联分析 |
| | | private void ParallelAnalysis() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var pumps = _hydroInfo.Pumps; |
| | | if (pumps == null || pumps.Count < 1) |
| | | { |
| | | XtraMessageBox.Show("无水泵信息"); |
| | | return; |
| | | } |
| | | var vmList = new List<XhsSinglePumpViewModel>(); |
| | | foreach (var pump in pumps) |
| | | { |
| | | if (!pump.RatedN.HasValue) |
| | | { |
| | | continue; |
| | | } |
| | | var qh = _hydroInfo.Curves?.Find(t => t.Code == pump.CurveQH)?.CurveData; |
| | | var qe = _hydroInfo.Curves?.Find(t => t.Code == pump.CurveQE)?.CurveData; |
| | | var qp = _hydroInfo.Curves?.Find(t => t.Code == pump.CurveQP)?.CurveData; |
| | | if (qh == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var qhPtList = qh.Select(x => new XhsSplinePointViewModel(x.X, x.Y)).ToList(); |
| | | var qePtList = qe?.Select(x => new XhsSplinePointViewModel(x.X, x.Y)).ToList(); |
| | | var qpPtList = qp?.Select(x => new XhsSplinePointViewModel(x.X, x.Y)).ToList(); |
| | | |
| | | var vm = new XhsSinglePumpViewModel(); |
| | | vmList.Add(vm); |
| | | vm.ID = pump.ID; |
| | | vm.Name = pump.Name; |
| | | vm.Code = pump.Code; |
| | | vm.IsBp = true; |
| | | vm.RunStatus = pump.LinkStatus == Yw.Hydro.LinkStatus.Open; |
| | | vm.RatedHz = pump.RatedHz; |
| | | vm.CurrentHz = Math.Round(pump.RatedHz * pump.SpeedRatio, 1); |
| | | vm.RatedSpeed = pump.RatedN.Value; |
| | | vm.CurrentSpeed = Math.Round(pump.RatedN.Value * pump.SpeedRatio, 1); |
| | | vm.CurveQH = qhPtList; |
| | | vm.CurveQE = qePtList; |
| | | vm.CurveQP = qpPtList; |
| | | |
| | | } |
| | | |
| | | var dlg = new PumpParallelAnalyDlg(); |
| | | dlg.SetBindingData(vmList); |
| | | dlg.ReloadDataEvent += (list) => |
| | | { |
| | | list?.ForEach(x => |
| | | { |
| | | var pump = pumps.Find(t => t.Code == x.Code); |
| | | if (pump != null) |
| | | { |
| | | pump.LinkStatus = x.RunStatus ? Yw.Hydro.PumpStatus.Open : Yw.Hydro.PumpStatus.Closed; |
| | | pump.SpeedRatio = x.CurrentHz / pump.RatedHz; |
| | | } |
| | | }); |
| | | var codes = list?.Select(x => x.Code).ToList(); |
| | | UpdateVisualViewModelProperty(codes); |
| | | ShowSelectedProperty(); |
| | | UpdateVisualListCtrl(); |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //并联分析 |
| | | private void barBtnParallel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | ParallelAnalysis(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 工况计算 |
| | | |
| | | //所有工况元组列表 |
| | | private Tuple<HydroWorkingVmo, HydroCheckResult, HydroCalcuResult> _allWorkingTupleList = null; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | #region 工况 |
| | | |
| | | |
| | | //显示工况计算窗体 |
| | | private void ShowWorkingCalcuDlg() |
| | | { |
| | | var dlg = new SetHydroWorkingDlg(); |
| | | dlg.HydroViewEvent += async (parter) => |
| | | { |
| | | _selectedVisual = parter as Yw.Model.HydroVisualInfo; |
| | | if (_selectedVisual != null) |
| | | { |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _selectedVisual.Code }); |
| | | } |
| | | ShowSelectedProperty(); |
| | | }; |
| | | dlg.HydroCalcuEvent += async (hydroInfo, workingInfo) => |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | _hydroInfo.UpdateWorkingInfo(workingInfo); |
| | | //校验 |
| | | _checkResult = _hydroInfo.Check(); |
| | | if (!_checkResult.Succeed) |
| | | { |
| | | ShowCheckCtrl(); |
| | | TipFormHelper.ShowWarn("校验失败,请检查后重试"); |
| | | return; |
| | | } |
| | | |
| | | WaitFormHelper.ShowWaitForm(this, "正在计算分析中,请稍候..."); |
| | | |
| | | |
| | | //await Task.Delay(5000); |
| | | |
| | | var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo); |
| | | _epaCalcuResult = netWork.CalcuMinorLoss(); |
| | | |
| | | WaitFormHelper.HideWaitForm(); |
| | | if (_epaCalcuResult.Succeed) |
| | | { |
| | | GetCalcuResultList(false); |
| | | UpdateVisualViewModelProperty(); |
| | | UpdateVisualViewModelCalcuProperty(); |
| | | UpdateVisualListCtrl(); |
| | | UpdateSelectedProperty(); |
| | | await _bimfaceCtrl?.SetLogicCalcuCustomLabels(_epaCalcuResult); |
| | | TipFormHelper.ShowSucceed("计算成功!"); |
| | | var codes = _hydroInfo.Pumps.Select(x => x.Code).ToList(); |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(codes); |
| | | } |
| | | else |
| | | { |
| | | ShowCalcuFailedCtrl(); |
| | | TipFormHelper.ShowError("计算失败!"); |
| | | } |
| | | ApplyGradingResultList(false); |
| | | UpdateVisualListCtrl(); |
| | | ShowSelectedProperty(); |
| | | }; |
| | | dlg.SetBindingData(_hydroInfo); |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region 计算结果 |
| | | |
| | | //所有计算结果列表 |
| | | private List<HydroCalcuResult> _allCalcuResultList = null; |
| | | private List<HydroCalcuVisualResult> _allCalcuResultList = null; |
| | | |
| | | //获取计算结果 |
| | | //true 使用缓存,false 不使用缓存 |
| | | private List<HydroCalcuResult> GetAllCalcuResultList(bool isCache = true) |
| | | private List<HydroCalcuVisualResult> GetCalcuResultList(bool isCache = true) |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return default; |
| | | } |
| | | if (_calcuResult == null) |
| | | if (_epaCalcuResult == null) |
| | | { |
| | | return default; |
| | | } |
| | | if (!_calcuResult.Succeed) |
| | | if (!_epaCalcuResult.Succeed) |
| | | { |
| | | return default; |
| | | } |
| | |
| | | return _allCalcuResultList; |
| | | } |
| | | |
| | | _allCalcuResultList = new List<HydroCalcuResult>(); |
| | | _allCalcuResultList = new List<HydroCalcuVisualResult>(); |
| | | |
| | | //节点 |
| | | var allNodeList = _hydroInfo.GetAllNodes(); |
| | |
| | | { |
| | | foreach (var node in allNodeList) |
| | | { |
| | | var calcuNode = _calcuResult.NodeList?.Find(x => x.Id == node.Code); |
| | | var calcuNode = _epaCalcuResult.NodeList?.Find(x => x.Id == node.Code); |
| | | if (calcuNode != null) |
| | | { |
| | | var calcuResult = new HydroCalcuNodeResult() |
| | |
| | | { |
| | | foreach (var link in allLinkList) |
| | | { |
| | | var calcuLink = _calcuResult.LinkList?.Find(x => x.Id == link.Code); |
| | | var calcuLink = _epaCalcuResult.LinkList?.Find(x => x.Id == link.Code); |
| | | if (calcuLink != null) |
| | | { |
| | | var calcuResult = new HydroCalcuLinkResult() |
| | |
| | | //水力计算 |
| | | private void barBtnHydroCalcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | ShowCalcuPrefixDlg(); |
| | | ShowWorkingCalcuDlg(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 构件查询 |
| | | |
| | | //查询组件 |
| | | private XhsProjectSimulationSearchCtrl _searchCtrl = null; |
| | | |
| | | //获取查询组件 |
| | | private XhsProjectSimulationSearchCtrl GetSearchCtrl() |
| | | { |
| | | if (_searchCtrl == null) |
| | | { |
| | | _searchCtrl = new XhsProjectSimulationSearchCtrl(); |
| | | _searchCtrl.Dock = DockStyle.Fill; |
| | | _searchCtrl.InitialData(() => _hydroInfo); |
| | | _searchCtrl.ApplySearchEvent += async (list) => |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var elementIds = new List<string>(); |
| | | if (list != null && list.Count > 0) |
| | | { |
| | | var first = list.First(); |
| | | var allParterList = _hydroInfo.GetAllParters(); |
| | | _parter = allParterList?.Find(x => x.Code == first.Code); |
| | | list.ForEach(x => elementIds.Add(x.Code)); |
| | | } |
| | | else |
| | | { |
| | | _parter = null; |
| | | } |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds); |
| | | ShowProperty(); |
| | | }; |
| | | } |
| | | return _searchCtrl; |
| | | } |
| | | |
| | | //显示查询控件 |
| | | private void ShowSearchCtrl() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var searchCtrl = GetSearchCtrl(); |
| | | this.controlContainerBottom.Controls.Clear(); |
| | | this.controlContainerBottom.Controls.Add(searchCtrl); |
| | | this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; |
| | | this.docPnlBottom.Text = "构件查询"; |
| | | this.docPnlBottom.Height = 350; |
| | | } |
| | | |
| | | //查询 |
| | | private void barBtnSearch_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | ShowSearchCtrl(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 模型标注 |
| | | |
| | | //所有标注列表 |
| | | private List<HydroMarkSetViewModel> _allMarkList = null; |
| | | |
| | | //显示标注窗体 |
| | | private void ShowMarkDlg() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_allMarkList == null) |
| | | { |
| | | _allMarkList = new List<HydroMarkSetViewModel>(); |
| | | if (_hydroInfo.Waterboxs != null && _hydroInfo.Waterboxs.Count > 0) |
| | | { |
| | | _allMarkList.Add(new HydroMarkSetViewModel() |
| | | { |
| | | Code = Yw.Hydro.ParterCatalog.Waterbox, |
| | | Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Waterbox), |
| | | MarkType = (int)eWaterboxMarkType.None |
| | | }); |
| | | } |
| | | if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0) |
| | | { |
| | | _allMarkList.Add(new HydroMarkSetViewModel() |
| | | { |
| | | Code = Yw.Hydro.ParterCatalog.Pump, |
| | | Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pump), |
| | | MarkType = (int)eWaterboxMarkType.None |
| | | }); |
| | | } |
| | | if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0) |
| | | { |
| | | _allMarkList.Add(new HydroMarkSetViewModel() |
| | | { |
| | | Code = Yw.Hydro.ParterCatalog.Valve, |
| | | Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Valve), |
| | | MarkType = (int)eWaterboxMarkType.None |
| | | }); |
| | | } |
| | | if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0) |
| | | { |
| | | _allMarkList.Add(new HydroMarkSetViewModel() |
| | | { |
| | | Code = Yw.Hydro.ParterCatalog.Pipe, |
| | | Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pipe), |
| | | MarkType = (int)eWaterboxMarkType.None |
| | | }); |
| | | } |
| | | if (_hydroInfo.Nozzles != null && _hydroInfo.Nozzles.Count > 0) |
| | | { |
| | | _allMarkList.Add(new HydroMarkSetViewModel() |
| | | { |
| | | Code = Yw.Hydro.ParterCatalog.Nozzle, |
| | | Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Nozzle), |
| | | MarkType = (int)eWaterboxMarkType.None |
| | | }); |
| | | } |
| | | } |
| | | var dlg = new SetHydroMarkDlg(); |
| | | dlg.SetBindingData(_hydroInfo, _allMarkList); |
| | | dlg.ReloadDataEvent += async (allResultList) => |
| | | { |
| | | var leadLabels = allResultList?.Select(x => new LogicMarkLeadLabel(x.Code, x.Text, 100000)).ToList(); |
| | | await _bimfaceCtrl?.SetLogicMarkLeadLabels(leadLabels); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //设置标注 |
| | | private void barBtnSetMark_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | ShowMarkDlg(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 颜色分级 |
| | | |
| | | //颜色分级应用列表 |
| | | private List<HydroGradingApplyViewModel> _allGradingApplyList = null; |
| | | //颜色分级编码列表 |
| | | private List<string> _allGradingCodeList = null; |
| | | |
| | | //设置颜色分级 |
| | | private void SetGrading() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new SetHydroGradingModelTreeDlg(); |
| | | dlg.SetBindingData(_hydroInfo.ID); |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //应用颜色分级 |
| | | private async void ApplyGrading() |
| | | { |
| | | if (_hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | 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.GetCatalogName(Yw.Hydro.ParterCatalog.Pump), |
| | | PropName = string.Empty |
| | | }); |
| | | } |
| | | if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0) |
| | | { |
| | | _allGradingApplyList.Add(new HydroGradingApplyViewModel() |
| | | { |
| | | Code = Yw.Hydro.ParterCatalog.Valve, |
| | | Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Valve), |
| | | PropName = string.Empty |
| | | }); |
| | | } |
| | | if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0) |
| | | { |
| | | _allGradingApplyList.Add(new HydroGradingApplyViewModel() |
| | | { |
| | | Code = Yw.Hydro.ParterCatalog.Pipe, |
| | | Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pipe), |
| | | PropName = string.Empty |
| | | }); |
| | | } |
| | | } |
| | | var dlg = new ApplyHydroGradingDlg(); |
| | | dlg.SetBindingData(() => _hydroInfo, _allGradingApplyList, GetAllCalcuResultList()); |
| | | dlg.ReloadDataEvent += (obj) => |
| | | { |
| | | _allGradingCodeList = obj?.Select(x => x.Code).Distinct().ToList(); |
| | | var objGroupList = obj?.GroupBy(x => x.Color).ToList(); |
| | | objGroupList?.ForEach(async x => |
| | | { |
| | | await _bimfaceCtrl?.OverrideComponentsColor(x.Select(t => t.Code).Distinct().ToList(), x.Key, 1); |
| | | }); |
| | | }; |
| | | if (dlg.ShowDialog() == DialogResult.Cancel) |
| | | { |
| | | await _bimfaceCtrl?.RestoreComponentsColor(_allGradingCodeList); |
| | | } |
| | | } |
| | | |
| | | //设置 |
| | | private void barBtnGradingSet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | SetGrading(); |
| | | } |
| | | |
| | | //应用 |
| | | private void barBtnGradingApply_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | ApplyGrading(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 人工刷新 |
| | | |
| | | //刷新 |
| | | private async void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (XtraMessageBox.Show("刷新后将丢失当前水力信息更改,是否继续刷新?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes) |
| | | { |
| | | if (_project == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_projectSite == null) |
| | | { |
| | | return; |
| | | } |
| | | var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance |
| | | .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation); |
| | | _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID); |
| | | _parter = null; |
| | | await _bimfaceCtrl?.ZoomAndSelectComponents(null); |
| | | ShowProperty(); |
| | | TipFormHelper.ShowSucceed("数据已刷新"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |