From a7c780692ab2d8072ad4cae0fecbf851c27231d9 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期五, 20 十二月 2024 11:57:29 +0800 Subject: [PATCH] 曲线匹配修改 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/05-function/SimulationFunctionCtrl.cs | 297 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 251 insertions(+), 46 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/05-function/SimulationFunctionCtrl.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/05-function/SimulationFunctionCtrl.cs index 58dba41..9fc8e31 100644 --- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/05-function/SimulationFunctionCtrl.cs +++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/05-function/SimulationFunctionCtrl.cs @@ -1,5 +1,6 @@ 锘縰sing DevExpress.Utils.Extensions; using DevExpress.Utils.Svg; +using DevExpress.XtraCharts; using Yw.DAL.Basic; using Yw.Vmo; @@ -30,6 +31,10 @@ /// </summary> public event Action<XhsProjectVmo, XhsProjectSiteVmo, XhsSchemeVmo, HydroWorkingVmo, bool> ProjectSiteWorkingCheckedEvent; /// <summary> + /// 椤圭洰绔欏伐鍐靛鍔犱簨浠� + /// </summary> + public event Action<XhsProjectVmo, XhsProjectSiteVmo, XhsSchemeVmo, HydroWorkingVmo> ProjectSiteWorkingAppendEvent; + /// <summary> /// 椤圭洰绔欏伐鍐垫洿鏂颁簨浠� /// </summary> public event Action<XhsProjectVmo, XhsProjectSiteVmo, XhsSchemeVmo, HydroWorkingVmo> ProjectSiteWorkingUpdateEvent; @@ -41,6 +46,18 @@ /// 鍒涘缓椤圭洰绔欐柟妗堜簨浠� /// </summary> public event Action<XhsProjectVmo, XhsProjectSiteVmo, Yw.Model.HydroModelInfo, SvgImage> CreateProjectSiteSchemeEvent; + /// <summary> + /// 椤圭洰绔欐柟妗堝鍔犱簨浠� + /// </summary> + public event Action<XhsProjectVmo, XhsProjectSiteVmo, XhsSchemeVmo> ProjectSiteSchemeAppendEvent; + /// <summary> + /// 椤圭洰绔欐柟妗堟洿鏂颁簨浠� + /// </summary> + public event Action<XhsProjectVmo, XhsProjectSiteVmo, XhsSchemeVmo> ProjectSiteSchemeUpdateEvent; + /// <summary> + /// 椤圭洰绔欐柟妗堢Щ闄や簨浠� + /// </summary> + public event Action<XhsProjectVmo, XhsProjectSiteVmo, XhsSchemeVmo> ProjectSiteSchemeRemoveEvent; private XhsProjectVmo _project = null;//椤圭洰 private XhsProjectSiteVmo _projectSite = null;//椤圭洰绔� @@ -87,7 +104,75 @@ }); } }); + await ShowInfo(); overlay.Close(); + } + + //椤圭洰绔欐鍐� + private async void elementProjectSiteInfo_Click(object sender, EventArgs e) + { + await ShowInfo(); + } + + //椤圭洰绔欐按鍔涙ā鎷� + private async void elementProjectSiteSimulation_Click(object sender, EventArgs e) + { + if (_project == null) + { + return; + } + if (_projectSite == null) + { + return; + } + var hydroInfo = await GetHydroInfo(null, true); + if (hydroInfo == null) + { + return; + } + this.ShowProjectSiteSimulationEvent?.Invoke(_project, _projectSite, null, hydroInfo, _allWorkingCheckedListDict, this.svgImg32[1]); + } + + //鍒涘缓椤圭洰绔欐柟妗� + private async void accordionControl1_ContextButtonClick(object sender, DevExpress.Utils.ContextItemClickEventArgs e) + { + if (_project == null) + { + return; + } + if (_projectSite == null) + { + return; + } + var element = e.DataItem as DevExpress.XtraBars.Navigation.AccordionControlElement; + if (element != this.elementProjectSiteSchemeList) + { + return; + } + var hydroInfo = await GetHydroInfo(null, true); + if (hydroInfo == null) + { + return; + } + this.CreateProjectSiteSchemeEvent?.Invoke(_project, _projectSite, hydroInfo, this.svgImg32[3]); + } + + private void accordionControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + this.popupMenu1.ShowPopup(MousePosition); + } + } + + private void barBtnCollpseAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + this.accordionControl1.CollapseAll(); + } + + private void barBtnExpandAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + this.accordionControl1.ExpandAll(); } #region 閫氱敤鏂规硶 @@ -114,7 +199,11 @@ { if (_hydroInfo == null) { - _hydroInfo = await GetHydroInfo(null); + hydroInfo = await GetHydroInfo(null); + if (_hydroInfo == null) + { + _hydroInfo = hydroInfo; + } } return _hydroInfo; } @@ -132,9 +221,12 @@ if (!_allSchemeHydroInfoDict.ContainsKey(scheme)) { hydroInfo = await GetHydroInfo(scheme); - _allSchemeHydroInfoDict.Add(scheme, hydroInfo); - return hydroInfo; + if (!_allSchemeHydroInfoDict.ContainsKey(scheme)) + { + _allSchemeHydroInfoDict.Add(scheme, hydroInfo); + } } + return _allSchemeHydroInfoDict[scheme]; } if (_allSchemeHydroInfoDict.ContainsKey(scheme)) @@ -146,7 +238,7 @@ _allSchemeHydroInfoDict.Add(scheme, hydroInfo); } - return hydroInfo; + return _allSchemeHydroInfoDict[scheme]; } //鑾峰彇姘村姏淇℃伅 @@ -182,6 +274,7 @@ /// <summary> /// 娣诲姞鏂规 + /// 瑙﹀彂椤圭洰绔欐柟妗堝鍔犱簨浠� /// </summary> public void AppendScheme(XhsSchemeVmo scheme) { @@ -235,11 +328,127 @@ { _allSchemeWorkingCheckedListDict.Add(scheme, new Dictionary<HydroWorkingVmo, bool>()); } + this.ProjectSiteSchemeAppendEvent?.Invoke(_project, _projectSite, scheme); + } + + /// <summary> + /// 鏇存柊鏂规 + /// 瑙﹀彂椤圭洰绔欐柟妗堟洿鏂颁簨浠� + /// </summary> + public void UpdateScheme(XhsSchemeVmo scheme) + { + if (_project == null) + { + return; + } + if (_projectSite == null) + { + return; + } + if (scheme == null) + { + return; + } + + var elementScheme = this.elementProjectSiteSchemeList.Elements + .FirstOrDefault(x => (x.Tag is XhsSchemeVmo) && (x.Tag as XhsSchemeVmo).ID == scheme.ID); + if (elementScheme == null) + { + return; + } + elementScheme.Text = scheme.Name; + elementScheme.Hint = scheme.Description; + elementScheme.Tag = scheme; + if (_allSchemeHydroInfoDict != null && _allSchemeHydroInfoDict.Count > 0) + { + var schemeKey = _allSchemeHydroInfoDict.Keys.FirstOrDefault(x => x.ID == scheme.ID); + if (schemeKey != null) + { + var hydroInfoValue = _allSchemeHydroInfoDict[schemeKey]; + _allSchemeHydroInfoDict.Remove(schemeKey); + _allSchemeHydroInfoDict.Add(scheme, hydroInfoValue); + } + } + if (_allSchemeWorkingCheckedListDict != null && _allSchemeWorkingCheckedListDict.Count > 0) + { + var schemeKey = _allSchemeWorkingCheckedListDict.Keys.FirstOrDefault(x => x.ID == scheme.ID); + if (schemeKey != null) + { + var workingCheckedValue = _allSchemeWorkingCheckedListDict[schemeKey]; + _allSchemeWorkingCheckedListDict.Remove(schemeKey); + _allSchemeWorkingCheckedListDict.Add(scheme, workingCheckedValue); + } + } + + this.ProjectSiteSchemeUpdateEvent?.Invoke(_project, _projectSite, scheme); + } + + /// <summary> + /// 绉婚櫎鏂规 + /// </summary> + public void RemoveScheme(XhsSchemeVmo scheme) + { + if (_project == null) + { + return; + } + if (_projectSite == null) + { + return; + } + if (scheme == null) + { + return; + } + + var elementScheme = this.elementProjectSiteSchemeList.Elements + .FirstOrDefault(x => (x.Tag is XhsSchemeVmo) && (x.Tag as XhsSchemeVmo).ID == scheme.ID); + if (elementScheme == null) + { + return; + } + if (elementScheme.Elements != null && elementScheme.Elements.Count > 0) + { + var workingElementList = elementScheme.Elements.ToList(); + foreach (var workingElement in workingElementList) + { + if (workingElement.HeaderControl != null) + { + this.accordionControl1.Controls.Remove(workingElement.HeaderControl); + } + elementScheme.Elements.Remove(workingElement); + } + } + this.elementProjectSiteSchemeList.Elements.Remove(elementScheme); + + if (this.elementProjectSiteSchemeList.Elements.Count < 1) + { + this.elementProjectSiteSchemeList.Style = DevExpress.XtraBars.Navigation.ElementStyle.Item; + } + + if (_allSchemeHydroInfoDict != null && _allSchemeHydroInfoDict.Count > 0) + { + var schemeKey = _allSchemeHydroInfoDict.Keys.FirstOrDefault(x => x.ID == scheme.ID); + if (schemeKey != null) + { + _allSchemeHydroInfoDict.Remove(schemeKey); + } + } + if (_allSchemeWorkingCheckedListDict != null && _allSchemeWorkingCheckedListDict.Count > 0) + { + var schemeKey = _allSchemeWorkingCheckedListDict.Keys.FirstOrDefault(x => x.ID == scheme.ID); + if (schemeKey != null) + { + _allSchemeWorkingCheckedListDict.Remove(schemeKey); + } + } + + this.ProjectSiteSchemeRemoveEvent?.Invoke(_project, _projectSite, scheme); } /// <summary> /// 娣诲姞宸ュ喌 - /// 绾坊鍔狅紝涓嶄細瑙﹀彂浜嬩欢 + /// 瑙﹀彂椤圭洰绔欏伐鍐靛鍔犱簨浠� /// </summary> public void AppendWorking(XhsSchemeVmo scheme, Yw.Vmo.HydroWorkingVmo working) { @@ -352,6 +561,8 @@ } } } + + this.ProjectSiteWorkingAppendEvent?.Invoke(_project, _projectSite, scheme, working); } /// <summary> @@ -523,10 +734,8 @@ this.ProjectSiteWorkingRemoveEvent?.Invoke(_project, _projectSite, scheme, working); } - #endregion - - //椤圭洰绔欐鍐� - private async void elementProjectSiteInfo_Click(object sender, EventArgs e) + //鏄剧ず淇℃伅 + private async Task ShowInfo() { if (_project == null) { @@ -544,51 +753,47 @@ this.ShowProjectSiteInfoEvent?.Invoke(_project, _projectSite, hydroInfo, this.svgImg32[0]); } - //椤圭洰绔欐按鍔涙ā鎷� - private async void elementProjectSiteSimulation_Click(object sender, EventArgs e) + /// <summary> + /// 淇濆瓨 + /// </summary> + public async Task<Yw.Model.HydroModelInfo> SaveModel(XhsSchemeVmo scheme, Yw.Model.HydroModelInfo hydroInfo) { - if (_project == null) - { - return; - } - if (_projectSite == null) - { - return; - } - var hydroInfo = await GetHydroInfo(null, true); if (hydroInfo == null) { - return; + return default; } - this.ShowProjectSiteSimulationEvent?.Invoke(_project, _projectSite, null, hydroInfo, _allWorkingCheckedListDict, this.svgImg32[1]); + var id = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(hydroInfo); + if (id < 1) + { + return default; + } + var db = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(id); + if (scheme == null) + { + _hydroInfo = db; + return _hydroInfo; + } + if (_allSchemeHydroInfoDict == null || _allSchemeHydroInfoDict.Count < 1) + { + return default; + } + var schemeKey = _allSchemeHydroInfoDict.Keys.FirstOrDefault(x => x.ID == scheme.ID); + if (schemeKey == null) + { + return default; + } + _allSchemeHydroInfoDict[schemeKey] = db; + return db; } - //鍒涘缓椤圭洰绔欐柟妗� - private async void accordionControl1_ContextButtonClick(object sender, DevExpress.Utils.ContextItemClickEventArgs e) + /// <summary> + /// 鍒锋柊 + /// </summary> + public async Task<Yw.Model.HydroModelInfo> RefreshModel(XhsSchemeVmo scheme) { - if (_project == null) - { - return; - } - if (_projectSite == null) - { - return; - } - var element = e.DataItem as DevExpress.XtraBars.Navigation.AccordionControlElement; - if (element != this.elementProjectSiteSchemeList) - { - return; - } - var hydroInfo = await GetHydroInfo(null, true); - if (hydroInfo == null) - { - return; - } - this.CreateProjectSiteSchemeEvent?.Invoke(_project, _projectSite, hydroInfo, this.svgImg32[3]); + return await GetHydroInfo(scheme, false); } - - - + #endregion } } -- Gitblit v1.9.3