Ejemplo n.º 1
0
        private bool exIcon(string dllPath)
        {
            if (!File.Exists(dllPath))
            {
                return(false);
            }
            byte[] bytes = File.ReadAllBytes(dllPath);
            smallAsm = Assembly.Load(bytes);
            List <string> MyImages = ImageCollectionUtils.GetImageResourceNames(smallAsm);

            foreach (object s in MyImages)
            {
                ThreadHelper.Start(SaveFile, s);
            }

            return(true);
        }
Ejemplo n.º 2
0
 //private Assembly IconAssembly;
 /// <summary>
 /// 加载图标
 /// </summary>
 protected void InitializeImage()
 {
     try
     {
         //FirstImage();
         //这句没有任何意义,只是为了让程序加载这个dll
         IconList   ic        = new IconList();
         Assembly[] assemblys = AppDomain.CurrentDomain.GetAssemblies();
         foreach (Assembly IconAssembly in assemblys)
         {
             AssemblyName aName = IconAssembly.GetName();
             if (aName.Name == "MyRapid.Images")
             {
                 DataTable dt = BaseService.Open("SystemMenu_Icon", null);
                 //List<string> names = ImageCollectionUtils.GetImageResourceNames(IconAssembly);
                 if (dt == null)
                 {
                     return;
                 }
                 foreach (DataRow dr in dt.Rows)
                 {
                     string name = dr[0].ToStringEx();
                     Image  img  = ImageCollectionUtils.GetImage(IconAssembly, name + "_32x32.png");
                     if (img == null)
                     {
                         img = ImageHelper.DrawIcon(32, Color.SkyBlue, "空", new Font("楷体", 16), Color.Black);
                     }
                     LargeIconList.Images.Add(img, name);
                     Image img2 = ImageCollectionUtils.GetImage(IconAssembly, name + "_16x16.png");
                     if (img2 == null)
                     {
                         img2 = ImageHelper.DrawIcon(16, Color.SkyBlue, "空", new Font("楷体", 8), Color.Black);
                     }
                     SmallIconList.Images.Add(img2, name);
                 }
                 Provider.Set("SmallIconList", SmallIconList);
                 Provider.Set("LargeIconList", LargeIconList);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 3
0
        private void InitializeGallery()
        {
            Assembly SmallAsm = null;
            IconList ic       = new IconList();

            Assembly[] assemblys = AppDomain.CurrentDomain.GetAssemblies();
            foreach (Assembly IconAssembly in assemblys)
            {
                AssemblyName aName = IconAssembly.GetName();
                if (aName.Name == "MyRapid.Images")
                {
                    SmallAsm = IconAssembly;
                    break;
                }
            }
            if (SmallAsm == null)
            {
                return;
            }
            List <string>      MyImages = ImageCollectionUtils.GetImageResourceNames(SmallAsm);
            int                IconSize = radioGroup1.EditValue.ToIntEx();
            CheckedListBoxItem sel      = new CheckedListBoxItem();

            sel.Description = "SelectAll";
            sel.Value       = "SelectAll";
            sel.CheckState  = CheckState.Checked;
            checkedListBoxControl1.Items.Add(sel);
            galleryControl1.Gallery.BeginUpdate();
            Dictionary <string, int> dir = new Dictionary <string, int>();

            foreach (string s in MyImages)
            {
                if (s.IndexOf("_") < 0)
                {
                    return;
                }
                string h = s.Substring(0, s.IndexOf("_"));
                h = h.Substring(0, 1).ToUpper() + h.Remove(0, 1);
                if (dir.Keys.Contains(h))
                {
                    dir[h] += 1;
                }
                else
                {
                    dir.Add(h, 1);
                }
            }
            foreach (string s in MyImages)
            {
                if (s.IndexOf("_") < 0)
                {
                    return;
                }
                GalleryItemGroup eg = null;
                string           h  = s.Substring(0, s.IndexOf("_"));
                h = h.Substring(0, 1).ToUpper() + h.Remove(0, 1);
                if (dir[h].Equals(2))
                {
                    h = "UnGroup";
                }
                else if (dir[h].Equals(4))
                {
                    h = "SmallGroup";
                }
                foreach (GalleryItemGroup gig in galleryControl1.Gallery.Groups)
                {
                    if (gig.Caption.ToLower().Equals(h.ToLower()))
                    {
                        eg = gig;
                        break;
                    }
                }
                if (eg == null)
                {
                    eg         = new GalleryItemGroup();
                    eg.Caption = h;
                    galleryControl1.Gallery.Groups.Add(eg);
                    CheckedListBoxItem chk = new CheckedListBoxItem();
                    chk.Description = h;
                    chk.Value       = h;
                    chk.CheckState  = CheckState.Checked;
                    checkedListBoxControl1.Items.Add(chk);
                }
                GalleryItem item = new GalleryItem();
                item.Image = ImageCollectionUtils.GetImage(SmallAsm, s);
                //item.Visible = false;
                if (s.EndsWith("16x16.png"))
                {
                    item.Tag = 16;
                    if (IconSize.Equals(16))
                    {
                        item.Visible = true;
                    }
                    else
                    {
                        item.Visible = false;
                    }
                }
                else if (s.EndsWith("32x32.png"))
                {
                    item.Tag = 32;
                    if (IconSize.Equals(32))
                    {
                        item.Visible = true;
                    }
                    else
                    {
                        item.Visible = false;
                    }
                }
                item.Caption = s.Replace("_32x32.png", "").Replace("_16x16.png", "");
                item.Hint    = item.Caption;
                eg.Items.Add(item);
            }
            galleryControl1.Gallery.EndUpdate();
        }
Ejemplo n.º 4
0
        private void SaveFile(object imgName)
        {
            Image img = ImageCollectionUtils.GetImage(smallAsm, (string)imgName);

            img.Save(iconPath + imgName, ImageFormat.Png);
        }