mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Databinding for plugin tab + faster image load
This commit is contained in:
@@ -20,7 +20,10 @@ namespace Wox.Infrastructure.Image
|
||||
{
|
||||
TopUsedImages[path] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void Cleanup()
|
||||
{
|
||||
if (TopUsedImages.Count > MaxCached)
|
||||
{
|
||||
var images = TopUsedImages.OrderByDescending(o => o.Value)
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace Wox.Infrastructure.Image
|
||||
|
||||
public static void Save()
|
||||
{
|
||||
_cache.Cleanup();
|
||||
_storage.Save();
|
||||
}
|
||||
|
||||
@@ -115,11 +116,6 @@ namespace Wox.Infrastructure.Image
|
||||
var img = Load(i.Key);
|
||||
if (img != null)
|
||||
{
|
||||
// todo happlebao magic
|
||||
// the image created on other threads can be accessed from main ui thread,
|
||||
// this line made it possible
|
||||
// should be changed the Dispatcher.InvokeAsync in the future
|
||||
img.Freeze();
|
||||
ImageSources[i.Key] = img;
|
||||
}
|
||||
});
|
||||
@@ -185,9 +181,9 @@ namespace Wox.Infrastructure.Image
|
||||
path = ErrorIcon;
|
||||
}
|
||||
}
|
||||
|
||||
ImageSources[path] = image;
|
||||
_cache.Add(path);
|
||||
image.Freeze();
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Wox.Infrastructure.Image
|
||||
{
|
||||
public class ImagePathConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null || value == DependencyProperty.UnsetValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var image = ImageLoader.Load(value.ToString());
|
||||
return image;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,6 @@
|
||||
<Compile Include="Hotkey\KeyEvent.cs" />
|
||||
<Compile Include="Image\ImageCache.cs" />
|
||||
<Compile Include="Image\ImageLoader.cs" />
|
||||
<Compile Include="Image\ImagePathConverter.cs" />
|
||||
<Compile Include="Logger\Log.cs" />
|
||||
<Compile Include="Storage\ISavable.cs" />
|
||||
<Compile Include="Storage\PluginJsonStorage.cs" />
|
||||
|
||||
Reference in New Issue
Block a user