public void UpdateFile(File file) { if (_stickers.TryGetValue(file.Id, out List <StickerViewModel> items) && items.Count > 0) { foreach (var item in items) { item.UpdateFile(file); if (item.Thumbnail?.File.Id == file.Id) { var container = Stickers.ContainerFromItem(item) as SelectorItem; if (container == null) { continue; } var content = container.ContentTemplateRoot as Grid; var photo = content.Children[0] as Image; photo.Source = PlaceholderHelper.GetWebPFrame(file.Local.Path); } else if (item.StickerValue.Id == file.Id) { _handler.ThrottleVisibleItems(); } } } if (_stickerSets.TryGetValue(file.Id, out List <StickerSetViewModel> sets) && sets.Count > 0) { foreach (var item in sets) { var cover = item.Thumbnail ?? item.Covers.FirstOrDefault()?.Thumbnail; if (cover == null) { continue; } cover.UpdateFile(file); var container = Toolbar.ContainerFromItem(item) as SelectorItem; if (container == null) { continue; } var content = container.ContentTemplateRoot as Grid; var photo = content?.Children[0] as Image; if (content == null) { continue; } if (item.IsAnimated) { photo.Source = PlaceholderHelper.GetLottieFrame(file.Local.Path, 0, 36, 36); } else { photo.Source = PlaceholderHelper.GetWebPFrame(file.Local.Path); } } } _zoomer.UpdateFile(file); }
public async void UpdateFile(File file) { if (!file.Local.IsDownloadingCompleted) { return; } if (_stickers.TryGetValue(file.Id, out List <ViewModels.Dialogs.StickerViewModel> items) && items.Count > 0) { var temp = await StorageFile.GetFileFromPathAsync(file.Local.Path); var buffer = await FileIO.ReadBufferAsync(temp); foreach (var item in items) { item.UpdateFile(file); var container = Stickers.ContainerFromItem(item) as SelectorItem; if (container == null) { return; } var content = container.ContentTemplateRoot as Image; content.Source = WebPImage.DecodeFromBuffer(buffer); } } foreach (MosaicMediaRow line in GifsView.Items) { var any = false; foreach (var item in line) { if (item.Item is Animation animation && animation.UpdateFile(file)) { any = true; } } if (!any) { continue; } var container = GifsView.ContainerFromItem(line) as SelectorItem; if (container == null) { continue; } var content = container.ContentTemplateRoot as MosaicRow; if (content == null) { continue; } content.UpdateFile(line, file); } foreach (ViewModels.Dialogs.StickerSetViewModel stickerSet in Toolbar.Items) { if (stickerSet.Covers == null) { continue; } var cover = stickerSet.Covers.FirstOrDefault(); if (cover == null || cover.Thumbnail == null) { continue; } var container = Toolbar.ContainerFromItem(stickerSet) as SelectorItem; if (container == null) { continue; } var content = container.ContentTemplateRoot as Image; if (content == null) { continue; } if (cover.UpdateFile(file)) { var temp = await StorageFile.GetFileFromPathAsync(file.Local.Path); var buffer = await FileIO.ReadBufferAsync(temp); content.Source = WebPImage.DecodeFromBuffer(buffer); } } //foreach (ViewModels.Dialogs.StickerViewModel item in Stickers.Items) //{ // if (item.UpdateFile(file) && file.Local.IsDownloadingCompleted) // { // var container = Stickers.ContainerFromItem(item) as SelectorItem; // if (container == null) // { // continue; // } // var content = container.ContentTemplateRoot as Image; // if (item.Thumbnail.Photo.Id == file.Id) // { // var temp = await StorageFile.GetFileFromPathAsync(file.Local.Path); // var buffer = await FileIO.ReadBufferAsync(temp); // content.Source = WebPImage.DecodeFromBuffer(buffer); // } // } //} }