ningshuxia
2025-03-24 7b8ae93d47186c442ff890a1a83d108f115924c7
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/XhsProjectSimulationMgrPage.cs
@@ -1,4 +1,5 @@
using DevExpress.XtraBars.Docking;
using DevExpress.Utils.Svg;
using DevExpress.XtraBars.Docking;
using DevExpress.XtraBars.Docking2010.Views;
using Yw.Vmo;
using Yw.WinFrmUI.Page;
@@ -13,15 +14,21 @@
            this.PageTitle.Caption = "水力模拟";
            this.PageTitle.HeaderSvgImage = this.svgImg32[0];
            this.PageTitle.SvgImageSize = new Size(24, 24);
            this.xhsProjectSimulationFunctionMgrCtrl1.ShowProjectSiteInfoEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteInfoEvent;
            this.xhsProjectSimulationFunctionMgrCtrl1.ShowProjectSiteSimulationEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteSimulationEvent;
            this.xhsProjectSimulationFunctionMgrCtrl1.ShowProjectSiteWorkingEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteWorkingEvent;
            this.xhsProjectSimulationFunctionMgrCtrl1.ProjectSiteWorkingCheckedEvent += XhsProjectSimulationFunctionMgrCtrl1_ProjectSiteWorkingCheckedEvent;
            this.simulationFunctionMgrCtrl1.ShowProjectSiteInfoEvent += SimulationFunctionMgrCtrl1_ShowProjectSiteInfoEvent;
            this.simulationFunctionMgrCtrl1.ShowProjectSiteSimulationEvent += SimulationFunctionMgrCtrl1_ShowProjectSiteSimulationEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingAppendEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingAppendEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingUpdateEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingUpdateEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingRemoveEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingRemoveEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingCheckedEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingCheckedEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingReloadEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingReloadEvent;
            this.simulationFunctionMgrCtrl1.CreateProjectSiteSchemeEvent += SimulationFunctionMgrCtrl1_CreateProjectSiteSchemeEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteSchemeAppendEvent += SimulationFunctionMgrCtrl1_ProjectSiteSchemeAppendEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteSchemeUpdateEvent += SimulationFunctionMgrCtrl1_ProjectSiteSchemeUpdateEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteSchemeRemoveEvent += SimulationFunctionMgrCtrl1_ProjectSiteSchemeRemoveEvent;
        }
        private XhsProjectVmo _project = null;//项目
        private object _locker = new object();//锁定对象
        private object _locker = new();//锁定对象
        /// <summary>
        /// 初始化数据源
@@ -33,7 +40,7 @@
            {
                return;
            }
            await this.xhsProjectSimulationFunctionMgrCtrl1.SetBindingData(_project);
            await this.simulationFunctionMgrCtrl1.SetBindingData(_project);
        }
        /// <summary>
@@ -61,8 +68,13 @@
        #region 功能面板
        //显示项目站概况事件
        private void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteInfoEvent
            (XhsProjectVmo project, XhsProjectSiteVmo projectSite, Yw.Model.HydroModelInfo hydroInfo, DevExpress.Utils.Svg.SvgImage svgImage)
        private void SimulationFunctionMgrCtrl1_ShowProjectSiteInfoEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                Yw.Model.HydroModelInfo hydroInfo,
                SvgImage svgImage
            )
        {
            lock (_locker)
            {
@@ -71,6 +83,7 @@
                    Modular = this.PageGuid.Modular,
                    MoudingType = eMoudingType.Tab,
                    Function = SimulationFunctionHelper.Info,
                    TagName = $"{project.ID}-{projectSite.ID}"
                };
                if (!IsExistPage(guid, true))
                {
@@ -83,8 +96,15 @@
        }
        //显示项目站水力模拟事件
        private void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteSimulationEvent
            (XhsProjectVmo project, XhsProjectSiteVmo projectSite, Yw.Model.HydroModelInfo hydroInfo, Dictionary<HydroWorkingVmo, bool> allWorkingCheckedListDict, DevExpress.Utils.Svg.SvgImage svgImage)
        private void SimulationFunctionMgrCtrl1_ShowProjectSiteSimulationEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme,
                Yw.Model.HydroModelInfo hydroInfo,
                Dictionary<HydroWorkingVmo, bool> allWorkingCheckedListDict,
                SvgImage svgImage
            )
        {
            lock (_locker)
            {
@@ -93,55 +113,147 @@
                    Modular = this.PageGuid.Modular,
                    MoudingType = eMoudingType.Tab,
                    Function = SimulationFunctionHelper.Simulation,
                    TagName = projectSite.ID.ToString()
                    TagName = $"{project.ID}-{projectSite.ID}-{scheme?.ID}"
                };
                if (!IsExistPage(guid, true))
                {
                    var page = new XhsProjectSimulationCorePage();
                    page.PageTitle.HeaderSvgImage = svgImage;
                    page.GetModelEvent += (s) =>
                    {
                        //获取模型事件
                        return this.simulationFunctionMgrCtrl1.GetModel(scheme);
                    };
                    page.RefreshModelEvent += () =>
                    {
                        //刷新模型事件
                        return this.simulationFunctionMgrCtrl1.RefreshModel(scheme);
                    };
                    page.AppendWorkingEvent += (working) =>
                    {
                        this.xhsProjectSimulationFunctionMgrCtrl1.AppendWorking(working);
                        //增加工况事件
                        this.simulationFunctionMgrCtrl1.AppendWorking(scheme, working);
                    };
                    page.SetBindingData(project, projectSite, hydroInfo, allWorkingCheckedListDict);
                    page.UpdateWorkingEvent += (working) =>
                    {
                        //更新工况事件
                        this.simulationFunctionMgrCtrl1.UpdateWorking(scheme, working);
                    };
                    page.RemoveWorkingEvent += (working) =>
                    {
                        //移除工况事件
                        this.simulationFunctionMgrCtrl1.RemoveWorking(scheme, working);
                    };
                    page.ReloadWorkingEvent += (dict) =>
                    {
                        //重载工况事件
                        this.simulationFunctionMgrCtrl1.ReloadWorking(scheme, dict);
                    };
                    page.UpdateSchemeEvent += (rhs) =>
                    {
                        //更新方案事件
                        this.simulationFunctionMgrCtrl1.UpdateScheme(rhs);
                    };
                    page.RemoveSchemeEvent += (rhs) =>
                    {
                        //移除方案事件
                        this.simulationFunctionMgrCtrl1.RemoveScheme(rhs);
                    };
                    page.SetBindingData(project, projectSite, scheme, hydroInfo, allWorkingCheckedListDict);
                    CreatePage(page, guid);
                }
            }
        }
        //显示项目站工况事件
        private void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteWorkingEvent
            (XhsProjectVmo project, XhsProjectSiteVmo projectSite, Yw.Model.HydroModelInfo hydroInfo, HydroWorkingVmo working, DevExpress.Utils.Svg.SvgImage svgImage)
        /// <summary>
        /// 项目站工况增加事件
        /// </summary>
        private void SimulationFunctionMgrCtrl1_ProjectSiteWorkingAppendEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme,
                HydroWorkingVmo working
            )
        {
            lock (_locker)
            {
                var guid = new PageGuid()
                {
                    Modular = this.PageGuid.Modular,
                    MoudingType = eMoudingType.Tab,
                    Function = SimulationFunctionHelper.Working,
                    TagName = working.ID.ToString()
                };
                if (!IsExistPage(guid, true))
                {
                    var page = new XhsProjectSimulationWorkingPage();
                    page.PageTitle.HeaderSvgImage = svgImage;
                    page.SetBindingData(project, projectSite, hydroInfo, working);
                    CreatePage(page, guid);
                }
            }
            //目前增加工况都是通过模拟界面增加的,功能管理控件属于被通知的,其他地方暂时不关心工况增加
        }
        //项目站工况选择改变事件
        private void XhsProjectSimulationFunctionMgrCtrl1_ProjectSiteWorkingCheckedEvent
            (XhsProjectVmo project, XhsProjectSiteVmo projectSite, Yw.Model.HydroModelInfo hydroInfo, HydroWorkingVmo working, bool hasChecked)
        //项目站工况更新事件
        private void SimulationFunctionMgrCtrl1_ProjectSiteWorkingUpdateEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme,
                HydroWorkingVmo working
            )
        {
            var guid = new PageGuid()
            {
                Modular = this.PageGuid.Modular,
                MoudingType = eMoudingType.Tab,
                Function = SimulationFunctionHelper.Simulation,
                TagName = projectSite.ID.ToString()
                TagName = $"{project.ID}-{projectSite.ID}-{scheme?.ID}"
            };
            var page = FindPage(guid);
            if (page == null)
            {
                return;
            }
            var ctrl = page as XhsProjectSimulationCorePage;
            if (ctrl == null)
            {
                return;
            }
            ctrl.UpdateWorkingCheckedList(working);
        }
        //项目站工况移除事件
        private void SimulationFunctionMgrCtrl1_ProjectSiteWorkingRemoveEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme,
                HydroWorkingVmo working
            )
        {
            var guid = new PageGuid()
            {
                Modular = this.PageGuid.Modular,
                MoudingType = eMoudingType.Tab,
                Function = SimulationFunctionHelper.Simulation,
                TagName = $"{project.ID}-{projectSite.ID}-{scheme?.ID}"
            };
            var page = FindPage(guid);
            if (page == null)
            {
                return;
            }
            var ctrl = page as XhsProjectSimulationCorePage;
            if (ctrl == null)
            {
                return;
            }
            ctrl.RemoveWorkingCheckedList(working);
        }
        //项目站工况选择改变事件
        private void SimulationFunctionMgrCtrl1_ProjectSiteWorkingCheckedEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme,
                HydroWorkingVmo working,
                bool hasChecked
            )
        {
            var guid = new PageGuid()
            {
                Modular = this.PageGuid.Modular,
                MoudingType = eMoudingType.Tab,
                Function = SimulationFunctionHelper.Simulation,
                TagName = $"{project.ID}-{projectSite.ID}-{scheme?.ID}"
            };
            var page = FindPage(guid);
            if (page == null)
@@ -156,44 +268,87 @@
            ctrl.UpdateWorkingCheckedList(working, hasChecked);
        }
        //创建项目方案事件
        private void XhsProjectSimulationFunctionMgrCtrl1_CreateProjectSchemeEvent(DevExpress.Utils.Svg.SvgImage svgImage)
        //项目站工况选择重载事件
        private void SimulationFunctionMgrCtrl1_ProjectSiteWorkingReloadEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme,
                Dictionary<HydroWorkingVmo, bool> dict
            )
        {
            //if (_projectSite == null)
            //{
            //    return;
            //}
            //var dlg = new AddXhsProjectSimulationSchemeDlg();
            //await dlg.SetBindingData(_projectSite.ID);
            //dlg.ReloadDataEvent += (scheme) =>
            //{
            //    this.xhsProjectSimulationFunctionMgrCtrl1.AppendScheme(scheme);
            //};
            //dlg.ShowDialog();
            var guid = new PageGuid()
            {
                Modular = this.PageGuid.Modular,
                MoudingType = eMoudingType.Tab,
                Function = SimulationFunctionHelper.Simulation,
                TagName = $"{project.ID}-{projectSite.ID}-{scheme?.ID}"
            };
            var page = FindPage(guid);
            if (page == null)
            {
                return;
            }
            var ctrl = page as XhsProjectSimulationCorePage;
            if (ctrl == null)
            {
                return;
            }
            ctrl.ReloadWorkingCheckedList(dict);
        }
            var dlg = new AddXhsSchemeDlg();
            // await dlg.SetBindingData(_project, _projectSite, _hydroInfo);
        //项目站方案创建事件
        private void SimulationFunctionMgrCtrl1_CreateProjectSiteSchemeEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                Yw.Model.HydroModelInfo hydroInfo,
                List<XhsSchemeVmo> allSchemeList,
                SvgImage svgImage
            )
        {
            WaitFormHelper.ShowWaitForm(this.FindForm(), "正在加载,请稍侯...");
            var dlg = new CreateXhsSchemeDlg();
            dlg.Shown += delegate { WaitFormHelper.HideWaitForm(this.FindForm()); };
            dlg.SetBindingData(project, projectSite, hydroInfo, allSchemeList);
            dlg.ReloadDataEvent += (rhs) =>
            {
                this.simulationFunctionMgrCtrl1.AppendScheme(rhs);
            };
            dlg.ShowDialog();
        }
        //显示项目方案事件
        private void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSchemeEvent(XhsSchemeVmo arg1, DevExpress.Utils.Svg.SvgImage arg2)
        //项目站方案增加事件
        private void SimulationFunctionMgrCtrl1_ProjectSiteSchemeAppendEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme
            )
        {
            //被动
        }
        //比较项目工况事件
        private void XhsProjectSimulationFunctionMgrCtrl1_CompareProjectWorkingEvent(DevExpress.Utils.Svg.SvgImage obj)
        //项目站方案更新事件
        private void SimulationFunctionMgrCtrl1_ProjectSiteSchemeUpdateEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme
            )
        {
            //被动
        }
        //显示项目工况事件
        private void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectWorkingEvent(HydroWorkingVmo arg1, DevExpress.Utils.Svg.SvgImage arg2)
        //项目站方案移除事件
        private void SimulationFunctionMgrCtrl1_ProjectSiteSchemeRemoveEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme
            )
        {
            //被动
        }
        #endregion
@@ -430,7 +585,6 @@
                        docPnl.Show();
                    }
                    break;
                case eMoudingType.Tab:
                    {
                        this.tabbedView1.BeginUpdate();
@@ -449,7 +603,6 @@
                        this.tabbedView1.Controller.Activate(doc);
                    }
                    break;
                default: break;
            }
            page.InitialDataSource();