private async void DownloadAndSetImage(Uri uri) { try { if (string.IsNullOrEmpty(Tag?.ToString())) { //Tag = "WorkingOnImage"; string name = InstagramApiSharp.Helpers.CryptoHelper.CalculateMd5(uri.ToString().ToLower()) + ".jpg"; StorageFolder folder; try { folder = await Helper.CachedFolder(); } catch { folder = ApplicationData.Current.LocalFolder; } Uri dl = await HttpNetHelper.DownloadFileAsync(uri, name, folder).ConfigureAwait(false); await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { BitmapImage bitmapImage = new BitmapImage { DecodePixelType = DecodePixelType.Physical, UriSource = dl }; PosterSource = bitmapImage; } catch (Exception ex) { _ = ex.PrintException($"{GetType().FullName}.DownloadAndSetImage.BitmapImage"); } }); } } catch (Exception ex) { _ = ex.PrintException($"{GetType().FullName}.DownloadAndSetImage"); } }
//public static readonly DependencyProperty SourceProperty = // DependencyProperty.Register("Source", // typeof(Uri), // typeof(CachedBitmap), // new PropertyMetadata(null)); async void GetImageAsync(Uri uri) { try { var name = uri.AbsoluteUri; name = name.Substring(name.IndexOf("/") + 1); name = WebUtility.UrlDecode(name); name = Uri.UnescapeDataString(name); StorageFolder folder; try { folder = await CachedFolder(); }catch { folder = ApplicationData.Current.LocalFolder; } try { var dl = await HttpNetHelper.DownloadFileAsync(uri, name, folder); Update(dl); } catch { } } catch { Update(uri); } }