예제 #1
0
        private void OpenFrm(string formName, Form parentForm)
        {
            a = Assembly.GetExecutingAssembly();
            Type frmType = GetFrmType(formName);

            BaseForm frm = Activator.CreateInstance(frmType) as BaseForm;

            if (frm != null)
            {
                frm.UserName = "******";
                //在父窗口中查找是否已经打开与待打开的窗体相同的窗体
                foreach (BaseForm f in parentForm.MdiChildren)
                {
                    //如果存在,则销毁新建的窗体,引用已经打开的窗体引用
                    if (f.Name == frm.Name)
                    {
                        frm.Dispose();
                        frm = f;
                        break;
                    }
                }

                GetControls(frm);

                //调整显示效果
                frm.MdiParent   = parentForm;
                frm.WindowState = FormWindowState.Normal;
                frm.Activate();
                frm.Show();
            }
        }
예제 #2
0
        public void SwitchTo(FormView view)
        {
            if (view == null)
            {
                throw new Exception("Argument cannot be null");
            }
            else if (!viewList.Contains(view))
            {
                throw new Exception("Control doesn't contain the view specified");
            }

            viewList.Remove(view);
            viewList.Insert(0, view);

            if (ActiveView != null)
            {
                ActiveView.ClearForm(BaseForm);
            }

            ActiveView = view;

            view.FillForm(BaseForm);
            view.OnSelect(new EventArgs());

            foreach (MenuItem item in ViewMenu.MenuItems)
            {
                item.Checked = false;
            }

            var menuItem = FindMenuItem(view.Text);

            if (menuItem != null)
            {
                menuItem.Checked = true;
            }

            if (ToolBar != null)
            {
                ToolBar.SetViewTools(view.Tools);
            }
            BaseForm.Invalidate();
            BaseForm.Activate();
        }