lixiaojun
2024-12-11 be1dcb30e552fff6a2cf733d6577b103665edded
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/XhsProjectSimulationMgrPage.cs
@@ -15,18 +15,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.xhsProjectSimulationFunctionMgrCtrl1.CreateProjectSiteSchemeEvent += XhsProjectSimulationFunctionMgrCtrl1_CreateProjectSiteSchemeEvent;
            this.xhsProjectSimulationFunctionMgrCtrl1.ShowProjectSiteSchemeEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteSchemeEvent;
            this.xhsProjectSimulationFunctionMgrCtrl1.ShowProjectSiteSchemeWorkingEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowProjectSiteSchemeWorkingEvent;
            this.simulationFunctionMgrCtrl1.ShowProjectSiteInfoEvent += SimulationFunctionMgrCtrl1_ShowProjectSiteInfoEvent;
            this.simulationFunctionMgrCtrl1.ShowProjectSiteSimulationEvent += SimulationFunctionMgrCtrl1_ShowProjectSiteSimulationEvent;
            this.simulationFunctionMgrCtrl1.ShowProjectSiteWorkingEvent += SimulationFunctionMgrCtrl1_ShowProjectSiteWorkingEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingAppendEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingAppendEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingUpdateEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingUpdateEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingRemoveEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingRemoveEvent;
            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingCheckedEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingCheckedEvent;
            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>
        /// 初始化数据源
@@ -38,7 +41,7 @@
            {
                return;
            }
            await this.xhsProjectSimulationFunctionMgrCtrl1.SetBindingData(_project);
            await this.simulationFunctionMgrCtrl1.SetBindingData(_project);
        }
        /// <summary>
@@ -66,8 +69,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)
            {
@@ -76,6 +84,7 @@
                    Modular = this.PageGuid.Modular,
                    MoudingType = eMoudingType.Tab,
                    Function = SimulationFunctionHelper.Info,
                    TagName = $"{project.ID}-{projectSite.ID}"
                };
                if (!IsExistPage(guid, true))
                {
@@ -88,8 +97,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)
            {
@@ -98,7 +114,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))
                {
@@ -106,17 +122,45 @@
                    page.PageTitle.HeaderSvgImage = svgImage;
                    page.AppendWorkingEvent += (working) =>
                    {
                        this.xhsProjectSimulationFunctionMgrCtrl1.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.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, SvgImage svgImage)
        private void SimulationFunctionMgrCtrl1_ShowProjectSiteWorkingEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme,
                Yw.Model.HydroModelInfo hydroInfo,
                HydroWorkingVmo working,
                SvgImage svgImage
            )
        {
            lock (_locker)
            {
@@ -125,21 +169,107 @@
                    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(scheme, rhs);
                    };
                    page.RemoveWorkingEvent += (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);
                }
            }
        }
        /// <summary>
        /// 项目站工况增加事件
        /// </summary>
        private void SimulationFunctionMgrCtrl1_ProjectSiteWorkingAppendEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme,
                HydroWorkingVmo working
            )
        {
            //目前增加工况都是通过模拟界面增加的,功能管理控件属于被通知的,其他地方暂时不关心工况增加
        }
        //项目站工况更新事件
        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()
            };
            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 = projectSite.ID.ToString()
            };
            var page = FindPage(guid);
            if (page == null)
            {
                return;
            }
            var ctrl = page as XhsProjectSimulationCorePage;
            if (ctrl == null)
            {
                return;
            }
            ctrl.RemoveWorkingCheckedList(working);
        }
        //项目站工况选择改变事件
        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()
            {
@@ -162,68 +292,61 @@
        }
        //项目站方案创建事件
        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();
            dlg.Shown += delegate { WaitFormHelper.HideWaitForm(this.FindForm()); };
            dlg.ReloadDataEvent += (rhs) =>
            {
                this.xhsProjectSimulationFunctionMgrCtrl1.AppendScheme(rhs);
                this.simulationFunctionMgrCtrl1.AppendScheme(rhs);
            };
            dlg.SetBindingData(project, projectSite, hydroInfo);
            dlg.ShowDialog();
            //var dlg = new CreateXhsSchemeDlg();
            //dlg.Shown += delegate { WaitFormHelper.HideWaitForm(this.FindForm()); };
            //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)
        //项目站方案增加事件
        private void SimulationFunctionMgrCtrl1_ProjectSiteSchemeAppendEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme
            )
        {
            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.xhsProjectSimulationFunctionMgrCtrl1.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)
        //项目站方案更新事件
        private void SimulationFunctionMgrCtrl1_ProjectSiteSchemeUpdateEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme
            )
        {
            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);
                }
            }
            //被动
        }
        //项目站方案移除事件
        private void SimulationFunctionMgrCtrl1_ProjectSiteSchemeRemoveEvent
            (
                XhsProjectVmo project,
                XhsProjectSiteVmo projectSite,
                XhsSchemeVmo scheme
            )
        {
            //被动
        }
        #endregion
@@ -460,7 +583,6 @@
                        docPnl.Show();
                    }
                    break;
                case eMoudingType.Tab:
                    {
                        this.tabbedView1.BeginUpdate();
@@ -479,7 +601,6 @@
                        this.tabbedView1.Controller.Activate(doc);
                    }
                    break;
                default: break;
            }
            page.InitialDataSource();