From f47abf649b85ce5fd21725fedaebba359a6dfd1d Mon Sep 17 00:00:00 2001
From: duheng <2784771470@qq.com>
Date: 星期二, 24 十二月 2024 09:20:02 +0800
Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/HStation/XHS.V1.0

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/XhsProjectSimulationMgrPage.cs |  428 +++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 349 insertions(+), 79 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/XhsProjectSimulationMgrPage.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/XhsProjectSimulationMgrPage.cs
index 3fd37e4..f437feb 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/XhsProjectSimulationMgrPage.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/XhsProjectSimulationMgrPage.cs
@@ -1,6 +1,8 @@
-锘縰sing DevExpress.XtraBars.Docking;
+锘縰sing DevExpress.Drawing;
+using DevExpress.Utils.Svg;
+using DevExpress.XtraBars.Docking;
 using DevExpress.XtraBars.Docking2010.Views;
-using HStation.Vmo;
+using Yw.Vmo;
 using Yw.WinFrmUI.Page;
 
 namespace HStation.WinFrmUI
@@ -13,26 +15,33 @@
             this.PageTitle.Caption = "姘村姏妯℃嫙";
             this.PageTitle.HeaderSvgImage = this.svgImg32[0];
             this.PageTitle.SvgImageSize = new Size(24, 24);
-
-            this.xhsProjectSimulationFunctionMgrCtrl1.ProjectSiteSelectedChangedEvent += xhsProjectSimulationFunctionMgrCtrl1_ProjectSiteSelectedChangedEvent;
-            this.xhsProjectSimulationFunctionMgrCtrl1.ShowXhsProjectInfoEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowXhsProjectInfoEvent;
-            this.xhsProjectSimulationFunctionMgrCtrl1.ShowXhsProjectSimulationEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowXhsProjectSimulationEvent;
-            this.xhsProjectSimulationFunctionMgrCtrl1.CreateXhsProjectSchemeEvent += XhsProjectSimulationFunctionMgrCtrl1_CreateXhsProjectSchemeEvent;
-            this.xhsProjectSimulationFunctionMgrCtrl1.CompareXhsProjectSchemeEvent += XhsProjectSimulationFunctionMgrCtrl1_CompareXhsProjectSchemeEvent;
-            PumpFullInfoViewDlg.JumpPumpFullInfoCtrl += ShowPumpInfo;
+            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 long _projectId;//椤圭洰id
         private XhsProjectVmo _project = null;//椤圭洰
-        private XhsProjectSiteVmo _projectSite = null;//椤圭洰绔�
-        private Yw.Model.HydroModelInfo _hydroInfo = null;//姘村姏淇℃伅
+        private object _locker = new();//閿佸畾瀵硅薄
 
         /// <summary>
         /// 鍒濆鍖栨暟鎹簮
         /// </summary>
-        public override void InitialDataSource()
+        public override async void InitialDataSource()
         {
             base.InitialDataSource();
+            if (_project == null)
+            {
+                return;
+            }
+            await this.simulationFunctionMgrCtrl1.SetBindingData(_project);
         }
 
         /// <summary>
@@ -41,96 +50,311 @@
         public async Task SetBindingData(long projectId)
         {
             _project = await BLLFactory<HStation.BLL.XhsProject>.Instance.GetByID(projectId);
-            await SetBindingData(_project);
+            SetBindingData(_project);
         }
 
         /// <summary>
         /// 璁剧疆鏁版嵁
         /// </summary>
-        public async Task SetBindingData(XhsProjectVmo project)
+        public void SetBindingData(XhsProjectVmo project)
         {
             if (project == null)
             {
                 return;
             }
             _project = project;
-            _projectId = project.ID;
             this.PageTitle.Caption = $"{_project.Name}\r\n椤圭洰妯℃嫙";
-            await this.xhsProjectSimulationFunctionMgrCtrl1.SetBindingData(_project);
         }
 
         #region 鍔熻兘闈㈡澘
 
-        //椤圭洰绔欓�夋嫨鏀瑰彉浜嬩欢
-        private async void xhsProjectSimulationFunctionMgrCtrl1_ProjectSiteSelectedChangedEvent(XhsProjectSiteVmo obj)
+        //鏄剧ず椤圭洰绔欐鍐典簨浠�
+        private void SimulationFunctionMgrCtrl1_ShowProjectSiteInfoEvent
+            (
+                XhsProjectVmo project,
+                XhsProjectSiteVmo projectSite,
+                Yw.Model.HydroModelInfo hydroInfo,
+                SvgImage svgImage
+            )
         {
-            _projectSite = obj;
-            if (_projectSite != null)
+            lock (_locker)
             {
-                var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance
-                   .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation);
-                _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID);
-                this.xhsProjectSimulationFunctionMgrCtrl1.ResetBindingData();
+                var guid = new PageGuid()
+                {
+                    Modular = this.PageGuid.Modular,
+                    MoudingType = eMoudingType.Tab,
+                    Function = SimulationFunctionHelper.Info,
+                    TagName = $"{project.ID}-{projectSite.ID}"
+                };
+                if (!IsExistPage(guid, true))
+                {
+                    var page = new XhsProjectSimulationInfoPage();
+                    page.PageTitle.HeaderSvgImage = svgImage;
+                    page.SetBindingData(project, projectSite, hydroInfo);
+                    CreatePage(page, guid);
+                }
             }
         }
 
-        //鏄剧ず椤圭洰淇℃伅浜嬩欢
-        private async void XhsProjectSimulationFunctionMgrCtrl1_ShowXhsProjectInfoEvent(DevExpress.Utils.Svg.SvgImage obj)
+        //鏄剧ず椤圭洰绔欐按鍔涙ā鎷熶簨浠�
+        private void SimulationFunctionMgrCtrl1_ShowProjectSiteSimulationEvent
+            (
+                XhsProjectVmo project,
+                XhsProjectSiteVmo projectSite,
+                XhsSchemeVmo scheme,
+                Yw.Model.HydroModelInfo hydroInfo,
+                Dictionary<HydroWorkingVmo, bool> allWorkingCheckedListDict,
+                SvgImage svgImage
+            )
+        {
+            lock (_locker)
+            {
+                var guid = new PageGuid()
+                {
+                    Modular = this.PageGuid.Modular,
+                    MoudingType = eMoudingType.Tab,
+                    Function = SimulationFunctionHelper.Simulation,
+                    TagName = $"{project.ID}-{projectSite.ID}-{scheme?.ID}"
+                };
+                if (!IsExistPage(guid, true))
+                {
+                    var page = new XhsProjectSimulationCorePage();
+                    page.PageTitle.HeaderSvgImage = svgImage;
+                    page.AppendWorkingEvent += (working) =>
+                    {
+                        //澧炲姞宸ュ喌浜嬩欢
+                        this.simulationFunctionMgrCtrl1.AppendWorking(scheme, working);
+                    };
+                    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 SimulationFunctionMgrCtrl1_ShowProjectSiteWorkingEvent
+            (
+                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 = $"{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, 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 = "xhs-project-simulation-info",
+                Function = SimulationFunctionHelper.Simulation,
+                TagName = $"{project.ID}-{projectSite.ID}-{scheme?.ID}"
             };
-            if (!IsExistPage(guid, true))
-            {
-                var page = new XhsProjectSimulationInfoPage();
-                await page.SetBindingData(_project, _projectSite, _hydroInfo);
-                CreatePage(page, guid);
-            }
-        }
-
-        //鏄剧ず姘村姏妯℃嫙浜嬩欢
-        private async void XhsProjectSimulationFunctionMgrCtrl1_ShowXhsProjectSimulationEvent(DevExpress.Utils.Svg.SvgImage obj)
-        {
-            var guid = new PageGuid()
-            {
-                Modular = this.PageGuid.Modular,
-                MoudingType = eMoudingType.Tab,
-                Function = "xhs-project-simulation-core",
-            };
-            if (!IsExistPage(guid, true))
-            {
-                var page = new XhsProjectSimulationCorePage();
-                await page.SetBindingData(_project, _projectSite, _hydroInfo);
-                CreatePage(page, guid);
-            }
-        }
-
-        //鍒涘缓椤圭洰鏂规浜嬩欢
-        private async void XhsProjectSimulationFunctionMgrCtrl1_CreateXhsProjectSchemeEvent(DevExpress.Utils.Svg.SvgImage obj)
-        {
-            if (_projectSite == null)
+            var page = FindPage(guid);
+            if (page == null)
             {
                 return;
             }
-            var dlg = new AddXhsProjectSimulationSchemeDlg();
-            await dlg.SetBindingData(_projectSite.ID);
-            dlg.ReloadDataEvent += (scheme) =>
+            var ctrl = page as XhsProjectSimulationCorePage;
+            if (ctrl == null)
             {
-                this.xhsProjectSimulationFunctionMgrCtrl1.AppendScheme(scheme);
+                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 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 = projectSite.ID.ToString()
+            };
+            var page = FindPage(guid);
+            if (page == null)
+            {
+                return;
+            }
+            var ctrl = page as XhsProjectSimulationCorePage;
+            if (ctrl == null)
+            {
+                return;
+            }
+            ctrl.UpdateWorkingCheckedList(working, hasChecked);
+        }
+
+        //椤圭洰绔欐柟妗堝垱寤轰簨浠�
+        private void SimulationFunctionMgrCtrl1_CreateProjectSiteSchemeEvent
+            (
+                XhsProjectVmo project,
+                XhsProjectSiteVmo projectSite,
+                Yw.Model.HydroModelInfo hydroInfo,
+                SvgImage svgImage
+            )
+        {
+            //WaitFormHelper.ShowWaitForm(this.FindForm(), "姝e湪鍔犺浇妯″瀷锛岃绋嶄警...");
+            //var dlg = new AddXhsSchemeDlg();
+            //dlg.Shown += delegate { WaitFormHelper.HideWaitForm(this.FindForm()); };
+            //dlg.ReloadDataEvent += (rhs) =>
+            //{
+            //    this.simulationFunctionMgrCtrl1.AppendScheme(rhs);
+            //};
+            //dlg.SetBindingData(project, projectSite, hydroInfo);
+            //dlg.ShowDialog();
+
+            WaitFormHelper.ShowWaitForm(this.FindForm(), "姝e湪鍔犺浇妯″瀷锛岃绋嶄警...");
+            var dlg = new CreateXhsSchemeDlg();
+            dlg.Shown += delegate { WaitFormHelper.HideWaitForm(this.FindForm()); };
+            dlg.SetBindingData(project, projectSite, hydroInfo);
+            dlg.ReloadDataEvent += (rhs) =>
+            {
+                this.simulationFunctionMgrCtrl1.AppendScheme(rhs);
             };
             dlg.ShowDialog();
         }
 
-        //姣旇緝椤圭洰鏂规浜嬩欢
-        private void XhsProjectSimulationFunctionMgrCtrl1_CompareXhsProjectSchemeEvent(DevExpress.Utils.Svg.SvgImage obj)
+        //椤圭洰绔欐柟妗堝鍔犱簨浠�
+        private void SimulationFunctionMgrCtrl1_ProjectSiteSchemeAppendEvent
+            (
+                XhsProjectVmo project,
+                XhsProjectSiteVmo projectSite,
+                XhsSchemeVmo scheme
+            )
         {
-            TipFormHelper.ShowWarn("姝e湪寮�鍙戜腑锛屾暚璇锋湡寰�...");
+            //琚姩
         }
 
-        #endregion 鍔熻兘闈㈡澘
+        //椤圭洰绔欐柟妗堟洿鏂颁簨浠�
+        private void SimulationFunctionMgrCtrl1_ProjectSiteSchemeUpdateEvent
+            (
+                XhsProjectVmo project,
+                XhsProjectSiteVmo projectSite,
+                XhsSchemeVmo scheme
+            )
+        {
+            //琚姩
+        }
+
+        //椤圭洰绔欐柟妗堢Щ闄や簨浠�
+        private void SimulationFunctionMgrCtrl1_ProjectSiteSchemeRemoveEvent
+            (
+                XhsProjectVmo project,
+                XhsProjectSiteVmo projectSite,
+                XhsSchemeVmo scheme
+            )
+        {
+            //琚姩
+        }
+
+        #endregion
 
         #region TabbedView 鐩稿叧浜嬩欢澶勭悊绋嬪簭
 
@@ -157,12 +381,28 @@
                 return;
         }
 
+        //姝e湪鍏抽棴Document
+        private void tabbedView1_DocumentClosing(object sender, DocumentCancelEventArgs e)
+        {
+            var page = e.Document.Control as DocumentPage;
+            if (page == null)
+            {
+                return;
+            }
+            if (!page.CanClose())
+            {
+                e.Cancel = true;
+                return;
+            }
+            page.UnRegistEvents();
+        }
+
         //鍏抽棴 姝ゆ椂鎺т欢宸茬粡涓虹┖
         private void tabbedView1_DocumentClosed(object sender, DocumentEventArgs e)
         {
         }
 
-        #endregion TabbedView 鐩稿叧浜嬩欢澶勭悊绋嬪簭
+        #endregion
 
         #region Page
 
@@ -348,7 +588,6 @@
                         docPnl.Show();
                     }
                     break;
-
                 case eMoudingType.Tab:
                     {
                         this.tabbedView1.BeginUpdate();
@@ -367,7 +606,6 @@
                         this.tabbedView1.Controller.Activate(doc);
                     }
                     break;
-
                 default: break;
             }
             page.InitialDataSource();
@@ -411,20 +649,52 @@
             }
         }
 
-        #endregion Page
-
-        private void ShowPumpInfo(PumpFullInfoCtrl pumpFullInfoCtrl)
+        //鏌ヨPage
+        private DocumentPage FindPage(PageGuid pguid)
         {
-            var guid = new PageGuid()
+            if (pguid == null)
             {
-                Modular = this.PageGuid.Modular,
-                MoudingType = eMoudingType.Tab,
-                Function = "xhs-project-pump-info",
-            };
-            if (!IsExistPage(guid, true))
-            {
-                CreatePage(pumpFullInfoCtrl, guid);
+                return default;
             }
+            if (this.dockManager1.Panels != null && this.dockManager1.Panels.Count > 0)
+            {
+                foreach (DockPanel panel in this.dockManager1.Panels)
+                {
+                    if (panel.Tag != null)
+                    {
+                        if (panel.Tag is PageGuid)
+                        {
+                            if ((panel.Tag as PageGuid).ToString() == pguid.ToString())
+                            {
+                                return panel.ControlContainer.Controls[0] as DocumentPage;
+                            }
+                        }
+                    }
+                }
+            }
+
+            if (this.tabbedView1.Documents != null && this.tabbedView1.Documents.Count > 0)
+            {
+                foreach (BaseDocument doc in this.tabbedView1.Documents)
+                {
+                    if (doc.Tag != null)
+                    {
+                        if (doc.Tag is PageGuid)
+                        {
+                            if ((doc.Tag as PageGuid).ToString() == pguid.ToString())
+                            {
+                                return doc.Control as DocumentPage;
+                            }
+                        }
+                    }
+                }
+            }
+
+            return default;
         }
+
+
+        #endregion
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3