public void InitiateDownload(StoreProduct storeProduct) { List <int> stickerIds = storeProduct.stickers.sticker_ids; string baseUrl = storeProduct.stickers.base_url; List <RemoteLocalMapping> downloadList = new List <RemoteLocalMapping>(); foreach (int stickerId in stickerIds) { downloadList.Add(new RemoteLocalMapping() { RemoteUri = baseUrl + (object)stickerId + "/256b.png", LocalPath = this.GetLocalPathForStickerId256(storeProduct, stickerId) }); if (ScaleFactor.GetScaleFactor() == 100) { downloadList.Add(new RemoteLocalMapping() { RemoteUri = baseUrl + (object)stickerId + "/128b.png", LocalPath = this.GetLocalPathForStickerId128(storeProduct, stickerId) }); } } downloadList.Add(new RemoteLocalMapping() { RemoteUri = storeProduct.base_url + "/background.png", LocalPath = storeProduct.id.ToString() + "background.png" }); BatchDownloadManager.GetDownloadManager(storeProduct.id.ToString(), downloadList).Start(); }
private void UpdateState(bool animate = false) { if (this.CurrentDataContext == null || this.CurrentDataContext.IsEmoji) { base.Visibility = Visibility.Collapsed; } else { StoreProduct stickerProduct = this.CurrentDataContext.StickerProduct; if (stickerProduct == null) { return; } if (BatchDownloadManager.IsDownloaded(stickerProduct.id.ToString())) { base.Visibility = Visibility.Collapsed; } else { base.Visibility = Visibility.Visible; int id = stickerProduct.id; if (BatchDownloadManager.IsDownloading(id.ToString())) { ((UIElement)this.progressBar).Visibility = Visibility.Visible; ((UIElement)this.ButtonDownload).Opacity = 0.0; id = stickerProduct.id; double to = BatchDownloadManager.DownloadProgress(id.ToString()); if (!animate) { ProgressBar progressBar = this.progressBar; id = stickerProduct.id; double num = BatchDownloadManager.DownloadProgress(id.ToString()); ((RangeBase)progressBar).Value = num; } else { ((DependencyObject)this.progressBar).Animate(((RangeBase)this.progressBar).Value, to, RangeBase.ValueProperty, 100, new int?(), null, null); } } else { ((UIElement)this.progressBar).Visibility = Visibility.Collapsed; ((UIElement)this.ButtonDownload).Opacity = 1.0; ((RangeBase)this.progressBar).Value = 0.0; } Uri uriSource = VeryLowProfileImageLoader.GetUriSource(this.previewImage); if (uriSource == null || uriSource.OriginalString != stickerProduct.photo_140) { VeryLowProfileImageLoader.SetUriSource(this.previewImage, stickerProduct.photo_140 == null ? null : new Uri(stickerProduct.photo_140)); } this.textBlockAuthor.Text = (stickerProduct.author ?? ""); this.textBlockTitle.Text = (stickerProduct.title ?? ""); this.textBlockDesc.Text = (stickerProduct.description ?? ""); } } }