private async void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { return; } var content = args.ItemContainer.ContentTemplateRoot as Grid; var stickerSet = args.Item as StickerSetInfo; var title = content.Children[1] as TextBlock; title.Text = stickerSet.Title; var subtitle = content.Children[2] as TextBlock; subtitle.Text = Locale.Declension("Stickers", stickerSet.Size); var file = stickerSet.GetThumbnail(out var outline, out _); if (file == null) { return; } if (file.Local.IsDownloadingCompleted) { if (content.Children[0] is Image photo) { photo.Source = await PlaceholderHelper.GetWebPFrameAsync(file.Local.Path, 48); ElementCompositionPreview.SetElementChildVisual(content.Children[0], null); } else if (args.Phase == 0 && content.Children[0] is LottieView lottie) { lottie.Source = UriEx.ToLocal(file.Local.Path); } } else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingActive) { if (content.Children[0] is Image photo) { photo.Source = null; } else if (args.Phase == 0 && content.Children[0] is LottieView lottie) { lottie.Source = null; } CompositionPathParser.ParseThumbnail(outline, out ShapeVisual visual, false); ElementCompositionPreview.SetElementChildVisual(content.Children[0], visual); _filesMap[file.Id].Add(stickerSet); ViewModel.ProtoService.DownloadFile(file.Id, 1); } args.Handled = true; }
private void UpdateThumbnail(MessageViewModel message, Sticker sticker) { _thumbnailShimmer = CompositionPathParser.ParseThumbnail(sticker, out ShapeVisual visual); ElementCompositionPreview.SetElementChildVisual(Player, visual); }
private void UpdateThumbnail(MessageViewModel message, IList <ClosedVectorPath> contours) { _thumbnailShimmer = CompositionPathParser.ParseThumbnail(contours, out ShapeVisual visual); ElementCompositionPreview.SetElementChildVisual(Player, visual); }
private async void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { return; } var content = args.ItemContainer.ContentTemplateRoot as Grid; var stickerSet = args.Item as StickerSetInfo; var title = content.Children[1] as TextBlock; title.Text = stickerSet.Title; var subtitle = content.Children[2] as TextBlock; subtitle.Text = Locale.Declension("Stickers", stickerSet.Size); var cover = stickerSet.GetThumbnail(); if (cover == null) { return; } var file = cover.StickerValue; if (file.Local.IsFileExisting()) { if (content.Children[0] is Image photo) { photo.Source = await PlaceholderHelper.GetWebPFrameAsync(file.Local.Path, 48); ElementCompositionPreview.SetElementChildVisual(content.Children[0], null); } else if (args.Phase == 0 && content.Children[0] is LottieView lottie) { lottie.Source = UriEx.ToLocal(file.Local.Path); } else if (args.Phase == 0 && content.Children[0] is AnimationView animation) { animation.Source = new LocalVideoSource(file); } } else { if (content.Children[0] is Image photo) { photo.Source = null; } else if (args.Phase == 0 && content.Children[0] is LottieView lottie) { lottie.Source = null; } else if (args.Phase == 0 && content.Children[0] is AnimationView animation) { animation.Source = null; } CompositionPathParser.ParseThumbnail(cover, out ShapeVisual visual, false); ElementCompositionPreview.SetElementChildVisual(content.Children[0], visual); UpdateManager.Subscribe(content, ViewModel.ProtoService, file, UpdateFile, true); if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingActive) { ViewModel.ProtoService.DownloadFile(file.Id, 1); } } args.Handled = true; }