From 2e8e85f65748ee5a5adf0dcda864aa4167cbf2ef Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期三, 11 十二月 2024 10:32:35 +0800 Subject: [PATCH] 冲突 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs | 1012 ++++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 653 insertions(+), 359 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 daca05e..77426c9 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 @@ -4,6 +4,7 @@ using DevExpress.XtraMap; using HStation.WinFrmUI.PhartRelation; using Mapster; +using NPOI.OpenXmlFormats.Dml; using NPOI.SS.Formula.Functions; using System.Diagnostics; using Yw.EPAnet; @@ -29,9 +30,28 @@ /// 鏂板宸ュ喌浜嬩欢 /// </summary> public event Action<HydroWorkingVmo> AppendWorkingEvent; + /// <summary> + /// 淇濆瓨妯″瀷浜嬩欢 + /// </summary> + public event Func<Yw.Model.HydroModelInfo, Task<Yw.Model.HydroModelInfo>> SaveModelEvent; + /// <summary> + /// 鍒锋柊妯″瀷浜嬩欢 + /// </summary> + public event Func<Task<Yw.Model.HydroModelInfo>> RefreshModelEvent; + /// <summary> + /// 鏇存柊鏂规浜嬩欢 + /// </summary> + public event Action<XhsSchemeVmo> UpdateSchemeEvent; + /// <summary> + /// 绉婚櫎鏂规浜嬩欢 + /// </summary> + public event Action<XhsSchemeVmo> RemoveSchemeEvent; + + private HStation.Vmo.XhsProjectVmo _project = null;//椤圭洰 private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;//椤圭洰绔� + private HStation.Vmo.XhsSchemeVmo _scheme = null;//鏂规 private Yw.Model.HydroModelInfo _hydroInfo = null;//姘村姏淇℃伅 private Dictionary<HydroWorkingVmo, bool> _allWorkingCheckedListDict = null;//鎵�鏈夊伐鍐甸�夋嫨鍒楄〃瀛楀吀 @@ -42,15 +62,27 @@ ( XhsProjectVmo project, XhsProjectSiteVmo projectSite, + XhsSchemeVmo scheme, Yw.Model.HydroModelInfo hydroInfo, Dictionary<HydroWorkingVmo, bool> allWorkingCheckedListDict ) { _project = project; _projectSite = projectSite; + _scheme = scheme; _hydroInfo = hydroInfo; _allWorkingCheckedListDict = allWorkingCheckedListDict; - //this.PageTitle.Caption = $"{_project.Name}\r\n姘村姏妯℃嫙"; + ResetMonitorValue(); + if (_scheme == null) + { + this.ribPageGroupForScheme.Visible = false; + this.PageTitle.Caption = $"姘村姏妯℃嫙"; + } + else + { + this.ribPageGroupForScheme.Visible = true; + this.PageTitle.Caption = $"妯℃嫙鏂规\r\n{_scheme.Name}"; + } } /// <summary> @@ -67,10 +99,10 @@ #region BIM鎺т欢 //bimface鎺т欢 - private XhsProjectSimulationBimfaceCtrl _bimfaceCtrl = null; + private SimulationBimfaceCtrl _bimfaceCtrl = null; //鑾峰彇 bimface 鎺т欢 - private async Task<XhsProjectSimulationBimfaceCtrl> GetBimfaceCtrl() + private async Task<SimulationBimfaceCtrl> GetBimfaceCtrl() { if (_hydroInfo == null) { @@ -79,7 +111,7 @@ if (_bimfaceCtrl == null) { var overlay = this.ShowOverlay(); - _bimfaceCtrl = new XhsProjectSimulationBimfaceCtrl(); + _bimfaceCtrl = new SimulationBimfaceCtrl(); _bimfaceCtrl.Dock = DockStyle.Fill; await _bimfaceCtrl.InitialData(_project, _projectSite); _bimfaceCtrl.LoadCompletedEvent += () => @@ -92,7 +124,7 @@ {//榧犳爣宸﹂敭鐐瑰嚮浜嬩欢 var visualListHelper = GetVisualListHelper(); var visual = visualListHelper.GetVisual(code); - SelectVisual(visual, eVisualSource.Bimface); + SelectVisual(visual, eSimulationVisualSource.Bimface); }; } return _bimfaceCtrl; @@ -129,7 +161,7 @@ { var visualListHelper = GetVisualListHelper(); var visuals = visualListHelper.GetVisualList(codes); - SelectVisual(visuals?.LastOrDefault(), eVisualSource.Q3d); + SelectVisual(visuals?.LastOrDefault(), eSimulationVisualSource.Q3d); }; } return _q3dCtrl; @@ -148,10 +180,10 @@ #region 灞炴�ф帶浠� //灞炴�ф帶浠� - private XhsProjectSimulationPropertyCtrl _propertyCtrl = null; + private SimulationPropertyCtrl _propertyCtrl = null; //鑾峰彇灞炴�ф帶浠� - private XhsProjectSimulationPropertyCtrl GetPropertyCtrl() + private SimulationPropertyCtrl GetPropertyCtrl() { if (_hydroInfo == null) { @@ -159,11 +191,12 @@ } if (_propertyCtrl == null) { - _propertyCtrl = new XhsProjectSimulationPropertyCtrl(); + _propertyCtrl = new SimulationPropertyCtrl(); _propertyCtrl.Dock = DockStyle.Fill; + _propertyCtrl.AllowEdit = true; _propertyCtrl.HydroViewEvent += (visual) => { - SelectVisual(visual, eVisualSource.Property); + SelectVisual(visual, eSimulationVisualSource.Property); }; _propertyCtrl.BlinkLinkNodeEvent += async (link, linkNodeCode) => { //寮鸿皟杩炴帴鑺傜偣 @@ -247,7 +280,7 @@ { if (this.controlContainerRight.Controls.Count > 0) { - if (this.controlContainerRight.Controls[0] is XhsProjectSimulationPropertyCtrl) + if (this.controlContainerRight.Controls[0] is SimulationPropertyCtrl) { return true; } @@ -279,6 +312,7 @@ var visualVmListHelper = GetVisualVmListHelper(); var vm = visualVmListHelper.GetVisual(visual); _propertyCtrl.SelectedObject = vm; + _propertyCtrl.UpdateRows(); } //鏇存柊灞炴�ф帶浠� @@ -287,105 +321,88 @@ _propertyCtrl?.UpdateRows(); } - //娓呯悊灞炴�ф帶浠� - private void ClearPropertyCtrl() - { - if (_propertyCtrl != null) - { - _propertyCtrl.SelectedObject = null; - } - } - #endregion #region 閫夋嫨鏋勪欢 - - //鍙鏉ユ簮 - protected enum eVisualSource - { - None, - Bimface, - Q3d, - Property, - List, - Search, - Monitor, - Check, - Calcu, - Warning, - } //閫夋嫨鏋勪欢 private Yw.Model.HydroVisualInfo _visual = null; //閫夋嫨鏋勪欢 - private void SelectVisual(HydroVisualInfo visual, eVisualSource source) + private void SelectVisual(HydroVisualInfo visual, eSimulationVisualSource source) { _visual = visual; switch (source) { - case eVisualSource.None: + case eSimulationVisualSource.None: { _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code); this.barBtnSetMonitor.Enabled = visual != null; SetPropertyCtrl(visual); } break; - case eVisualSource.Bimface: + case eSimulationVisualSource.Bimface: { this.barBtnSetMonitor.Enabled = visual != null; SetPropertyCtrl(visual); } break; - case eVisualSource.Q3d: + case eSimulationVisualSource.Q3d: { _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code); this.barBtnSetMonitor.Enabled = visual != null; SetPropertyCtrl(visual); } break; - case eVisualSource.Property: + case eSimulationVisualSource.Property: { _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code); this.barBtnSetMonitor.Enabled = visual != null; } break; - case eVisualSource.List: + case eSimulationVisualSource.List: { _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code); this.barBtnSetMonitor.Enabled = visual != null; SetPropertyCtrl(visual); } break; - case eVisualSource.Search: + case eSimulationVisualSource.Set: { _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code); this.barBtnSetMonitor.Enabled = visual != null; SetPropertyCtrl(visual); } break; - case eVisualSource.Monitor: + case eSimulationVisualSource.Search: { _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code); this.barBtnSetMonitor.Enabled = visual != null; SetPropertyCtrl(visual); } break; - case eVisualSource.Check: + case eSimulationVisualSource.Monitor: { _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code); this.barBtnSetMonitor.Enabled = visual != null; SetPropertyCtrl(visual); } break; - case eVisualSource.Calcu: + case eSimulationVisualSource.Check: { _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code); this.barBtnSetMonitor.Enabled = visual != null; SetPropertyCtrl(visual); } break; - case eVisualSource.Warning: + case eSimulationVisualSource.Calcu: + { + _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code); + this.barBtnSetMonitor.Enabled = visual != null; + SetPropertyCtrl(visual); + } + break; + case eSimulationVisualSource.Warning: { _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code); this.barBtnSetMonitor.Enabled = visual != null; @@ -394,6 +411,13 @@ break; default: break; } + } + + //閫夋嫨鏋勪欢 + private void SelectVisual(string code, eSimulationVisualSource source) + { + var visual = GetVisual(code); + SelectVisual(visual, source); } #endregion @@ -414,6 +438,35 @@ _visualListHelper.InitialData(_hydroInfo); } return _visualListHelper; + } + + //閲嶇疆鍙鍒楄〃 + private void ResetVisualList() + { + var helper = GetVisualListHelper(); + helper.InitialData(_hydroInfo); + } + + //鑾峰彇鍙鏋勪欢 + private Yw.Model.HydroVisualInfo GetVisual(string code) + { + var helper = GetVisualListHelper(); + var visual = helper.GetVisual(code); + return visual; + } + + //鑾峰彇鍙鍒楄〃 + private List<Yw.Model.HydroVisualInfo> GetVisualList() + { + var helper = GetVisualListHelper(); + return helper.GetVisualList(); + } + + //鑾峰彇姘存簮鍒楄〃 + private List<Yw.Model.HydroSourceInfo> GetSourceList() + { + var helper = GetVisualListHelper(); + return helper.GetSourceList(); } #endregion @@ -439,6 +492,13 @@ return _visualVmListHelper; } + //鑾峰彇鍙瑙嗗浘鍒楄〃 + private List<HydroVisualViewModel> GetVisualViewModelList() + { + var helper = GetVisualVmListHelper(); + return helper.GetVisualList(); + } + #endregion #region 鏄庣粏鎺т欢 @@ -455,11 +515,11 @@ _visualListCtrl.Dock = DockStyle.Fill; _visualListCtrl.HydroClickInfoEvent += (visual) => { - SelectVisual(visual, eVisualSource.List); + SelectVisual(visual, eSimulationVisualSource.List); }; _visualListCtrl.HydroChangedInfoEvent += (visualList) => { - SelectVisual(_visual, eVisualSource.List); + SelectVisual(_visual, eSimulationVisualSource.List); }; } return _visualListCtrl; @@ -522,6 +582,15 @@ return; } _visualListCtrl?.UpdateBindingData(); + var calcuResult = GetCalcuResult(); + if (calcuResult != null && calcuResult.Succeed) + { + _visualListCtrl.SetCalcuView(); + } + else + { + _visualListCtrl.SetNormalView(); + } } //鏋勪欢鏄庣粏 @@ -616,24 +685,27 @@ { 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) + if (this.SaveModelEvent == null) + { + return; + } + var hydroInfo = await this.SaveModelEvent.Invoke(_hydroInfo); + if (hydroInfo == null) { TipFormHelper.ShowError("淇濆瓨澶辫触锛�"); return; } - _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(id); + _hydroInfo = hydroInfo; + TipFormHelper.ShowSucceed("淇濆瓨鎴愬姛锛�"); + + + //Stopwatch sw = new Stopwatch(); + //sw.Start(); + //鑰楁椂宸ㄥぇ鐨勪唬鐮� + //sw.Stop(); + //TimeSpan ts2 = sw.Elapsed; + //Console.WriteLine("Stopwatch鎬诲叡鑺辫垂{0}ms.", ts2.TotalMilliseconds); } #endregion @@ -646,182 +718,290 @@ //姘村簱 this.barBtnSetReservoirList.ItemClick += delegate { - //var dlg = new HydroReservoirBulkSetListDlg(); - //dlg.ShowDialog(); + var allVisualViewModelList = GetVisualViewModelList(); + var dlg = new SetHydroReservoirListDlg(); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; + dlg.ShowDialog(); }; //姘存睜 this.barBtnSetTankList.ItemClick += delegate { - //var dlg = new HydroTankBulkSetListDlg(); - //dlg.ShowDialog(); + var allVisualViewModelList = GetVisualViewModelList(); + var dlg = new SetHydroTankListDlg(); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; + dlg.ShowDialog(); }; //姘寸 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) => - //{ - - //}; - //dlg.ShowDialog(); + var allVisualViewModelList = GetVisualViewModelList(); + var dlg = new SetHydroWaterboxListDlg(); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; + dlg.ShowDialog(); }; //杩炴帴鑺傜偣 this.barBtnSetJunctionList.ItemClick += delegate { - //var dlg = new HydroJunctionBulkSetListDlg(); - //dlg.ShowDialog(); + var allVisualViewModelList = GetVisualViewModelList(); + var dlg = new SetHydroJunctionListDlg(); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; + dlg.ShowDialog(); }; //闂峰ご 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) => - //{ - - //}; - //dlg.ShowDialog(); + var allVisualViewModelList = GetVisualViewModelList(); + var dlg = new SetHydroBluntheadListDlg(); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; + 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) => - //{ - - //}; - //dlg.ShowDialog(); + var allVisualVmList = GetVisualViewModelList(); + var dlg = new SetHydroElbowListDlg(); + dlg.SetBindingData(allVisualVmList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; + dlg.ShowDialog(); }; //涓夐�� this.barBtnSetThreelinkList.ItemClick += delegate { - if (_hydroInfo == null) - { - return; - } + var allVisualViewModelList = GetVisualViewModelList(); var dlg = new SetHydroThreelinkListDlg(); - dlg.SetBindingData(_hydroInfo); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; dlg.ShowDialog(); }; //鍥涢�� this.barBtnSetFourlinkList.ItemClick += delegate { - if (_hydroInfo == null) - { - return; - } + var allVisualViewModelList = GetVisualViewModelList(); var dlg = new SetHydroFourlinkListDlg(); - dlg.SetBindingData(_hydroInfo); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; dlg.ShowDialog(); }; //姘磋〃 this.barBtnSetMeterList.ItemClick += delegate { - if (_hydroInfo == null) - { - return; - } + var allVisualViewModelList = GetVisualViewModelList(); var dlg = new SetHydroMeterListDlg(); - dlg.SetBindingData(_hydroInfo); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; dlg.ShowDialog(); }; //娴侀噺璁� this.barBtnSetFlowmeterList.ItemClick += delegate { - if (_hydroInfo == null) - { - return; - } + var allVisualViewModelList = GetVisualViewModelList(); var dlg = new SetHydroFlowmeterListDlg(); - dlg.SetBindingData(_hydroInfo); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; dlg.ShowDialog(); }; //鍘嬪姏琛� this.barBtnSetPressmeterList.ItemClick += delegate { - if (_hydroInfo == null) - { - return; - } + var allVisualViewModelList = GetVisualViewModelList(); var dlg = new SetHydroPressmeterListDlg(); - dlg.SetBindingData(_hydroInfo); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; dlg.ShowDialog(); }; //绠¢亾 this.barBtnSetPipeList.ItemClick += delegate { - if (_hydroInfo == null) - { - return; - } + var allVisualViewModelList = GetVisualViewModelList(); var dlg = new SetHydroPipeListDlg(); - dlg.SetBindingData(_hydroInfo); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; + dlg.ShowDialog(); + }; + //杩囨浮浠� + this.barBtnSetTranslationList.ItemClick += delegate + { + var allVisualViewModelList = GetVisualViewModelList(); + var dlg = new SetHydroTranslationListDlg(); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; dlg.ShowDialog(); }; //姘存车 this.barBtnSetPumpList.ItemClick += delegate { - if (_hydroInfo == null) - { - return; - } + var allVisualViewModelList = GetVisualViewModelList(); var dlg = new SetHydroPumpListDlg(); - dlg.SetBindingData(_hydroInfo); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; dlg.ShowDialog(); }; //闃�闂� this.barBtnSetValveList.ItemClick += delegate { - if (_hydroInfo == null) - { - return; - } + var allVisualViewModelList = GetVisualViewModelList(); var dlg = new SetHydroValveListDlg(); - dlg.SetBindingData(_hydroInfo); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; + dlg.ShowDialog(); + }; + //鎹㈢儹鍣� + this.barBtnSetExchangerList.ItemClick += delegate + { + var allVisualViewModelList = GetVisualViewModelList(); + var dlg = new SetHydroExchangerListDlg(); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; + dlg.ShowDialog(); + }; + //鎹㈢儹鍣� + this.barBtnSetCompressorList.ItemClick += delegate + { + var allVisualViewModelList = GetVisualViewModelList(); + var dlg = new SetHydroCompressorListDlg(); + dlg.SetBindingData(allVisualViewModelList); + dlg.HydroClickInfoEvent += (visual) => + { + SelectVisual(visual, eSimulationVisualSource.Set); + }; + dlg.HydroChangedInfoEvent += visuals => + { + SelectVisual(visuals?.FirstOrDefault(), eSimulationVisualSource.Set); + UpdateVisualListCtrl(); + }; dlg.ShowDialog(); }; } @@ -991,6 +1171,26 @@ this.barBtnSetTranslationList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; } + //姘存车 + if (_hydroInfo.Pumps == null || _hydroInfo.Pumps.Count < 1) + { + this.barBtnSetPumpList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetPumpList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //闃�闂� + if (_hydroInfo.Valves == null || _hydroInfo.Valves.Count < 1) + { + this.barBtnSetValveList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetValveList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + //鎹㈢儹鍣� if (_hydroInfo.Exchangers == null || _hydroInfo.Exchangers.Count < 1) { @@ -1011,25 +1211,6 @@ this.barBtnSetCompressorList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; } - //姘存车 - if (_hydroInfo.Pumps == null || _hydroInfo.Pumps.Count < 1) - { - this.barBtnSetPumpList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; - } - else - { - this.barBtnSetPumpList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; - } - - //闃�闂� - if (_hydroInfo.Valves == null || _hydroInfo.Valves.Count < 1) - { - this.barBtnSetValveList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; - } - else - { - this.barBtnSetValveList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; - } } @@ -1052,12 +1233,12 @@ _searchCtrl.InitialData(allVisualVmList); _searchCtrl.HydroClickInfoEvent += (visual) => { - SelectVisual(visual, eVisualSource.Check); + SelectVisual(visual, eSimulationVisualSource.Check); }; _searchCtrl.HydroSearchInfoEvent += (list) => { var visual = list?.FirstOrDefault(); - SelectVisual(visual, eVisualSource.Search); + SelectVisual(visual, eSimulationVisualSource.Search); }; } return _searchCtrl; @@ -1265,31 +1446,24 @@ //鍒锋柊 private async void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { + if (this.RefreshModelEvent == null) + { + return; + } 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); - _visual = null; - await _bimfaceCtrl?.ZoomAndSelectComponents(null); - //ShowSelectedProperty(); - TipFormHelper.ShowSucceed("鏁版嵁宸插埛鏂�"); - var visualListHelper = GetVisualListHelper(); - visualListHelper.InitialData(_hydroInfo); + var hydroInfo = await this.RefreshModelEvent.Invoke(); + if (hydroInfo == null) + { + TipFormHelper.ShowError("鍒锋柊澶辫触锛�"); + return; + } + _hydroInfo = hydroInfo; + SelectVisual(visual: null, eSimulationVisualSource.None); + + ResetVisualList(); + TipFormHelper.ShowSucceed("鍒锋柊鎴愬姛锛�"); } } @@ -1350,6 +1524,13 @@ return _monitorHelper; } + //鑾峰彇鐩戞祴鐐瑰垪琛� + private async Task<List<HydroMonitorVmo>> GetMonitorList() + { + var helper = GetMonitorHelper(); + return await helper.Get(); + } + //璁剧疆鐩戞祴鐐瑰垪琛� private async void SetMonitorList(HydroVisualInfo visual) { @@ -1405,6 +1586,19 @@ return _monitorValueHelper; } + //閲嶇疆 + private void ResetMonitorValue() + { + var allWorkingList = GetWorkingList(); + var working = allWorkingList?.LastOrDefault(x => !string.IsNullOrEmpty(x.MonitorInfo)); + if (working != null) + { + var helper = GetMonitorValueHelper(); + helper.Reset(working.MonitorInfo); + } + + } + #endregion #region 鐩戞祴鍊兼帶浠� @@ -1423,7 +1617,7 @@ { var visualListHelper = GetVisualListHelper(); var visual = visualListHelper.GetVisual(code); - SelectVisual(visual, eVisualSource.Monitor); + SelectVisual(visual, eSimulationVisualSource.Monitor); }; } return _monitorValueListCtrl; @@ -1522,7 +1716,7 @@ { var visualListHelper = GetVisualListHelper(); var visual = visualListHelper.GetVisual(code); - SelectVisual(visual, eVisualSource.Check); + SelectVisual(visual, eSimulationVisualSource.Check); }; } return _checkCtrl; @@ -1686,7 +1880,7 @@ { var visualListHelper = GetVisualListHelper(); var visual = visualListHelper.GetVisual(code); - SelectVisual(visual, eVisualSource.Warning); + SelectVisual(visual, eSimulationVisualSource.Warning); }; } return _calcuWarningCtrl; @@ -1851,7 +2045,6 @@ return; } var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo); - var json = JsonHelper.Object2Json(netWork); var result = netWork.ToInpString(); File.WriteAllText(fileName, result); TipFormHelper.ShowSucceed("瀵煎嚭鎴愬姛"); @@ -1861,7 +2054,38 @@ #region 姘存车鍒楄〃 - #region 骞惰仈妯℃嫙 + //鎬ц兘鏇茬嚎 + private void PumpFeat() + { + if (_hydroInfo == null) + { + return; + } + var pumps = _hydroInfo.Pumps; + if (pumps == null || pumps.Count < 1) + { + XtraMessageBox.Show("鏃犳按娉典俊鎭�"); + return; + } + var dlg = new SimulationPumpFeatDlg(); + dlg.SaveEvent += async (list) => + { + pumps.ForEach(x => x.UpdateWorkingInfo(list)); + var visualVmListHelper = GetVisualVmListHelper(); + visualVmListHelper.UpdateProperty(pumps.Select(x => x as Yw.Model.HydroVisualInfo).ToList()); + SelectVisual(_visual, eSimulationVisualSource.None); + var gradingHelper = await GetGradingHelper(); + gradingHelper.Set(); + }; + dlg.SetBindingData(_hydroInfo); + dlg.ShowDialog(); + } + + //鎬ц兘鏇茬嚎 + private void barBtnPumpCurve_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + PumpFeat(); + } //骞惰仈妯℃嫙 private void PumpParallel() @@ -1876,71 +2100,34 @@ 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) => + var dlg = new SimulationPumpParallelDlg(); + dlg.SaveEvent += async (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; + pump.LinkStatus = x.LinkStatus; + pump.SpeedRatio = x.SpeedRatio; } }); - var codes = list?.Select(x => x.Code).ToList(); - //UpdateVisualViewModelProperty(codes); - //ShowSelectedProperty(); - UpdateVisualListCtrl(); - return true; + var visualVmListHelper = GetVisualVmListHelper(); + visualVmListHelper.UpdateProperty(pumps.Select(x => x as Yw.Model.HydroVisualInfo).ToList()); + SelectVisual(_visual, eSimulationVisualSource.None); + var gradingHelper = await GetGradingHelper(); + gradingHelper.Set(); }; + dlg.SetBindingData(_hydroInfo); dlg.ShowDialog(); } //骞惰仈妯℃嫙 private void barBtnPumpParallel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { + PumpParallel(); } - - #endregion #endregion @@ -1961,7 +2148,7 @@ dlg.SetBindingData(_hydroInfo, allWorkingList, allMonitorValueList); dlg.HydroViewEvent += (visual) => { - SelectVisual(visual, eVisualSource.Calcu); + SelectVisual(visual, eSimulationVisualSource.Calcu); }; dlg.HydroCalcuEvent += async (vm) => { @@ -1974,7 +2161,11 @@ working.ModelID = vm.ModelID; working.Name = vm.Name; working.WorkingInfo = JsonHelper.Object2Json(vm.WorkingInfo); - working.MonitorInfo = JsonHelper.Object2Json(vm.MonitorInfo); + var useWorkingMonitorInfo = vm.MonitorInfo?.Where(x => x.PropValue.HasValue).ToList(); + if (useWorkingMonitorInfo != null && useWorkingMonitorInfo.Count > 0) + { + working.MonitorInfo = JsonHelper.Object2Json(useWorkingMonitorInfo); + } working.SortCode = vm.SortCode; working.Description = vm.Description; @@ -1990,7 +2181,7 @@ } WaitFormHelper.ShowWaitForm(this, "姝e湪璁$畻鍒嗘瀽涓紝璇风◢鍊�..."); - //await Task.Delay(3000); + await Task.Delay(3000); var calcuResult = _hydroInfo.Calcu(Yw.EPAnet.CalcuMode.MinorLoss); WaitFormHelper.HideWaitForm(); workingHelper.InitialData(hydroInfo, working, checkResult, calcuResult); @@ -2001,6 +2192,7 @@ ShowCalcuWarningCtrl(calcuResult); } this.barBtnAddWorking.Enabled = true; + this.barBtnExportWord.Enabled = true; TipFormHelper.ShowSucceed("璁$畻鎴愬姛锛�"); } else @@ -2016,6 +2208,25 @@ #endregion + #region 褰撳墠鏋勪欢 + + SelectVisual(_visual, eSimulationVisualSource.Calcu); + + #endregion + + #region 鏋勪欢鏄庣粏 + + UpdateVisualListCtrl(); + + #endregion + + #region 棰滆壊鍒嗙骇 + + var gradingHelper = await GetGradingHelper(); + gradingHelper.Set(); + + #endregion + #region 璁$畻鏍囩 var calcuResultLabelHelper = await GetCalcuResultLabelHelper(); @@ -2024,15 +2235,31 @@ #endregion }; - dlg.ShowDialog(); - } //姘村姏璁$畻 private void barBtnCalcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { Calcu(); + } + + #endregion + + #region 瀵煎嚭鎶ュ憡 + + private void barBtnExportWord_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + var fileName = FileDialogHelper.SaveWordDoc("瀵煎嚭Word鎶ュ憡"); + if (string.IsNullOrEmpty(fileName)) + { + return; + } + var vm = new ReportViewModel(); + vm.ProjectName = _project.Name; + vm.Description = _project.Description; + SimulationWordReport word = new SimulationWordReport(); + word.Create(fileName, vm); } #endregion @@ -2088,6 +2315,7 @@ { this.barBtnAddWorking.Enabled = false; workingHelper.ResetWorking(rhs); + UpdateWorkingCheckedList(rhs, false); this.AppendWorkingEvent?.Invoke(rhs); }; dlg.ShowDialog(); @@ -2118,6 +2346,20 @@ return _workingCheckedListHelper; } + //鑾峰彇宸ュ喌鍒楄〃 + private List<HydroWorkingVmo> GetWorkingList() + { + var helper = GetWorkingCheckedListHelper(); + return helper.GetWorkingList(); + } + + //鏇存柊宸ュ喌閫夋嫨鍒楄〃 + public void UpdateWorkingCheckedList(HydroWorkingVmo working) + { + var helper = GetWorkingCheckedListHelper(); + helper.Update(working); + } + //鏇存柊宸ュ喌閫夋嫨鍒楄〃 public void UpdateWorkingCheckedList(HydroWorkingVmo working, bool hasChecked) { @@ -2125,10 +2367,38 @@ helper.Update(working, hasChecked); } + //绉婚櫎宸ュ喌閫夋嫨鍒楄〃 + public void RemoveWorkingCheckedList(HydroWorkingVmo working) + { + var helper = GetWorkingCheckedListHelper(); + helper.Remove(working); + } + #endregion #region 宸ュ喌鍒嗘瀽 + + //閫夋嫨杩涘彛姘存簮 + private void SelectInputSource() + { + var sources = GetSourceList(); + if (sources != null) + { + if (sources.Count == 1) + { + SelectVisual(sources[0], eSimulationVisualSource.None); + } + else + { + var source = sources.FirstOrDefault(x => x.Flags.Contains(HStation.Xhs.Flags.杩涘彛)); + if (source != null) + { + SelectVisual(source, eSimulationVisualSource.None); + } + } + } + } //绮惧害璇勪及 private async void barBtnWorkingEvaluation_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) @@ -2161,97 +2431,32 @@ //姘存车鍒嗘瀽 private void barBtnPumpAnaly_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { - if (_hydroInfo == null) + var workingCheckedListHelper = GetWorkingCheckedListHelper(); + var allCheckedWorkingList = workingCheckedListHelper.GetCheckedWorkingList(); + if (allCheckedWorkingList == null || allCheckedWorkingList.Count < 1) { - return; - } - if (_hydroInfo.Pumps == null || _hydroInfo.Pumps.Count < 1) - { - return; - } - - var calcuResultHelper = GetCalcuResultHelper(); - var vmList = new List<XhsSinglePumpViewModel>(); - foreach (var pump in _hydroInfo.Pumps) - { - if (!pump.RatedN.HasValue) + var workingHelper = GetWorkingHelper(); + if (!workingHelper.Initialized) { - continue; + TipFormHelper.ShowWarn("璇疯绠楀悗閲嶈瘯锛�"); + return; } - 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); - vm.CurveQH = qhPtList; - vm.CurveQE = qePtList; - vm.CurveQP = qpPtList; - - var calcuResultVisualDict = calcuResultHelper.GetVisualDict(); - if (calcuResultVisualDict != null && calcuResultVisualDict.Count > 0) - { - //var calcuResult = allCalcuResultList.Find(x => x.Code == pump.Code) as HydroCalcuLinkResult; - //if (calcuResult != null) - //{ - // if (calcuResult.CalcuFlow.HasValue) - // { - // vm.CalcuQ = Math.Abs(calcuResult.CalcuFlow.Value); - // } - - // var calcuResultStart = allCalcuResultList.Find(x => x.Code == pump.StartCode) as HydroCalcuNodeResult; - // var calcuResultEnd = allCalcuResultList.Find(x => x.Code == pump.EndCode) as HydroCalcuNodeResult; - // if (calcuResultStart != null && calcuResultEnd != null) - // { - // if (calcuResultStart.CalcuHead.HasValue && calcuResultEnd.CalcuHead.HasValue) - // { - // vm.CalcuH = Math.Round(Math.Abs(calcuResultStart.CalcuHead.Value - calcuResultEnd.CalcuHead.Value), 4); - // } - // } - //} - } - + var dlg = new SimulationSingleWorkingPumpAnalyDlg(); + dlg.SetBindingData(workingHelper.HydroInfo, workingHelper.CalcuResult); + dlg.ShowDialog(); } - - var dlg = new PumpParallelAnalyDlg(); - dlg.SetBindingData(vmList); - dlg.ReloadDataEvent += (list) => + else { - list?.ForEach(x => - { - var pump = _hydroInfo.Pumps?.Find(t => t.Code == x.Code); - if (pump != null) - { - pump.LinkStatus = x.RunStatus ? Yw.Hydro.PumpStatus.Open : Yw.Hydro.PumpStatus.Closed; - pump.SpeedRatio = Math.Round(x.CurrentHz / pump.RatedHz, 1); - } - }); - //ShowSelectedProperty(); - return true; - }; - dlg.ShowDialog(); + var dlg = new SimulationMultiWorkingPumpAnalyDlg(); + dlg.SetBindingData(_hydroInfo, allCheckedWorkingList); + dlg.ShowDialog(); + } } //鑳芥晥鍒嗘瀽 - private void barBtnWorkingPower_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + private async void barBtnWorkingPower_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { + var allMonitorList = await GetMonitorList(); var workingCheckedListHelper = GetWorkingCheckedListHelper(); var allCheckedWorkingList = workingCheckedListHelper.GetCheckedWorkingList(); if (allCheckedWorkingList == null || allCheckedWorkingList.Count < 1) @@ -2263,13 +2468,14 @@ return; } var dlg = new SimulationSingleWorkingEnergyDlg(); - dlg.SetBindingData(workingHelper.HydroInfo, workingHelper.CalcuResult); + dlg.SetBindingData(workingHelper.Working, workingHelper.HydroInfo, allMonitorList, workingHelper.CalcuResult); dlg.ShowDialog(); } else { + var dlg = new SimulationMultiWorkingEnergyDlg(); - dlg.SetBindingData(_hydroInfo, allCheckedWorkingList); + dlg.SetBindingData(_hydroInfo, allMonitorList, allCheckedWorkingList); dlg.ShowDialog(); } } @@ -2279,8 +2485,12 @@ { if (_visual == null) { - TipFormHelper.ShowWarn("璇烽�夋嫨鏋勪欢鍚庨噸璇曪紒"); - return; + SelectInputSource(); + if (_visual == null) + { + TipFormHelper.ShowWarn("璇烽�夋嫨鏋勪欢鍚庨噸璇曪紒"); + return; + } } HydroVisualInfo visual = _visual; if (_visual is HydroLinkInfo linkInfo) @@ -2300,12 +2510,20 @@ return; } var dlg = new HydroSingleWorkingLossCurveDlg(); + dlg.HydroClickEvent += (code) => + { + SelectVisual(code, eSimulationVisualSource.None); + }; dlg.SetBindingData(workingHelper.HydroInfo, workingHelper.CalcuResult, visual); dlg.ShowDialog(); } else { var dlg = new HydroMultiWorkingLossCurveDlg(); + dlg.HydroClickEvent += (code) => + { + SelectVisual(code, eSimulationVisualSource.None); + }; dlg.SetBindingData(_hydroInfo, allCheckedWorkingList, visual); dlg.ShowDialog(); } @@ -2341,8 +2559,15 @@ { if (_visual == null) { - TipFormHelper.ShowWarn("璇烽�夋嫨鏋勪欢鍚庨噸璇曪紒"); - return; + if (_visual == null) + { + SelectInputSource(); + if (_visual == null) + { + TipFormHelper.ShowWarn("璇烽�夋嫨鏋勪欢鍚庨噸璇曪紒"); + return; + } + } } HydroVisualInfo visual = _visual; if (_visual is HydroLinkInfo linkInfo) @@ -2378,10 +2603,79 @@ #endregion + #region 鏂规绠$悊 + //鏇存柊鏂规 + private void UpdateScheme() + { + if (_scheme == null) + { + return; + } + if (_hydroInfo == null) + { + return; + } + var dlg = new EditXhsSchemeDlg(); + dlg.SetBindingData(_scheme, _hydroInfo); + dlg.ReloadDataEvent += (rhs) => + { + _scheme = rhs; + this.PageTitle.Caption = $"妯℃嫙鏂规\r\n{_scheme.Name}"; + UpdatePageTitle(this.PageGuid, this.PageTitle); + this.UpdateSchemeEvent?.Invoke(_scheme); + }; + dlg.ShowDialog(); + } + //缂栬緫鏂规 + private void barBtnEditScheme_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + UpdateScheme(); + } + //鍒犻櫎鏂规 + private async void DeleteScheme() + { + var bol = XtraMessageBox.Show("璇烽棶鏄惁鍒犻櫎褰撳墠鏂规锛�", "璇㈤棶", MessageBoxButtons.YesNo) == DialogResult.Yes; + if (!bol) + { + return; + } + if (_scheme == null) + { + return; + } + var relation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance + .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsScheme, _scheme.ID, HStation.Xhs.Purpose.Simulation); + if (relation == null) + { + TipFormHelper.ShowError("姘村姏妯℃嫙鏂规鍒犻櫎澶辫触锛岃閲嶈瘯锛�"); + return; + } + if (!await BLLFactory<Yw.BLL.HydroModelRelation>.Instance.DeleteAllByID(relation.ID)) + { + TipFormHelper.ShowError("姘村姏妯℃嫙鏂规鍒犻櫎澶辫触锛岃閲嶈瘯锛�"); + return; + } + if (!await BLLFactory<HStation.BLL.XhsScheme>.Instance.DeleteByID(_scheme.ID)) + { + TipFormHelper.ShowError("姘村姏妯℃嫙鏂规鍒犻櫎澶辫触锛岃閲嶈瘯锛�"); + return; + } + this.RemoveSchemeEvent?.Invoke(_scheme); + TipFormHelper.ShowSucceed("姘村姏妯℃嫙鏂规鍒犻櫎鎴愬姛锛�"); + ClosePage(this.PageGuid); + } + + //鍒犻櫎鏂规 + private void barBtnDeleteScheme_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + DeleteScheme(); + } + + #endregion } } \ No newline at end of file -- Gitblit v1.9.3