/// <summary> /// 窗口打开方法, /// </summary> /// <param name="IOpenForm"></param> void OpenForm(IOpenModuleForm IOpenForm, bool ib) { if (IOpenForm == null) { Msg.ShowError("窗口打开错误!!您打开的窗口不存在!!请联系系统开发商。错误代码:YIESysOpenForm76"); return; } if (String.IsNullOrEmpty(IOpenForm.FormAssembly) || String.IsNullOrEmpty(IOpenForm.FormName)) { Msg.ShowError("窗口打开错误!未设置要打开的窗口!请联系系统开发商。错误代码:YIESysOpenForm82"); return; } try { System.Reflection.Assembly asm = System.Reflection.Assembly.Load(IOpenForm.FormAssembly); //程序集名 object frmObj = asm.CreateInstance(IOpenForm.FormAssembly + "." + IOpenForm.FormName); //程序集+form的类名。 Form childForm = (Form)frmObj; childForm.Tag = IOpenForm.FormTag; //tag属性要重新写一次,否则在第二次的时候取不到。原因还不清楚。有知道的望告知。 childForm.MdiParent = MainFormMDI.MainMDIForm; childForm.Show(); MainFormMDI.MainTabManager.Pages[childForm].Image = IOpenForm.FormImage16; MainFormMDI.MainTabManager.Pages[childForm].ShowCloseButton = DevExpress.Utils.DefaultBoolean.True; //if (ib) RegeditMenu(IOpenForm); } catch (Exception e) { Msg.ShowException(e); } }
public void OpenGroupControl(IOpenModuleForm IOpenModule) { _IOpenForm = IOpenModule; if (_IOpenForm == null) { Msg.ShowError("窗口打开错误!!未设置导航窗口!!请联系系统开发商。错误代码YIEAccontForm-32"); return; } if (String.IsNullOrEmpty(_IOpenForm.FormAssembly) || String.IsNullOrEmpty(_IOpenForm.FormName)) { Msg.ShowError("窗口打开错误!设置导航窗口!请联系系统开发商。错误代码:YIEAccontForm-37"); } if (xtabAccont.TabPages.Count > 0) { //判断是否打开,如果打开直接几选择 foreach (DevExpress.XtraTab.XtraTabPage pages in xtabAccont.TabPages) { if (pages.Name == _IOpenForm.FormName) { xtabAccont.SelectedTabPage = pages; return; } } } try { //xtabAccont.TabPages.Clear(); System.Reflection.Assembly asm = System.Reflection.Assembly.Load(_IOpenForm.FormAssembly); //程序集名 object Obj = asm.CreateInstance(_IOpenForm.FormAssembly + "." + _IOpenForm.FormName); //程序集+form的类名。 //创建新的当行页面 DevExpress.XtraEditors.XtraUserControl xControlPage; xControlPage = (DevExpress.XtraEditors.XtraUserControl)Obj; DevExpress.XtraTab.XtraTabPage AddPage = new DevExpress.XtraTab.XtraTabPage(); //设置导航页面属性 AddPage.Name = _IOpenForm.FormName; xControlPage.Dock = DockStyle.Fill; AddPage.Controls.Add(xControlPage); //不显示右上角的关闭X AddPage.ShowCloseButton = DevExpress.Utils.DefaultBoolean.False; xtabAccont.TabPages.Add(AddPage); xtabAccont.SelectedTabPage = AddPage; this.Activate(); } catch (Exception e) { Msg.ShowException(e); } }
/// <summary> /// 窗口打开方法 /// </summary> /// <param name="FormModule"></param> public void OpenForm(IOpenModuleForm FormModule) { if (FormModule == null) { return; } //窗口是否已经打开 //if (FormIsOpen(FormModule)) return; if (FormIsOpenNew(FormModule)) { return; } //窗口打开类型 //FormOpen = FormModule.FormOpenType; //打开窗口 OpenForm(FormModule, MainFormMDI.RegOldBar); }
/// <summary> /// 注册近期访问窗口--在窗口打开事件中调用 /// </summary> /// <param name="as_Caption">窗口显示的文本</param> /// <param name="as_Tag">打开的Form名</param> /// <param name="as_ImageIndex">Ribbon上显示的图标名称</param> void RegeditMenu(IOpenModuleForm IOpenForm) { DevExpress.XtraBars.BarSubItem barOld = MainFormMDI.OldBarSubItem; //最近访问的菜单只存储4条,多的将以前的删除掉加入新的 if (barOld.ItemLinks.Count > 3) { int mod = barOld.ItemLinks.Count % 4; barOld.ItemLinks.Remove(barOld.ItemLinks[mod]); } //添加新的菜单 BarButtonItem btnitem = new BarButtonItem(); btnitem.Name = IOpenForm.FormName; btnitem.Caption = IOpenForm.FormText; btnitem.Tag = IOpenForm.FormTag; btnitem.LargeGlyph = IOpenForm.FormImage32; barOld.AddItem(btnitem); btnitem.ItemClick += new ItemClickEventHandler(btnitem_ItemClick); }
public bool FormIsOpenNew(IOpenModuleForm FormModule) { // 是否已经打开了?(用循环来判断) foreach (Form childrenForm in MainFormMDI.MainMDIForm.MdiChildren) { if (childrenForm.Tag != null) { if (childrenForm.Tag.ToString() == FormModule.FormTag) { //是的话就是把他显示 childrenForm.Visible = true; //并激活该窗体 childrenForm.Activate(); return(true); } } // childrenForm.Tag.ToString(); //检测是不是当前子窗体名称 } return(false); }
/// <summary> /// 窗口是否已经打开 /// </summary> /// <param name="FormModule"></param> /// <returns></returns> public bool FormIsOpen(IOpenModuleForm FormModule) { return(FormIsOpen(FormModule.FormName)); }
public void NavGroupExpanded(IOpenModuleForm GroupModule) { OpenGroupControl(GroupModule); }
void OpenGroupControl(IOpenModuleForm IOpenForm) { if (IOpenForm == null) { Msg.ShowError("窗口打开错误!!未设置导航窗口!!请联系系统开发商。错误代码YIEAccontForm-32"); return; } if (String.IsNullOrEmpty(IOpenForm.FormAssembly) || String.IsNullOrEmpty(IOpenForm.FormName)) { Msg.ShowError("窗口打开错误!设置导航窗口!请联系系统开发商。错误代码:YIEAccontForm-37"); } if (MainFormMDI.AccontTabControl.TabPages.Count > 0) { //判断是否打开,如果打开直接几选择 foreach (DevExpress.XtraTab.XtraTabPage pages in MainFormMDI.AccontTabControl.TabPages) { if (pages.Name == IOpenForm.FormName) { MainFormMDI.AccontTabControl.SelectedTabPage = pages; MainFormMDI.MainTabManager.Pages[MainFormMDI.AccontForm].Image = IOpenForm.FormImage16; return; } } } try { //xtabAccont.TabPages.Clear(); System.Reflection.Assembly asm = System.Reflection.Assembly.Load(IOpenForm.FormAssembly); //程序集名 object Obj = asm.CreateInstance(IOpenForm.FormAssembly + "." + IOpenForm.FormName); //程序集+form的类名。 //创建新的当行页面 DevExpress.XtraEditors.XtraUserControl xControlPage; xControlPage = (DevExpress.XtraEditors.XtraUserControl)Obj; DevExpress.XtraTab.XtraTabPage AddPage = new DevExpress.XtraTab.XtraTabPage(); //设置导航页面属性 AddPage.Name = IOpenForm.FormName; xControlPage.Dock = DockStyle.Fill; AddPage.Controls.Add(xControlPage); //不显示右上角的关闭X AddPage.ShowCloseButton = DevExpress.Utils.DefaultBoolean.False; MainFormMDI.AccontTabControl.TabPages.Add(AddPage); MainFormMDI.AccontTabControl.SelectedTabPage = AddPage; MainFormMDI.AccontForm.Activate(); if (FormIsOpen(MainFormMDI.AccontForm.Name)) { MainFormMDI.MainTabManager.Pages[MainFormMDI.AccontForm].Image = IOpenForm.FormImage16; return; } MainFormMDI.AccontForm.MdiParent = MainFormMDI.MainMDIForm; MainFormMDI.AccontForm.Show(); MainFormMDI.MainTabManager.Pages[MainFormMDI.AccontForm].Image = IOpenForm.FormImage16; MainFormMDI.MainTabManager.Pages[MainFormMDI.AccontForm].ShowCloseButton = DevExpress.Utils.DefaultBoolean.True; //xtab_manager.Pages[xtab_manager.ActiveFloatForm].Image = IOpenModuleForm.FormImage16; } catch (Exception e) { Msg.ShowException(e); } }