1、主界面使用MDI布局,使用户可以在同一时间,打开多个界面。同时在右上角放置控制MDIChild 窗口的按键,使得用户可以方便的来打选中、关闭,全部关闭对应的窗口。图如下:
主要代码如下:
bool OpenOnce(XtraForm frm) { foreach (XtraForm mdifrm in MdiChildren) { if (frm.Text == mdifrm.Text) { mdifrm.Activate(); return false; } //else //{ // mdifrm.Close(); //} } return true; } public void closeOther() { foreach (XtraForm mdifrm in this.MdiChildren) { mdifrm.Close(); } } public void closeThis() { this.ActiveMdiChild.Close(); }
2.在进入主界面时,加载一个默认NavForm 房间状态,或者导航页。(这个Form 使用上面的方对其无效,关闭不掉。)
if (e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; }
3.菜单与MDI的影响
public void barManager1_Merge(object sender, BarManagerMergeEventArgs e) { if (e.ChildManager.Form is XtraForm) { Bar sourceBar = e.ChildManager.Bars["Tools"]; barManager1.Bars["Tools"].Merge(sourceBar); sourceBar.Visible = false; barButtonItem64.Visibility = BarItemVisibility.Never; } } public void barManager1_UnMerge(object sender, BarManagerMergeEventArgs e) { Bar parentBar = barManager1.Bars["Tools"]; parentBar.UnMerge(); barButtonItem64.Visibility = BarItemVisibility.Always; }