duheng
2024-07-18 7bf79c6515f27ba9be8d2b3fb4e3ceae5718e3e5
Desktop/HStation.DeskTop.Xhs.Main/GuideMain.cs
@@ -12,6 +12,7 @@
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Yw.WinFrmUI;
namespace HStation.Desktop
{
@@ -160,16 +161,16 @@
        /// </summary>
        private void barBtnProject_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var guid = new SurfaceGuid()
            var guid = new PageGuid()
            {
                Function = "项目管理",
                Modular = eModular.Basic
                Modular = ""
            };
            if (!IsExistPage(guid, true))
            {
                var page = new XhsProjectMainPanel();
                page.PageTitle.Caption = guid.Function;
                page.SurfaceGuid = guid;
                page.PageGuid = guid;
                CreatePage(page, guid);
            }
        }
@@ -179,16 +180,16 @@
        /// </summary>
        private void barBtnPumpManage_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var guid = new SurfaceGuid()
            var guid = new PageGuid()
            {
                Function = "泵管理",
                Modular = eModular.Basic
                Modular = ""
            };
            if (!IsExistPage(guid, true))
            {
                var page = new PumpProductMainPanel();
                page.PageTitle.Caption = guid.Function;
                page.SurfaceGuid = guid;
                page.PageGuid = guid;
                CreatePage(page, guid);
            }
        }
@@ -198,16 +199,16 @@
        /// </summary>
        private void barButtonTypeManage_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var guid = new SurfaceGuid()
            var guid = new PageGuid()
            {
                Function = "类型管理",
                Modular = eModular.Basic
                Modular = ""
            };
            if (!IsExistPage(guid, true))
            {
                var page = new SysTypeManageMainPanel();
                page.PageTitle.Caption = guid.Function;
                page.SurfaceGuid = guid;
                page.PageGuid = guid;
                CreatePage(page, guid);
            }
        }
@@ -217,16 +218,16 @@
        /// </summary>
        private void BtnCatlogManage_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var guid = new SurfaceGuid()
            var guid = new PageGuid()
            {
                Function = "分类管理",
                Modular = eModular.Basic
                Modular = ""
            };
            if (!IsExistPage(guid, true))
            {
                var page = new SysCatalogManageMainPanel();
                page.PageTitle.Caption = guid.Function;
                page.SurfaceGuid = guid;
                page.PageGuid = guid;
                CreatePage(page, guid);
            }
        }
@@ -236,16 +237,16 @@
        /// </summary>
        private void BtnPropManage_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var guid = new SurfaceGuid()
            var guid = new PageGuid()
            {
                Function = "属性管理",
                Modular = eModular.Basic
                Modular = ""
            };
            if (!IsExistPage(guid, true))
            {
                var page = new SysPropManageMainPanel();
                page.PageTitle.Caption = guid.Function;
                page.SurfaceGuid = guid;
                page.PageGuid = guid;
                CreatePage(page, guid);
            }
        }
@@ -335,7 +336,7 @@
        }
        //是否存在Page
        private bool IsExistPage(WinFrmUI.SurfaceGuid sguid, bool isActivateDoc)
        private bool IsExistPage(PageGuid sguid, bool isActivateDoc)
        {
            if (sguid == null)
                return false;
@@ -346,9 +347,9 @@
                {
                    if (doc.Tag != null)
                    {
                        if (doc.Tag is WinFrmUI.SurfaceGuid)
                        if (doc.Tag is PageGuid)
                        {
                            if ((doc.Tag as WinFrmUI.SurfaceGuid).ToString() == sguid.ToString())
                            if ((doc.Tag as PageGuid).ToString() == sguid.ToString())
                            {
                                if (isActivateDoc)
                                    this.tabbedView1.Controller.Activate(doc);
@@ -363,19 +364,19 @@
        }
        //更新数据
        private void RefreshPageData(WinFrmUI.SurfaceGuid sguid)
        private void RefreshPageData(PageGuid sguid)
        {
            if (sguid == null)
                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 WinFrmUI.SurfaceGuid && (x.Tag as WinFrmUI.SurfaceGuid).ToString() == sguid.ToString());
                var doc = this.tabbedView1.Documents.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == sguid.ToString());
                if (doc != null)
                {
                    if (doc.Control is WinFrmUI.DocumentPage page)
                    if (doc.Control is DocumentPage page)
                    {
                        page.RefreshDataSource();
                        page.RefreshData();
                    }
                    return;
                }
@@ -383,21 +384,21 @@
        }
        //更新PageTitle
        private void UpdatePageTitle(WinFrmUI.SurfaceGuid sguid, WinFrmUI.PageTitle title)
        private void UpdatePageTitle(PageGuid sguid, PageTitle title)
        {
            if (sguid == null || title == null)
                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 WinFrmUI.SurfaceGuid && (x.Tag as WinFrmUI.SurfaceGuid).ToString() == sguid.ToString());
                var doc = this.tabbedView1.Documents.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == sguid.ToString());
                if (doc != null)
                {
                    doc.Caption = title.Caption;
                    doc.ImageOptions.Image = title.HeaderImage;
                    doc.ImageOptions.SvgImage = title.HeaderSvgImage;
                    doc.ImageOptions.SvgImageSize = title.SvgImageSize;
                    if (doc.Control is WinFrmUI.DocumentPage page)
                    if (doc.Control is DocumentPage page)
                    {
                        page.PageTitle = title;
                    }
@@ -407,11 +408,11 @@
        }
        //创建Page
        private bool CreatePage(WinFrmUI.DocumentPage page, WinFrmUI.SurfaceGuid sguid)
        private bool CreatePage(DocumentPage page, PageGuid sguid)
        {
            if (page == null || sguid == null)
                return false;
            page.SurfaceGuid = sguid;
            page.PageGuid = sguid;
            page.Dock = DockStyle.Fill;
            page.IsExistPageEvent += IsExistPage;
            page.CreatePageEvent += CreatePage;
@@ -434,7 +435,7 @@
            }
            else
            {
                doc.Caption = page.SurfaceGuid?.Function;
                doc.Caption = page.PageGuid?.Function;
            }
            doc.Tag = sguid;
            this.tabbedView1.EndUpdate();
@@ -446,21 +447,21 @@
        }
        //关闭Page
        private void ClosePage(WinFrmUI.SurfaceGuid sguid)
        private void ClosePage(PageGuid sguid)
        {
            if (this.tabbedView1.Documents != null && this.tabbedView1.Documents.Count > 0)
            {
                var doc = this.tabbedView1.Documents.ToList().Find(x => x.Tag != null && x.Tag is WinFrmUI.SurfaceGuid && (x.Tag as WinFrmUI.SurfaceGuid).ToString() == sguid.ToString());
                var doc = this.tabbedView1.Documents.ToList().Find(x => x.Tag != null && x.Tag is PageGuid && (x.Tag as PageGuid).ToString() == sguid.ToString());
                if (doc != null)
                {
                    var page = doc.Control as WinFrmUI.DocumentPage;
                    var page = doc.Control as DocumentPage;
                    this.tabbedView1.Controller.Close(doc);//会触发正在关闭和关闭事件
                }
            }
        }
        //查找page
        private WinFrmUI.DocumentPage FindPage(WinFrmUI.SurfaceGuid sguid, bool isActiveDoc)
        private DocumentPage FindPage(PageGuid sguid, bool isActiveDoc)
        {
            if (sguid == null)
                return default;
@@ -473,7 +474,7 @@
                {
                    if (isActiveDoc)
                        this.tabbedView1.Controller.Activate(doc);
                    if (doc.Control is WinFrmUI.DocumentPage page)
                    if (doc.Control is DocumentPage page)
                    {
                        return page;
                    }
@@ -491,16 +492,16 @@
        private void GuideMain_Load(object sender, EventArgs e)
        {
            var guid = new SurfaceGuid()
            var guid = new PageGuid()
            {
                Function = "项目总览",
                Modular = eModular.Basic
                Modular = ""
            };
            if (!IsExistPage(guid, true))
            {
                var page = new HomePageMainPanel();
                page.PageTitle.Caption = guid.Function;
                page.SurfaceGuid = guid;
                page.PageGuid = guid;
                CreatePage(page, guid);
            }
        }