using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; using System.Windows.Forms; namespace LYFZ.Software.UI { ///// ///// 子窗体加载模式 ///// //public enum ChildFormLoadingMode //{ // /// // /// 普通显示,向用户显示具有指定所有者的窗体 // /// // Show = 1, // /// // /// 将窗体显示为模式对话框,并将当前活动窗口设置为它的所有者。 // /// // ShowDialog = 2, // /// // /// 嵌入式 // /// // ShowEmbedded = 3 //} /// /// 动态菜单操作类 /// public class DynamicMenu:LYFZ.DynamicMenu.DynamicMenu { /// /// 设置是否显示工具按钮说明文 /// public new static bool SetShowToolsDescription(ToolStripMenuItem menuItem) { return LYFZ.DynamicMenu.DynamicMenu.SetShowToolsDescription(menuItem); } public new static string SetInterfaceSelect(ToolStripMenuItem menuItem) { return LYFZ.DynamicMenu.DynamicMenu.SetInterfaceSelect(menuItem); } #region 早期代码 /* private static SortedList assemblyList = new SortedList(); private static LYFZ.BLL.BLL_SystemToolsMenu bllMenu = new BLL.BLL_SystemToolsMenu(false); /// /// 当IsOverrideSystemMeun为true时设置设置重写的的菜单项 /// public static List MenuItems = null; /// /// 嵌入式显示(时尚模式) /// /// 类全名 /// 父控件集合 /// public static LYFZ.ComponentLibrary.BaseContentsFormMain ShowEmbeddedFashionChildForm(string classFullName, System.Windows.Forms.Control.ControlCollection controls, string dllKey) { // LYFZ.ComponentLibrary.BaseContentsFormMain frm = DynamicMenu.ShowEmbeddedFashionChildForm(DynamicMenu.GetShowFormMain(classFullName, dllKey),controls); string frmKey = "FashionFrmKey_" +classFullName.Replace('.','_'); LYFZ.ComponentLibrary.BaseContentsFormMain frm = DynamicMenu.GetSortedListInForm(frmKey); if (frm == null) { frm = DynamicMenu.ShowEmbeddedFashionChildForm(DynamicMenu.GetShowFormMain(classFullName, dllKey), controls); sFormList.Add(frmKey, frm); } return frm; } /// /// 嵌入式显示(时尚模式) /// /// 类全名 /// 父控件集合 /// public static LYFZ.ComponentLibrary.BaseContentsFormMain ShowEmbeddedFashionChildForm(LYFZ.ComponentLibrary.BaseContentsFormMain frm, System.Windows.Forms.Control.ControlCollection controls) { System.GC.Collect(); frm.Name = "frmContainerMain"; frm.TopLevel = false; frm.IsShadow = false; frm.IsMaximized = false; frm.IsShowBtnFormMenu = true; frm.IsShowBtnFormSkin = true; frm.MaximizeBox = true; frm.MinimizeBox = true; frm.FormMobile = false; frm.BottomBgImageHeight = 0; frm.IsUserControlsSize = false; frm.IsCloseForm = false; frm.IsMinimize = false; frm.IsLoginValidation = true; frm.Dock = System.Windows.Forms.DockStyle.Fill; frm.IsCustomScrollBar = true; frm.SetCoverageTitleButtonEvent(); ClosThisForm(controls); controls.Clear(); controls.Add(frm); frm.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; frm.Show(); return frm; } /// /// 嵌入式显示(经典模式) /// /// 类全名 /// 父控件集合 /// 导入的dll唯一标识 /// public static LYFZ.ComponentLibrary.BaseContentsFormMain ShowEmbeddedClassicChildForm(string classFullName, System.Windows.Forms.Control.ControlCollection controls,string dllKey) { // LYFZ.ComponentLibrary.BaseContentsFormMain frm = DynamicMenu.ShowEmbeddedClassicChildForm(DynamicMenu.GetShowFormMain(classFullName, dllKey), controls); ; try { string frmKey = "ClassicFrmKey_" + classFullName.Replace('.', '_'); LYFZ.ComponentLibrary.BaseContentsFormMain frm = DynamicMenu.GetSortedListInForm(frmKey); if (frm == null) { frm = DynamicMenu.ShowEmbeddedClassicChildForm(DynamicMenu.GetShowFormMain(classFullName, dllKey), controls); if (frm != null) { sFormList.Add(frmKey, frm); } } return frm; } catch { return null; } } /// /// 嵌入式显示(经典模式) /// /// 要显示的窗体 /// 父控件集合 /// public static LYFZ.ComponentLibrary.BaseContentsFormMain ShowEmbeddedClassicChildForm(LYFZ.ComponentLibrary.BaseContentsFormMain frm, System.Windows.Forms.Control.ControlCollection controls) { System.GC.Collect(); if (frm != null) { frm.Name = "frmContainerMain" + LYFZ.WinAPI.CustomPublicMethod.GenerateId().ToString(); frm.TopLevel = false; frm.IsShadow = false; frm.MaximizeBox = false; frm.MinimizeBox = false; frm.IsShowCloseBox = false; frm.TitleBgImageHeight = 0; frm.BottomBgImageHeight = 0; frm.IsMaximized = false; frm.FormMobile = false; frm.IsUserControlsSize = false; frm.IsLoginValidation = true; frm.Dock = System.Windows.Forms.DockStyle.Fill; frm.IsCustomScrollBar = false; ClosThisForm(controls); controls.Clear(); System.GC.Collect(); System.Threading.Thread.Sleep(2); frm.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; controls.Add(frm); try { frm.Show(); AddTestBtn(frm); } catch { ShowEmbeddedClassicChildForm(GetErrorFrm(frm.GetType().FullName), controls); } } return frm; } public static void AddTestBtn(LYFZ.ComponentLibrary.BaseContentsFormMain frm) { if (!BLL.BLL_SystemGlobalSetting.IsEnableVideoButton) return; if ( MenuItems == null) { MenuItems = bllMenu.GetSystemQuickTools(); MenuItems = MenuItems.Union(bllMenu.GetSystemMenuList()).ToList(); List list = bllMenu.GetSystemToolsList(); foreach (LYFZ.Model.Model_SystemToolsMenu.ToolsGroup gp in list) { MenuItems = MenuItems.Union(gp.Items).ToList(); } List list2 = bllMenu.GetSystemMenuList(); foreach (LYFZ.Model.Model_SystemToolsMenu.Item it in list2) { MenuItems = MenuItems.Union(it.ChildItems).ToList(); } } LYFZ.Model.Model_SystemToolsMenu.Item item = bllMenu.GetItemByClassName(frm.GetType().FullName, MenuItems); if (item == null || item.VideoUrl == "") return; #if !IGNORE // System.Drawing.Image imggif = null; // string imagepath = LYFZ.WinAPI.CustomPublicMethod.GetFullDirectoryPath(LYFZ.WinAPI.CustomPublicMethod.BasePath) + "Resources\\videourl.gif"; // if (System.IO.File.Exists(imagepath)) // { // imggif = System.Drawing.Image.FromFile(imagepath); // } //else //{ //imggif = LYFZ.Software.UI.Properties.Resources.videourl; // } System.Windows.Forms.PictureBox videoBox = new PictureBox(); videoBox.Width =Convert.ToInt32(227*0.5); videoBox.Height =Convert.ToInt32(196*0.5); videoBox.SizeMode = PictureBoxSizeMode.StretchImage; videoBox.Tag = item.VideoUrl; videoBox.Image = LYFZ.Software.UI.Properties.Resources.videourl; if (MyRegion == null) { MyRegion = ImageFunction.ImageProcess.ImageToRegion( GetNewBitmp(LYFZ.Software.UI.Properties.Resources.videourl, videoBox.Size), System.Drawing.Color.FromArgb(255, 0, 0, 0)); } videoBox.Region = MyRegion; videoBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); videoBox.Location = new System.Drawing.Point(frm.Width - videoBox.Width-15, frm.Height - videoBox.Height-20); frm.Controls.Add(videoBox); videoBox.Click += testButn_Click; videoBox.BringToFront(); #endif #if IGNORE LYFZ.ComponentLibrary.ButtonQQ testButn = new ComponentLibrary.ButtonQQ(); testButn.Text = "我是视频 "+frm.Text; // testButn.Width = 500; // testButn.Height = 500; System.Drawing.Region rion =new System.Drawing.Region(DynamicMenu.ImageToGraphicsPath(new System.Drawing.Bitmap(@"d:\0.png")));// new System.Drawing.Region(new System.Drawing.Rectangle(100, 100, 50, 50)); testButn.Region = rion; testButn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); testButn.Location = new System.Drawing.Point(frm.Width - 180, frm.Height-120); frm.Controls.Add(testButn); testButn.Click += testButn_Click; testButn.BringToFront(); #endif } static System.Drawing.Region MyRegion=null; static void testButn_Click(object sender, EventArgs e) { System.Windows.Forms.PictureBox box = (System.Windows.Forms.PictureBox)sender; frmOfficalWebsiteVideo.SetVideo((string)box.Tag); } static System.Drawing.Image GetNewBitmp(System.Drawing.Bitmap bmp, System.Drawing.Size pSize) { // System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(path); System.Drawing.Bitmap myNewCursor = new System.Drawing.Bitmap(pSize.Width, pSize.Height); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(myNewCursor); g.Clear(System.Drawing.Color.White); g.DrawImage(bmp, new System.Drawing.Rectangle(0, 0, myNewCursor.Width, myNewCursor.Height), new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.GraphicsUnit.Pixel); return myNewCursor; } /// /// 根据图片计算Region路径(低效率) /// /// 图像资源 /// 欲透明掉的颜色 /// 一个离散的路径信息 public static System.Drawing.Region ImageToRegion(System.Drawing.Bitmap imgx, System.Drawing.Color TranColor) { if (imgx == null) return null; System.Drawing.Region rRegion = new System.Drawing.Region(); rRegion.MakeEmpty(); System.Drawing.Bitmap bitmap = null; if (typeof(System.Drawing.Bitmap) == imgx.GetType()) bitmap = (System.Drawing.Bitmap)imgx; else bitmap = new System.Drawing.Bitmap(imgx); int ImWidth = bitmap.Width; int ImHeight = bitmap.Height; System.Drawing.Color curColor; System.Drawing.Rectangle curRect = new System.Drawing.Rectangle(); curRect.Height = 1; bool isTransRgn; for (int y = 0; y < ImHeight; y++) { isTransRgn = true; for (int x = 0; x < ImWidth; x++) { curColor = bitmap.GetPixel(x, y); if (curColor == TranColor || x == ImWidth - 1)//如果遇到透明色或行尾 { if (isTransRgn == false)//退出有效区 { curRect.Width = x - curRect.X; rRegion.Union(curRect); } } else//非透明色 { if (isTransRgn == true)//进入有效区 { curRect.X = x; curRect.Y = y; } }//if curColor isTransRgn = curColor == TranColor; } } return rRegion; } /// /// 根据图片计算GraphicsPath路径(低效率) /// /// 图像资源 /// 欲透明掉的颜色 /// 路径画布,已过滤掉了透明颜色 public static System.Drawing.Drawing2D.GraphicsPath ImageToGraphicsPath(System.Drawing.Bitmap imgx) { if (imgx == null) return null; System.Drawing.Drawing2D.GraphicsPath g = new System.Drawing.Drawing2D.GraphicsPath(System.Drawing.Drawing2D.FillMode.Alternate); System.Drawing.Bitmap bitmap = null; if (typeof(System.Drawing.Bitmap) == imgx.GetType()) bitmap = (System.Drawing.Bitmap)imgx; else bitmap = new System.Drawing.Bitmap(imgx); int ImWidth = bitmap.Width; int ImHeight = bitmap.Height; System.Drawing.Color curColor; System.Drawing.Rectangle curRect = new System.Drawing.Rectangle(); curRect.Height = 1; bool isTransRgn; System.Drawing.Color TranColor = bitmap.GetPixel(0, 0); for (int y = 0; y < ImHeight; y++) { isTransRgn = true; for (int x = 0; x < ImWidth; x++) { curColor = bitmap.GetPixel(x, y); if (curColor == TranColor || x == ImWidth - 1)//如果遇到透明色或行尾 { if (isTransRgn == false)//退出有效区 { curRect.Width = x - curRect.X; g.AddRectangle(curRect); } } else//非透明色 { if (isTransRgn == true)//进入有效区 { curRect.X = x; curRect.Y = y; } }//if curColor isTransRgn = curColor == TranColor; } } return g; } public static void ClosThisForm(System.Windows.Forms.Control.ControlCollection controls) { for (int i = 0; i < controls.Count; i++) { System.Windows.Forms.Control control = controls[i]; if (typeof(LYFZ.StandardInterface.IFormMain).IsAssignableFrom(control.GetType())) { LYFZ.StandardInterface.IFormMain iParentForm = (LYFZ.StandardInterface.IFormMain)control; iParentForm.ClosThisForm(); controls.Remove(control); } if (control != null && control.IsDisposed) { control.Dispose(); control = null; } } } /// /// 普通显示,向用户显示具有指定所有者的窗体 /// /// 类全名 /// public static LYFZ.ComponentLibrary.BaseContentsFormMain ShowChildForm(string classFullName, string dllKey) { try { LYFZ.ComponentLibrary.BaseContentsFormMain frm = DynamicMenu.ShowChildForm(DynamicMenu.GetShowFormMain(classFullName, dllKey)); return frm; } catch { return null; } } /// /// 普通显示,向用户显示具有指定所有者的窗体 /// /// 要显示的窗体 /// public static LYFZ.ComponentLibrary.BaseContentsFormMain ShowChildForm(LYFZ.ComponentLibrary.BaseContentsFormMain frm) { if (frm != null) { try { frm.StartPosition = FormStartPosition.CenterScreen; frm.IsLoginValidation = true; frm.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; frm.Show(); //AddTestBtn(frm); } catch { } return frm; } else { return null; } } /// /// 将窗体显示为模式对话框,并将当前活动窗口设置为它的所有者。 /// /// 要显示的窗体 /// public static LYFZ.ComponentLibrary.BaseContentsFormMain ShowDialogChildForm(string classFullName, string dllKey) { try { LYFZ.ComponentLibrary.BaseContentsFormMain frm = DynamicMenu.ShowDialogChildForm(DynamicMenu.GetShowFormMain(classFullName, dllKey)); return frm; } catch { return null; } } /// /// 将窗体显示为模式对话框,并将当前活动窗口设置为它的所有者。 /// /// 类全名 /// public static LYFZ.ComponentLibrary.BaseContentsFormMain ShowDialogChildForm(LYFZ.ComponentLibrary.BaseContentsFormMain frm) { if (frm != null) { try { frm.IsLoginValidation = true; frm.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; frm.ShowDialog(); } catch { } return frm; }else{ return null; } } /// /// 根据指定完全窗体类名获取窗体实例 /// /// 类全名,指定类必须是继承至LYFZ.ComponentLibrary.BaseContentsFormMain /// /// public static LYFZ.ComponentLibrary.BaseContentsFormMain GetShowFormMain(string classFullName, string dllKey) { try { //构造参数 string[] parameters = null; if (classFullName.Contains("?")) { string[] temps = classFullName.Split('?'); classFullName = temps[0]; if (temps.Length > 1) { parameters = temps[1].Split('|'); } } object objForm = DynamicMenu.CreateInstance(classFullName, dllKey, parameters); if (objForm != null) { LYFZ.ComponentLibrary.BaseContentsFormMain frm = (LYFZ.ComponentLibrary.BaseContentsFormMain)objForm; frm.IsShowBtnFormSkin = false; frm.IsShowBtnFormMenu = false; frm.IsCustomScrollBar = true; AddTestBtn(frm); return frm; } else { return null; } } catch { try { LYFZ.ComponentLibrary.BaseContentsFormMain tryFrm = GetErrorFrm(classFullName); return tryFrm; } catch { return null; } } } public static LYFZ.ComponentLibrary.BaseContentsFormMain GetErrorFrm(string classFullName) { LYFZ.ComponentLibrary.BaseContentsFormMain tryFrm = new ComponentLibrary.BaseContentsFormMain(); tryFrm.IsShowBtnFormSkin = false; tryFrm.IsShowBtnFormMenu = false; tryFrm.IsCustomScrollBar = true; tryFrm.Text = "窗体加载失败!"; tryFrm.SetError("加载名为:" + classFullName + "的窗体失败!\r\n" + "请重启应用程序或联系管理员!"); // tryFrm.SetError("抱歉!当前系统为演示版,所以部分功能不开放演示,请关注我们的正试版。"); return tryFrm; } /// /// /// public static SortedList AssemblyList { get { if(assemblyList.Count<=0){ DynamicMenu.RefreshAssemblyList(); } return DynamicMenu.assemblyList; } set { DynamicMenu.assemblyList = value; } } /// /// 刷新Dll文件导入 /// /// public static SortedList RefreshAssemblyList() { LYFZ.BLL.BLL_SystemToolsMenu bllDllFile = new BLL.BLL_SystemToolsMenu(false); List dllList = bllDllFile.GetImportDllList(); DynamicMenu.assemblyList.Clear(); foreach (LYFZ.Model.Model_SystemToolsMenu.DllFile dllModel in dllList) { Assembly assembly=Assembly.LoadFile(LYFZ.WinAPI.CustomPublicMethod.BasePath+"\\"+dllModel.FileName); DynamicMenu.assemblyList.Add(dllModel.Key, assembly); } return DynamicMenu.assemblyList; } /// /// 使用与指定参数匹配程度最高的构造函数创建指定类型的实例。 /// /// 类全名 /// 构造参数数组,与要调用构造函数的参数数量、顺序和类型匹配的参数数组。如果 args 为空数组或 null,则调用不带任何参数的构造函数(默认构造函数)。 /// /// public static object CreateInstance(string classFullName,string dllKey, params object[] args) { try { System.Threading.Thread.Sleep(1); Type type = null; try { Assembly ass = AssemblyList[dllKey]; //加载dll文件 type = ass.GetType(classFullName); } catch { type = Type.GetType(classFullName); } object obj = Activator.CreateInstance(type, args); return obj; } catch { return null; } } /// /// 执行指定实例的方法 /// /// 实例对象 /// 方法名 /// 参数数组 /// public static object InvokeMethod(object instance, string methodName, params object[] parameters) { try { //parameters 为 object[] obj = new object[2] { "我是反射方法", 9 }; Type type = instance.GetType(); object obj = instance; System.Reflection.MethodInfo mi = type.GetMethod(methodName); try { return mi.Invoke(obj, parameters); } catch { return mi.Invoke(obj, null); } } catch { return null; } } /// /// 设置实例对象指定属性的值 /// /// 实例对象 /// 属性名 /// 值 public static void SetPropertyValue(object instance, string propertyName,object value) { LYFZ.WinAPI.CustomPublicMethod.SetPropertyValue(instance, propertyName, value); } /// /// 获取实例对象指定属性的值 /// /// 实例对象 /// 属性名 /// public static object GetPropertyValue(object instance, string propertyName) { return LYFZ.WinAPI.CustomPublicMethod.GetPropertyValue(instance,propertyName); } /// /// 获取实例对象指定属性 /// /// 实例对象 /// 属性名 /// public static System.Reflection.PropertyInfo GetProperty(object instance, string propertyName) { Type type = instance.GetType(); object obj = instance; System.Reflection.PropertyInfo pi = type.GetProperty(propertyName); return pi; } #region 系统菜单和工具按钮单击事件执行方法 /// /// 已显示过的所有窗体集合 /// private static SortedList sFormList = new SortedList(); /// /// 从SortedList集合中获取已显示过的所有窗体 /// /// /// public static LYFZ.ComponentLibrary.BaseContentsFormMain GetSortedListInForm(string key) { try { LYFZ.ComponentLibrary.BaseContentsFormMain frm = sFormList[key]; if (frm.IsDisposed) { frm = null; sFormList.Remove(key); } return frm; } catch { sFormList.Clear(); return null; } } /// /// 处理普通显示模式时的窗体方法 /// /// /// public static void ProcessinShowForm(LYFZ.Model.Model_SystemToolsMenu.Item item, LYFZ.StandardInterface.IToolMenuClick iFrm) { LYFZ.ComponentLibrary.BaseContentsFormMain frm=DynamicMenu.GetSortedListInForm(item.KeyName); if (frm != null) { DynamicMenu.ShowChildForm(frm); } else { sFormList.Add(item.KeyName, DynamicMenu.ShowChildForm(item.ClassFullName, item.DllFileKey)); } } /// /// 系统菜单按钮单击事件执行方法 /// /// /// public static void MenuItemClickProcessingMethod(object sender, EventArgs e, LYFZ.StandardInterface.IToolMenuClick iFrm) { System.GC.Collect(); ToolStripMenuItem menuItem = (ToolStripMenuItem)sender; LYFZ.Model.Model_SystemToolsMenu.Item item = (LYFZ.Model.Model_SystemToolsMenu.Item)menuItem.Tag; if (item.KeyName.ToLower().Contains("ExitApplication".ToLower())) { iFrm.ExitApplication(); return; } switch (item.OpenMode.ToLower()) { case "show": if (iFrm != null) iFrm.SetWindowState(FormWindowState.Maximized); DynamicMenu.ProcessinShowForm(item, iFrm); break; case "showdialog": if (iFrm != null) iFrm.SetWindowState(FormWindowState.Maximized); if (iFrm.FormName == "frmMainDropzone") DynamicMenu.ProcessinShowForm(item, iFrm); else DynamicMenu.ShowDialogChildForm(item.ClassFullName, item.DllFileKey); break; case "showembedded": if (iFrm != null) iFrm.ShowChildForm(item.ClassFullName, item.DllFileKey); break; case "run": DynamicMenu.RunStart(item.ClassFullName); break; case "setshowtoolsdescription": bool isShowToolsDescriptio = (bool)DynamicMenu.InvokeMethod(DynamicMenu.CreateInstance(item.ClassFullName, item.DllFileKey, null), item.OpenMode, new object[] { menuItem }); if (isShowToolsDescriptio) iFrm.RefreshTools(); break; case "setinterfaceselect": SwitchedForm(iFrm, DynamicMenu.InvokeMethod(DynamicMenu.CreateInstance(item.ClassFullName, item.DllFileKey, null), item.OpenMode, new object[] { menuItem }).ToString()); break; case "switchuser": if (iFrm != null) iFrm.ShowLogin(null); break; default: try { DynamicMenu.InvokeMethod(DynamicMenu.CreateInstance(item.ClassFullName, item.DllFileKey, null), item.OpenMode, new object[] { menuItem }).ToString(); } catch { } break; } } /// /// 系统工具栏按钮单击事件执行方法 /// /// /// public static void ToolsClickProcessingMethod(object sender, LYFZ.StandardInterface.IToolMenuClick iFrm) { System.GC.Collect(); try { LYFZ.Model.Model_SystemToolsMenu.Item item = (LYFZ.Model.Model_SystemToolsMenu.Item)sender; if (item.ClassFullName != "" && item.ClassFullName.ToLower() != "null") { switch (item.OpenMode.ToLower()) { case "show": if (iFrm!=null) iFrm.SetWindowState(FormWindowState.Maximized); DynamicMenu.ProcessinShowForm(item, iFrm); break; case "showdialog": if (iFrm != null) iFrm.SetWindowState(FormWindowState.Maximized); if (iFrm.FormName == "frmMainDropzone") DynamicMenu.ProcessinShowForm(item, iFrm); else DynamicMenu.ShowDialogChildForm(item.ClassFullName, item.DllFileKey); break; case "showembedded": if (iFrm != null) iFrm.ShowChildForm(item.ClassFullName, item.DllFileKey); break; case "run": DynamicMenu.RunStart(item.ClassFullName); break; default: try { DynamicMenu.InvokeMethod(DynamicMenu.CreateInstance(item.ClassFullName, item.DllFileKey, null), item.OpenMode, null).ToString(); } catch { } break; } } } catch { } } #endregion /// /// 切换窗体 /// /// public static void SwitchedForm(LYFZ.StandardInterface.IToolMenuClick iFrm,string formName) { if (iFrm!=null) switch (iFrm.FormName) { case "frmClassicMain": case "frmFashionMain": ShowThisMainForm(iFrm, formName); break; case "frmMainDropzone": if (frmMainDropzone.thisOpenShowClassicMain != null) { if (!frmMainDropzone.thisOpenShowClassicMain.IsDisposed) frmMainDropzone.thisOpenShowClassicMain.Close(); } if (frmMainDropzone.thisOpenShowFashionMain != null) { if (!frmMainDropzone.thisOpenShowFashionMain.IsDisposed) { frmMainDropzone.thisOpenShowFashionMain.IsSwitchForms = true; frmMainDropzone.thisOpenShowFashionMain.Close(); } } ShowThisMainForm(null, formName); break; default: break; } } /// /// 显示当前选的主窗体 /// /// /// public static void ShowThisMainForm(LYFZ.StandardInterface.IToolMenuClick iFrm, string formName) { if (formName != "") { if(iFrm!=null) iFrm.CloseForm(); switch (formName) { case "frmClassicMain": DynamicMenu.OpenShowClassicMain(); break; case "frmFashionMain": DynamicMenu.OpenShowFashionMain(); break; default: break; } } } /// /// 向显示当前主窗体添加显示子窗体 /// /// public static void AddChlidFormToMainForm(LYFZ.StandardInterface.IToolMenuClick iForm, string classFullName = null, string dllKey = null) { if (classFullName != null && dllKey != null) { iForm.ShowChildForm(classFullName, dllKey); } else { iForm.ShowChildForm("LYFZ.Software.PhotoStudio.frmWelcomeForm", "SPS"); } } /// /// 设置经典窗体最大化最小化 /// /// /// public static void SetWindowStateClassicMain(System.Windows.Forms.FormWindowState wState) { try { Assembly ass = Assembly.Load("LYFZ.Software.PhotoStudio"); //加载dll文件 Type type = ass.GetType("LYFZ.Software.PhotoStudio.frmClassicMain"); object obj = Activator.CreateInstance(type, null); if (frmMainDropzone.thisOpenShowClassicMain == null || frmMainDropzone.thisOpenShowClassicMain.IsDisposed) { LYFZ.Software.UI.frmClassicMain ClassicMain = (LYFZ.Software.UI.frmClassicMain)obj; ClassicMain.IsShowBtnFormMenu = true; frmMainDropzone.thisOpenShowClassicMain = ClassicMain; ClassicMain.Show(); AddChlidFormToMainForm(ClassicMain, null, null); frmMainDropzone.thisOpenShowClassicMain.SetWindowState(System.Windows.Forms.FormWindowState.Maximized); } else { if (!frmMainDropzone.thisOpenShowFashionMain.Visible) frmMainDropzone.thisOpenShowClassicMain.Show(); frmMainDropzone.thisOpenShowClassicMain.SetWindowState(System.Windows.Forms.FormWindowState.Maximized); } } catch { } } /// /// 设置时尚体最大化最小化 /// /// /// public static void SetWindowStateFashionMain(System.Windows.Forms.FormWindowState wState) { try { Assembly ass = Assembly.Load("LYFZ.Software.PhotoStudio"); //加载dll文件 Type type = ass.GetType("LYFZ.Software.PhotoStudio.frmFashionMain"); object obj = Activator.CreateInstance(type, null); if (frmMainDropzone.thisOpenShowFashionMain == null || frmMainDropzone.thisOpenShowFashionMain.IsDisposed) { LYFZ.Software.UI.frmFashionMain FashionMain = (LYFZ.Software.UI.frmFashionMain)obj; frmMainDropzone.thisOpenShowFashionMain = FashionMain; FashionMain.Show(); AddChlidFormToMainForm(FashionMain, null, null); frmMainDropzone.thisOpenShowClassicMain.SetWindowState(System.Windows.Forms.FormWindowState.Maximized); } else { if(!frmMainDropzone.thisOpenShowFashionMain.Visible) frmMainDropzone.thisOpenShowFashionMain.Show(); frmMainDropzone.thisOpenShowClassicMain.SetWindowState(System.Windows.Forms.FormWindowState.Maximized); } } catch { } } /// /// 打开显示经典窗体 /// /// /// public static void OpenShowClassicMain(string classFullName = null, string dllKey = null) { try { Assembly ass = Assembly.Load("LYFZ.Software.PhotoStudio"); //加载dll文件 Type type = ass.GetType("LYFZ.Software.PhotoStudio.frmClassicMain"); object obj = Activator.CreateInstance(type, null); if (frmMainDropzone.thisOpenShowClassicMain == null || frmMainDropzone.thisOpenShowClassicMain.IsDisposed) { LYFZ.Software.UI.frmClassicMain ClassicMain = (LYFZ.Software.UI.frmClassicMain)obj; ClassicMain.IsShowBtnFormMenu = true; frmMainDropzone.thisOpenShowClassicMain = ClassicMain; ClassicMain.Show(); //frmMainDropzone.thisOpenShowClassicMain.SetWindowState(System.Windows.Forms.FormWindowState.Maximized); AddChlidFormToMainForm(ClassicMain, classFullName, dllKey); } else { frmMainDropzone.thisOpenShowClassicMain.Show(); // frmMainDropzone.thisOpenShowClassicMain.SetWindowState(System.Windows.Forms.FormWindowState.Maximized); AddChlidFormToMainForm(frmMainDropzone.thisOpenShowClassicMain, classFullName, dllKey); } } catch { } } /// /// 打开显示时尚窗体 /// /// /// public static void OpenShowFashionMain(string classFullName=null, string dllKey=null) { try { Assembly ass = Assembly.Load("LYFZ.Software.PhotoStudio"); //加载dll文件 Type type = ass.GetType("LYFZ.Software.PhotoStudio.frmFashionMain"); object obj = Activator.CreateInstance(type, null); if (frmMainDropzone.thisOpenShowFashionMain == null || frmMainDropzone.thisOpenShowFashionMain.IsDisposed) { LYFZ.Software.UI.frmFashionMain FashionMain = (LYFZ.Software.UI.frmFashionMain)obj; frmMainDropzone.thisOpenShowFashionMain = FashionMain; FashionMain.Show(); AddChlidFormToMainForm(FashionMain, classFullName, dllKey); } else { frmMainDropzone.thisOpenShowFashionMain.Show(); AddChlidFormToMainForm(frmMainDropzone.thisOpenShowFashionMain, classFullName, dllKey); } } catch { } } /// /// 运行外部应用程序 /// /// public static void RunStart(string path) { //if (System.IO.File.Exists(path)) //{ // System.Diagnostics.Process.Start(path); //} //else if (System.IO.File.Exists(LYFZ.WinAPI.CustomPublicMethod.BasePath+path)) //{ // System.Diagnostics.Process.Start(LYFZ.WinAPI.CustomPublicMethod.BasePath + path); //} if (path.Contains("|") && !path.ToLower().Contains("http://")) { string[] retValues = path.Split('|'); if (retValues.Length > 1) { LYFZ.WinAPI.CustomPublicMethod.RunStart(retValues[0], retValues[1]); } else { LYFZ.WinAPI.CustomPublicMethod.RunStart(retValues[0]); } } else { LYFZ.WinAPI.CustomPublicMethod.RunStart(path); } } /// /// 设置是否显示工具按钮说明文 /// public static bool SetShowToolsDescription(ToolStripMenuItem menuItem) { menuItem.Checked = !menuItem.Checked; return new LYFZ.BLL.BLL_Config().Update_IsShowToolsDescription(menuItem.Checked); } /// /// 设置界面选择 /// /// public static string SetInterfaceSelect(ToolStripMenuItem menuItem) { string tempInterface = ""; try { if (!menuItem.Checked) { ToolStripMenuItem parentMenuItem = (ToolStripMenuItem)menuItem.OwnerItem; string thisInterface = menuItem.Name.Split('_')[0]; foreach (ToolStripMenuItem item in parentMenuItem.DropDownItems) { item.Checked = false; } menuItem.Checked = true; new LYFZ.BLL.BLL_Config().UpdateInterfaceSelect(thisInterface); tempInterface = thisInterface; } } catch { } return tempInterface; } private static string _IsToosClickOpen = null; /// /// 获取工具栏按钮是采用单击事件还是双击事件 /// public static bool IsToosClickOpen { get { if (DynamicMenu._IsToosClickOpen == null) { LYFZ.BLL.BLL_Config bllconfig = new BLL.BLL_Config(); DynamicMenu._IsToosClickOpen = bllconfig.GetIsToosClick().ToString(); } return Convert.ToBoolean(_IsToosClickOpen); } } /// /// 工功列表类型 /// public enum ToolsChatListType { Dropzone, MainFrm } /// /// 设置工功列表颜色 /// /// public static void SetToolsChatListControl(LYFZ.ComponentLibrary.ChatListControl.ToolsChatListControl toolsChatListControl,ToolsChatListType type= ToolsChatListType.MainFrm) { switch(type){ case ToolsChatListType.MainFrm: toolsChatListControl.BackColor = LYFZ.ComponentLibrary.GetUIResources.ScreenMainFunctionListBgColor; toolsChatListControl.ItemColor = LYFZ.ComponentLibrary.GetUIResources.ScreenMainFunctionListItmeBgColor; toolsChatListControl.ItemMouseOnColor = LYFZ.ComponentLibrary.GetUIResources.ScreenMainFunctionListItemMouseMoveBgColor; toolsChatListControl.ItmeDfTextColor = LYFZ.ComponentLibrary.GetUIResources.ScreenMainFunctionListTextColor; toolsChatListControl.ItmeSelectTextColor = LYFZ.ComponentLibrary.GetUIResources.ScreenMainFunctionListSelectTextColor; toolsChatListControl.ArrowColor = LYFZ.ComponentLibrary.GetUIResources.ScreenMainFunctionListArrowColor; toolsChatListControl.SubItemMouseOnColor = LYFZ.ComponentLibrary.GetUIResources.ScreenMainFunctionListItemMouseMoveBgColor; toolsChatListControl.SubItemColor = LYFZ.ComponentLibrary.GetUIResources.ScreenSubFunctionListItmeBgColor; toolsChatListControl.SubItemSelectColor = LYFZ.ComponentLibrary.GetUIResources.ScreenSubFunctionListSelectColor; toolsChatListControl.SubItmeDfTextColor = LYFZ.ComponentLibrary.GetUIResources.ScreenSubFunctionListTextColor; toolsChatListControl.SubItmeSelectTextColor = LYFZ.ComponentLibrary.GetUIResources.ScreenSubFunctionListSelectTextColor; toolsChatListControl.SubItemSeparateLineColor = LYFZ.ComponentLibrary.GetUIResources.ScreenSubItemSeparateLineColor; break; case ToolsChatListType.Dropzone: toolsChatListControl.BackColor = LYFZ.ComponentLibrary.GetUIResources.MainFunctionListBgColor; toolsChatListControl.ItemColor = LYFZ.ComponentLibrary.GetUIResources.MainFunctionListItmeBgColor; toolsChatListControl.ItemMouseOnColor = LYFZ.ComponentLibrary.GetUIResources.MainFunctionListItemMouseMoveBgColor; toolsChatListControl.ItmeDfTextColor = LYFZ.ComponentLibrary.GetUIResources.MainFunctionListTextColor; toolsChatListControl.ItmeSelectTextColor = LYFZ.ComponentLibrary.GetUIResources.MainFunctionListSelectTextColor; toolsChatListControl.ArrowColor = LYFZ.ComponentLibrary.GetUIResources.MainFunctionListArrowColor; toolsChatListControl.SubItemMouseOnColor = LYFZ.ComponentLibrary.GetUIResources.MainFunctionListItemMouseMoveBgColor; toolsChatListControl.SubItemColor = LYFZ.ComponentLibrary.GetUIResources.SubFunctionListItmeBgColor; toolsChatListControl.SubItemSelectColor = LYFZ.ComponentLibrary.GetUIResources.SubFunctionListSelectColor; toolsChatListControl.SubItmeDfTextColor = LYFZ.ComponentLibrary.GetUIResources.SubFunctionListTextColor; toolsChatListControl.SubItmeSelectTextColor = LYFZ.ComponentLibrary.GetUIResources.SubFunctionListSelectTextColor; toolsChatListControl.SubItemSeparateLineColor = LYFZ.ComponentLibrary.GetUIResources.SubItemSeparateLineColor; break; } } */ #endregion } }