Пример #1
0
 public static void ShowUserControl(this PanelControl pnl, XtraUserControl type)
 {
     //if(pnl.Controls[type.] == type)
     if (pnl.Controls[type.Name] is XtraUserControl userControl)
     {
         type.BringToFront();
     }
     else
     {
         pnl.Controls.Add(type);
         type.BringToFront();
     }
 }
Пример #2
0
        public void OnUINavigatorEvent(UIFuncItemInfo funcItemInfo)
        {
            if (funcItemInfo.Function == UIFunctionEnum.Backward)
            {
                if (m_PreviousFuncItemInfo != null)
                {
                    OnUINavigatorEvent(m_PreviousFuncItemInfo);
                }
                return;
            }

            funcItemInfo = Container.Instance.NaviRecord.GetSubItem(funcItemInfo);
            Container.Instance.NaviRecord.RegisterSubItem(funcItemInfo);

            // m_tabCtrlContainer.SuspendLayout();

            XtraUserControl tabTree = GetNaviContent(funcItemInfo.Function);

            if (tabTree != null)
            {
                tabTree.BringToFront();
                m_PreviousFuncItemInfo = m_CurrentFuncItemInfo;

                if (funcItemInfo.Function == UIFunctionEnum.Backward)
                {
                    m_PreviousFuncItemInfo = null;
                    m_CurrentFuncItemInfo  = m_PreviousFuncItemInfo;
                }
                else
                {
                    m_CurrentFuncItemInfo = funcItemInfo;
                }
            }
            // m_tabCtrlContainer.ResumeLayout();
        }
Пример #3
0
        private void ModuleSelect(Type t, NavBarLinkEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                if (t == null)
                {
                    return;
                }
                object ui = Activator.CreateInstance(t);
                if (ui == null)
                {
                    return;
                }
                ChucNang cn = e.Link.Item.Tag as ChucNang;

                switch (t.Name)
                {
                case "ucTuDienDuLieu":
                    ((Modules.ucTuDienDuLieu)ui).ChucNang = cn;
                    break;
                }

                switch (t.BaseType.Name)
                {
                case "XtraForm":
                    XtraForm xForm = (XtraForm)ui;
                    foreach (Form fr in frmMain.Instance.xtraTabbedMdiManager.MdiParent.MdiChildren)
                    {
                        if (fr.Name == string.Format("{0}{1}", t.Name, cn.ModuleID))
                        {
                            fr.Focus();
                            return;
                        }
                    }
                    xForm.Name += cn.ModuleID;
                    InvokeMethod(t, xForm, e);
                    if (!string.IsNullOrEmpty(cn.LoaiChucNang.MaLoai))
                    {
                        if (cn.LoaiChucNang.MaLoai == "Popup")
                        {
                            xForm.Tag  = cn;
                            xForm.Text = e.Link.Caption;
                            xForm.ShowDialog();
                        }
                        else
                        {
                            xForm.MdiParent = frmMain.Instance;
                            xForm.Tag       = cn;
                            xForm.Text      = e.Link.Caption;
                            xForm.Show();
                            xForm.Focus();
                        }
                    }
                    else
                    {
                        xForm.MdiParent = frmMain.Instance;
                        xForm.Tag       = cn;
                        xForm.Text      = e.Link.Caption;
                        xForm.Show();
                        xForm.Focus();
                    }
                    break;

                case "Form":
                    Form form = (Form)ui;
                    foreach (Form fr in frmMain.Instance.xtraTabbedMdiManager.MdiParent.MdiChildren)
                    {
                        if (fr.Name == string.Format("{0}{1}", t.Name, cn.ModuleID))
                        {
                            fr.Focus();
                            return;
                        }
                    }
                    form.Name += cn.ModuleID;
                    InvokeMethod(t, form, e);
                    if (!string.IsNullOrEmpty(cn.LoaiChucNang.MaLoai))
                    {
                        if (cn.LoaiChucNang.MaLoai == "Popup")
                        {
                            form.Tag  = cn;
                            form.Text = e.Link.Caption;
                            form.ShowDialog();
                        }
                        else
                        {
                            form.MdiParent = frmMain.Instance;
                            form.Tag       = cn;
                            form.Text      = e.Link.Caption;
                            form.Show();
                            form.Focus();
                        }
                    }
                    else
                    {
                        form.MdiParent = frmMain.Instance;
                        form.Tag       = cn;
                        form.Text      = e.Link.Caption;
                        form.Show();
                        form.Focus();
                    }
                    break;

                case "XtraUserControl":
                    if (AppContainer != null)
                    {
                        if (!AppContainer.Controls.ContainsKey(string.Format("{0}{1}", t.Name, cn.ModuleID)))
                        {
                            XtraUserControl xc = (XtraUserControl)ui;
                            ////Phan quyen tung control
                            //bool result = false;
                            //DataServices.TaiKhoan.KiemTraPhanQuyenControl(UserInfo.UserID, xc.Name, ref result);
                            //if (result)
                            //{
                            //    MethodInfo mi = FindMethod(t, "KhongDuocPhepCapNhat", result.ToString());
                            //    if (mi != null)
                            //        mi.Invoke(xc, new string[] { result.ToString() });
                            //}

                            if (!AppContainer.Controls.Contains(xc))
                            {
                                xc.Name           = string.Format("{0}{1}", t.Name, cn.ModuleID);
                                xc.Dock           = DockStyle.Fill;
                                xc.Tag            = cn;
                                AppContainer.Text = e.Link.Caption;
                                InvokeMethod(t, xc, e);
                                AppContainer.Controls.Add(xc);
                                xc.BringToFront();
                                xc.Focus();
                            }
                        }
                        else
                        {
                            AppContainer.Text = e.Link.Caption;
                            AppContainer.Controls[AppContainer.Controls.IndexOfKey(string.Format("{0}{1}", t.Name, cn.ModuleID))].BringToFront();
                            AppContainer.Controls[AppContainer.Controls.IndexOfKey(string.Format("{0}{1}", t.Name, cn.ModuleID))].Focus();
                        }
                    }
                    break;

                case "UserControl":
                    Cursor.Current = Cursors.WaitCursor;
                    if (AppContainer != null)
                    {
                        if (!AppContainer.Controls.ContainsKey(string.Format("{0}{1}", t.Name, cn.ModuleID)))
                        {
                            UserControl uc = Activator.CreateInstance(t) as UserControl;
                            if (uc != null)
                            {
                                if (!AppContainer.Controls.Contains(uc))
                                {
                                    uc.Name           = string.Format("{0}{1}", t.Name, cn.ModuleID);
                                    uc.Dock           = DockStyle.Fill;
                                    uc.Tag            = cn;
                                    AppContainer.Text = e.Link.Caption;
                                    InvokeMethod(t, uc, e);
                                    AppContainer.Controls.Add(uc);
                                    uc.BringToFront();
                                    uc.Focus();
                                }
                            }
                        }
                        else
                        {
                            AppContainer.Text = e.Link.Caption;
                            AppContainer.Controls[AppContainer.Controls.IndexOfKey(string.Format("{0}{1}", t.Name, cn.ModuleID))].BringToFront();
                            AppContainer.Controls[AppContainer.Controls.IndexOfKey(string.Format("{0}{1}", t.Name, cn.ModuleID))].Focus();
                        }
                    }
                    Cursor.Current = Cursors.Default;
                    break;

                case "Object":
                    Object obj = Activator.CreateInstance(t) as Object;
                    if (obj != null)
                    {
                        InvokeMethod(t, obj, e);
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message + "\n" + ex.StackTrace, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            Cursor.Current = Cursors.Default;
        }