/// <summary> /// 初始化加载图标资源 /// </summary> /// <returns></returns> private DXImageGalleryLoader LoadData() { this.ImageCollection = new Dictionary <string, GalleryItem>(); this.Categories = new List <string>(); this.Collection = new List <string>(); this.Size = new List <string>(); using (System.Resources.ResourceReader reader = GetResourceReader(DevExpress.Utils.DxImageAssemblyUtil.ImageAssembly)) { System.Collections.IDictionaryEnumerator dict = reader.GetEnumerator(); while (dict.MoveNext()) { string key = (string)dict.Key as string; if (!DevExpress.Utils.DxImageAssemblyUtil.ImageProvider.IsBrowsable(key)) { continue; } if (key.EndsWith(".png", StringComparison.Ordinal)) { string reg = @"(?<collection>\S*?)/(?<category>\S*?)/(?<name>\S*)"; var collectionItem = CRegex.GetText(key, reg, "collection"); var categoryItem = CRegex.GetText(key, reg, "category"); string sizeReg = @"_(?<size>\S*)\."; var sizeItem = CRegex.GetText(key, sizeReg, "size"); if (!this.Collection.Contains(collectionItem)) { this.Collection.Add(collectionItem); } if (!this.Categories.Contains(categoryItem)) { this.Categories.Add(categoryItem); } if (!this.Size.Contains(sizeItem)) { this.Size.Add(sizeItem); } Image image = GetImageFromStream((System.IO.Stream)dict.Value); if (image != null) { var item = new DevExpress.XtraBars.Ribbon.GalleryItem(image, key, key); if (!ImageCollection.ContainsKey(key)) { ImageCollection.Add(key, item); } } } } } return(this); }
public static void LoadImages() { var retrievedImages = DatabaseService.GetAllImages(); ImageCollection.Clear(); foreach (var dao in retrievedImages) { var img = ImageEncodingService.Base64ToSKImage(dao.Base64); var galleryImageEntry = new ImageEntry(img, dao.Name, dao.CreationTime, dao.Id); if (ImageCollection.ContainsKey(dao.CreationTime.Date)) { ImageCollection[dao.CreationTime.Date].Add(galleryImageEntry); } else { ImageCollection.Add(dao.CreationTime.Date, new GalleryImageSection(dao.CreationTime.Date)); ImageCollection[dao.CreationTime.Date].Add(galleryImageEntry); } } }