public void UpdateFile(File file)
        {
            if (_animations.TryGetValue(file.Id, out List <Animation> items) && items.Count > 0)
            {
                foreach (var item in items)
                {
                    item.UpdateFile(file);

                    var index = ViewModel.Items.IndexOf(item);
                    if (index < 0)
                    {
                        continue;
                    }

                    if (item.Thumbnail?.File.Id == file.Id)
                    {
                        var button = Repeater.TryGetElement(index) as Button;
                        if (button == null)
                        {
                            continue;
                        }

                        var content = button.Content as Grid;
                        var image   = content.Children[0] as Image;

                        image.Source = new BitmapImage(new Uri("file:///" + file.Local.Path));
                    }
                    else if (item.AnimationValue.Id == file.Id)
                    {
                        _handler.ThrottleVisibleItems();
                    }
                }
            }

            if (ApiInfo.IsFullExperience || Windows.UI.ViewManagement.UIViewSettings.GetForCurrentView().UserInteractionMode == Windows.UI.ViewManagement.UserInteractionMode.Mouse)
            {
                _zoomer.UpdateFile(file);
            }
        }
Esempio n. 2
0
        public void UpdateFile(File file)
        {
            if (_animations.TryGetValue(file.Id, out List <Animation> items) && items.Count > 0)
            {
                foreach (var item in items)
                {
                    item.UpdateFile(file);

                    var index = ViewModel.Items.IndexOf(item);
                    if (index < 0)
                    {
                        continue;
                    }

                    if (item.Thumbnail?.File.Id == file.Id)
                    {
                        var button = Repeater.TryGetElement(index) as Button;
                        if (button == null)
                        {
                            continue;
                        }

                        var content = button.Content as Grid;
                        var image   = content.Children[0] as Image;

                        image.Source = new BitmapImage(new Uri("file:///" + file.Local.Path));
                    }
                    else if (item.AnimationValue.Id == file.Id)
                    {
                        _handler.ThrottleVisibleItems();
                    }
                }
            }

            _zoomer.UpdateFile(file);
        }
Esempio n. 3
0
        public void UpdateFile(File file)
        {
            if (!file.Local.IsDownloadingCompleted)
            {
                return;
            }

            if (_thumbnails.TryGetValue(file.Id, out List <InlineQueryResult> items) && items.Count > 0)
            {
                foreach (var result in items)
                {
                    result.UpdateFile(file);

                    var index = ViewModel.InlineBotResults?.IndexOf(result) ?? -1;
                    if (index < 0)
                    {
                        continue;
                    }

                    var button = Repeater.TryGetElement(index) as Button;
                    if (button == null)
                    {
                        continue;
                    }

                    var content = button.Content as Grid;
                    if (content.Children[0] is Image image)
                    {
                        if (result is InlineQueryResultAnimation || result is InlineQueryResultPhoto || result is InlineQueryResultVideo)
                        {
                            image.Source = new BitmapImage(new Uri("file:///" + file.Local.Path));
                        }
                        else if (result is InlineQueryResultSticker)
                        {
                            image.Source = PlaceholderHelper.GetWebPFrame(file.Local.Path);
                        }
                    }
                    else if (content.Children[0] is Grid presenter)
                    {
                        //var presenter = content.Children[0] as Grid;
                        var thumb = presenter.Children[0] as Image;
                        thumb.Source = new BitmapImage(new Uri("file:///" + file.Local.Path));
                    }
                }
            }

            if (_files.TryGetValue(file.Id, out List <InlineQueryResult> items2) && items2.Count > 0)
            {
                foreach (var result in items2)
                {
                    result.UpdateFile(file);

                    var index = ViewModel.InlineBotResults?.IndexOf(result) ?? -1;
                    if (index < 0)
                    {
                        continue;
                    }

                    var button = Repeater.TryGetElement(index) as Button;
                    if (button == null)
                    {
                        continue;
                    }

                    _handler.ThrottleVisibleItems();
                }
            }

            _zoomer.UpdateFile(file);
        }