mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
Save when exit
1. fix image cache 2. fix save when exit since destructor won't be called 3. fix #583 #582 (partially) #581 (partially) #580
This commit is contained in:
@@ -9,6 +9,7 @@ using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Infrastructure.Storage;
|
||||
|
||||
namespace Wox.Infrastructure.Image
|
||||
@@ -71,7 +72,7 @@ namespace Wox.Infrastructure.Image
|
||||
|
||||
public static void PreloadImages()
|
||||
{
|
||||
Stopwatch.Debug($"Preload {_cache.TopUsedImages.Count} images", () =>
|
||||
Stopwatch.Debug("Preload images from cache", () =>
|
||||
{
|
||||
_cache.TopUsedImages.AsParallel().Where(i => !_imageSources.ContainsKey(i.Key)).ForAll(i =>
|
||||
{
|
||||
@@ -87,6 +88,7 @@ namespace Wox.Infrastructure.Image
|
||||
}
|
||||
});
|
||||
});
|
||||
Log.Info($"Preload {_cache.TopUsedImages.Count} images from cache");
|
||||
}
|
||||
|
||||
public static ImageSource Load(string path, bool addToCache = true)
|
||||
|
||||
11
Wox.Infrastructure/Storage/ISavable.cs
Normal file
11
Wox.Infrastructure/Storage/ISavable.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
/// <summary>
|
||||
/// Save plugin settings/cache,
|
||||
/// todo should be merged into a abstract class intead of seperate interface
|
||||
/// </summary>
|
||||
public interface ISavable
|
||||
{
|
||||
void Save();
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,7 @@
|
||||
<Compile Include="Image\ImageCache.cs" />
|
||||
<Compile Include="Image\ImageLoader.cs" />
|
||||
<Compile Include="Logger\Log.cs" />
|
||||
<Compile Include="Storage\ISavable.cs" />
|
||||
<Compile Include="Storage\PluginSettingsStorage.cs" />
|
||||
<Compile Include="Storage\Storage.cs" />
|
||||
<Compile Include="Stopwatch.cs" />
|
||||
|
||||
Reference in New Issue
Block a user