mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 19:49:15 +08:00
fix missing image cache
This commit is contained in:
parent
c2132e3772
commit
461e650e05
@ -130,43 +130,42 @@ namespace Wox.Infrastructure.Image
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
image = ImageSources[ErrorIcon];
|
||||
_cache.Add(ErrorIcon);
|
||||
}
|
||||
else if (ImageSources.ContainsKey(path))
|
||||
{
|
||||
image = ImageSources[path];
|
||||
_cache.Add(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
string ext = Path.GetExtension(path).ToLower();
|
||||
|
||||
if (path.StartsWith("data:", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
image = new BitmapImage(new Uri(path));
|
||||
ImageSources[path] = image;
|
||||
}
|
||||
else if (Path.IsPathRooted(path))
|
||||
{
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
image = ShellIcon(path);
|
||||
ImageSources[path] = image;
|
||||
}
|
||||
else if (File.Exists(path))
|
||||
{
|
||||
if (ImageExtions.Contains(ext))
|
||||
var externsion = Path.GetExtension(path).ToLower();
|
||||
if (ImageExtions.Contains(externsion))
|
||||
{
|
||||
image = new BitmapImage(new Uri(path));
|
||||
ImageSources[path] = image;
|
||||
}
|
||||
else
|
||||
{
|
||||
image = AssociatedIcon(path);
|
||||
ImageSources[path] = image;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
image = ImageSources[ErrorIcon];
|
||||
path = ErrorIcon;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -175,13 +174,16 @@ namespace Wox.Infrastructure.Image
|
||||
if (File.Exists(defaultDirectoryPath))
|
||||
{
|
||||
image = new BitmapImage(new Uri(defaultDirectoryPath));
|
||||
ImageSources[path] = image;
|
||||
}
|
||||
else
|
||||
{
|
||||
image = ImageSources[ErrorIcon];
|
||||
path = ErrorIcon;
|
||||
}
|
||||
}
|
||||
|
||||
ImageSources[path] = image;
|
||||
_cache.Add(path);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user