mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add logic for IcoPath's that are web URL's
This commit is contained in:
parent
2c790bf7e0
commit
ffbd8fd650
1 changed files with 21 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
|
@ -113,7 +114,27 @@ namespace Flow.Launcher.Infrastructure.Image
|
||||||
{
|
{
|
||||||
return new ImageResult(ImageCache[path], ImageType.Cache);
|
return new ImageResult(ImageCache[path], ImageType.Cache);
|
||||||
}
|
}
|
||||||
|
if (path.StartsWith("http://") || path.StartsWith("https://"))
|
||||||
|
{
|
||||||
|
// Download image from url
|
||||||
|
using (WebClient client = new WebClient())
|
||||||
|
{
|
||||||
|
using (MemoryStream stream = new MemoryStream(client.DownloadData(path)))
|
||||||
|
{
|
||||||
|
var image = new BitmapImage();
|
||||||
|
image.BeginInit();
|
||||||
|
image.CacheOption = BitmapCacheOption.OnLoad;
|
||||||
|
image.StreamSource = stream;
|
||||||
|
image.EndInit();
|
||||||
|
image.Freeze();
|
||||||
|
ImageCache[path] = image;
|
||||||
|
return new ImageResult(image, ImageType.Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
if (path.StartsWith("data:", StringComparison.OrdinalIgnoreCase))
|
if (path.StartsWith("data:", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var imageSource = new BitmapImage(new Uri(path));
|
var imageSource = new BitmapImage(new Uri(path));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue