Exemplo n.º 1
0
        /// <summary>
        /// main界面按钮跳转
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void barButtonItem_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                VusermenuDto barItemMenu = GetMenuFromMenus(e.Item.Name);
                if (barItemMenu == null)
                {
                    return;
                }
                if (barItemMenu.Menurule == null)
                {
                    return;
                }
                Form form = this.MdiChildren.FirstOrDefault(f => f.GetType().FullName == barItemMenu.Menurule);
                if (form == null)
                {
                    form = ServiceProviderManager.GetForm(barItemMenu.Menurule);
                }
                form.MdiParent = this;
                form.Show();
                form.Activate();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 2
0
        void navBarItem_LinkClicked(object sender, NavBarLinkEventArgs e)
        {
            VusermenuDto barItemMenu = GetMenuFromMenus(e.Link.Item.Name);

            if (barItemMenu == null)
            {
                return;
            }
            if (barItemMenu.Menurule == null)
            {
                return;
            }
            foreach (var item in assemblies)
            {
                Type formType = item.GetType(barItemMenu.Menurule);
                if (formType != null)
                {
                    if (typeof(Form).IsAssignableFrom(formType))
                    {
                        int    inx      = (barItemMenu.Menurule).LastIndexOf(".") + 1;
                        string formname = (barItemMenu.Menurule).Substring(inx);
                        Form   frm      = GetMdiForm(formname);
                        if (frm == null)
                        {
                            frm           = (Form)Activator.CreateInstance(formType);
                            frm.MdiParent = this;
                        }
                        frm.Activate();
                        ActiveRibbonPage(e.Link.Item.Name);
                        frm.Show();
                    }
                    else
                    {
                        XtraMessageBox.Show("指定的类型不能是从Form类型继承", "温馨提示");
                    }
                    return;
                }
            }
            XtraMessageBox.Show("指定的类型不存在", "温馨提示");
        }