using DevExpress.CodeParser; using DevExpress.Utils; using DevExpress.XtraBars.Docking; using DevExpress.XtraBars.Docking2010.Views; using DevExpress.XtraBars.Navigation; using DevExpress.XtraBars.Ribbon; using DevExpress.XtraEditors; using HStation.WinFrmUI; using HStation.WinFrmUI.Basic; using HStation.WinFrmUI.Xhs.PumpProduct; using System.IO; using Yw.WinFrmUI; using Yw.WinFrmUI.Page; using static DevExpress.XtraPrinting.BarCode.DataBarExpandedPatternProcessor; namespace HStation.Desktop { public partial class MainForm : RibbonForm { public MainForm() { InitializeComponent(); } #region TileNavPane Ïà¹Ø´¦Àí //×î´ó»¯×îС»¯´°Ìå private void nbNormal_ElementClick(object sender, NavElementEventArgs e) { if (this.WindowState == FormWindowState.Maximized) { this.WindowState = FormWindowState.Normal; } else { this.WindowState = FormWindowState.Maximized; } } //×îС»¯´°Ìå private void nbMin_ElementClick(object sender, NavElementEventArgs e) { this.WindowState = FormWindowState.Minimized; } //¹Ø±Õ´°Ìå private void nabClose_ElementClick(object sender, NavElementEventArgs e) { this.Close(); } //ÒÆ¶¯´°Ìå private void tileNavPane_MouseDown(object sender, MouseEventArgs e) { if (e.Clicks >= 2) { if (this.WindowState == FormWindowState.Maximized) { this.WindowState = FormWindowState.Normal; } else { this.WindowState = FormWindowState.Maximized; } } else { var hitInfo = this.tileNavPane.CalcHitInfo(e.Location); if (hitInfo.InButton) { return; } this.DragMove(); } } //¹¦Äܵã»÷ʼþ private void tileNavPane_ElementClick(object sender, NavElementEventArgs e) { var item = e.Element as NavButton; if (item.Tag != null) { if (item.Tag is string) { } } } //Ê×Ò³ private void nbTitle_ElementClick(object sender, NavElementEventArgs e) { var guid = new PageGuid() { Modular = "Xhs", MoudingType = eMoudingType.Tab, Function = "Home" }; if (!IsExistPage(guid, true)) { var page = new HomeXhsProjectPage(); CreatePage(page, guid); } } //ÏîÄ¿¹ÜÀí private void nbProjectMgr_ElementClick(object sender, NavElementEventArgs e) { var guid = new PageGuid() { Modular = "Xhs", MoudingType = eMoudingType.Tab, Function = "ProjectMgr", }; if (!IsExistPage(guid, true)) { var page = new XhsProjectMgrPage(); CreatePage(page, guid); } } //Ä£Ð͹ÜÀí private void nbBimfaceMgr_ElementClick(object sender, NavElementEventArgs e) { var pt = this.tileNavPane.PointToClient(MousePosition); var hitInfo = this.tileNavPane.CalcHitInfo(pt); if (hitInfo.ButtonInfo != null) { if (_bimfaceMgrBeakCtrl == null) { var peakItemList = new List() { new TilePeekItem(){ Caption="Îļþ¹ÜÀí", SvgImage=svgImg32[0], SvgImageSize=new Size(24,24), Click=()=>{ this.flyoutPanel1.HideBeakForm(); var guid=new PageGuid(){ Modular="Bimface", MoudingType=eMoudingType.Tab, Function="fileMgr", }; if(!IsExistPage(guid,true)) { var page=new Yw.WinFrmUI.BimfaceFileMgrPage(); CreatePage(page,guid); } } } }; _bimfaceMgrBeakCtrl = peakItemList.CreatePeekCtrl(); } this.flyoutPanel1.Size = _bimfaceMgrBeakCtrl.Size; this.flyoutPanelControl1.Controls.Clear(); this.flyoutPanelControl1.Controls.Add(_bimfaceMgrBeakCtrl); var rectangle = this.RectangleToScreen(hitInfo.ButtonInfo.Bounds); this.flyoutPanel1.ShowBeakForm(rectangle); } } private Control _bimfaceMgrBeakCtrl = null;//bimface¹ÜÀíµ¯³ö½çÃæ //ϵͳÅäÖà private void nbSystemConfig_ElementClick(object sender, NavElementEventArgs e) { var pt = this.tileNavPane.PointToClient(MousePosition); var hitInfo = this.tileNavPane.CalcHitInfo(pt); if (hitInfo.ButtonInfo != null) { if (_SystemConfigBeakCtrl == null) { var peakItemList = new List() { new TilePeekItem(){ Caption="Ë®±Ã¹ÜÀí", SvgImage=svgImg32[0], SvgImageSize=new Size(24,24), Click=()=>{ this.flyoutPanel1.HideBeakForm(); var guid=new PageGuid(){ Modular="Asstes", MoudingType=eMoudingType.Tab, Function="pumpMgr", }; if(!IsExistPage(guid,true)) { var page=new PumpProductMainPanel(); CreatePage(page,guid); } } }, new TilePeekItem(){ Caption="ÀàÐ͹ÜÀí", SvgImage=svgImg32[0], SvgImageSize=new Size(24,24), Click=()=>{ this.flyoutPanel1.HideBeakForm(); var guid=new PageGuid(){ Modular="Basic", MoudingType=eMoudingType.Tab, Function="TypeMgr", }; if(!IsExistPage(guid,true)) { var page=new SysTypeManageMainPanel(); CreatePage(page,guid); } } }, new TilePeekItem(){ Caption="·ÖÀà¹ÜÀí", SvgImage=svgImg32[0], SvgImageSize=new Size(24,24), Click=()=>{ this.flyoutPanel1.HideBeakForm(); var guid=new PageGuid(){ Modular="Basic", MoudingType=eMoudingType.Tab, Function="CataLogMgr", }; if(!IsExistPage(guid,true)) { var page=new SysCatalogManageMainPanel(); CreatePage(page,guid); } } }, new TilePeekItem(){ Caption="ÊôÐÔ¹ÜÀí", SvgImage=svgImg32[0], SvgImageSize=new Size(24,24), Click=()=>{ this.flyoutPanel1.HideBeakForm(); var guid=new PageGuid(){ Modular="Basic", MoudingType=eMoudingType.Tab, Function="PropMgr", }; if(!IsExistPage(guid,true)) { var page=new SysPropManageMainPanel(); CreatePage(page,guid); } } } }; _SystemConfigBeakCtrl = peakItemList.CreatePeekCtrl(); } this.flyoutPanel1.Size = _SystemConfigBeakCtrl.Size; this.flyoutPanelControl1.Controls.Clear(); this.flyoutPanelControl1.Controls.Add(_SystemConfigBeakCtrl); var rectangle = this.RectangleToScreen(hitInfo.ButtonInfo.Bounds); this.flyoutPanel1.ShowBeakForm(rectangle); } } private Control _SystemConfigBeakCtrl = null;//ϵͳÅäÖõ¯³ö½çÃæ #endregion TileNavPane Ïà¹Ø´¦Àí #region ´°Ìåʼþ //½çÃæ¼ÇÔØÊ¼þ private void MainForm_Load(object sender, EventArgs e) { } //½çÃæÏÔʾʼþ private void MainForm_Shown(object sender, EventArgs e) { var guid = new PageGuid() { Modular = "Xhs", MoudingType = eMoudingType.Tab, Function = "Home" }; if (!IsExistPage(guid, true)) { var page = new HomeXhsProjectPage(); CreatePage(page, guid); } } //½çÃæÕýÔÚÍ˳öʱȷÈÏ private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { if (XtraMessageBox.Show("ÊÇ·ñ¹Ø±Õ³ÌÐò£¿", "Ìáʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) { e.Cancel = true; return; } } } //½çÃæÍ˳ö private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { } //´°Ìå³ß´ç¸Ä±ä private void MainForm_Resize(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Maximized) { } else { } } #endregion ´°Ìåʼþ #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; SelectModular(surfaceGuid.Modular, surfaceGuid); } //Ìí¼Ó 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 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 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 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 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 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);//²»»á´¥·¢ÕýÔڹرպ͹رÕʼþ } } } 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 #region Modular //Ñ¡ÔñÄ£¿é private void SelectModular(string modular, PageGuid pageGuid = null) { //foreach (NavButton item in this.tileNavPane.Buttons) //{ // if (item.Tag == null) // continue; // if (item.Tag is int) // { // if (((int)item.Tag) == (int)modular) // { // item.Appearance.BackColor = Color.FromArgb(255, 128, 0); // } // else // { // item.Appearance.BackColor = Color.Transparent; // } // } //} //this.docPnlFuncList.Text = modular.ToString(); //this.funcTreeListCtrl1.SetBindingData(modular, surfaceGuid); //if (surfaceGuid == null) //{ // var func = this.funcTreeListCtrl1.SetDefault(); // if (func != null) // CreateFuncPage(func); //} } #endregion Modular } }