private void getPage(int page) { int imageCount = Statics.ResourceCatalog.Count(r => r.Contains("ResourceCats")); if (imageCount < 1 || page < 1) { return; } PageCount = ((imageCount - 1) / defaultTake) + 1; // The above checks ensures this does not go badly. PhotoThumbnails.Clear(); ImageSourceReader.Cleanup(); try { var imageFiles = Statics.ResourceCatalog.Where( p => p.Contains("ResourceCats")).Skip(calculateSkip(page)).Take(defaultTake); foreach (string image in imageFiles) { BitmapImage bitmapImage = ImageSourceReader.Read(image); if (bitmapImage == null) { continue; } string[] imageNameSplit = image.Split('.'); string filename = "ResourceCats." + imageNameSplit[2] + ".jpg"; PhotoThumbnails.Add(new CatModel() { Filename = filename, Portrait = bitmapImage }); } } catch (Exception Ex) { LogWriter.Exception("Error pulling catalog data. Please make sure there are no cats chewing on the cables behind your PC.", Ex); } PageCurrent = page; }
private void LoadThumbnails(Album AlbumItem) { var storage = StorageFactory.GetStorage(); var store = Data.Storage.StorageFactory.GetStorage(TenantProvider.CurrentTenantID.ToString(), "photo"); var items = storage.GetAlbumItems(AlbumItem); var thumbnails = new List <Dictionary <String, String> >(); for (int i = 0, n = items.Count; i < n; i++) { var thumbnail = new Dictionary <String, String>(); thumbnail.Add("Id", items[i].Id.ToString()); thumbnail.Add("Name", (items[i].Name ?? string.Empty).HtmlEncode()); thumbnail.Add("Src", ImageHTMLHelper.GetImageUrl(items[i].ExpandedStoreThumb, store)); thumbnails.Add(thumbnail); } PhotoThumbnails.DataSource = thumbnails; PhotoThumbnails.DataBind(); }