From abbe29e54421c136aa6eb4ef11935c70d818101a Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期五, 20 九月 2024 11:59:09 +0800
Subject: [PATCH] 属性修改

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/XhsProjectSimulationMgrPage.cs |  521 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 520 insertions(+), 1 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/XhsProjectSimulationMgrPage.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/XhsProjectSimulationMgrPage.cs
index 83eb05a..60c53e8 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/XhsProjectSimulationMgrPage.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/XhsProjectSimulationMgrPage.cs
@@ -1,4 +1,9 @@
-锘縩amespace HStation.WinFrmUI
+锘縰sing DevExpress.XtraBars.Docking;
+using DevExpress.XtraBars.Docking2010.Views;
+using HStation.Vmo;
+using Yw.WinFrmUI.Page;
+
+namespace HStation.WinFrmUI
 {
     public partial class XhsProjectSimulationMgrPage : Yw.WinFrmUI.DocumentPage
     {
@@ -6,6 +11,520 @@
         {
             InitializeComponent();
             this.PageTitle.Caption = "姘村姏妯℃嫙";
+            this.PageTitle.HeaderSvgImage = this.svgImg32[0];
+            this.PageTitle.SvgImageSize = new Size(24, 24);
+
+            this.xhsProjectSimulationSchemeMgrCtrl1.ProjectSiteSelectedChangedEvent += XhsProjectSimulationSchemeMgrCtrl1_ProjectSiteSelectedChangedEvent;
+            this.xhsProjectSimulationFunctionMgrCtrl1.ShowXhsProjectInfoEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowXhsProjectInfoEvent;
+            this.xhsProjectSimulationFunctionMgrCtrl1.ShowXhsProjectSimulationEvent += XhsProjectSimulationFunctionMgrCtrl1_ShowXhsProjectSimulationEvent;
+            this.xhsProjectSimulationFunctionMgrCtrl1.CreateXhsProjectSchemeEvent += XhsProjectSimulationFunctionMgrCtrl1_CreateXhsProjectSchemeEvent;
+            this.xhsProjectSimulationFunctionMgrCtrl1.CompareXhsProjectSchemeEvent += XhsProjectSimulationFunctionMgrCtrl1_CompareXhsProjectSchemeEvent;
         }
+
+        private long _projectId;//椤圭洰id
+        private XhsProjectVmo _project = null;//椤圭洰
+        private XhsProjectSiteVmo _projectSite = null;//椤圭洰绔�
+        private Yw.Model.HydroModelInfo _hydroInfo = null;//姘村姏淇℃伅
+
+        /// <summary>
+        /// 璁剧疆鏁版嵁
+        /// </summary>
+        public async Task SetBindingData(XhsProjectVmo project)
+        {
+            if (project == null)
+            {
+                return;
+            }
+            _project = project;
+            _projectId = project.ID;
+            this.PageTitle.Caption = $"{_project.Name}\r\n姘村姏妯℃嫙";
+            await this.xhsProjectSimulationSchemeMgrCtrl1.SetBindingData(_project);
+        }
+
+        /// <summary>
+        /// 缁戝畾鏁版嵁
+        /// </summary>
+        public async Task SetBindingData(long projectId)
+        {
+            _project = await BLLFactory<HStation.BLL.XhsProject>.Instance.GetByID(projectId);
+            await SetBindingData(_project);
+            //this.xhsSchemeMgrListCtrl1.SetBindingData(projectId);
+            //_project = await new BLL.XhsProjectStd().GetByID(projectId);
+            //this.PageTitle.Caption = 
+            //var projectSite = await new BLL.XhsProjectSiteStd().GetDefaultByProjectID(_project.ID);
+            //if (projectSite == null)
+            //{
+            //    return;
+            //}
+
+            //var relation = await new Yw.BLL.HydroModelRelation()
+            //    .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, projectSite.ID, Yw.Bimface.Purpose.Simulation);
+            //if (relation == null)
+            //{
+            //    return;
+            //}
+
+            //_hydroInfo = await new Yw.BLL.HydroModelInfo().GetByID(relation.ModelID);
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栨暟鎹簮
+        /// </summary>
+        public override void InitialDataSource()
+        {
+            base.InitialDataSource();
+        }
+
+        //椤圭洰绔欓�夋嫨鏀瑰彉浜嬩欢
+        private async void XhsProjectSimulationSchemeMgrCtrl1_ProjectSiteSelectedChangedEvent(XhsProjectSiteVmo obj)
+        {
+            _projectSite = obj;
+            if (_projectSite != null)
+            {
+                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);
+            }
+        }
+
+        //鏄剧ず椤圭洰淇℃伅浜嬩欢
+        private async void XhsProjectSimulationFunctionMgrCtrl1_ShowXhsProjectInfoEvent(DevExpress.Utils.Svg.SvgImage obj)
+        {
+            var guid = new PageGuid()
+            {
+                Modular = this.PageGuid.Modular,
+                MoudingType = eMoudingType.Tab,
+                Function = "xhs-project-simulation-info",
+            };
+            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)
+            {
+                return;
+            }
+            var dlg = new AddXhsProjectSimulationSchemeDlg();
+            await dlg.SetBindingData(_projectSite.ID);
+            dlg.ReloadDataEvent += (scheme) =>
+            {
+                this.xhsProjectSimulationSchemeMgrCtrl1.AppendScheme(scheme);
+            };
+            dlg.ShowDialog();
+        }
+
+        //姣旇緝椤圭洰鏂规浜嬩欢
+        private void XhsProjectSimulationFunctionMgrCtrl1_CompareXhsProjectSchemeEvent(DevExpress.Utils.Svg.SvgImage obj)
+        {
+
+        }
+
+
+
+
+
+
+
+        //鍔熻兘鐐瑰嚮
+        private async void accordionControl1_ElementClick(object sender, DevExpress.XtraBars.Navigation.ElementClickEventArgs e)
+        {
+            var tag = e.Element.Tag;
+            if (tag is not string code)
+                return;
+
+            var svg_image_size = new Size(24, 24);
+            switch (code)
+            {
+                case "basic_info":
+                    {
+                        var guid = new PageGuid()
+                        {
+                            Modular = this.PageGuid.Modular,
+                            MoudingType = eMoudingType.Tab,
+                            Function = "basic_info",
+                        };
+                        if (!IsExistPage(guid, true))
+                        {
+                            var page = new XhsSchemeBasicInfoPage();
+                            page.SetBindingData(_project.ID);
+                            page.PageTitle.Caption = e.Element.Text;
+                            page.PageTitle.HeaderSvgImage = e.Element.ImageOptions.SvgImage;
+                            page.PageTitle.SvgImageSize = svg_image_size;
+                            CreatePage(page, guid);
+                        }
+                    }
+                    break;
+                case "asset_mgr":
+                    {
+                        var guid = new PageGuid()
+                        {
+                            Modular = this.PageGuid.Modular,
+                            MoudingType = eMoudingType.Tab,
+                            Function = "asset_mgr",
+                        };
+                        if (!IsExistPage(guid, true))
+                        {
+                            var page = new XhsSchemeAssetMgrPage();
+                            await page.SetBindingData(_project.ID);
+                            page.PageTitle.Caption = e.Element.Text;
+                            page.PageTitle.HeaderSvgImage = e.Element.ImageOptions.SvgImage;
+                            page.PageTitle.SvgImageSize = svg_image_size;
+                            CreatePage(page, guid);
+                        }
+                    }
+                    break;
+                case "hydraulic_simulation":
+                    {
+                        var guid = new PageGuid()
+                        {
+                            Modular = this.PageGuid.Modular,
+                            MoudingType = eMoudingType.Tab,
+                            Function = "hydraulic_simulation",
+                        };
+                        if (!IsExistPage(guid, true))
+                        {
+                            var page = new XhsSchemeHydraulicSimulationPage();
+                            await page.SetBindingData(_project.ID);
+                            page.PageTitle.Caption = e.Element.Text;
+                            page.PageTitle.HeaderSvgImage = e.Element.ImageOptions.SvgImage;
+                            page.PageTitle.SvgImageSize = svg_image_size;
+                            CreatePage(page, guid);
+                        }
+                    }
+                    break;
+                case "create_scheme":
+                    {
+                        var dlg = new CreateSchemeDlg();
+                        dlg.ShowDialog();
+                    }
+                    break;
+                case "scheme_comparison":
+                    {
+                        var guid = new PageGuid()
+                        {
+                            Modular = this.PageGuid.Modular,
+                            MoudingType = eMoudingType.Tab,
+                            Function = "scheme_comparison",
+                        };
+                        if (!IsExistPage(guid, true))
+                        {
+                            var page = new XhsSchemeComparisonPage();
+                            page.PageTitle.Caption = e.Element.Text;
+                            page.PageTitle.HeaderSvgImage = e.Element.ImageOptions.SvgImage;
+                            page.PageTitle.SvgImageSize = svg_image_size;
+                            CreatePage(page, guid);
+                        }
+                    }
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        #region TabbedView 鐩稿叧浜嬩欢澶勭悊绋嬪簭
+
+        //閫変腑
+        private void tabbedView1_DocumentSelected(object sender, DocumentEventArgs e)
+        {
+            if (e.Document == null)
+                return;
+            var surfaceGuid = e.Document.Tag as PageGuid;
+            if (surfaceGuid == null)
+                return;
+        }
+
+        //娣诲姞
+        private void tabbedView1_DocumentAdded(object sender, DocumentEventArgs e)
+        {
+        }
+
+        //婵�娲�
+        private void tabbedView1_DocumentActivated(object sender, DocumentEventArgs e)
+        {
+            var page = e.Document.Control as DocumentPage;
+            if (page == null)
+                return;
+        }
+
+        //鍏抽棴 姝ゆ椂鎺т欢宸茬粡涓虹┖
+        private void tabbedView1_DocumentClosed(object sender, DocumentEventArgs e)
+        {
+        }
+
+        #endregion TabbedView 鐩稿叧浜嬩欢澶勭悊绋嬪簭
+
+        #region Page
+
+        //鏄惁瀛樺湪Page
+        private new bool IsExistPage(PageGuid pguid, bool isActivePage)
+        {
+            if (pguid == null)
+            {
+                return false;
+            }
+            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())
+                            {
+                                if (isActivePage)
+                                {
+                                    panel.Show();
+                                }
+                                return true;
+                            }
+                        }
+                    }
+                }
+            }
+
+            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())
+                            {
+                                if (isActivePage)
+                                {
+                                    this.tabbedView1.Controller.Activate(doc);
+                                }
+                                return true;
+                            }
+                        }
+                    }
+                }
+            }
+
+            return false;
+        }
+
+        //鏇存柊鏁版嵁
+        private new void RefreshPageData(PageGuid pguid)
+        {
+            if (pguid == null)
+            {
+                return;
+            }
+            if (this.dockManager1.Panels != null && this.dockManager1.Panels.Count > 0)
+            {
+                var panel = this.dockManager1.Panels.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == pguid.ToString());
+                if (panel != null)
+                {
+                    if (panel.ControlContainer.Controls.Count > 0)
+                    {
+                        var page = panel.ControlContainer.Controls[0] as DocumentPage;
+                        if (page != null)
+                        {
+                            page.RefreshData();
+                        }
+                    }
+                    return;
+                }
+            }
+
+            if (this.tabbedView1.Documents != null && this.tabbedView1.Documents.Count > 0)
+            {
+                var doc = this.tabbedView1.Documents.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == pguid.ToString());
+                if (doc != null)
+                {
+                    var page = doc.Control as DocumentPage;
+                    if (page != null)
+                    {
+                        page.RefreshData();
+                    }
+                    return;
+                }
+            }
+        }
+
+        //鏇存柊PageTitle
+        private new void UpdatePageTitle(PageGuid pguid, PageTitle title)
+        {
+            if (pguid == null || title == null)
+                return;
+
+            if (this.dockManager1.Panels != null && this.dockManager1.Panels.Count > 0)
+            {
+                var panel = this.dockManager1.Panels.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == pguid.ToString());
+                if (panel != null)
+                {
+                    panel.Text = title.Caption;
+                    panel.ImageOptions.Image = title.HeaderImage;
+                    panel.ImageOptions.SvgImage = title.HeaderSvgImage;
+                    panel.ImageOptions.SvgImageSize = title.SvgImageSize;
+                    if (panel.ControlContainer.Controls.Count > 0)
+                    {
+                        var page = panel.ControlContainer.Controls[0] as DocumentPage;
+                        if (page != null)
+                        {
+                            page.PageTitle = title;
+                        }
+                    }
+                    return;
+                }
+            }
+
+            if (this.tabbedView1.Documents != null && this.tabbedView1.Documents.Count > 0)
+            {
+                var doc = this.tabbedView1.Documents.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == pguid.ToString());
+                if (doc != null)
+                {
+                    doc.Caption = title.Caption;
+                    doc.ImageOptions.Image = title.HeaderImage;
+                    doc.ImageOptions.SvgImage = title.HeaderSvgImage;
+                    doc.ImageOptions.SvgImageSize = title.SvgImageSize;
+                    var page = doc.Control as DocumentPage;
+                    if (page != null)
+                    {
+                        page.PageTitle = title;
+                    }
+                    return;
+                }
+            }
+        }
+
+        //鍒涘缓Page
+        private new bool CreatePage(DocumentPage page, PageGuid pguid)
+        {
+            if (page == null || pguid == null)
+            {
+                return false;
+            }
+            page.PageGuid = pguid;
+            page.Dock = DockStyle.Fill;
+            page.IsExistPageEvent += IsExistPage;
+            page.CreatePageEvent += CreatePage;
+            page.RefreshPageDataEvent += RefreshPageData;
+            page.UpdatePageTitleEvent += UpdatePageTitle;
+            page.ClosePageEvent += ClosePage;
+            page.RegistEvents();
+            switch (pguid.MoudingType)
+            {
+                case eMoudingType.Dock:
+                    {
+                        this.dockManager1.BeginUpdate();
+                        DockPanel docPnl = null;
+                        if (pguid.DockType == eDockType.Left)
+                        {
+                            docPnl = this.dockManager1.AddPanel(DockingStyle.Left);
+                        }
+                        else if (pguid.DockType == eDockType.Right)
+                        {
+                            docPnl = this.dockManager1.AddPanel(DockingStyle.Right);
+                        }
+
+                        docPnl.Footer = Directory.GetCurrentDirectory();
+                        if (page.PageTitle != null)
+                        {
+                            docPnl.Text = page.PageTitle.Caption;
+                            docPnl.ImageOptions.Image = page.PageTitle.HeaderImage;
+                            docPnl.ImageOptions.SvgImage = page.PageTitle.HeaderSvgImage;
+                            docPnl.ImageOptions.SvgImageSize = page.PageTitle.SvgImageSize;
+                            docPnl.Options.ShowCloseButton = page.PageTitle.AllowClose;
+                        }
+                        docPnl.ControlContainer.Controls.Add(page);
+                        docPnl.Tag = pguid;
+                        this.dockManager1.EndUpdate();
+                        docPnl.Show();
+                    }
+                    break;
+
+                case eMoudingType.Tab:
+                    {
+                        this.tabbedView1.BeginUpdate();
+                        var doc = this.tabbedView1.AddDocument(page);
+                        doc.Footer = Directory.GetCurrentDirectory();
+                        if (page.PageTitle != null)
+                        {
+                            doc.Caption = page.PageTitle.Caption;
+                            doc.ImageOptions.Image = page.PageTitle.HeaderImage;
+                            doc.ImageOptions.SvgImage = page.PageTitle.HeaderSvgImage;
+                            doc.ImageOptions.SvgImageSize = page.PageTitle.SvgImageSize;
+                            doc.Properties.AllowClose = page.PageTitle.AllowClose ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False;
+                        }
+                        doc.Tag = pguid;
+                        this.tabbedView1.EndUpdate();
+                        this.tabbedView1.Controller.Activate(doc);
+                    }
+                    break;
+
+                default: break;
+            }
+            page.InitialDataSource();
+            return true;
+        }
+
+        //鍏抽棴Page
+        private new void ClosePage(PageGuid pguid)
+        {
+            switch (pguid.MoudingType)
+            {
+                case eMoudingType.Dock:
+                    {
+                        if (this.dockManager1.Panels != null && this.dockManager1.Panels.Count > 0)
+                        {
+                            var panel = this.dockManager1.Panels.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == pguid.ToString());
+                            if (panel != null)
+                            {
+                                if (panel.Visibility != DockVisibility.Hidden)
+                                    panel.Close();//浼氳Е鍙戞鍦ㄥ叧闂拰鍏抽棴浜嬩欢
+                                                  //this.dockManager1.RemovePanel(panel);//涓嶄細瑙﹀彂姝e湪鍏抽棴鍜屽叧闂簨浠�
+                            }
+                        }
+                    }
+                    break;
+
+                case eMoudingType.Tab:
+                    {
+                        if (this.tabbedView1.Documents != null && this.tabbedView1.Documents.Count > 0)
+                        {
+                            var doc = this.tabbedView1.Documents.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == pguid.ToString());
+                            if (doc != null)
+                            {
+                                this.tabbedView1.Controller.Close(doc);//浼氳Е鍙戞鍦ㄥ叧闂拰鍏抽棴浜嬩欢
+                            }
+                        }
+                    }
+                    break;
+
+                default: break;
+            }
+        }
+
+        #endregion Page
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3