using DevExpress.XtraBars.Docking;
|
using DevExpress.XtraBars.Docking2010.Views;
|
using DevExpress.XtraBars.Navigation;
|
using DevExpress.XtraBars.Ribbon;
|
using DevExpress.XtraEditors;
|
using HStation.WinFrmUI;
|
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 int)
|
{
|
// var modular = (eModular)(int)item.Tag;
|
// SelectModular(modular, null);
|
}
|
}
|
}
|
|
|
#endregion
|
|
#region ´°Ìåʼþ
|
|
//½çÃæ¼ÇÔØÊ¼þ
|
private void MainForm_Load(object sender, EventArgs e)
|
{
|
|
}
|
|
//½çÃæÏÔʾʼþ
|
private void MainForm_Shown(object sender, EventArgs e)
|
{
|
var homeGuid = new PageGuid()
|
{
|
Modular = "Xhs",
|
MoudingType = eMoudingType.Tab,
|
Function = "home"
|
};
|
var homePage = new HomeXhsProjectPage();
|
this.CreatePage(homePage, homeGuid);
|
}
|
|
//½çÃæÕýÔÚÍ˳öʱȷÈÏ
|
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
|
|
#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.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.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
|
|
#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
|
|
|
|
}
|
}
|