duheng
2024-12-07 1e387f457092df846ec04e2c6792b83244aae04e
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,7 +19,18 @@
            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;//项目站
@@ -80,10 +92,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 +103,7 @@
            }
            if (_bimfaceCtrl == null)
            {
                _bimfaceCtrl = new XhsProjectSimulationBimfaceCtrl();
                _bimfaceCtrl = new SimulationBimfaceCtrl();
                _bimfaceCtrl.Dock = DockStyle.Fill;
                await _bimfaceCtrl.InitialData(_project, _projectSite);
                _bimfaceCtrl.LoadCompletedEvent += async () =>
@@ -234,7 +246,7 @@
                {
                    if (this.controlContainerRight.Controls.Count > 0)
                    {
                        if (this.controlContainerRight.Controls[0] is XhsProjectSimulationPropertyCtrl)
                        if (this.controlContainerRight.Controls[0] is SimulationPropertyCtrl)
                        {
                            return true;
                        }
@@ -1405,26 +1417,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();
        }
        //并联分析
@@ -1608,23 +1620,23 @@
            }
            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)
                    {
                        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 PumpParallelAnalyDlg();
            //dlg.SetBindingData(vmList);
            //dlg.ReloadDataEvent += (list) =>
            //{
            //    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();
        }
        //能效分析
@@ -1712,9 +1724,63 @@
        #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
    }