Shuxia Ning
2025-02-06 aac8f8fb4a9ec6b388117bd76f891195edfa7cab
Desktop/PBS.Desktop.Core/MainForm.cs
@@ -1,14 +1,11 @@
using DevExpress.Utils.Svg;
using DevExpress.XtraBars.Docking;
using DevExpress.XtraBars.Docking2010.Views;
using DevExpress.XtraBars.Navigation;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraEditors;
using DevExpress.XtraTab;
using DevExpress.XtraTab.ViewInfo;
using HStation.WinFrmUI;
using HStation.WinFrmUI.Assets;
using HStation.WinFrmUI.Xhs.PumpProduct;
using PBS.WinFrmUI.WE;
using PBS.Desktop;
using System.Drawing.Drawing2D;
using System.IO;
using Yw.WinFrmUI;
@@ -30,15 +27,22 @@
            this.accordionControlFunction.Appearance.AccordionControl.BackColor = Color.White;
            this.accordionControlFunction.Appearance.AccordionControl.BorderColor = Color.White;
            //this.accordionControlFunction.ResizeMode = AccordionControlResizeMode.None;
            this.accordionControlFunction.AllowHtmlText = true;
            this.accordionControlFunction.HtmlTemplates.HamburgerHeaderPanel.Template = @"<div class='hamburger-header-background'></div>";
            this.accordionControlFunction.HtmlTemplates.HamburgerHeaderPanel.Styles = @".hamburger-header-background {background-color: #ffffff; height: 100%;width: 100%;}";
            this.xtraTabContrl.AllowGlyphSkinning = DevExpress.Utils.DefaultBoolean.True;
        }
            this.tabbedView1.Style = DockingViewStyle.Classic;
            this.tabbedView1.Appearance.BackColor = Color.White;
            //this.tabbedView1.AppearancePage.Header.BackColor = Color.White;
            this.tabbedView1.AppearancePage.HeaderSelected.Font = new Font("微软雅黑", 10f, FontStyle.Bold);
        private HatchBrush myHatchBrush1 = new HatchBrush(HatchStyle.BackwardDiagonal, Color.LightGray, Color.AliceBlue);
           // this.tabbedView1.CustomDrawTabHeader += TabbedView1_CustomDrawTabHeader;
        }
        HatchBrush myHatchBrush1 = new HatchBrush(HatchStyle.BackwardDiagonal, Color.LightGray, Color.AliceBlue);
        private void TabbedView1_CustomDrawTabHeader(object sender, DevExpress.XtraTab.TabHeaderCustomDrawEventArgs e)
        {
            e.Cache.FillRectangle(myHatchBrush1, e.Bounds);
@@ -115,9 +119,9 @@
            if (btn.Tag is not string tag)
                return;
            PageGuid pguid = null;
            if (this.xtraTabContrl.SelectedTabPage != null)
            if (this.tabbedView1.ActiveDocument != null)
            {
                pguid = this.xtraTabContrl.SelectedTabPage.Tag as PageGuid;
                pguid = this.tabbedView1.ActiveDocument.Tag as PageGuid;
            }
            SelectModular(tag, pguid);
        }
@@ -181,26 +185,40 @@
        #region TabbedView 相关事件处理程序
        //选中
        private void xtraTabContrl_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
        private void tabbedView1_DocumentSelected(object sender, DocumentEventArgs e)
        {
            if (e.Page == null)
            if (e.Document == null)
                return;
            var pguid = e.Page.Tag as PageGuid;
            var pguid = e.Document.Tag as PageGuid;
            if (pguid == null)
                return;
            SelectModular(pguid.Modular, pguid);
        }
        //关闭
        private void xtraTabContrl_CloseButtonClick(object sender, EventArgs e)
        //添加
        private void tabbedView1_DocumentAdded(object sender, DocumentEventArgs e)
        {
            var arg = e as ClosePageButtonEventArgs;
            var last_index = this.xtraTabContrl.SelectedTabPageIndex - 1;
            this.xtraTabContrl.TabPages.Remove(arg.Page as XtraTabPage);
            if (last_index > 0)
            if (this.tabbedView1.Documents.Count > 1)
            {
                this.xtraTabContrl.SelectedTabPageIndex = last_index;
                if (!this.tabbedView1.DocumentGroupProperties.ShowTabHeader)
                {
                }
            }
        }
        //激活
        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 相关事件处理程序
@@ -235,9 +253,9 @@
                }
            }
            if (this.xtraTabContrl.TabPages != null && this.xtraTabContrl.TabPages.Count > 0)
            if (this.tabbedView1.Documents != null && this.tabbedView1.Documents.Count > 0)
            {
                foreach (XtraTabPage doc in this.xtraTabContrl.TabPages)
                foreach (BaseDocument doc in this.tabbedView1.Documents)
                {
                    if (doc.Tag != null)
                    {
@@ -247,7 +265,7 @@
                            {
                                if (isActivePage)
                                {
                                    this.xtraTabContrl.SelectedTabPage = doc;
                                    this.tabbedView1.Controller.Activate(doc);
                                }
                                return true;
                            }
@@ -283,12 +301,12 @@
                }
            }
            if (this.xtraTabContrl.TabPages != null && this.xtraTabContrl.TabPages.Count > 0)
            if (this.tabbedView1.Documents != null && this.tabbedView1.Documents.Count > 0)
            {
                var doc = this.xtraTabContrl.TabPages.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == pguid.ToString());
                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.Controls[0] as DocumentPage;
                    var page = doc.Control as DocumentPage;
                    if (page != null)
                    {
                        page.RefreshData();
@@ -325,16 +343,16 @@
                }
            }
            if (this.xtraTabContrl.TabPages != null && this.xtraTabContrl.TabPages.Count > 0)
            if (this.tabbedView1.Documents != null && this.tabbedView1.Documents.Count > 0)
            {
                var doc = this.xtraTabContrl.TabPages.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == pguid.ToString());
                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.Text = title.Caption;
                    doc.Caption = title.Caption;
                    doc.ImageOptions.Image = title.HeaderImage;
                    doc.ImageOptions.SvgImage = title.HeaderSvgImage;
                    doc.ImageOptions.SvgImageSize = title.SvgImageSize;
                    var page = doc.Controls[0] as DocumentPage;
                    var page = doc.Control as DocumentPage;
                    if (page != null)
                    {
                        page.PageTitle = title;
@@ -392,20 +410,20 @@
                case eMoudingType.Tab:
                    {
                        var sel_page = new XtraTabPage();
                        page.Dock = DockStyle.Fill;
                        sel_page.Controls.Add(page);
                        this.xtraTabContrl.TabPages.Add(sel_page);
                        this.tabbedView1.BeginUpdate();
                        var doc = this.tabbedView1.AddDocument(page);
                        doc.Footer = Directory.GetCurrentDirectory();
                        if (page.PageTitle != null)
                        {
                            sel_page.Text = page.PageTitle.Caption;
                            sel_page.ImageOptions.Image = page.PageTitle.HeaderImage;
                            sel_page.ImageOptions.SvgImage = page.PageTitle.HeaderSvgImage;
                            sel_page.ImageOptions.SvgImageSize = page.PageTitle.SvgImageSize;
                            //doc.Properties.AllowClose = page.PageTitle.AllowClose ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False;
                            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;
                        }
                        sel_page.Tag = pguid;
                        this.xtraTabContrl.SelectedTabPage = sel_page;
                        doc.Tag = pguid;
                        this.tabbedView1.EndUpdate();
                        this.tabbedView1.Controller.Activate(doc);
                    }
                    break;
@@ -437,12 +455,12 @@
                case eMoudingType.Tab:
                    {
                        if (this.xtraTabContrl.TabPages != null && this.xtraTabContrl.TabPages.Count > 0)
                        if (this.tabbedView1.Documents != null && this.tabbedView1.Documents.Count > 0)
                        {
                            var doc = this.xtraTabContrl.TabPages.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == pguid.ToString());
                            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.xtraTabContrl.TabPages.Remove(doc);
                                this.tabbedView1.Controller.Close(doc);//会触发正在关闭和关闭事件
                            }
                        }
                    }
@@ -564,6 +582,7 @@
            return false;
        }
        //获取
        private List<AccordionElement> GetAccordionElementList(string modular)
@@ -651,8 +670,6 @@
                        {
                            if (!IsExistPage(guid, true))
                            {
                                var page=new WaterUtensilMainPage();
                                CreatePage(page, guid);
                            }
                        }),
                        Get("用水当量",new PageGuid()
@@ -664,8 +681,6 @@
                        {
                            if (!IsExistPage(guid, true))
                            {
                                var page=new WaterWEMgr();
                                CreatePage(page, guid);
                            }
                        })
                    }
@@ -687,13 +702,13 @@
                        }, svgImgItem32[6], new Size(18, 18), (caption,guid,svg,size) =>
                        {
                            if (!IsExistPage(guid, true))
                            {
                             var page=new AssetsManufacturerMainPage();
                            {
                                var page = new DocumentPage();
                                page.PageGuid = guid;
                                page.PageTitle.Caption = caption;
                                page.PageTitle.HeaderSvgImage = svg;
                                page.PageTitle.SvgImageSize = size;
                                CreatePage(page,guid);
                                CreatePage(page, guid);
                            }
                        }),
                        Get("水泵管理",new PageGuid()
@@ -722,13 +737,7 @@
                        {
                            if (!IsExistPage(guid, true))
                            {
                                var page=new PackageManageMainPage();
                                page.PageGuid = guid;
                                page.PageTitle.Caption = caption;
                                page.PageTitle.HeaderSvgImage = svg;
                                page.PageTitle.SvgImageSize = size;
                                CreatePage(page,guid);
                             }
                            }
                        })
                    }
                };