private static void ProcessImages(WriteableBitmap wb, List <string> localUris, List <Rect> map, Action <string> callback, int ind, long userOrChatId, bool isChat) { if (ind >= localUris.Count || ind >= map.Count) { Rectangle rectangle = new Rectangle(); rectangle.Width = (double)ConversationTileImageFormatter.DIMENSION; rectangle.Height = (double)ConversationTileImageFormatter.DIMENSION; rectangle.Fill = (Brush) new SolidColorBrush(Colors.Black); rectangle.Opacity = 0.2; wb.Render((UIElement)rectangle, (Transform)null); wb.Invalidate(); using (IsolatedStorageFile storeForApplication = IsolatedStorageFile.GetUserStoreForApplication()) { string path = "/Shared/ShellContent/conversationTileImg" + (object)userOrChatId + isChat.ToString() + ".jpg"; if (!storeForApplication.DirectoryExists("/Shared/ShellContent")) { storeForApplication.CreateDirectory("/Shared/ShellContent"); } using (IsolatedStorageFileStream storageFileStream = new IsolatedStorageFileStream(path, FileMode.Create, FileAccess.Write, storeForApplication)) { int targetWidth = ConversationTileImageFormatter.DIMENSION; int targetHeight = ConversationTileImageFormatter.DIMENSION; wb.SaveJpeg((Stream)storageFileStream, targetWidth, targetHeight, 0, 80); } callback(path); } } else { string uri = localUris[ind]; Rect rect = map[ind]; double width = rect.Width; rect = map[ind]; double height = rect.Height; Image image1 = ConversationTileImageFormatter.CreateImage(uri, width, height); WriteableBitmap writeableBitmap = wb; Image image2 = image1; TranslateTransform translateTransform = new TranslateTransform(); rect = map[ind]; double x = rect.X; translateTransform.X = x; rect = map[ind]; double y = rect.Y; translateTransform.Y = y; writeableBitmap.Render((UIElement)image2, (Transform)translateTransform); ConversationTileImageFormatter.ProcessImages(wb, localUris, map, callback, ind + 1, userOrChatId, isChat); } }
private static void ProcessImages(WriteableBitmap wb, List <string> localUris, List <Rect> map, Action <string> callback, int ind, long userOrChatId, bool isChat) { if (ind >= localUris.Count || ind >= map.Count) { Rectangle rectangle = new Rectangle(); ((FrameworkElement)rectangle).Width = ((double)ConversationTileImageFormatter.DIMENSION); ((FrameworkElement)rectangle).Height = ((double)ConversationTileImageFormatter.DIMENSION); ((Shape)rectangle).Fill = ((Brush) new SolidColorBrush(Colors.Black)); ((UIElement)rectangle).Opacity = 0.2; wb.Render((UIElement)rectangle, null); wb.Invalidate(); IsolatedStorageFile storeForApplication = IsolatedStorageFile.GetUserStoreForApplication(); try { string str = string.Concat(new object[4] { "/Shared/ShellContent/conversationTileImg", userOrChatId, isChat.ToString(), ".jpg" }); if (!storeForApplication.DirectoryExists("/Shared/ShellContent")) { storeForApplication.CreateDirectory("/Shared/ShellContent"); } IsolatedStorageFileStream storageFileStream = new IsolatedStorageFileStream(str, (FileMode)2, (FileAccess)2, storeForApplication); try { int dimension1 = ConversationTileImageFormatter.DIMENSION; int dimension2 = ConversationTileImageFormatter.DIMENSION; System.Windows.Media.Imaging.Extensions.SaveJpeg(wb, (Stream)storageFileStream, dimension1, dimension2, 0, 80); } finally { if (storageFileStream != null) { ((IDisposable)storageFileStream).Dispose(); } } callback(str); } finally { if (storeForApplication != null) { ((IDisposable)storeForApplication).Dispose(); } } } else { string localUri = localUris[ind]; Rect rect = map[ind]; // ISSUE: explicit reference operation double width = rect.Width; rect = map[ind]; // ISSUE: explicit reference operation double height = rect.Height; Image image1 = ConversationTileImageFormatter.CreateImage(localUri, width, height); WriteableBitmap writeableBitmap = wb; Image image2 = image1; TranslateTransform translateTransform = new TranslateTransform(); rect = map[ind]; // ISSUE: explicit reference operation double x = rect.X; translateTransform.X = x; rect = map[ind]; // ISSUE: explicit reference operation double y = rect.Y; translateTransform.Y = y; writeableBitmap.Render((UIElement)image2, (Transform)translateTransform); ConversationTileImageFormatter.ProcessImages(wb, localUris, map, callback, ind + 1, userOrChatId, isChat); } }