This commit is contained in:
bao-qian 2016-04-22 22:42:26 +01:00
parent 03051a95cf
commit 681f57f703
3 changed files with 25 additions and 23 deletions

View file

@ -7,14 +7,14 @@ using Wox.Infrastructure;
namespace Wox.Plugin.ControlPanel
{
public class ControlPanel : IPlugin,IPluginI18n
public class ControlPanel : IPlugin, IPluginI18n
{
private PluginInitContext context;
private List<ControlPanelItem> controlPanelItems = new List<ControlPanelItem>();
private string iconFolder;
private string fileType;
public void Init(PluginInitContext context)
public void Init(PluginInitContext context)
{
this.context = context;
controlPanelItems = ControlPanelList.Create(48);
@ -46,25 +46,27 @@ namespace Wox.Plugin.ControlPanel
var fuzzyMather = FuzzyMatcher.Create(myQuery);
if (MatchProgram(item, fuzzyMather))
{
results.Add(new Result
var result = new Result
{
Title = item.LocalizedString,
SubTitle = item.InfoTip,
Score = item.Score,
IcoPath = Path.Combine(context.CurrentPluginMetadata.PluginDirectory, @"Images\\ControlPanelIcons\\" + item.GUID + fileType),
IcoPath = Path.Combine(context.CurrentPluginMetadata.PluginDirectory,
@"Images\\ControlPanelIcons\\" + item.GUID + fileType),
Action = e =>
{
try
{
Process.Start(item.ExecutablePath);
try
{
Process.Start(item.ExecutablePath);
}
catch (Exception)
{
//Silently Fail for now.. todo
}
catch (Exception)
{
//Silently Fail for now..
return true;
}
return true;
}
});
};
results.Add(result);
}
}

View file

@ -13,7 +13,8 @@ namespace Wox.Converters
{
return null;
}
return App.ImageLoader.Load(value.ToString());
var image = App.ImageLoader.Load(value.ToString());
return image;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

View file

@ -16,7 +16,7 @@ namespace Wox.ImageLoader
{
public class ImageLoader
{
private readonly ConcurrentDictionary<string, ImageSource> ImageSources = new ConcurrentDictionary<string, ImageSource>();
private readonly ConcurrentDictionary<string, ImageSource> _imageSources = new ConcurrentDictionary<string, ImageSource>();
private readonly List<string> ImageExts = new List<string>
{
@ -40,7 +40,7 @@ namespace Wox.ImageLoader
};
private readonly ImageCache _cache;
private readonly BinaryStorage<ImageCache> _storage;
private readonly BinaryStorage<ImageCache> _storage;
public ImageLoader()
{
@ -74,7 +74,7 @@ namespace Wox.ImageLoader
{
Stopwatch.Debug($"Preload {_cache.TopUsedImages.Count} images", () =>
{
_cache.TopUsedImages.AsParallel().Where(i => !ImageSources.ContainsKey(i.Key)).ForAll(i =>
_cache.TopUsedImages.AsParallel().Where(i => !_imageSources.ContainsKey(i.Key)).ForAll(i =>
{
var img = Load(i.Key, false);
if (img != null)
@ -84,8 +84,7 @@ namespace Wox.ImageLoader
// this line made it possible
// should be changed the Dispatcher.InvokeAsync in the future
img.Freeze();
ImageSources[i.Key] = img;
_imageSources[i.Key] = img;
}
});
});
@ -104,9 +103,9 @@ namespace Wox.ImageLoader
}
if (ImageSources.ContainsKey(path))
if (_imageSources.ContainsKey(path))
{
img = ImageSources[path];
img = _imageSources[path];
}
else
{
@ -127,9 +126,9 @@ namespace Wox.ImageLoader
if (img != null && addToCache)
{
if (!ImageSources.ContainsKey(path))
if (!_imageSources.ContainsKey(path))
{
ImageSources[path] = img;
_imageSources[path] = img;
}
}
}