Ejemplo n.º 1
0
        private async Task CacheThumbnail(Addon addon)
        {
            if (string.IsNullOrEmpty(addon.ThumbnailUrl))
            {
                return;
            }

            try
            {
                using var imageStream = await addon.ThumbnailUrl.GetStreamAsync();

                using Image image = Image.Load(imageStream);
                image.Mutate(x => x.Resize(new ResizeOptions
                {
                    Size = new Size
                    {
                        Width  = 80,
                        Height = 80
                    }
                }));

                image.Save(addon.GetThumbnailCachePath());
            }
            catch (Exception ex)
            {
                _analyticsService.Track(ex, "Failed to download thumbnail");
            }
        }
Ejemplo n.º 2
0
        private async Task CacheThumbnail(Addon addon)
        {
            if (string.IsNullOrEmpty(addon.ThumbnailUrl))
            {
                return;
            }

            try
            {
                Log.Information($"Caching thumbnail {addon.Name}: {addon.ThumbnailUrl}");
                using var imageStream = await addon.ThumbnailUrl.GetStreamAsync();

                using Image image = Image.Load(imageStream);
                image.Mutate(x => x.Resize(new ResizeOptions
                {
                    Size = new Size
                    {
                        Width  = 80,
                        Height = 80
                    }
                }));

                image.Save(addon.GetThumbnailCachePath());
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"Failed to download thumbnail {addon.Name}");
            }
        }
Ejemplo n.º 3
0
        public static string GetThumbnailPath(this Addon addon)
        {
            var thumbnailCachePath = addon.GetThumbnailCachePath();

            if (string.IsNullOrEmpty(addon.ThumbnailUrl) || !File.Exists(thumbnailCachePath))
            {
                return("pack://application:,,,/WowUp;component/Assets/wowup_logo_1.png");
            }

            return(thumbnailCachePath);
        }