private void ShowForm(RibbonForm form, RibbonWindowSmartPartInfo smartPartInfo) { SetWindowProperties(form, smartPartInfo); if (smartPartInfo.Modal) { SetWindowLocation(form, smartPartInfo); // Argument can be null. It's the default for the other overload. form.ShowDialog(ownerForm); } else { if (ownerForm != null) // Call changes if no owner is specified. { form.Show(ownerForm); } else { form.Show(); } SetWindowLocation(form, smartPartInfo); form.BringToFront(); } }
public void CreateMDIControl(string strTitle, string strTag, RibbonForm frmBase, Image image) { try { DevExpress.XtraTabbedMdi.XtraMdiTabPage currentPage = null; if (currentPage == null) { loading.ShowWaitForm(); frmBase.Dock = DockStyle.Fill; frmBase.FormClosing += new FormClosingEventHandler(frm_FormClosing); frmBase.Text = strTitle; frmBase.Tag = strTag; if (!IsTabbedMdi) { frmBase.ClientSize = new Size(this.Width, this.Height); } frmBase.MdiParent = this; if (image != null) { frmBase.ShowIcon = true; } else { image = base.Icon.ToBitmap(); } frmBase.Show(); currentPage = xtraTabbedMdiMgr.SelectedPage; xtraTabbedMdiMgr.SelectedPage.Image = image; } else { xtraTabbedMdiMgr.SelectedPage = currentPage; } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } finally { loading.CloseWaitForm(); LayoutMdi(); } }
private void BenimMenumItemClickMethod(ItemClickEventArgs e) { try { RibbonForm f = FormBul(e.Item.Name); if (MDIFormAcikMi(f)) { XtraMdiTabPage page = FindPageByText(f.Text); xtraTabbedMdiManager1.SelectedPage = page; Ribbon.HideApplicationButtonContentControl(); return; } Ribbon.HideApplicationButtonContentControl(); f.Ribbon.MdiMergeStyle = RibbonMdiMergeStyle.Always; f.MdiParent = Master.ActiveForm; //this; f.Show(); Ribbon.SelectedPage = f.Ribbon.Pages[0]; } catch (Exception Hata) { //Genel.LogErrorYaz(iFormID, Hata); //XtraMessageBox.Show(Genel.DilGetirMesaj(1034) + "\n\n" + Hata.Message, Genel.DilGetirMesaj(2), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
Dictionary <Type, RibbonForm> mdiForms = new Dictionary <Type, RibbonForm>(); //存储mdi窗体 /// <summary> /// 显示Mdi窗体 /// </summary> /// <param name="ucControl"></param> public void ShowMdiForm(UCBase ucControl) { if (ucControl == null) { return; } try { Type ucType = ucControl.GetType(); if (ucType.BaseType != typeof(UCBase) && ucType.BaseType.BaseType != typeof(UCBase)) { return; //类型不正确 返回 } if (mdiForms.ContainsKey(ucType)) //限定同一类型控件只能打开一个 { if (mdiForms[ucType] != null) { mdiForms[ucType].Activate(); return; } else { mdiForms.Remove(ucType); } } mdiForms.Add(ucType, null); //this.ShowWaitingPanel(() => //{ //if (ucBase is UCMainPage) //{ // UCMainPage mainPage = (UCMainPage)ucBase; // mainPage.BtnClick += x => // { // ShowMdiForm(x); // }; //} // return ucBase; // }, x => //{ // UCBase ucBase = (UCBase)x; RibbonForm mdiFrm = new RibbonForm() { MdiParent = this, Text = ucControl.Title, Dock = DockStyle.Fill }; ucControl.Dock = DockStyle.Fill; mdiFrm.Controls.Add(ucControl); mdiFrm.Disposed += (object sender, EventArgs e) => { if (mdiForms.ContainsKey(ucType)) { //if (!loginOut) mdiForms.Remove(ucType); } GC.Collect(); }; mdiForms[ucType] = mdiFrm; mdiFrm.Show(); // }); } catch (Exception e) { throw new Exception("打开Mdi窗体出错!原因:" + e.Message); } }
/// <summary> /// 显示Mdi窗体 /// </summary> /// <param name="ucControl"></param> public void ShowMdiForm(UCBase ucControl) { try { Type ucType = ucControl.GetType(); if (ucType.BaseType != typeof(UCBase) && ucType.BaseType.BaseType != typeof(UCBase)) { return; //类型不正确 返回 } if (mdiForms.ContainsKey(ucType)) //限定同一类型控件只能打开一个 { if (mdiForms[ucType] != null) { mdiForms[ucType].Activate(); return; } else { mdiForms.Remove(ucType); } } mdiForms.Add(ucType, null); //this.ShowWaitingPanel(() => //{ if (ucControl is UCMainPage) { UCMainPage mainPage = (UCMainPage)ucControl; mainPage.BtnClick += ShowMdiForm; } if (ucControl is UCUserInfo) { UCUserInfo userInfo = (UCUserInfo)ucControl; userInfo.ShowPHR += userInfo_ShowPHR; } // return ucBase; // }, x => //{ // UCBase ucBase = (UCBase)x; RibbonForm mdiFrm = new RibbonForm() { MdiParent = this, Text = ucControl.Title, Dock = DockStyle.Fill }; ucControl.Dock = DockStyle.Fill; mdiFrm.Controls.Add(ucControl); mdiFrm.FormClosing += (object sender, FormClosingEventArgs e) => { if (e.CloseReason == CloseReason.UserClosing && !loginOut) { if (ucControl is UCMainPage) //阻止关闭主页 { e.Cancel = true; } } }; mdiFrm.Disposed += (object sender, EventArgs e) => { if (mdiForms.ContainsKey(ucType)) { if (!loginOut) { mdiForms.Remove(ucType); } } GC.Collect(); }; mdiForms[ucType] = mdiFrm; mdiFrm.Show(); // }); } catch (Exception e) { throw new Exception("打开Mdi窗体出错!原因:" + e.Message); } }