private async void UpdateFile(object target, File file)
        {
            var content = target as Grid;

            if (content == null)
            {
                return;
            }

            if (content.Children[0] is Image photo)
            {
                photo.Source = await PlaceholderHelper.GetWebPFrameAsync(file.Local.Path, 48);

                ElementCompositionPreview.SetElementChildVisual(content.Children[0], null);
            }
            else if (content.Children[0] is LottieView lottie)
            {
                lottie.Source = UriEx.ToLocal(file.Local.Path);
                _handler.ThrottleVisibleItems();
            }
            else if (content.Children[0] is AnimationView animation)
            {
                animation.Source = new LocalVideoSource(file);
                _handler.ThrottleVisibleItems();
            }
        }
Beispiel #2
0
        public void Activate(Chat chat)
        {
            _isActive = true;
            _handler.ThrottleVisibleItems();

            if (chat != null)
            {
                ViewModel.Update();
            }
        }
Beispiel #3
0
        public void UpdateFile(File file)
        {
            foreach (Sticker sticker in List.Items)
            {
                if (sticker.UpdateFile(file) && file.Local.IsDownloadingCompleted)
                {
                    if (file.Id == sticker.Thumbnail?.File.Id)
                    {
                        var container = List.ContainerFromItem(sticker) as SelectorItem;
                        if (container == null)
                        {
                            continue;
                        }

                        var content = container.ContentTemplateRoot as Grid;
                        if (content == null)
                        {
                            continue;
                        }

                        var photo = content.Children[0] as Image;
                        photo.Source = PlaceholderHelper.GetWebPFrame(file.Local.Path);
                    }
                    else if (file.Id == sticker.StickerValue.Id)
                    {
                        _handler.ThrottleVisibleItems();
                    }
                }
            }

            _zoomer.UpdateFile(file);
        }
Beispiel #4
0
        private void UpdateFile(object target, File file)
        {
            if (target is Grid content)
            {
                if (content.Children[0] is LottieView stickerView)
                {
                    stickerView.Source = UriEx.ToLocal(file.Local.Path);
                }
                else if (content.Children[0] is AnimationView animationView)
                {
                    animationView.Source = new LocalVideoSource(file);
                }
            }

            _handler.ThrottleVisibleItems();
        }
        public void Handle(UpdateFile update)
        {
            if (!update.File.Local.IsDownloadingCompleted)
            {
                return;
            }

            if (_filesMap.TryGetValue(update.File.Id, out List <StickerSetInfo> stickers))
            {
                this.BeginOnUIThread(async() =>
                {
                    foreach (var stickerSet in stickers.ToImmutableHashSet())
                    {
                        stickerSet.UpdateFile(update.File);

                        var container = List.ContainerFromItem(stickerSet) as SelectorItem;
                        if (container == null)
                        {
                            continue;
                        }

                        var content = container.ContentTemplateRoot as Grid;
                        if (content == null)
                        {
                            continue;
                        }

                        if (content.Children[0] is Image photo)
                        {
                            photo.Source = await PlaceholderHelper.GetWebPFrameAsync(update.File.Local.Path, 48);
                            ElementCompositionPreview.SetElementChildVisual(content.Children[0], null);
                        }
                        else if (content.Children[0] is LottieView lottie)
                        {
                            lottie.Source = UriEx.ToLocal(update.File.Local.Path);
                            _handler.ThrottleVisibleItems();
                        }
                    }
                });
            }
        }
 public void Activate()
 {
     _isActive = true;
     _handler.ThrottleVisibleItems();
 }