diff --git a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs index 423da32597..582495f327 100644 --- a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs +++ b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs @@ -51,8 +51,11 @@ namespace Wox.Plugin.Folder x => x.Nickname.StartsWith(input, StringComparison.OrdinalIgnoreCase)).ToList(); List results = userFolderLinks.Select( - item => new Result(item.Nickname, "Images/folder.png", "Ctrl + Enter to open the directory") + item => new Result() { + Title = item.Nickname, + IcoPath = "Images/folder.png", + SubTitle = "Ctrl + Enter to open the directory", Action = c => { if (c.SpecialKeyState.CtrlPressed) @@ -128,8 +131,10 @@ namespace Wox.Plugin.Folder string firstResult = "Open current directory"; if (incompleteName.Length > 0) firstResult = "Open " + rawQuery; - results.Add(new Result(firstResult, "Images/folder.png") + results.Add(new Result { + Title = firstResult, + IcoPath = "Images/folder.png", Score = 10000, Action = c => { @@ -147,8 +152,11 @@ namespace Wox.Plugin.Folder if (incompleteName.Length != 0 && !dir.Name.ToLower().StartsWith(incompleteName)) continue; DirectoryInfo dirCopy = dir; - var result = new Result(dir.Name, "Images/folder.png", "Ctrl + Enter to open the directory") + var result = new Result { + Title = dir.Name, + IcoPath = "Images/folder.png", + SubTitle = "Ctrl + Enter to open the directory", Action = c => { if (c.SpecialKeyState.CtrlPressed) @@ -180,8 +188,10 @@ namespace Wox.Plugin.Folder if (incompleteName.Length != 0 && !file.Name.ToLower().StartsWith(incompleteName)) continue; string filePath = file.FullName; - var result = new Result(Path.GetFileName(filePath), "Images/file.png") + var result = new Result { + Title = Path.GetFileName(filePath), + IcoPath = "Images/file.png", Action = c => { try diff --git a/Plugins/Wox.Plugin.PluginManagement/Main.cs b/Plugins/Wox.Plugin.PluginManagement/Main.cs index 1f333d650d..216157a1c7 100644 --- a/Plugins/Wox.Plugin.PluginManagement/Main.cs +++ b/Plugins/Wox.Plugin.PluginManagement/Main.cs @@ -153,7 +153,6 @@ namespace Wox.Plugin.PluginManagement string pluginUrl = APIBASE + "/media/" + r1.plugin_file; Client.DownloadFile(pluginUrl, filePath); context.API.InstallPlugin(filePath); - context.API.ReloadPlugins(); } catch (Exception exception) { diff --git a/Wox.Core/Plugin/PluginConfig.cs b/Wox.Core/Plugin/PluginConfig.cs index 7d0ba4958e..12508831cf 100644 --- a/Wox.Core/Plugin/PluginConfig.cs +++ b/Wox.Core/Plugin/PluginConfig.cs @@ -19,7 +19,7 @@ namespace Wox.Core.Plugin /// /// /// - public static List Parse(List pluginDirectories) + public static List Parse(string[] pluginDirectories) { pluginMetadatas.Clear(); foreach (string pluginDirectory in pluginDirectories) diff --git a/Wox.Core/Plugin/PluginInstaller.cs b/Wox.Core/Plugin/PluginInstaller.cs index d4155a917f..dce4545555 100644 --- a/Wox.Core/Plugin/PluginInstaller.cs +++ b/Wox.Core/Plugin/PluginInstaller.cs @@ -34,7 +34,7 @@ namespace Wox.Core.Plugin return; } - string pluginFolerPath = PluginManager.PluginDirectory; + string pluginFolerPath = PluginManager.UserDirectory; string newPluginName = plugin.Name .Replace("/", "_") diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index 5e81babd0f..a28ccd7cf3 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -17,13 +17,11 @@ namespace Wox.Core.Plugin /// public static class PluginManager { - public const string DirectoryName = "Plugins"; private static IEnumerable _contextMenuPlugins; /// /// Directories that will hold Wox plugin directory /// - private static readonly List PluginDirectories = new List(); public static List AllPlugins { get; private set; } @@ -34,47 +32,31 @@ namespace Wox.Core.Plugin private static IEnumerable InstantQueryPlugins { get; set; } public static IPublicAPI API { private set; get; } - public static readonly string PluginDirectory = Path.Combine(WoxDirectroy.Executable, DirectoryName); + public const string DirectoryName = "Plugins"; + public static readonly string PreinstalledDirectory = Path.Combine(Infrastructure.Wox.ProgramPath, DirectoryName); + public static readonly string UserDirectory = Path.Combine(Infrastructure.Wox.DataPath, DirectoryName); + private static readonly string[] Directories = { PreinstalledDirectory, UserDirectory }; - private static void SetupPluginDirectories() + private static void ValidateUserDirectory() { - PluginDirectories.Add(PluginDirectory); - MakesurePluginDirectoriesExist(); - } - - private static void MakesurePluginDirectoriesExist() - { - foreach (string pluginDirectory in PluginDirectories) + if (!Directory.Exists(UserDirectory)) { - if (!Directory.Exists(pluginDirectory)) - { - try - { - Directory.CreateDirectory(pluginDirectory); - } - catch (Exception e) - { - Log.Error(e); - } - } + Directory.CreateDirectory(UserDirectory); } } - /// - /// Load and init all Wox plugins - /// - /// - public static void Initialize() + static PluginManager() { - SetupPluginDirectories(); - - var metadatas = PluginConfig.Parse(PluginDirectories); - AllPlugins = new CSharpPluginLoader().LoadPlugin(metadatas).Concat( - new JsonRPCPluginLoader().LoadPlugin(metadatas)).ToList(); + ValidateUserDirectory(); } public static void InitializePlugins(IPublicAPI api) { + var metadatas = PluginConfig.Parse(Directories); + var plugins1 = new CSharpPluginLoader().LoadPlugin(metadatas); + var plugins2 = new JsonRPCPluginLoader().LoadPlugin(metadatas); + AllPlugins = plugins1.Concat(plugins2).ToList(); + //load plugin i18n languages ResourceMerger.UpdatePluginLanguages(); @@ -228,14 +210,6 @@ namespace Wox.Core.Plugin return metadata.ActionKeywords.Contains(Query.GlobalPluginWildcardSign); } - private static bool IsInstantQueryPlugin(PluginPair plugin) - { - //any plugin that takes more than 200ms for AvgQueryTime won't be treated as IInstantQuery plugin anymore. - return plugin.AvgQueryTime < 200 && - plugin.Plugin is IInstantQuery && - InstantQueryPlugins.Any(p => p.Metadata.ID == plugin.Metadata.ID); - } - /// /// get specified plugin, return null if not found /// diff --git a/Wox.Core/Plugin/PythonPlugin.cs b/Wox.Core/Plugin/PythonPlugin.cs index a5971a7723..fc74a1d7ab 100644 --- a/Wox.Core/Plugin/PythonPlugin.cs +++ b/Wox.Core/Plugin/PythonPlugin.cs @@ -8,7 +8,7 @@ namespace Wox.Core.Plugin { internal class PythonPlugin : JsonRPCPlugin { - private static readonly string PythonHome = Path.Combine(WoxDirectroy.Executable, "PythonHome"); + private static readonly string PythonHome = Path.Combine(Infrastructure.Wox.ProgramPath, "PythonHome"); private readonly ProcessStartInfo _startInfo; public override string SupportedLanguage => AllowedLanguage.Python; diff --git a/Wox.Core/Resource/Internationalization.cs b/Wox.Core/Resource/Internationalization.cs index dafdd671e1..cce4686243 100644 --- a/Wox.Core/Resource/Internationalization.cs +++ b/Wox.Core/Resource/Internationalization.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Windows; -using Wox.Core.UserSettings; using Wox.Infrastructure.Exception; using Wox.Infrastructure.Logger; using Wox.Plugin; diff --git a/Wox.Core/Resource/Resource.cs b/Wox.Core/Resource/Resource.cs index 9ac7f28894..c93546a8cc 100644 --- a/Wox.Core/Resource/Resource.cs +++ b/Wox.Core/Resource/Resource.cs @@ -8,7 +8,7 @@ namespace Wox.Core.Resource { public string DirectoryName { get; protected set; } - protected string DirectoryPath => Path.Combine(WoxDirectroy.Executable, DirectoryName); + protected string DirectoryPath => Path.Combine(Infrastructure.Wox.ProgramPath, DirectoryName); public abstract ResourceDictionary GetResourceDictionary(); } diff --git a/Wox.Infrastructure/Image/ImageLoader.cs b/Wox.Infrastructure/Image/ImageLoader.cs index 788395a8e7..7f9fd26f5f 100644 --- a/Wox.Infrastructure/Image/ImageLoader.cs +++ b/Wox.Infrastructure/Image/ImageLoader.cs @@ -94,7 +94,7 @@ namespace Wox.Infrastructure.Image ImageSource image = null; if (string.IsNullOrEmpty(path)) { - path = Path.Combine(WoxDirectroy.Executable, "Images", "app.png"); + path = Path.Combine(Wox.ProgramPath, "Images", "app.png"); image = new BitmapImage(new Uri(path)); return image; } @@ -131,14 +131,14 @@ namespace Wox.Infrastructure.Image } else { - path = Path.Combine(WoxDirectroy.Executable, "Images", Path.GetFileName(path)); + path = Path.Combine(Wox.ProgramPath, "Images", Path.GetFileName(path)); if (File.Exists(path)) { image = new BitmapImage(new Uri(path)); } else { - path = Path.Combine(WoxDirectroy.Executable, "Images", "app.png"); + path = Path.Combine(Wox.ProgramPath, "Images", "app.png"); image = new BitmapImage(new Uri(path)); } } diff --git a/Wox.Infrastructure/Storage/BinaryStorage.cs b/Wox.Infrastructure/Storage/BinaryStorage.cs index 3165530b06..ed12467201 100644 --- a/Wox.Infrastructure/Storage/BinaryStorage.cs +++ b/Wox.Infrastructure/Storage/BinaryStorage.cs @@ -13,30 +13,20 @@ namespace Wox.Infrastructure.Storage /// Normally, it has better performance, but not readable /// You MUST mark implement class as Serializable /// - public class BinaryStorage where T : class, new() + public class BinaryStorage : Storage where T : new() { - private T _binary; - - private string FilePath { get; } - private string FileName { get; } - private const string FileSuffix = ".dat"; - private string DirectoryPath { get; } - private const string DirectoryName = "Config"; - public BinaryStorage() { - FileName = typeof(T).Name; - DirectoryPath = Path.Combine(WoxDirectroy.Executable, DirectoryName); - FilePath = Path.Combine(DirectoryPath, FileName + FileSuffix); ; + FileSuffix = ".dat"; + DirectoryName = "Cache"; + DirectoryPath = Path.Combine(DirectoryPath, DirectoryName); + FilePath = Path.Combine(DirectoryPath, FileName + FileSuffix); + + ValidateDirectory(); } - public T Load() + public override T Load() { - if (!Directory.Exists(DirectoryPath)) - { - Directory.CreateDirectory(DirectoryPath); - } - if (File.Exists(FilePath)) { using (var stream = new FileStream(FilePath, FileMode.Open)) @@ -55,7 +45,7 @@ namespace Wox.Infrastructure.Storage { LoadDefault(); } - return _binary; + return Data; } private void Deserialize(FileStream stream) @@ -69,17 +59,17 @@ namespace Wox.Infrastructure.Storage try { - _binary = (T)binaryFormatter.Deserialize(stream); + Data = (T)binaryFormatter.Deserialize(stream); } catch (SerializationException e) { - LoadDefault(); Log.Error(e); + LoadDefault(); } catch (InvalidCastException e) { - LoadDefault(); Log.Error(e); + LoadDefault(); } finally { @@ -87,9 +77,10 @@ namespace Wox.Infrastructure.Storage } } - private void LoadDefault() + public override void LoadDefault() { - _binary = new T(); + Data = new T(); + Save(); } private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) @@ -108,7 +99,7 @@ namespace Wox.Infrastructure.Storage return ayResult; } - public void Save() + public override void Save() { using (var stream = new FileStream(FilePath, FileMode.Create)) { @@ -119,7 +110,7 @@ namespace Wox.Infrastructure.Storage try { - binaryFormatter.Serialize(stream, _binary); + binaryFormatter.Serialize(stream, Data); } catch (SerializationException e) { diff --git a/Wox.Infrastructure/Storage/JsonStorage.cs b/Wox.Infrastructure/Storage/JsonStorage.cs index 398c8b1c61..3cfd29e106 100644 --- a/Wox.Infrastructure/Storage/JsonStorage.cs +++ b/Wox.Infrastructure/Storage/JsonStorage.cs @@ -7,23 +7,19 @@ namespace Wox.Infrastructure.Storage /// /// Serialize object using json format. /// - public class JsonStrorage where T : new() + public class JsonStrorage : Storage where T : new() { - private T _json; private readonly JsonSerializerSettings _serializerSettings; - protected string FileName { get; set; } - protected string FilePath { get; set; } - protected const string FileSuffix = ".json"; - protected string DirectoryPath { get; set; } - protected const string DirectoryName = "Config"; - internal JsonStrorage() { - FileName = typeof(T).Name; - DirectoryPath = Path.Combine(WoxDirectroy.Executable, DirectoryName); + FileSuffix = ".json"; + DirectoryName = "Settings"; + DirectoryPath = Path.Combine(DirectoryPath, DirectoryName); FilePath = Path.Combine(DirectoryPath, FileName + FileSuffix); + ValidateDirectory(); + // use property initialization instead of DefaultValueAttribute // easier and flexible for default value of object _serializerSettings = new JsonSerializerSettings @@ -33,13 +29,8 @@ namespace Wox.Infrastructure.Storage }; } - public T Load() + public override T Load() { - if (!Directory.Exists(DirectoryPath)) - { - Directory.CreateDirectory(DirectoryPath); - } - if (File.Exists(FilePath)) { var searlized = File.ReadAllText(FilePath); @@ -56,33 +47,31 @@ namespace Wox.Infrastructure.Storage { LoadDefault(); } - - return _json; + return Data; } private void Deserialize(string searlized) { try { - _json = JsonConvert.DeserializeObject(searlized, _serializerSettings); + Data = JsonConvert.DeserializeObject(searlized, _serializerSettings); } catch (JsonSerializationException e) { LoadDefault(); Log.Error(e); } - } - private void LoadDefault() + public override void LoadDefault() { - _json = JsonConvert.DeserializeObject("{}", _serializerSettings); + Data = JsonConvert.DeserializeObject("{}", _serializerSettings); Save(); } - public void Save() + public override void Save() { - string serialized = JsonConvert.SerializeObject(_json, Formatting.Indented); + string serialized = JsonConvert.SerializeObject(Data, Formatting.Indented); File.WriteAllText(FilePath, serialized); } } diff --git a/Wox.Infrastructure/Storage/PluginSettingsStorage.cs b/Wox.Infrastructure/Storage/PluginSettingsStorage.cs index 2dd242fbb5..18ad200e5b 100644 --- a/Wox.Infrastructure/Storage/PluginSettingsStorage.cs +++ b/Wox.Infrastructure/Storage/PluginSettingsStorage.cs @@ -6,15 +6,14 @@ namespace Wox.Infrastructure.Storage { public PluginJsonStorage() { - var pluginDirectoryName = "Plugins"; - + DirectoryName = "Plugins"; + // C# releated, add python releated below - var type = typeof (T); - FileName = type.Name; - var assemblyName = type.Assembly.GetName().Name; - DirectoryPath = Path.Combine(WoxDirectroy.Executable, DirectoryName, pluginDirectoryName, assemblyName); - + var assemblyName = DataType.Assembly.GetName().Name; + DirectoryPath = Path.Combine(DirectoryPath, DirectoryName, assemblyName); FilePath = Path.Combine(DirectoryPath, FileName + FileSuffix); + + ValidateDirectory(); } } } diff --git a/Wox.Infrastructure/Storage/Storage.cs b/Wox.Infrastructure/Storage/Storage.cs new file mode 100644 index 0000000000..780ead2356 --- /dev/null +++ b/Wox.Infrastructure/Storage/Storage.cs @@ -0,0 +1,46 @@ +using System; +using System.IO; + +namespace Wox.Infrastructure.Storage +{ + public class Storage + { + protected T Data; + protected Type DataType { get; } + public string FileName { get; } + public string FilePath { get; set; } + public string FileSuffix { get; set; } + public string DirectoryPath { get; set; } + public string DirectoryName { get; set; } + + public virtual T Load() + { + throw new NotImplementedException(); + } + + public virtual void Save() + { + throw new NotImplementedException(); + } + + public virtual void LoadDefault() + { + throw new NotImplementedException(); + } + + protected Storage() + { + DataType = typeof (T); + FileName = DataType.Name; + DirectoryPath = Wox.DataPath; + } + + protected void ValidateDirectory() + { + if (!Directory.Exists(DirectoryPath)) + { + Directory.CreateDirectory(DirectoryPath); + } + } + } +} diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index 44ee979b07..b8f3f47178 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -78,8 +78,8 @@ + - @@ -90,6 +90,7 @@ + diff --git a/Wox.Infrastructure/Wox.cs b/Wox.Infrastructure/Wox.cs new file mode 100644 index 0000000000..4ae784a600 --- /dev/null +++ b/Wox.Infrastructure/Wox.cs @@ -0,0 +1,13 @@ +using System; +using System.IO; +using System.Reflection; + +namespace Wox.Infrastructure +{ + public static class Wox + { + public const string Name = "Wox"; + public static readonly string ProgramPath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString(); + public static readonly string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Name); + } +} diff --git a/Wox.Infrastructure/WoxDirectroy.cs b/Wox.Infrastructure/WoxDirectroy.cs deleted file mode 100644 index 2cf383f28e..0000000000 --- a/Wox.Infrastructure/WoxDirectroy.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Wox.Infrastructure -{ - public static class WoxDirectroy - { - public static string Executable { get; internal set; } - } -} diff --git a/Wox.Plugin/IPublicAPI.cs b/Wox.Plugin/IPublicAPI.cs index 356671a661..2c19c0a3bd 100644 --- a/Wox.Plugin/IPublicAPI.cs +++ b/Wox.Plugin/IPublicAPI.cs @@ -82,11 +82,6 @@ namespace Wox.Plugin /// Plugin path (ends with .wox) void InstallPlugin(string path); - /// - /// Reload all plugins - /// - void ReloadPlugins(); - /// /// Get translation of current language /// You need to implement IPluginI18n if you want to support multiple languages for your plugin diff --git a/Wox.Plugin/Result.cs b/Wox.Plugin/Result.cs index 9a9bbe2184..53f0658d91 100644 --- a/Wox.Plugin/Result.cs +++ b/Wox.Plugin/Result.cs @@ -60,7 +60,7 @@ namespace Wox.Plugin public override int GetHashCode() { var hashcode = (Title?.GetHashCode() ?? 0) ^ - (SubTitle?.GetHashCode() ?? 0) ; + (SubTitle?.GetHashCode() ?? 0); return hashcode; } @@ -69,18 +69,21 @@ namespace Wox.Plugin return Title + SubTitle; } - public Result(string Title = null, string IcoPath = null, string SubTitle = null) + [Obsolete("Use IContextMenu instead")] + /// + /// Context menus associate with this result + /// + public List ContextMenu { get; set; } + + [Obsolete("Use Object initializers instead")] + public Result(string Titles, string IcoPath, string SubTitle = null) { this.Title = Title; this.IcoPath = IcoPath; this.SubTitle = SubTitle; } - [Obsolete("Use IContextMenu instead")] - /// - /// Context menus associate with this result - /// - public List ContextMenu { get; set; } + public Result() { } /// /// Additional data associate with this result diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index 4194a4597d..c6fb67a19c 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -1,16 +1,12 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.IO; using System.Linq; -using System.Reflection; -using System.Threading; using System.Threading.Tasks; using System.Windows; using Wox.CommandArgs; using Wox.Core.Plugin; using Wox.Helper; -using Wox.Infrastructure; using Wox.Infrastructure.Image; using Wox.ViewModel; using Stopwatch = Wox.Infrastructure.Stopwatch; @@ -40,11 +36,9 @@ namespace Wox Stopwatch.Debug("Startup Time", () => { base.OnStartup(e); - WoxDirectroy.Executable = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString(); RegisterUnhandledException(); Task.Factory.StartNew(ImageLoader.PreloadImages); - PluginManager.Initialize(); MainViewModel mainVM = new MainViewModel(); API = new PublicAPIInstance(mainVM, mainVM._settings); diff --git a/Wox/Msg.xaml.cs b/Wox/Msg.xaml.cs index e3689b12df..9873128c42 100644 --- a/Wox/Msg.xaml.cs +++ b/Wox/Msg.xaml.cs @@ -38,7 +38,7 @@ namespace Wox Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty)); fadeOutStoryboard.Children.Add(fadeOutAnimation); - imgClose.Source = ImageLoader.Load(Path.Combine(WoxDirectroy.Executable, "Images\\close.png")); + imgClose.Source = ImageLoader.Load(Path.Combine(Infrastructure.Wox.ProgramPath, "Images\\close.png")); imgClose.MouseUp += imgClose_MouseUp; } @@ -66,7 +66,7 @@ namespace Wox } if (!File.Exists(iconPath)) { - imgIco.Source = ImageLoader.Load(Path.Combine(WoxDirectroy.Executable, "Images\\app.png")); + imgIco.Source = ImageLoader.Load(Path.Combine(Infrastructure.Wox.ProgramPath, "Images\\app.png")); } else { imgIco.Source = ImageLoader.Load(iconPath); diff --git a/Wox/PublicAPIInstance.cs b/Wox/PublicAPIInstance.cs index 64171fc9e4..e405648e83 100644 --- a/Wox/PublicAPIInstance.cs +++ b/Wox/PublicAPIInstance.cs @@ -118,15 +118,6 @@ namespace Wox Application.Current.Dispatcher.Invoke(() => PluginManager.InstallPlugin(path)); } - public void ReloadPlugins() - { - Application.Current.Dispatcher.Invoke(() => - { - PluginManager.Initialize(); - PluginManager.InitializePlugins(this); - }); - } - public string GetTranslation(string key) { return InternationalizationManager.Instance.GetTranslation(key); diff --git a/Wox/ViewModel/MainViewModel.cs b/Wox/ViewModel/MainViewModel.cs index bfdc3e3989..8bbac730dc 100644 --- a/Wox/ViewModel/MainViewModel.cs +++ b/Wox/ViewModel/MainViewModel.cs @@ -496,7 +496,7 @@ namespace Wox.ViewModel Title = string.Format(executeQueryHistoryTitle,history.Query), SubTitle = string.Format(lastExecuteTime,history.ExecutedDateTime), IcoPath = "Images\\history.png", - PluginDirectory = WoxDirectroy.Executable, + PluginDirectory = Infrastructure.Wox.ProgramPath, Action = _ =>{ QueryText = history.Query; OnTextBoxSelected(); @@ -511,9 +511,11 @@ namespace Wox.ViewModel Result menu; if (_topMostRecord.IsTopMost(result)) { - menu = new Result(InternationalizationManager.Instance.GetTranslation("cancelTopMostInThisQuery"), "Images\\down.png") + menu = new Result { - PluginDirectory = WoxDirectroy.Executable, + Title = InternationalizationManager.Instance.GetTranslation("cancelTopMostInThisQuery"), + IcoPath = "Images\\down.png", + PluginDirectory = Infrastructure.Wox.ProgramPath, Action = _ => { _topMostRecord.Remove(result); @@ -524,9 +526,11 @@ namespace Wox.ViewModel } else { - menu = new Result(InternationalizationManager.Instance.GetTranslation("setAsTopMostInThisQuery"), "Images\\up.png") + menu = new Result { - PluginDirectory = WoxDirectroy.Executable, + Title = InternationalizationManager.Instance.GetTranslation("setAsTopMostInThisQuery"), + IcoPath = "Images\\up.png", + PluginDirectory = Infrastructure.Wox.ProgramPath, Action = _ => { _topMostRecord.AddOrUpdate(result); @@ -551,8 +555,11 @@ namespace Wox.ViewModel var icon = metadata.IcoPath; var subtitle = $"{author}: {metadata.Author}, {website}: {metadata.Website} {version}: {metadata.Version}"; - var menu = new Result(title, icon, subtitle) + var menu = new Result { + Title = title, + IcoPath = icon, + SubTitle = subtitle, PluginDirectory = metadata.PluginDirectory, Action = _ => false };