| | |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Windows.Forms; |
| | | using Yw.WinFrmUI; |
| | | |
| | | namespace HStation.Desktop |
| | | { |
| | |
| | | /// </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); |
| | | } |
| | | } |
| | |
| | | /// </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); |
| | | } |
| | | } |
| | |
| | | /// </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); |
| | | } |
| | | } |
| | |
| | | /// </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); |
| | | } |
| | | } |
| | |
| | | /// </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); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | //是否存在Page |
| | | private bool IsExistPage(WinFrmUI.SurfaceGuid sguid, bool isActivateDoc) |
| | | private bool IsExistPage(PageGuid sguid, bool isActivateDoc) |
| | | { |
| | | if (sguid == null) |
| | | return false; |
| | |
| | | { |
| | | 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); |
| | |
| | | } |
| | | |
| | | //更新数据 |
| | | 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; |
| | | } |
| | |
| | | } |
| | | |
| | | //更新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; |
| | | } |
| | |
| | | } |
| | | |
| | | //创建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; |
| | |
| | | } |
| | | else |
| | | { |
| | | doc.Caption = page.SurfaceGuid?.Function; |
| | | doc.Caption = page.PageGuid?.Function; |
| | | } |
| | | doc.Tag = sguid; |
| | | this.tabbedView1.EndUpdate(); |
| | |
| | | } |
| | | |
| | | //关闭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; |
| | |
| | | { |
| | | if (isActiveDoc) |
| | | this.tabbedView1.Controller.Activate(doc); |
| | | if (doc.Control is WinFrmUI.DocumentPage page) |
| | | if (doc.Control is DocumentPage page) |
| | | { |
| | | return page; |
| | | } |
| | |
| | | |
| | | 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); |
| | | } |
| | | } |