예제 #1
0
 /// <summary>
 /// 加载选定的子窗口
 /// </summary>
 /// <param name="assemblyName">程序集</param>
 /// <param name="selectedNodeName">当前选择的窗体名称</param>
 private void LoadChildrenForm(string assemblyName, string formName)
 {
     if (formName.Length == 0)
     {
         return;
     }
     // 是否已经打开了?
     foreach (Form childrenForm in this.MdiChildren)
     {
         if (childrenForm.Name == formName)
         {
             childrenForm.Visible = true;
             childrenForm.Activate();
             return;
         }
     }
     // 一些特殊的页面处理。
     switch (formName)
     {
         case "FormLogOn":
             // 关闭所有打开的窗口
             foreach (Form childrenForm in this.MdiChildren)
             {
                 childrenForm.Close();
             }
             this.ShowChildrenForm(assemblyName, formName);
             break;
         case "FrmScreenLock":
             {
                 tmrLock.Stop();
                 var lcForm = new FrmScreenLock();
                 if (lcForm.ShowDialog(this) == DialogResult.OK)
                 {
                     LoadFormLockInfo();
                 }
             }
             break;
         default:
             this.ShowChildrenForm(assemblyName, formName);
             return;
     }
 }
예제 #2
0
 private void tmrLock_Tick(object sender, EventArgs e)
 {
     // 这里先判断是否进行锁屏
     if (this.IsLockSystem.Equals(false.ToString()))
     {
         // 不再进行循环判断了
         this.tmrLock.Enabled = false;
         return;
     }
     if (this.IsLockSystem)
     {
         long i = getIdleTick();
         if (i > this.LockWaitMinute * 1000 * 60)
         {
             this.tmrLock.Stop();
             var lcForm = new FrmScreenLock();
             if (lcForm.ShowDialog() == DialogResult.OK)
             {
                 this.LoadFormLockInfo();
             }
         }
     }
 }
예제 #3
0
        /// <summary>
        /// 打开新窗体
        /// </summary>
        private void OpenForm(TreeNode treeNode)
        {
            //DataRow dataRow = treeNode.Tag as DataRow;
            BaseModuleEntity moduleEntity = treeNode.Tag as BaseModuleEntity;

            // 若又没C\S窗体,又没B\S网址,那就是空的,不执行任何操作
            //if (string.IsNullOrEmpty(dataRow[BaseModuleEntity.FieldFormName].ToString())
            //    && string.IsNullOrEmpty(dataRow[BaseModuleEntity.FieldAssemblyName].ToString())
            //    && string.IsNullOrEmpty(dataRow[BaseModuleEntity.FieldNavigateUrl].ToString()))
            if (string.IsNullOrEmpty(moduleEntity.FormName)
                && string.IsNullOrEmpty(moduleEntity.AssemblyName)
                && string.IsNullOrEmpty(moduleEntity.NavigateUrl))
            {
                return;
            }
            // 如果打开的是消息窗口
            if (moduleEntity.FormName == "FrmMessage")
            {
                if (barLeft.Items.Contains("dockContainerItem2"))
                {
                    barLeft.AutoHide = false;
                    barLeft.SelectedDockContainerItem = dockContainerItem2;
                }
                if (barRightN.Items.Contains("dockContainerItem2"))
                {
                    barRightN.AutoHide = false;
                    barRightN.SelectedDockContainerItem = dockContainerItem2;
                }
                if (barRight.Items.Contains("dockContainerItem2"))
                {
                    barRight.AutoHide = false;
                    barRight.SelectedDockContainerItem = dockContainerItem2;
                    barRight.Focus();
                }
                return;
            }
            // 如果为锁定窗体
            if (moduleEntity.FormName == "FrmLock")
            {
                tmrLock.Stop();
                var  frmLock = new FrmScreenLock();
                if (frmLock.ShowDialog(this) == DialogResult.OK)
                {
                    LoadFormLockInfo();
                }
                return;
            }
            // 优先打开C\S窗体
            if (!string.IsNullOrEmpty(moduleEntity.FormName))
            {
                // 通过数据库的值获得要打开的模块对应的窗体类型。
                System.Type type = System.Type.GetType(moduleEntity.AssemblyName + "." + moduleEntity.FormName + "," + moduleEntity.AssemblyName);
                if (type == null)
                {
                    // MessageBox.Show(AppMessage.MSG1000, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                object obj = (object)Activator.CreateInstance(type, null);
                BaseForm mdiForm = obj as BaseForm;
                // 判断是否弹出窗口,进行特殊处理
                if (mdiForm.ShowDialogOnly)
                {
                    mdiForm.HelpButton = false;
                    mdiForm.ShowInTaskbar = false;
                    mdiForm.MinimizeBox = false;
                    mdiForm.ShowDialog(this);
                    return;
                }
                // 打开窗口
                if (!this.AllowSameMenu)
                {
                    if (TabIsExist(moduleEntity.Code))
                    {
                        return;
                    }
                }
                CreateTabControl(mdiForm, moduleEntity.Code, moduleEntity.Code);
                return;
            }
            // 这里是直接打开可执行文件的方法
            if (string.IsNullOrEmpty(moduleEntity.FormName) && !string.IsNullOrEmpty(moduleEntity.AssemblyName))
            {
                string assemblyName = moduleEntity.AssemblyName;
                assemblyName = this.UserInfo.GetUserParameter(assemblyName);
                System.Diagnostics.Process.Start(assemblyName);
                return;
            }
            // 最后判断是否为要打开的网址
            string url = moduleEntity.NavigateUrl;
            if (!string.IsNullOrEmpty(url))
            {
                url = this.UserInfo.GetUrl(url);

                if (treeNode.Text == "办公管理")
                {
                    this.webBrowser.Url = new Uri(url);
                    // tabControlMain.Refresh();
                    tabControlMain.SelectedTab = this.tabItemMain;
                    return;
                }
                if (TabIsExist("Browser"))
                {
                    FrmIE frmIE = (FrmIE)tabControlMain.SelectedPanel.Controls[0];
                    frmIE.webBrowser.Navigate(url);
                }
                else
                {
                    FrmIE frmIE = new FrmIE { MUrl = url };
                    // 浏览器为了标识Name保持只打开一个
                    CreateTabControl(frmIE, "Browser", moduleEntity.Code);
                }
            }
        }
예제 #4
0
 /// <summary>
 /// 加载选定的子窗口
 /// </summary>
 /// <param name="assemblyName">程序集</param>
 /// <param name="selectedNodeName">当前选择的窗体名称</param>
 private void LoadChildrenForm(string assemblyName, string formName, bool showIntask)
 {
     if (formName.Length == 0)
     {
         return;
     }
     // 是否已经打开了?若已经打开了这个窗体,那就不用重复打开了
     foreach (Form childrenForm in this.OwnedForms)
     {
         if (childrenForm.Name == formName)
         {
             childrenForm.Visible = true;
             childrenForm.Activate();
             return;
         }
     }
     // 一些特殊的页面处理,重新登录时,需要把其他页面都自动关闭了。
     switch (formName)
     {
         case "FrmLogOn":
             // 关闭所有打开的窗口
             foreach (Form childrenForm in this.MdiChildren)
             {
                 childrenForm.Close();
             }
             this.ShowChildrenForm(assemblyName, formName, true);
             break;
         case "FrmScreenLock":
             {
                 tmrLock.Stop();
                 // 隐藏notifyIcon
                 this.notifyIcon.Visible = false;
                 // 隐藏子窗口
                 foreach (Form childrenForm in this.OwnedForms)
                 {
                     childrenForm.Visible = false;
                 }
                 var lcForm = new FrmScreenLock();
                 if (lcForm.ShowDialog(this) == DialogResult.OK)
                 {
                     // 显示notifyIcon
                     this.notifyIcon.Visible = true;
                     // 显示子窗口
                     foreach (Form childrenForm in this.OwnedForms)
                     {
                         childrenForm.Visible = true;
                     }
                     LoadFormLockInfo();
                 }
             }
             break;
         default:
             this.ShowChildrenForm(assemblyName, formName, true);
             return;
     }
 }