lixiaojun
2024-12-10 eb3ec7dfafe071de899112c918851db18bde6109
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/XhsProjectSimulationMgrPage.cs
@@ -15,20 +15,17 @@
            this.PageTitle.Caption = "水力模拟";
            this.PageTitle.HeaderSvgImage = this.svgImg32[0];
            this.PageTitle.SvgImageSize = new Size(24, 24);
            this.simulationFunctionMgrCtrl1.ShowProjectSiteInfoEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteInfoEvent;
            this.simulationFunctionMgrCtrl1.ShowProjectSiteSimulationEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteSimulationEvent;
            this.simulationFunctionMgrCtrl1.ShowProjectSiteWorkingEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteWorkingEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingUpdateEvent += XhsProjectSimulationFunctionMgrCtrl1_ProjectSiteWorkingUpdateEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingRemoveEvent += XhsProjectSimulationFunctionMgrCtrl1_ProjectSiteWorkingRemoveEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingCheckedEvent += XhsProjectSimulationFunctionMgrCtrl1_ProjectSiteWorkingCheckedEvent;
            this.simulationFunctionMgrCtrl1.CreateProjectSiteSchemeEvent += XhsProjectSimulationFunctionMgrCtrl1_CreateProjectSiteSchemeEvent;
            this.simulationFunctionMgrCtrl1.ShowProjectSiteSchemeEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteSchemeEvent;
            this.simulationFunctionMgrCtrl1.ShowProjectSiteSchemeWorkingEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteSchemeWorkingEvent;
            this.simulationFunctionMgrCtrl1.ShowProjectSiteInfoEvent += SimulationFunctionMgrCtrl1_ShowProjectSiteInfoEvent;
            this.simulationFunctionMgrCtrl1.ShowProjectSiteSimulationEvent += SimulationFunctionMgrCtrl1_ShowProjectSiteSimulationEvent;
            this.simulationFunctionMgrCtrl1.ShowProjectSiteWorkingEvent += SimulationFunctionMgrCtrl1_ShowProjectSiteWorkingEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingUpdateEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingUpdateEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingRemoveEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingRemoveEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingCheckedEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingCheckedEvent;
            this.simulationFunctionMgrCtrl1.CreateProjectSiteSchemeEvent += SimulationFunctionMgrCtrl1_CreateProjectSiteSchemeEvent;
        }
        private XhsProjectVmo _project = null;//项目
        private object _locker = new object();//锁定对象
        /// <summary>
        /// 初始化数据源
@@ -68,8 +65,13 @@
        #region 功能面板
        //显示项目站概况事件
        private void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteInfoEvent
            (XhsProjectVmo project, XhsProjectSiteVmo projectSite, Yw.Model.HydroModelInfo hydroInfo, SvgImage svgImage)
        private void SimulationFunctionMgrCtrl1_ShowProjectSiteInfoEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                Yw.Model.HydroModelInfo hydroInfo,
                SvgImage svgImage
            )
        {
            lock (_locker)
            {
@@ -78,6 +80,7 @@
                    Modular = this.PageGuid.Modular,
                    MoudingType = eMoudingType.Tab,
                    Function = SimulationFunctionHelper.Info,
                    TagName = $"{project.ID}-{projectSite.ID}"
                };
                if (!IsExistPage(guid, true))
                {
@@ -90,8 +93,15 @@
        }
        //显示项目站水力模拟事件
        private void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteSimulationEvent
            (XhsProjectVmo project, XhsProjectSiteVmo projectSite, Yw.Model.HydroModelInfo hydroInfo, Dictionary<HydroWorkingVmo, bool> allWorkingCheckedListDict, SvgImage svgImage)
        private void SimulationFunctionMgrCtrl1_ShowProjectSiteSimulationEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme,
                Yw.Model.HydroModelInfo hydroInfo,
                Dictionary<HydroWorkingVmo, bool> allWorkingCheckedListDict,
                SvgImage svgImage
            )
        {
            lock (_locker)
            {
@@ -100,7 +110,7 @@
                    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))
                {
@@ -108,17 +118,32 @@
                    page.PageTitle.HeaderSvgImage = svgImage;
                    page.AppendWorkingEvent += (working) =>
                    {
                        this.simulationFunctionMgrCtrl1.AppendWorking(working);
                        this.simulationFunctionMgrCtrl1.AppendWorking(scheme, working);
                    };
                    page.SetBindingData(project, projectSite, hydroInfo, allWorkingCheckedListDict);
                    page.SaveModelEvent += (rhs) =>
                    {
                        return this.simulationFunctionMgrCtrl1.SaveModel(scheme, rhs);
                    };
                    page.RefreshModelEvent += () =>
                    {
                        return this.simulationFunctionMgrCtrl1.RefreshModel(scheme);
                    };
                    page.SetBindingData(project, projectSite, scheme, hydroInfo, allWorkingCheckedListDict);
                    CreatePage(page, guid);
                }
            }
        }
        //显示项目站工况事件
        private void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteWorkingEvent
            (XhsProjectVmo project, XhsProjectSiteVmo projectSite, Yw.Model.HydroModelInfo hydroInfo, HydroWorkingVmo working, SvgImage svgImage)
        private void SimulationFunctionMgrCtrl1_ShowProjectSiteWorkingEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme,
                Yw.Model.HydroModelInfo hydroInfo,
                HydroWorkingVmo working,
                SvgImage svgImage
            )
        {
            lock (_locker)
            {
@@ -127,29 +152,34 @@
                    Modular = this.PageGuid.Modular,
                    MoudingType = eMoudingType.Tab,
                    Function = SimulationFunctionHelper.Working,
                    TagName = working.ID.ToString()
                    TagName = $"{project.ID}-{projectSite.ID}-{scheme?.ID}-{working.ID}"
                };
                if (!IsExistPage(guid, true))
                {
                    var page = new XhsProjectSimulationWorkingPage();
                    page.UpdateWorkingEvent += (rhs) =>
                    {
                        this.simulationFunctionMgrCtrl1.UpdateWorking(rhs);
                        this.simulationFunctionMgrCtrl1.UpdateWorking(scheme, rhs);
                    };
                    page.RemoveWorkingEvent += (rhs) =>
                    {
                        this.simulationFunctionMgrCtrl1.RemoveWorking(rhs);
                        this.simulationFunctionMgrCtrl1.RemoveWorking(scheme, rhs);
                    };
                    page.PageTitle.HeaderSvgImage = svgImage;
                    page.SetBindingData(project, projectSite, hydroInfo, working);
                    page.SetBindingData(project, projectSite, scheme, hydroInfo, working);
                    CreatePage(page, guid);
                }
            }
        }
        //项目站工况更新事件
        private void XhsProjectSimulationFunctionMgrCtrl1_ProjectSiteWorkingUpdateEvent
            (XhsProjectVmo project, XhsProjectSiteVmo projectSite, Yw.Model.HydroModelInfo hydroInfo, HydroWorkingVmo working)
        private void SimulationFunctionMgrCtrl1_ProjectSiteWorkingUpdateEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme,
                HydroWorkingVmo working
            )
        {
            var guid = new PageGuid()
            {
@@ -172,8 +202,13 @@
        }
        //项目站工况移除事件
        private void XhsProjectSimulationFunctionMgrCtrl1_ProjectSiteWorkingRemoveEvent
            (XhsProjectVmo project, XhsProjectSiteVmo projectSite, Yw.Model.HydroModelInfo hydroInfo, HydroWorkingVmo working)
        private void SimulationFunctionMgrCtrl1_ProjectSiteWorkingRemoveEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme,
                HydroWorkingVmo working
            )
        {
            var guid = new PageGuid()
            {
@@ -196,8 +231,14 @@
        }
        //项目站工况选择改变事件
        private void XhsProjectSimulationFunctionMgrCtrl1_ProjectSiteWorkingCheckedEvent
            (XhsProjectVmo project, XhsProjectSiteVmo projectSite, Yw.Model.HydroModelInfo hydroInfo, HydroWorkingVmo working, bool hasChecked)
        private void SimulationFunctionMgrCtrl1_ProjectSiteWorkingCheckedEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme,
                HydroWorkingVmo working,
                bool hasChecked
            )
        {
            var guid = new PageGuid()
            {
@@ -220,8 +261,13 @@
        }
        //项目站方案创建事件
        private void XhsProjectSimulationFunctionMgrCtrl1_CreateProjectSiteSchemeEvent
            (XhsProjectVmo project, XhsProjectSiteVmo projectSite, Yw.Model.HydroModelInfo hydroInfo, SvgImage svgImage)
        private void SimulationFunctionMgrCtrl1_CreateProjectSiteSchemeEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                Yw.Model.HydroModelInfo hydroInfo,
                SvgImage svgImage
            )
        {
            WaitFormHelper.ShowWaitForm(this.FindForm(), "正在加载模型,请稍侯...");
            var dlg = new AddXhsSchemeDlg();
@@ -232,56 +278,6 @@
            };
            dlg.SetBindingData(project, projectSite, hydroInfo);
            dlg.ShowDialog();
        }
        //显示项目站方案事件
        private void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteSchemeEvent
            (XhsProjectVmo project, XhsProjectSiteVmo projectSite, XhsSchemeVmo scheme, Yw.Model.HydroModelInfo hydroInfo, Dictionary<HydroWorkingVmo, bool> dict, SvgImage svgImage)
        {
            lock (_locker)
            {
                var guid = new PageGuid()
                {
                    Modular = this.PageGuid.Modular,
                    MoudingType = eMoudingType.Tab,
                    Function = SimulationFunctionHelper.Scheme,
                    TagName = scheme.ID.ToString()
                };
                if (!IsExistPage(guid, true))
                {
                    var page = new XhsProjectSimulationSchemePage();
                    page.PageTitle.HeaderSvgImage = svgImage;
                    page.AppendWorkingEvent += (working) =>
                    {
                        this.simulationFunctionMgrCtrl1.AppendSchemeWorking(scheme, working);
                    };
                    page.SetBindingData(project, projectSite, scheme, hydroInfo, dict);
                    CreatePage(page, guid);
                }
            }
        }
        //显示项目站方案工况事件
        private void XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteSchemeWorkingEvent
            (XhsProjectVmo project, XhsProjectSiteVmo projectSite, XhsSchemeVmo scheme, Yw.Model.HydroModelInfo hydroInfo, HydroWorkingVmo working, SvgImage svgImage)
        {
            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, scheme, hydroInfo, working);
                    CreatePage(page, guid);
                }
            }
        }
        #endregion