From 681f57f7039bf4edcb83ee943c3d60440c0e5fc8 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Fri, 22 Apr 2016 22:42:26 +0100 Subject: [PATCH] Misc --- .../Wox.Plugin.ControlPanel/ControlPanel.cs | 28 ++++++++++--------- Wox/Converters/ImagePathConverter.cs | 3 +- Wox/ImageLoader/ImageLoader.cs | 17 ++++++----- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Plugins/Wox.Plugin.ControlPanel/ControlPanel.cs b/Plugins/Wox.Plugin.ControlPanel/ControlPanel.cs index f0b7cfe883..cff0eb3c1a 100644 --- a/Plugins/Wox.Plugin.ControlPanel/ControlPanel.cs +++ b/Plugins/Wox.Plugin.ControlPanel/ControlPanel.cs @@ -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 controlPanelItems = new List(); 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); } } diff --git a/Wox/Converters/ImagePathConverter.cs b/Wox/Converters/ImagePathConverter.cs index 4a5beb5b25..a15c54cc42 100644 --- a/Wox/Converters/ImagePathConverter.cs +++ b/Wox/Converters/ImagePathConverter.cs @@ -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) diff --git a/Wox/ImageLoader/ImageLoader.cs b/Wox/ImageLoader/ImageLoader.cs index fe655b4c82..f75ceea005 100644 --- a/Wox/ImageLoader/ImageLoader.cs +++ b/Wox/ImageLoader/ImageLoader.cs @@ -16,7 +16,7 @@ namespace Wox.ImageLoader { public class ImageLoader { - private readonly ConcurrentDictionary ImageSources = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _imageSources = new ConcurrentDictionary(); private readonly List ImageExts = new List { @@ -40,7 +40,7 @@ namespace Wox.ImageLoader }; private readonly ImageCache _cache; - private readonly BinaryStorage _storage; + private readonly BinaryStorage _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; } } }