示例#1
0
        string GetModuleName(object addIn)
        {
            string guid = string.Empty;

            if (addIn is IAddIn)
            {
                guid = ((IAddIn)addIn).Guid.ToString();
            }
            else
            {
                guid = MetaHelper.GetModuleGuid(addIn.GetType());
            }

            Module module = XContext.ModuleList.Where(p => p.Guid == guid).FirstOrDefault();

            if (module == null)
            {
                using (DbEntities db = new DbEntities())
                {
                    module = db.Modules.Where(p => p.Guid == guid.ToUpper()).FirstOrDefault();
                }
            }

            if (module != null)
            {
                return(module.Name);
            }
            else
            {
                return(ModuleManager.GetModuleName(addIn));
            }
        }
示例#2
0
        void SetModule(object addIn)
        {
            string guid = string.Empty;

            if (addIn is IAddIn)
            {
                guid = ((IAddIn)addIn).Guid.ToString();
            }
            else
            {
                guid = MetaHelper.GetModuleGuid(addIn.GetType());
            }

            if (addIn is AboutForm)
            {
                this.Icon = (addIn as AboutForm).Icon;
            }
            else if (addIn is LoginForm)
            {
                this.Icon = (addIn as LoginForm).Icon;
            }
            else if (guid.Length > 0)
            {
                Module module = XContext.ModuleList.Where(p => p.Guid == guid).FirstOrDefault();
                if (module == null)
                {
                    using (DbEntities db = new DbEntities())
                    {
                        module = db.Modules.Where(p => p.Guid == guid.ToUpper()).FirstOrDefault();
                    }
                }

                if (module != null)
                {
                    this.Text = module.Name;
                    try
                    {
                        using (System.IO.MemoryStream ms = new System.IO.MemoryStream(module.Icon))
                        {
                            this.Icon = System.Drawing.Image.FromStream(ms).ToIcon();
                        }
                    }
                    catch { }
                }
                else
                {
                    this.Text = ModuleManager.GetModuleName(addIn);
                }
            }
        }