mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
This reverts commit c651a4b36e.
This commit is contained in:
@@ -7,7 +7,6 @@ using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Infrastructure.Image
|
||||
@@ -20,16 +19,8 @@ namespace Wox.Infrastructure.Image
|
||||
|
||||
private readonly ConcurrentDictionary<string, ImageSource> _data = new ConcurrentDictionary<string, ImageSource>();
|
||||
|
||||
[NonSerialized]
|
||||
private readonly WoxJsonStorage<ConcurrentDictionary<string, int>> _usageStorage;
|
||||
|
||||
public ConcurrentDictionary<string, int> Usage { get; private set; } = new ConcurrentDictionary<string, int>();
|
||||
|
||||
public ImageCache()
|
||||
{
|
||||
_usageStorage = new WoxJsonStorage<ConcurrentDictionary<string, int>>("ImageUsageCache");
|
||||
}
|
||||
|
||||
public ImageSource this[string path]
|
||||
{
|
||||
get
|
||||
@@ -96,14 +87,9 @@ namespace Wox.Infrastructure.Image
|
||||
return new Dictionary<string, int>(Usage);
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
public void SetUsageAsDictionary(Dictionary<string, int> usage)
|
||||
{
|
||||
Usage = _usageStorage.Load();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_usageStorage.Save();
|
||||
Usage = new ConcurrentDictionary<string, int>(usage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace Wox.Infrastructure.Image
|
||||
private static readonly ImageCache ImageCache = new ImageCache();
|
||||
private static readonly ConcurrentDictionary<string, string> GuidToKey = new ConcurrentDictionary<string, string>();
|
||||
|
||||
private static BinaryStorage<Dictionary<string, int>> _storage;
|
||||
private static IImageHashGenerator _hashGenerator;
|
||||
|
||||
public static string ErrorIconPath { get; set; }
|
||||
@@ -48,8 +49,9 @@ namespace Wox.Infrastructure.Image
|
||||
|
||||
public static void Initialize(Theme theme)
|
||||
{
|
||||
_storage = new BinaryStorage<Dictionary<string, int>>("Image");
|
||||
_hashGenerator = new ImageHashGenerator();
|
||||
ImageCache.Initialize();
|
||||
ImageCache.SetUsageAsDictionary(_storage.TryLoad(new Dictionary<string, int>()));
|
||||
|
||||
foreach (var icon in new[] { Constant.DefaultIcon, Constant.ErrorIcon, Constant.LightThemedDefaultIcon, Constant.LightThemedErrorIcon })
|
||||
{
|
||||
@@ -76,7 +78,7 @@ namespace Wox.Infrastructure.Image
|
||||
public static void Save()
|
||||
{
|
||||
ImageCache.Cleanup();
|
||||
ImageCache.Save();
|
||||
_storage.Save(ImageCache.GetUsageAsDictionary());
|
||||
}
|
||||
|
||||
// Todo : Update it with icons specific to each theme.
|
||||
|
||||
Reference in New Issue
Block a user