From 828911bb8a1e71a3c6c28f70b5e9d9562451d7f4 Mon Sep 17 00:00:00 2001
From: duheng <2784771470@qq.com>
Date: 星期五, 20 十二月 2024 14:33:12 +0800
Subject: [PATCH] 修改阀门,水池单独匹配界面

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/08-working/XhsProjectSimulationWorkingPage.cs |  548 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 295 insertions(+), 253 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/08-working/XhsProjectSimulationWorkingPage.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/08-working/XhsProjectSimulationWorkingPage.cs
index fededcb..01db1af 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/08-working/XhsProjectSimulationWorkingPage.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/08-working/XhsProjectSimulationWorkingPage.cs
@@ -9,6 +9,7 @@
 using Yw.WinFrmUI.Q3d;
 using Yw.EPAnet;
 using Mapster;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
 namespace HStation.WinFrmUI
 {
     public partial class XhsProjectSimulationWorkingPage : DocumentPage
@@ -18,32 +19,24 @@
             InitializeComponent();
             this.PageTitle.Caption = "姘村姏妯℃嫙宸ュ喌";
             this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden;
+
         }
+
+
+        /// <summary>
+        /// 鏇存柊宸ュ喌浜嬩欢
+        /// </summary>
+        public event Action<HydroWorkingVmo> UpdateWorkingEvent;
+        /// <summary>
+        /// 绉婚櫎宸ュ喌浜嬩欢
+        /// </summary>
+        public event Action<HydroWorkingVmo> RemoveWorkingEvent;
 
         private HStation.Vmo.XhsProjectVmo _project = null;//椤圭洰
         private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;//椤圭洰绔�
         private XhsSchemeVmo _scheme = null;//鏂规
         private Yw.Model.HydroModelInfo _hydroInfo = null;//姘村姏淇℃伅
         private HydroWorkingVmo _working = null;//宸ュ喌
-
-        /// <summary>
-        /// 缁戝畾鏁版嵁
-        /// </summary>
-        public void SetBindingData
-            (
-                XhsProjectVmo project,
-                XhsProjectSiteVmo projectSite,
-                Yw.Model.HydroModelInfo hydroInfo,
-                HydroWorkingVmo working
-            )
-        {
-            _project = project;
-            _projectSite = projectSite;
-            _hydroInfo = hydroInfo.Adapt<Yw.Model.HydroModelInfo>();
-            _working = working;
-            _hydroInfo.UpdateWorkingInfo(_working.WorkingInfo);
-            this.PageTitle.Caption = $"姘村姏妯℃嫙\r\n{_working.Name}";
-        }
 
         /// <summary>
         /// 缁戝畾鏁版嵁
@@ -63,7 +56,14 @@
             _hydroInfo = hydroInfo.Adapt<Yw.Model.HydroModelInfo>();
             _working = working;
             _hydroInfo.UpdateWorkingInfo(_working.WorkingInfo);
-            this.PageTitle.Caption = $"{scheme.Name}\r\n{_working.Name}";
+            if (_scheme == null)
+            {
+                this.PageTitle.Caption = $"姘村姏妯℃嫙\r\n{_working.Name}";
+            }
+            else
+            {
+                this.PageTitle.Caption = $"{scheme.Name}\r\n{_working.Name}";
+            }
         }
 
         /// <summary>
@@ -80,10 +80,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)
             {
@@ -91,7 +91,7 @@
             }
             if (_bimfaceCtrl == null)
             {
-                _bimfaceCtrl = new XhsProjectSimulationBimfaceCtrl();
+                _bimfaceCtrl = new SimulationBimfaceCtrl();
                 _bimfaceCtrl.Dock = DockStyle.Fill;
                 await _bimfaceCtrl.InitialData(_project, _projectSite);
                 _bimfaceCtrl.LoadCompletedEvent += async () =>
@@ -111,7 +111,7 @@
                 {//榧犳爣宸﹂敭鐐瑰嚮浜嬩欢
                     var visualListHelper = GetVisualListHelper();
                     var visual = visualListHelper.GetVisual(code);
-                    SelectVisual(visual, eVisualSource.Bimface);
+                    SelectVisual(visual, eSimulationVisualSource.Bimface);
                 };
             }
             return _bimfaceCtrl;
@@ -148,7 +148,7 @@
                 {
                     var visualListHelper = GetVisualListHelper();
                     var visuals = visualListHelper.GetVisualList(codes);
-                    SelectVisual(visuals?.LastOrDefault(), eVisualSource.Q3d);
+                    SelectVisual(visuals?.LastOrDefault(), eSimulationVisualSource.Q3d);
                 };
             }
             return _q3dCtrl;
@@ -167,10 +167,10 @@
         #region 灞炴�ф帶浠�
 
         //灞炴�ф帶浠�
-        private XhsProjectSimulationPropertyCtrl _propertyCtrl = null;
+        private SimulationPropertyCtrl _propertyCtrl = null;
 
         //鑾峰彇灞炴�ф帶浠�
-        private XhsProjectSimulationPropertyCtrl GetPropertyCtrl()
+        private SimulationPropertyCtrl GetPropertyCtrl()
         {
             if (_hydroInfo == null)
             {
@@ -178,11 +178,12 @@
             }
             if (_propertyCtrl == null)
             {
-                _propertyCtrl = new XhsProjectSimulationPropertyCtrl();
+                _propertyCtrl = new SimulationPropertyCtrl();
                 _propertyCtrl.Dock = DockStyle.Fill;
+                _propertyCtrl.AllowEdit = false;
                 _propertyCtrl.HydroViewEvent += (visual) =>
                 {
-                    SelectVisual(visual, eVisualSource.Property);
+                    SelectVisual(visual, eSimulationVisualSource.Property);
                 };
                 _propertyCtrl.BlinkLinkNodeEvent += async (link, linkNodeCode) =>
                 { //寮鸿皟杩炴帴鑺傜偣
@@ -221,38 +222,6 @@
                     await Task.Delay(5000);
                     await _bimfaceCtrl?.ClearBlinkComponents();
                 };
-                _propertyCtrl.PropertyValueChangedEvent += async (visual) =>
-                {
-                    if (visual == null)
-                    {
-                        return;
-                    }
-                    UpdateVisualListCtrl();
-                    var gradingHelper = await GetGradingHelper();
-                    gradingHelper.Set();
-                };
-                _propertyCtrl.MarkPropertyValueChangedEvent += async (visual) =>
-                {
-                    //鏍囨敞灞炴�у彂鐢熸敼鍙�
-                    //鍒ゆ柇褰撳墠鏄惁鏈夋爣娉ㄥ睍绀猴紝鑻ユ湁鍒欐洿鏂版爣娉紝鏈�濂芥槸鏇存柊鍗曚釜鏍囨敞
-                    var markHelper = await GetMarkHelper();
-                    markHelper.Set(visual);
-                };
-                _propertyCtrl.GradingPropertyValueChangedEvent += async (visual) =>
-                {
-                    //鍒嗙骇灞炴�у彂鐢熸敼鍙�
-                    //鍒ゆ柇褰撳墠鏄惁鏈夊垎绾у睍绀猴紝鑻ユ湁鍒欐洿鏂板垎绾э紝鏈�濂芥槸鏇存柊鍗曚釜鍒嗙骇
-                    var gradingHelper = await GetGradingHelper();
-                    gradingHelper.Set(visual);
-                };
-                _propertyCtrl.FlowEffectPropertyValueChangedEvent += async (visual) =>
-                {
-                    //娴佸悜灞炴�у彂鐢熸敼鍙�
-                    //鍒ゆ柇娴佸悜鏄惁鍔犺浇锛屽鏋滃姞杞藉垯鏇存柊娴佸悜锛屾渶濂芥槸鏇存柊鍗曚釜娴佸悜
-                    var flowEffectHelper = await GetFlowEffectHelper();
-                    flowEffectHelper.Set(visual);
-                };
-
             }
             return _propertyCtrl;
         }
@@ -266,7 +235,7 @@
                 {
                     if (this.controlContainerRight.Controls.Count > 0)
                     {
-                        if (this.controlContainerRight.Controls[0] is XhsProjectSimulationPropertyCtrl)
+                        if (this.controlContainerRight.Controls[0] is SimulationPropertyCtrl)
                         {
                             return true;
                         }
@@ -306,96 +275,79 @@
             _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);
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Bimface:
+                case eSimulationVisualSource.Bimface:
                     {
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Q3d:
+                case eSimulationVisualSource.Q3d:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Property:
+                case eSimulationVisualSource.Property:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                     }
                     break;
-                case eVisualSource.List:
+                case eSimulationVisualSource.List:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Search:
+                case eSimulationVisualSource.Set:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Monitor:
+                case eSimulationVisualSource.Search:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Check:
+                case eSimulationVisualSource.Monitor:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Calcu:
+                case eSimulationVisualSource.Check:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
                     }
                     break;
-                case eVisualSource.Warning:
+                case eSimulationVisualSource.Calcu:
+                    {
+                        _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
+                        SetPropertyCtrl(visual);
+                    }
+                    break;
+                case eSimulationVisualSource.Warning:
                     {
                         _bimfaceCtrl?.ZoomAndSelectComponent(visual?.Code);
                         SetPropertyCtrl(visual);
@@ -403,6 +355,13 @@
                     break;
                 default: break;
             }
+        }
+
+        //閫夋嫨鏋勪欢
+        private void SelectVisual(string code, eSimulationVisualSource source)
+        {
+            var visual = GetVisual(code);
+            SelectVisual(visual, source);
         }
 
         #endregion
@@ -423,6 +382,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
@@ -448,6 +436,23 @@
             return _visualVmListHelper;
         }
 
+        //鑾峰彇鍙瑙嗗浘
+        private HydroVisualViewModel GetVisualViewModel(string code)
+        {
+            if (string.IsNullOrEmpty(code))
+            {
+                return default;
+            }
+            var visualVmListHelper = GetVisualVmListHelper();
+            return visualVmListHelper.GetVisual(code);
+        }
+
+        //鑾峰彇鍙瑙嗗浘
+        private HydroVisualViewModel GetVisualViewModel(Yw.Model.HydroVisualInfo visual)
+        {
+            return GetVisualViewModel(visual?.Code);
+        }
+
         #endregion
 
         #region 鏄庣粏鎺т欢
@@ -464,11 +469,7 @@
                 _visualListCtrl.Dock = DockStyle.Fill;
                 _visualListCtrl.HydroClickInfoEvent += (visual) =>
                 {
-                    SelectVisual(visual, eVisualSource.List);
-                };
-                _visualListCtrl.HydroChangedInfoEvent += (visualList) =>
-                {
-                    SelectVisual(_visual, eVisualSource.List);
+                    SelectVisual(visual, eSimulationVisualSource.List);
                 };
             }
             return _visualListCtrl;
@@ -512,15 +513,7 @@
             var visualVmListHelper = GetVisualVmListHelper();
             var allVisualVmList = visualVmListHelper.GetVisualList();
             visualListCtrl.SetBindingData(allVisualVmList);
-            var calcuResult = GetCalcuResult();
-            if (calcuResult != null && calcuResult.Succeed)
-            {
-                visualListCtrl.SetCalcuView();
-            }
-            else
-            {
-                visualListCtrl.SetNormalView();
-            }
+            visualListCtrl.SetResultView();
         }
 
         //鏇存柊鏋勪欢鏄庣粏鎺т欢
@@ -633,12 +626,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;
@@ -901,6 +894,13 @@
             return _monitorHelper;
         }
 
+        //鑾峰彇鐩戞祴鐐瑰垪琛�
+        private async Task<List<HydroMonitorVmo>> GetMonitorList()
+        {
+            var helper = GetMonitorHelper();
+            return await helper.Get();
+        }
+
         #endregion
 
         #region 鐩戞祴鍊�
@@ -939,7 +939,7 @@
                 {
                     var visualListHelper = GetVisualListHelper();
                     var visual = visualListHelper.GetVisual(code);
-                    SelectVisual(visual, eVisualSource.Monitor);
+                    SelectVisual(visual, eSimulationVisualSource.Monitor);
                 };
             }
             return _monitorValueListCtrl;
@@ -1038,7 +1038,7 @@
                 {
                     var visualListHelper = GetVisualListHelper();
                     var visual = visualListHelper.GetVisual(code);
-                    SelectVisual(visual, eVisualSource.Check);
+                    SelectVisual(visual, eSimulationVisualSource.Check);
                 };
             }
             return _checkCtrl;
@@ -1191,7 +1191,7 @@
                 {
                     var visualListHelper = GetVisualListHelper();
                     var visual = visualListHelper.GetVisual(code);
-                    SelectVisual(visual, eVisualSource.Warning);
+                    SelectVisual(visual, eSimulationVisualSource.Warning);
                 };
             }
             return _calcuWarningCtrl;
@@ -1364,7 +1364,7 @@
 
         #endregion
 
-        #region 骞惰仈璁$畻
+        #region 骞惰仈妯℃嫙
 
         //骞惰仈鍒嗘瀽
         private void ParallelAnalysis()
@@ -1415,26 +1415,26 @@
 
             }
 
-            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();
+            //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();
         }
 
         //骞惰仈鍒嗘瀽
@@ -1529,124 +1529,29 @@
 
         #region 宸ュ喌鍒嗘瀽
 
-        #region 宸ュ喌璇勪及
-
-
-
-        //绮惧害璇勪及
-        private void barBtnWorkingEvaluation_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        //閫夋嫨杩涘彛姘存簮
+        private void SelectInputSource()
         {
-
-        }
-
-        #endregion
-
-        #region 宸ュ喌骞惰仈
-
-        //骞惰仈鍒嗘瀽
-        private void barBtnAnaly_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
-        {
-            if (_hydroInfo == null)
+            var sources = GetSourceList();
+            if (sources != null)
             {
-                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)
+                if (sources.Count == 1)
                 {
-                    continue;
+                    SelectVisual(sources[0], eSimulationVisualSource.None);
                 }
-                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)
+                else
                 {
-                    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 PumpParallelAnalyDlg();
-            dlg.SetBindingData(vmList);
-            dlg.ReloadDataEvent += (list) =>
-            {
-                list?.ForEach(x =>
-                {
-                    var pump = _hydroInfo.Pumps?.Find(t => t.Code == x.Code);
-                    if (pump != null)
+                    var source = sources.FirstOrDefault(x => x.Flags.Contains(HStation.Xhs.Flags.杩涘彛));
+                    if (source != null)
                     {
-                        pump.LinkStatus = x.RunStatus ? Yw.Hydro.PumpStatus.Open : Yw.Hydro.PumpStatus.Closed;
-                        pump.SpeedRatio = Math.Round(x.CurrentHz / pump.RatedHz, 1);
+                        SelectVisual(source, eSimulationVisualSource.None);
                     }
-                });
-                //ShowSelectedProperty();
-                return true;
-            };
-            dlg.ShowDialog();
+                }
+            }
         }
 
-        #endregion
-
-        //鑳芥晥鍒嗘瀽
-        private void barBtnWorkingPower_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
-        {
-            var workingHelper = GetWorkingHelper();
-            var dlg = new SimulationSingleWorkingEnergyDlg();
-            dlg.SetBindingData(workingHelper.HydroInfo, workingHelper.CalcuResult);
-            dlg.ShowDialog();
-        }
-
-        //鎹熷け鏇茬嚎
-        private void barBtnWorkingLossCurve_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        //姘存车鍒嗘瀽
+        private void barBtnPumpAnaly_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
             var workingHelper = GetWorkingHelper();
             if (!workingHelper.Initialized)
@@ -1654,19 +1559,72 @@
                 TipFormHelper.ShowError("宸ュ喌璁$畻澶辫触锛�");
                 return;
             }
-            if (_visual == null)
+            var dlg = new SimulationSingleWorkingPumpAnalyDlg();
+            dlg.SetBindingData(workingHelper.HydroInfo, workingHelper.CalcuResult);
+            dlg.ShowDialog();
+        }
+
+        //绮惧害璇勪及
+        private async void barBtnWorkingEvaluation_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            var workingHelper = GetWorkingHelper();
+            if (!workingHelper.Initialized)
             {
-                TipFormHelper.ShowWarn("璇烽�夋嫨鏋勪欢锛�");
+                TipFormHelper.ShowWarn("宸ュ喌璁$畻澶辫触锛�");
                 return;
             }
-            HydroVisualInfo visual = _visual;
-            if (_visual is HydroLinkInfo linkInfo)
+            var allMonitorList = await GetMonitorList();
+            var dlg = new HydroSingleWorkingEvaluationDlg();
+            dlg.SetBindingData(workingHelper.HydroInfo, allMonitorList, workingHelper.Working, workingHelper.CalcuResult);
+            dlg.ShowDialog();
+        }
+
+        //鑳芥晥鍒嗘瀽
+        private async void barBtnWorkingPower_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            var workingHelper = GetWorkingHelper();
+            if (!workingHelper.Initialized)
             {
-                var visualListHelper = GetVisualListHelper();
-                visual = visualListHelper.GetVisual(linkInfo.StartCode);
+                TipFormHelper.ShowWarn("宸ュ喌璁$畻澶辫触锛�");
+                return;
+            }
+            var allMonitorList = await GetMonitorList();
+            var dlg = new SimulationSingleWorkingEnergyDlg();
+            dlg.SetBindingData(workingHelper.Working, workingHelper.HydroInfo, allMonitorList, workingHelper.CalcuResult);
+            dlg.ShowDialog();
+        }
+
+        //鎹熷け鏇茬嚎
+        private void barBtnWorkingLossCurve_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            if (_visual == null)
+            {
+                SelectInputSource();
+                if (_visual == null)
+                {
+                    TipFormHelper.ShowWarn("璇烽�夋嫨鏋勪欢鍚庨噸璇曪紒");
+                    return;
+                }
+            }
+
+            var workingHelper = GetWorkingHelper();
+            if (!workingHelper.Initialized)
+            {
+                TipFormHelper.ShowError("宸ュ喌璁$畻澶辫触锛�");
+                return;
+            }
+
+            HydroVisualInfo visual = _visual;
+            if (_visual is HydroLinkInfo link)
+            {
+                visual = GetVisual(link.StartCode);
             }
 
             var dlg = new HydroSingleWorkingLossCurveDlg();
+            dlg.HydroClickEvent += (code) =>
+            {
+                SelectVisual(code, eSimulationVisualSource.None);
+            };
             dlg.SetBindingData(workingHelper.HydroInfo, workingHelper.CalcuResult, visual);
             dlg.ShowDialog();
         }
@@ -1686,16 +1644,100 @@
         }
 
         //缁煎悎鍒嗘瀽
-        private void barBtnWorkingAnaly_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        private async void barBtnWorkingAnaly_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            XtraMessageBox.Show("姝e湪寮�鍙戜腑锛屾暚璇锋湡寰咃紒");
+            var workingHelper = GetWorkingHelper();
+            if (!workingHelper.Initialized)
+            {
+                TipFormHelper.ShowError("宸ュ喌璁$畻澶辫触锛�");
+                return;
+            }
+            if (_visual == null)
+            {
+                if (_visual == null)
+                {
+                    SelectInputSource();
+                    if (_visual == null)
+                    {
+                        TipFormHelper.ShowWarn("璇烽�夋嫨鏋勪欢鍚庨噸璇曪紒");
+                        return;
+                    }
+                }
+            }
+
+            HydroVisualInfo visual = _visual;
+            if (_visual is HydroLinkInfo linkInfo)
+            {
+                var visualListHelper = GetVisualListHelper();
+                visual = visualListHelper.GetVisual(linkInfo.StartCode);
+            }
+
+            var allMonitorList = await GetMonitorList();
+
+            var dlg = new SimulationSingleWorkingAnalyDlg();
+            dlg.SetBindingData(workingHelper.HydroInfo, allMonitorList, workingHelper.Working, workingHelper.CalcuResult, visual);
+            dlg.ShowDialog();
         }
 
         #endregion
 
+        #region 鏇存柊宸ュ喌
 
+        //缂栬緫
+        private void barBtnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            if (_working == null)
+            {
+                return;
+            }
+            var dlg = new EditHydroWorkingDlg();
+            dlg.SetBindingData(_working);
+            dlg.ReloadDataEvent += (rhs) =>
+            {
+                _working = rhs;
+                this.PageTitle.Caption = $"姘村姏妯℃嫙\r\n{_working.Name}";
+                UpdatePageTitle(this.PageGuid, this.PageTitle);
+                this.UpdateWorkingEvent?.Invoke(_working);
+            };
+            dlg.ShowDialog();
+        }
 
+        #endregion
 
+        #region 鍒犻櫎宸ュ喌
+
+        //鍒犻櫎
+        private async void barBtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            if (_hydroInfo == null)
+            {
+                return;
+            }
+            if (_working == null)
+            {
+                return;
+            }
+            var bol = XtraMessageBox.Show("璇烽棶鏄惁鍒犻櫎褰撳墠宸ュ喌锛�", "璇㈤棶", MessageBoxButtons.YesNo) == DialogResult.Yes;
+            if (!bol)
+            {
+                return;
+            }
+            bol = await BLLFactory<Yw.BLL.HydroWorking>.Instance.DeleteByID(_working.ID);
+            if (!bol)
+            {
+                TipFormHelper.ShowError("鍒犻櫎澶辫触锛�");
+                return;
+            }
+            this.RemoveWorkingEvent?.Invoke(_working);
+            TipFormHelper.ShowSucceed("鍒犻櫎鎴愬姛锛�");
+            ClosePage(this.PageGuid);
+        }
+
+        #endregion
 
 
     }

--
Gitblit v1.9.3