using DevExpress.Utils; using DevExpress.XtraTab; using Lskj.Control; using Lskj.Core; using Lskj.Util; using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Lskj.WorkshopProgram { public sealed class Manager { /// /// 主程序 /// private static FrmMain _frmMain = null; public static XtraTabControl TabMain = null; public static int MinusTheHeight = 0; public static int frmHeight = 0; public static string NotificationDataSQL;//sql编号 public static string ConditionNumber;//是否有条件 public static exetowinform fr = null; /// /// 记录当前打开的窗口 /// public static Dictionary ModuleForms = new Dictionary(); /// /// 说明:打开模块 /// 创建人:龚宇超 /// 创建日期:2017-08-18 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public static void OpenModule(string name, string route) { try { DllModule module = new DllModule { name = name, route = route }; string[] args = new string[] { name, route }; AddModuleToTab(module, args); } catch (Exception ex) { MessageUtil.Show(ex.Message); } } //} /// /// 说明:添加模块到tab中 /// 创建人:龚宇超 /// 创建日期:2017-08-16 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The tab main. /// The module. /// The arguments. public static void AddModuleToTab(DllModule module, string[] args) { try { //IForm iform = FormHelper.LoadDllForm(module.DllName, args); // 菜单打开的模块默认最大化,界面FormState设置为Normal模式,否则会出现界面不是全屏,会显示默认阴影界面 //iform.SubForm.WindowState = _frmMain.WindowState; Form form = new Form(); // 表示组成应用程序的用户界面的窗口或对话框。 Panel panel = new Panel(); fr = new exetowinform(panel, ""); fr.Start(module.route); panel.Dock = DockStyle.Fill; form.Controls.Add(panel); string guid = Guid.NewGuid().ToString(); XtraTabPage tp = new XtraTabPage(); tp.Text = module.name; tp.Tag = guid; // 这个必须有不然会提示:"不能向tabControl中添加顶级控件" form.TopLevel = false; form.Location = new Point(0, 0); //form.Dock = DockStyle.Fill; form.Width = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width; form.Height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - MinusTheHeight; form.FormBorderStyle = FormBorderStyle.None; tp.AutoScroll = true; tp.Controls.Add(form); tp.ShowCloseButton = DefaultBoolean.True; tp.Dock = DockStyle.Fill; TabMain.TabPages.Add(tp); TabMain.SelectedTabPage = tp; form.Show(); ModuleForms.Add(guid, module); //LastModuleForm.Add(module); //Lskj.Main.Model.AutoSizeChange.ControllInitializeSize(form);//调整控件大小 } catch (Exception ex) { MessageUtil.Show(ex.InnerException != null ? ex.InnerException.Message : ex.Message); } } /// /// 说明:特殊dll模块处理 /// 创建人:龚宇超 /// 创建日期:2018-04-20 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// Name of the DLL. /// System.String. private static string ReplaceDllFileName(string dllName) { switch (dllName.ToLower().Trim()) { case "pubspec.dll": dllName = "Lskj.PubSpec.dll"; break; } return dllName; } private static void ExitSystem() { try { // 退出系统 if (DBConfig.Instance.NoticeExit) { Process[] p1 = Process.GetProcessesByName("Ls_Notice"); foreach (Process item in p1) item.Kill(); } } catch (Exception) { } } /// /// 说明:打开主程序 /// 创建人:龚宇超 /// 创建日期:2017-08-14 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DialogResult. private static DialogResult RunMainForm() { _frmMain = new FrmMain(); return _frmMain.ShowDialog(); } /// /// 说明:获得通知数据执行的sql编码 /// 创建人:曹屹峰 /// 创建日期:2021-11-3 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private static void GetNotificationDataSQL() { string[] PwdState = AESUtil.Decrypt(IniHelper.Read(DBConfig.Instance.ServerName + DBConfig.Instance.DataBase)).Split('^'); if (PwdState.Length == 3) { NotificationDataSQL = PwdState[1].ToString(); ConditionNumber = PwdState[1].ToString(); return; } if (Lskj.Business.Impl.BaseImpl.HasExistsColumn("p_systemNotification", "billdocument_id")) { ConditionNumber = "1"; } if (Lskj.Business.Impl.BaseImpl.HasExistsColumn("p_systemNotification", "msgid")) { NotificationDataSQL = "1"; } else if (Lskj.Business.Impl.BaseImpl.HasExistsColumn("p_systemNotification", "menuid")) { NotificationDataSQL = "2"; } else { NotificationDataSQL = "3"; } IniHelper.Write(DBConfig.Instance.ServerName + DBConfig.Instance.DataBase, AESUtil.Encrypt("NotificationDataSQL,ConditionNumber" + "^" + NotificationDataSQL + "^" + ConditionNumber)); } } }