duheng
2024-11-27 5d8b95b69c1bf800f2a2ebee62c6f7181c0bd7c8
Desktop/HStation.Desktop.PBS.Core/MainForm.cs
@@ -4,11 +4,10 @@
using DevExpress.XtraBars.Navigation;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraEditors;
using HStation.WinFrmUI;
using HStation.WinFrmUI.Assets;
using HStation.WinFrmUI.Basic;
using HStation.WinFrmUI.PBS;
using DevExpress.XtraTab;
using DevExpress.XtraTab.ViewInfo;
using HStation.WinFrmUI.Xhs.PumpProduct;
using System.Drawing.Drawing2D;
using System.IO;
using Yw.WinFrmUI;
using Yw.WinFrmUI.Page;
@@ -29,28 +28,21 @@
            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.tabbedView1.Style = DockingViewStyle.Classic;
            this.tabbedView1.Appearance.BackColor = Color.White;
            //this.tabbedView1.AppearancePage.Header.BackColor = Color.White;
            this.xtraTabContrl.AllowGlyphSkinning = DevExpress.Utils.DefaultBoolean.True;
        }
        HatchBrush myHatchBrush1 = new HatchBrush(HatchStyle.BackwardDiagonal, Color.LightGray, Color.AliceBlue);
        private void TabbedView1_CustomDrawTabHeader(object sender, DevExpress.XtraTab.TabHeaderCustomDrawEventArgs e)
        {
            // 阻止默认绘制
            e.Handled = true;
            // 设置圆角为0,去除圆角效果
            //e.Cache.RoundRect = false;
            // 使用默认绘制方法绘制其他元素,如背景、文本和按钮
            e.DefaultDrawBackground();
            e.Cache.FillRectangle(myHatchBrush1, e.Bounds);
            e.DefaultDrawText();
            e.DefaultDrawImage();
            e.DefaultDrawButtons();
            e.Handled = true;
        }
        #region TileNavPane 相关处理
@@ -120,9 +112,9 @@
            if (btn.Tag is not string tag)
                return;
            PageGuid pguid = null;
            if (this.tabbedView1.ActiveDocument != null)
            if (this.xtraTabContrl.SelectedTabPage != null)
            {
                pguid = this.tabbedView1.ActiveDocument.Tag as PageGuid;
                pguid = this.xtraTabContrl.SelectedTabPage.Tag as PageGuid;
            }
            SelectModular(tag, pguid);
        }
@@ -148,6 +140,8 @@
            //if (!IsExistPage(guid, true))
            //{
            //}
            SelectModular("BasicData");
        }
        //界面正在退出时确认
@@ -184,40 +178,26 @@
        #region TabbedView 相关事件处理程序
        //选中
        private void tabbedView1_DocumentSelected(object sender, DocumentEventArgs e)
        private void xtraTabContrl_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
        {
            if (e.Document == null)
            if (e.Page == null)
                return;
            var pguid = e.Document.Tag as PageGuid;
            var pguid = e.Page.Tag as PageGuid;
            if (pguid == null)
                return;
            SelectModular(pguid.Modular, pguid);
        }
        //添加
        private void tabbedView1_DocumentAdded(object sender, DocumentEventArgs e)
        //关闭
        private void xtraTabContrl_CloseButtonClick(object sender, EventArgs e)
        {
            if (this.tabbedView1.Documents.Count > 1)
            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.DocumentGroupProperties.ShowTabHeader)
                {
                }
                this.xtraTabContrl.SelectedTabPageIndex = last_index;
            }
        }
        //激活
        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 相关事件处理程序
@@ -252,9 +232,9 @@
                }
            }
            if (this.tabbedView1.Documents != null && this.tabbedView1.Documents.Count > 0)
            if (this.xtraTabContrl.TabPages != null && this.xtraTabContrl.TabPages.Count > 0)
            {
                foreach (BaseDocument doc in this.tabbedView1.Documents)
                foreach (XtraTabPage doc in this.xtraTabContrl.TabPages)
                {
                    if (doc.Tag != null)
                    {
@@ -264,7 +244,7 @@
                            {
                                if (isActivePage)
                                {
                                    this.tabbedView1.Controller.Activate(doc);
                                    this.xtraTabContrl.SelectedTabPage = doc;
                                }
                                return true;
                            }
@@ -300,12 +280,12 @@
                }
            }
            if (this.tabbedView1.Documents != null && this.tabbedView1.Documents.Count > 0)
            if (this.xtraTabContrl.TabPages != null && this.xtraTabContrl.TabPages.Count > 0)
            {
                var doc = this.tabbedView1.Documents.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == pguid.ToString());
                var doc = this.xtraTabContrl.TabPages.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;
                    var page = doc.Controls[0] as DocumentPage;
                    if (page != null)
                    {
                        page.RefreshData();
@@ -342,16 +322,16 @@
                }
            }
            if (this.tabbedView1.Documents != null && this.tabbedView1.Documents.Count > 0)
            if (this.xtraTabContrl.TabPages != null && this.xtraTabContrl.TabPages.Count > 0)
            {
                var doc = this.tabbedView1.Documents.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == pguid.ToString());
                var doc = this.xtraTabContrl.TabPages.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.Text = title.Caption;
                    doc.ImageOptions.Image = title.HeaderImage;
                    doc.ImageOptions.SvgImage = title.HeaderSvgImage;
                    doc.ImageOptions.SvgImageSize = title.SvgImageSize;
                    var page = doc.Control as DocumentPage;
                    var page = doc.Controls[0] as DocumentPage;
                    if (page != null)
                    {
                        page.PageTitle = title;
@@ -409,20 +389,20 @@
                case eMoudingType.Tab:
                    {
                        this.tabbedView1.BeginUpdate();
                        var doc = this.tabbedView1.AddDocument(page);
                        doc.Footer = Directory.GetCurrentDirectory();
                        var sel_page = new XtraTabPage();
                        page.Dock = DockStyle.Fill;
                        sel_page.Controls.Add(page);
                        this.xtraTabContrl.TabPages.Add(sel_page);
                        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;
                            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.Tag = pguid;
                        this.tabbedView1.EndUpdate();
                        this.tabbedView1.Controller.Activate(doc);
                        sel_page.Tag = pguid;
                        this.xtraTabContrl.SelectedTabPage = sel_page;
                    }
                    break;
@@ -454,12 +434,12 @@
                case eMoudingType.Tab:
                    {
                        if (this.tabbedView1.Documents != null && this.tabbedView1.Documents.Count > 0)
                        if (this.xtraTabContrl.TabPages != null && this.xtraTabContrl.TabPages.Count > 0)
                        {
                            var doc = this.tabbedView1.Documents.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == pguid.ToString());
                            var doc = this.xtraTabContrl.TabPages.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);//会触发正在关闭和关闭事件
                                this.xtraTabContrl.TabPages.Remove(doc);
                            }
                        }
                    }
@@ -488,7 +468,7 @@
                    {
                        if (tag == modular)
                        {
                            btn.Appearance.BackColor = Color.FromArgb(1, 96, 188);
                            btn.Appearance.BackColor = Color.FromArgb(50, 121, 197);
                            btn.Appearance.ForeColor = Color.White;
                        }
                        else
@@ -501,7 +481,7 @@
                //初始功能列表
                this.accordionControlFunction.Elements.Clear();
                var list = GetAccordionElementList1(modular);
                var list = GetAccordionElementList(modular);
                if (list != null && list.Count > 0)
                {
                    foreach (var element in list)
@@ -582,356 +562,9 @@
            return false;
        }
        //获取
        private List<AccordionElement> GetAccordionElementList(string modular)
        {
            var list = new List<AccordionElement>();
            if (modular == "BasicData")
            {
                var place_mgr_ele = new AccordionElement()
                {
                    Id = "place",
                    Caption = "场所管理",
                    SvgImage = svgImgGroup32[0],
                    SvgImageSize = new Size(24, 24),
                    AllowGlyphSkinning = true,
                    PageGuid = new PageGuid()
                    {
                        Modular = "BasicData",
                        MoudingType = eMoudingType.Tab,
                        Function = "DistrictMgr",
                    },
                    Elements = new List<AccordionElement>() {
                        new()
                        {
                            Caption="行政区域",
                            SvgImage=svgImgItem32[0],
                            SvgImageSize=new Size(18,18),
                            AllowGlyphSkinning=true,
                            Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="DistrictMgr",
                                };
                                if(!IsExistPage(guid,true))
                                {
                                    var test=new DocumentPage();
                                    test.PageGuid=guid;
                                    test.PageTitle.Caption="行政区域";
                                    test.PageTitle.HeaderSvgImage=svgImgItem32[0];
                                    test.PageTitle.SvgImageSize=new Size(18,18);
                                    CreatePage(test,guid);
                                }
                            },
                        },
                        new (){
                            Caption="场所建筑",
                            SvgImage=svgImgItem32[1],
                            SvgImageSize=new Size(18,18),
                            AllowGlyphSkinning=true,
                            Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="PlaceMgr",
                                };
                                if(!IsExistPage(guid,true))
                                {
                                    var test=new PlaceMgrPage();
                                    test.PageGuid=guid;
                                    test.PageTitle.Caption="场所建筑";
                                    test.PageTitle.HeaderSvgImage=svgImgItem32[1];
                                    test.PageTitle.SvgImageSize=new Size(18,18);
                                    CreatePage(test,guid);
                                }
                            }
                        },
                        new (){
                            Caption="场所设施",
                            SvgImage=svgImgItem32[2],
                            SvgImageSize=new Size(18,18),
                            AllowGlyphSkinning=true,
                            Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="FacilityMgr",
                                };
                                if(!IsExistPage(guid,true))
                                {
                                    var test=new DocumentPage();
                                    test.PageGuid=guid;
                                    test.PageTitle.Caption="场所设施";
                                    test.PageTitle.HeaderSvgImage=svgImgItem32[2];
                                    test.PageTitle.SvgImageSize=new Size(18,18);
                                    CreatePage(test,guid);
                                }
                            }
                        }
                    }
                };
                var we_mgr_ele = new AccordionElement()
                {
                    Id = "we",
                    Caption = "当量管理",
                    SvgImage = svgImgGroup32[1],
                    SvgImageSize = new Size(24, 24),
                    AllowGlyphSkinning = true,
                    Elements = new List<AccordionElement>() {
                        new()
                        {
                            Caption="用水器具",
                            SvgImage=svgImgItem32[4],
                            SvgImageSize=new Size(18,18),
                            AllowGlyphSkinning=true,
                            Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="WaterUtensilMgr",
                                };
                                if(!IsExistPage(guid,true))
                                {
                                }
                            }
                        },
                        new (){
                            Caption="用水当量",
                            SvgImage=svgImgItem32[5],
                            SvgImageSize=new Size(18,18),
                            AllowGlyphSkinning=true,
                            Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="WaterWEMgr",
                                };
                                if(!IsExistPage(guid,true))
                                {
                                }
                            }
                        }
                    }
                };
                var asset_mgr_ele = new AccordionElement()
                {
                    Id = "asset",
                    Caption = "产品管理",
                    SvgImage = svgImgGroup32[2],
                    SvgImageSize = new Size(24, 24),
                    AllowGlyphSkinning = true,
                    Elements = new List<AccordionElement>() {
                        new (){
                            Caption="厂商管理",
                            SvgImage=svgImgItem32[6],
                            SvgImageSize=new Size(18,18),
                            AllowGlyphSkinning=true,
                            Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="AssetsManufacturerMgr",
                                };
                                if(!IsExistPage(guid,true))
                                {
                                    var page=new AssetsManufacturerMainPage();
                                    CreatePage(page,guid);
                                 }
                            }
                        },
                        new (){
                            Caption="水泵管理",
                            SvgImage=svgImgItem32[7],
                            SvgImageSize=new Size(18,18),
                            AllowGlyphSkinning=true,
                            Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="AssetsPumpMgr",
                                };
                                if(!IsExistPage(guid,true))
                                {
                                     var page=new PumpProductMainPage();
                                    CreatePage(page,guid);
                                }
                            }
                        },
                        new (){
                            Caption="成套设备",
                            SvgImage=svgImgItem32[8],
                            SvgImageSize=new Size(18,18),
                            AllowGlyphSkinning = true,
                            Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="AssetsKitMgr",
                                };
                                if(!IsExistPage(guid,true))
                                {
                                    var page=new PackageManageMainPage();
                                    CreatePage(page,guid);
                                }
                            }
                        }
                    }
                };
                var system_config_ele = new AccordionElement()
                {
                    Id = "asset",
                    Caption = "系统配置",
                    SvgImage = svgImgGroup32[3],
                    SvgImageSize = new Size(24, 24),
                    AllowGlyphSkinning = true,
                    Elements = new List<AccordionElement>() {
                       new (){
                       Caption="类型管理",
                       SvgImage=svgImgItem32[9],
                       SvgImageSize=new Size(18,18),
                       AllowGlyphSkinning=true,
                       Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="SystemTypeMgr",
                                };
                                if(!IsExistPage(guid,true))
                                {
                                }
                            }
                       },
                          new (){
                            Caption="分类管理",
                            SvgImage=svgImgItem32[10],
                            SvgImageSize=new Size(18,18),
                            AllowGlyphSkinning=true,
                            Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="SystemCatalogMgr",
                                };
                                if(!IsExistPage(guid,true))
                                {
                                    var page=new SysCatalogManageMainPanel();
                                    CreatePage(page,guid);
                                }
                            }
                         },      new (){
                            Caption="属性管理",
                            SvgImage=svgImgItem32[11],
                            SvgImageSize=new Size(18,18),
                            AllowGlyphSkinning=true,
                            Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="SystemPropMgr",
                                };
                                if(!IsExistPage(guid,true))
                                {
                                      var page=new SysPropManageMainPanel();
                                    CreatePage(page,guid);
                                }
                            }
                         },
                        new (){
                            Caption="字典类型",
                            SvgImage=svgImgItem32[12],
                            SvgImageSize=new Size(18,18),
                            AllowGlyphSkinning=true,
                            Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="SystemDictMgr",
                                };
                                if(!IsExistPage(guid,true))
                                {
                                    var page=new HStation.WinFrmUI.Dict.DictManageMainPanel();
                                    CreatePage(page,guid);
                                }
                            }
                        }
                     }
                };
                var auth_config_ele = new AccordionElement()
                {
                    Id = "asset",
                    Caption = "权限配置",
                    SvgImage = svgImgGroup32[4],
                    SvgImageSize = new Size(24, 24),
                    AllowGlyphSkinning = true,
                    Elements = new List<AccordionElement>() {
                        new (){
                            Caption="角色管理",
                            SvgImage=svgImgItem32[13],
                            SvgImageSize=new Size(18,18),
                            AllowGlyphSkinning=true,
                            Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="RoleMgr",
                                 };
                                if(!IsExistPage(guid,true))
                                {
                                }
                            }
                        },
                        new (){
                            Caption="用户管理",
                            SvgImage=svgImgItem32[14],
                            SvgImageSize=new Size(18,18),
                            AllowGlyphSkinning=true,
                            Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="UserMgr",
                                };
                                if(!IsExistPage(guid,true))
                                {
                                }
                            }
                        },
                        new (){
                            Caption="菜单管理",
                            SvgImage=svgImgItem32[15],
                            SvgImageSize=new Size(18,18),
                            AllowGlyphSkinning=true,
                            Click=()=>{
                                var guid=new PageGuid(){
                                    Modular="BasicData",
                                    MoudingType=eMoudingType.Tab,
                                    Function="MenuMgr",
                                };
                                if(!IsExistPage(guid,true))
                                {
                                }
                            }
                        },
                    }
                };
                list.Add(place_mgr_ele);
                list.Add(we_mgr_ele);
                list.Add(asset_mgr_ele);
                list.Add(system_config_ele);
                list.Add(auth_config_ele);
            }
            return list;
        }
        //获取
        private List<AccordionElement> GetAccordionElementList1(string modular)
        {
            var list = new List<AccordionElement>();
            if (modular == "BasicData")
@@ -1049,6 +682,12 @@
                        {
                            if (!IsExistPage(guid, true))
                            {
                                var page = new DocumentPage();
                                page.PageGuid = guid;
                                page.PageTitle.Caption = caption;
                                page.PageTitle.HeaderSvgImage = svg;
                                page.PageTitle.SvgImageSize = size;
                                CreatePage(page, guid);
                            }
                        }),
                        Get("水泵管理",new PageGuid()
@@ -1061,7 +700,11 @@
                            if (!IsExistPage(guid, true))
                            {
                                var page=new PumpProductMainPage();
                                    CreatePage(page,guid);
                                page.PageGuid = guid;
                                page.PageTitle.Caption = caption;
                                page.PageTitle.HeaderSvgImage = svg;
                                page.PageTitle.SvgImageSize = size;
                                CreatePage(page,guid);
                            }
                        }),
                        Get("成套设备",new PageGuid()
@@ -1207,5 +850,8 @@
        }
        #endregion Modular
    }
}