From ccc8d7e5cdf637d6f4572859f6fd3142a39ad353 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Fri, 26 Dec 2014 22:51:04 +0800 Subject: [PATCH] Refactoring. --- Plugins/Wox.Plugin.PluginManagement/Main.cs | 8 +++--- Wox.Core/Plugin/JsonRPCPlugin.cs | 13 +++++---- Wox.Core/Plugin/PluginConfig.cs | 6 ++-- Wox.Core/Plugin/PluginManager.cs | 28 +++++++++++++------ .../QueryDispatcher/IQueryDispatcher.cs | 7 +++++ .../Plugin/QueryDispatcher/QueryDispatcher.cs | 21 ++++++++++++++ .../SystemPluginQueryDispatcher.cs | 13 ++++----- .../UserPluginQueryDispatcher.cs | 22 +++++++-------- Wox.Core/README.txt | 2 +- Wox.Core/Wox.Core.csproj | 7 ++++- Wox.Infrastructure/ChineseToPinYin.cs | 15 ---------- Wox.Infrastructure/Wox.Infrastructure.csproj | 11 +++----- .../Program/ProgramSetting.xaml | 3 +- .../Program}/StringEmptyConverter.cs | 5 +--- ...ginIndicator.cs => UserPluginIndicator.cs} | 2 +- .../Wox.Plugin.SystemPlugins.csproj | 3 +- Wox.Plugin/IPublicAPI.cs | 7 ++++- Wox.Plugin/PluginType.cs | 2 +- Wox/CommandArgs/ReloadPluginCommandArg.cs | 2 +- Wox/Commands/BaseCommand.cs | 18 ------------ Wox/Commands/CommandFactory.cs | 28 ------------------- Wox/Helper/PluginInstaller.cs | 2 +- Wox/ImageLoader/ImageCacheStroage.cs | 4 +-- Wox/MainWindow.xaml.cs | 10 +++---- Wox/SettingWindow.xaml.cs | 2 +- .../Storage/UserSelectedRecordStorage.cs | 7 ++--- Wox/Wox.csproj | 5 +--- 27 files changed, 114 insertions(+), 139 deletions(-) create mode 100644 Wox.Core/Plugin/QueryDispatcher/IQueryDispatcher.cs create mode 100644 Wox.Core/Plugin/QueryDispatcher/QueryDispatcher.cs rename Wox/Commands/SystemCommand.cs => Wox.Core/Plugin/QueryDispatcher/SystemPluginQueryDispatcher.cs (79%) rename Wox/Commands/PluginCommand.cs => Wox.Core/Plugin/QueryDispatcher/UserPluginQueryDispatcher.cs (57%) delete mode 100644 Wox.Infrastructure/ChineseToPinYin.cs rename {Wox.Infrastructure => Wox.Plugin.SystemPlugins/Program}/StringEmptyConverter.cs (87%) rename Wox.Plugin.SystemPlugins/{ThirdpartyPluginIndicator.cs => UserPluginIndicator.cs} (97%) delete mode 100644 Wox/Commands/BaseCommand.cs delete mode 100644 Wox/Commands/CommandFactory.cs rename {Wox.Infrastructure => Wox}/Storage/UserSelectedRecordStorage.cs (88%) diff --git a/Plugins/Wox.Plugin.PluginManagement/Main.cs b/Plugins/Wox.Plugin.PluginManagement/Main.cs index 960a2c328c..a2153610d7 100644 --- a/Plugins/Wox.Plugin.PluginManagement/Main.cs +++ b/Plugins/Wox.Plugin.PluginManagement/Main.cs @@ -197,7 +197,7 @@ namespace Wox.Plugin.PluginManagement private List ListUnInstalledPlugins(Query query) { List results = new List(); - List allInstalledPlugins = ParseThirdPartyPlugins(); + List allInstalledPlugins = ParseUserPlugins(); if (query.ActionParameters.Count > 1) { string pluginName = query.ActionParameters[1]; @@ -235,7 +235,7 @@ namespace Wox.Plugin.PluginManagement private List ListInstalledPlugins() { List results = new List(); - foreach (PluginMetadata plugin in ParseThirdPartyPlugins()) + foreach (PluginMetadata plugin in ParseUserPlugins()) { results.Add(new Result() { @@ -247,7 +247,7 @@ namespace Wox.Plugin.PluginManagement return results; } - private static List ParseThirdPartyPlugins() + private static List ParseUserPlugins() { List pluginMetadatas = new List(); if (!Directory.Exists(PluginPath)) @@ -276,7 +276,7 @@ namespace Wox.Plugin.PluginManagement try { metadata = JsonConvert.DeserializeObject(File.ReadAllText(configPath)); - metadata.PluginType = PluginType.ThirdParty; + metadata.PluginType = PluginType.User; metadata.PluginDirectory = pluginDirectory; } catch (Exception) diff --git a/Wox.Core/Plugin/JsonRPCPlugin.cs b/Wox.Core/Plugin/JsonRPCPlugin.cs index 1b878dfce3..0809826300 100644 --- a/Wox.Core/Plugin/JsonRPCPlugin.cs +++ b/Wox.Core/Plugin/JsonRPCPlugin.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.IO; using System.Reflection; using System.Threading; +using System.Windows.Forms; using Newtonsoft.Json; using Wox.Infrastructure.Exceptions; using Wox.Infrastructure.Logger; @@ -74,7 +75,6 @@ namespace Wox.Core.Plugin } catch (Exception e) { - ErrorReporting.TryShowErrorMessageBox(e.Message, e); Log.Error(e.Message); } } @@ -83,12 +83,12 @@ namespace Wox.Core.Plugin private void ExecuteWoxAPI(string method, object[] parameters) { - MethodInfo methodInfo = App.Window.GetType().GetMethod(method); - if (methodInfo != null) + MethodInfo methodInfo = PluginManager.API.GetType().GetMethod(method); + if (methodInfo != null) { try { - methodInfo.Invoke(App.Window, parameters); + methodInfo.Invoke(PluginManager.API, parameters); } catch (Exception) { @@ -132,7 +132,7 @@ namespace Wox.Core.Plugin string result = reader.ReadToEnd(); if (result.StartsWith("DEBUG:")) { - System.Windows.Forms.MessageBox.Show(new Form { TopMost = true }, result.Substring(6)); + MessageBox.Show(new Form { TopMost = true }, result.Substring(6)); return ""; } if (string.IsNullOrEmpty(result)) @@ -142,7 +142,8 @@ namespace Wox.Core.Plugin string error = errorReader.ReadToEnd(); if (!string.IsNullOrEmpty(error)) { - ErrorReporting.TryShowErrorMessageBox(error, new WoxJsonRPCException(error)); + //todo: + // ErrorReporting.TryShowErrorMessageBox(error, new WoxJsonRPCException(error)); } } } diff --git a/Wox.Core/Plugin/PluginConfig.cs b/Wox.Core/Plugin/PluginConfig.cs index 0359ef6483..5d6c8137d4 100644 --- a/Wox.Core/Plugin/PluginConfig.cs +++ b/Wox.Core/Plugin/PluginConfig.cs @@ -28,7 +28,7 @@ namespace Wox.Core.Plugin ParseSystemPlugins(); foreach (string pluginDirectory in pluginDirectories) { - ParseThirdPartyPlugins(pluginDirectory); + ParseUserPlugins(pluginDirectory); } if (PluginManager.DebuggerMode != null) @@ -56,7 +56,7 @@ namespace Wox.Core.Plugin }); } - private static void ParseThirdPartyPlugins(string pluginDirectory) + private static void ParseUserPlugins(string pluginDirectory) { string[] directories = Directory.GetDirectories(pluginDirectory); @@ -88,7 +88,7 @@ namespace Wox.Core.Plugin try { metadata = JsonConvert.DeserializeObject(File.ReadAllText(configPath)); - metadata.PluginType = PluginType.ThirdParty; + metadata.PluginType = PluginType.User; metadata.PluginDirectory = pluginDirectory; } catch (Exception) diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index 91af115ba8..e3b0217869 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -15,8 +15,10 @@ namespace Wox.Core.Plugin public static class PluginManager { public static String DebuggerMode { get; private set; } + public static IPublicAPI API { get; private set; } + private static List plugins = new List(); - + /// /// Directories that will hold Wox plugin directory /// @@ -26,10 +28,14 @@ namespace Wox.Core.Plugin { pluginDirectories.Add( Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Plugins")); - pluginDirectories.Add( - Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".Wox"),"Plugins")); - MakesurePluginDirectoriesExist(); + string userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE"); + if (userProfilePath != null) + { + pluginDirectories.Add(Path.Combine(Path.Combine(userProfilePath, ".Wox"), "Plugins")); + } + + MakesurePluginDirectoriesExist(); } private static void MakesurePluginDirectoriesExist() @@ -46,8 +52,9 @@ namespace Wox.Core.Plugin /// /// Load and init all Wox plugins /// - public static void Init() + public static void Init(IPublicAPI api) { + API = api; plugins.Clear(); List pluginMetadatas = PluginConfig.Parse(pluginDirectories); @@ -61,11 +68,16 @@ namespace Wox.Core.Plugin { CurrentPluginMetadata = pair.Metadata, Proxy = HttpProxy.Instance, - API = App.Window + API = API })); } } + public static void Query(Query query) + { + QueryDispatcher.QueryDispatcher.Dispatch(query); + } + public static List AllPlugins { get @@ -74,11 +86,11 @@ namespace Wox.Core.Plugin } } - public static bool HitThirdpartyKeyword(Query query) + public static bool IsUserPluginQuery(Query query) { if (string.IsNullOrEmpty(query.ActionName)) return false; - return plugins.Any(o => o.Metadata.PluginType == PluginType.ThirdParty && o.Metadata.ActionKeyword == query.ActionName); + return plugins.Any(o => o.Metadata.PluginType == PluginType.User && o.Metadata.ActionKeyword == query.ActionName); } public static void ActivatePluginDebugger(string path) diff --git a/Wox.Core/Plugin/QueryDispatcher/IQueryDispatcher.cs b/Wox.Core/Plugin/QueryDispatcher/IQueryDispatcher.cs new file mode 100644 index 0000000000..c5312a0332 --- /dev/null +++ b/Wox.Core/Plugin/QueryDispatcher/IQueryDispatcher.cs @@ -0,0 +1,7 @@ +namespace Wox.Core.Plugin.QueryDispatcher +{ + internal interface IQueryDispatcher + { + void Dispatch(Wox.Plugin.Query query); + } +} diff --git a/Wox.Core/Plugin/QueryDispatcher/QueryDispatcher.cs b/Wox.Core/Plugin/QueryDispatcher/QueryDispatcher.cs new file mode 100644 index 0000000000..0e0eb62fb9 --- /dev/null +++ b/Wox.Core/Plugin/QueryDispatcher/QueryDispatcher.cs @@ -0,0 +1,21 @@ + +namespace Wox.Core.Plugin.QueryDispatcher +{ + internal static class QueryDispatcher + { + private static IQueryDispatcher pluginCmd = new UserPluginQueryDispatcher(); + private static IQueryDispatcher systemCmd = new SystemPluginQueryDispatcher(); + + public static void Dispatch(Wox.Plugin.Query query) + { + if (PluginManager.IsUserPluginQuery(query)) + { + pluginCmd.Dispatch(query); + } + else + { + systemCmd.Dispatch(query); + } + } + } +} diff --git a/Wox/Commands/SystemCommand.cs b/Wox.Core/Plugin/QueryDispatcher/SystemPluginQueryDispatcher.cs similarity index 79% rename from Wox/Commands/SystemCommand.cs rename to Wox.Core/Plugin/QueryDispatcher/SystemPluginQueryDispatcher.cs index d1ca9eb4fc..b72c2e0760 100644 --- a/Wox/Commands/SystemCommand.cs +++ b/Wox.Core/Plugin/QueryDispatcher/SystemPluginQueryDispatcher.cs @@ -1,20 +1,17 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading; -using Wox.Core.Plugin; using Wox.Infrastructure.Storage.UserSettings; using Wox.Plugin; using Wox.Plugin.SystemPlugins; -namespace Wox.Commands +namespace Wox.Core.Plugin.QueryDispatcher { - public class SystemCommand : BaseCommand + public class SystemPluginQueryDispatcher : IQueryDispatcher { private IEnumerable allSytemPlugins = PluginManager.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.System); - public override void Dispatch(Query query) + public void Dispatch(Query query) { var queryPlugins = allSytemPlugins; if (UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == query.ActionName && o.Enabled)) @@ -34,7 +31,7 @@ namespace Wox.Commands List results = pair1.Plugin.Query(query); results.ForEach(o => { o.AutoAjustScore = true; }); - App.Window.PushResults(query, pair1.Metadata, results); + PluginManager.API.PushResults(query, pair1.Metadata, results); }); } } diff --git a/Wox/Commands/PluginCommand.cs b/Wox.Core/Plugin/QueryDispatcher/UserPluginQueryDispatcher.cs similarity index 57% rename from Wox/Commands/PluginCommand.cs rename to Wox.Core/Plugin/QueryDispatcher/UserPluginQueryDispatcher.cs index d233f766b9..6c709e5bdc 100644 --- a/Wox/Commands/PluginCommand.cs +++ b/Wox.Core/Plugin/QueryDispatcher/UserPluginQueryDispatcher.cs @@ -2,26 +2,24 @@ using System.Collections.Generic; using System.Linq; using System.Threading; -using Wox.Core.Plugin; -using Wox.Helper; using Wox.Infrastructure.Logger; using Wox.Infrastructure.Storage.UserSettings; using Wox.Plugin; -namespace Wox.Commands +namespace Wox.Core.Plugin.QueryDispatcher { - public class PluginCommand : BaseCommand + public class UserPluginQueryDispatcher : IQueryDispatcher { - public override void Dispatch(Query query) + public void Dispatch(Query query) { - PluginPair thirdPlugin = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.ActionName); - if (thirdPlugin != null && !string.IsNullOrEmpty(thirdPlugin.Metadata.ActionKeyword)) + PluginPair userPlugin = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.ActionName); + if (userPlugin != null && !string.IsNullOrEmpty(userPlugin.Metadata.ActionKeyword)) { - var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == thirdPlugin.Metadata.ID); + var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == userPlugin.Metadata.ID); if (customizedPluginConfig != null && customizedPluginConfig.Disabled) { //need to stop the loading animation - UpdateResultView(null); + PluginManager.API.StopLoadingBar(); return; } @@ -29,12 +27,12 @@ namespace Wox.Commands { try { - List results = thirdPlugin.Plugin.Query(query) ?? new List(); - App.Window.PushResults(query,thirdPlugin.Metadata,results); + List results = userPlugin.Plugin.Query(query) ?? new List(); + PluginManager.API.PushResults(query,userPlugin.Metadata,results); } catch (Exception queryException) { - Log.Error(string.Format("Plugin {0} query failed: {1}", thirdPlugin.Metadata.Name, + Log.Error(string.Format("Plugin {0} query failed: {1}", userPlugin.Metadata.Name, queryException.Message)); #if (DEBUG) { diff --git a/Wox.Core/README.txt b/Wox.Core/README.txt index 3cd91680db..5a0b695dc5 100644 --- a/Wox.Core/README.txt +++ b/Wox.Core/README.txt @@ -1,4 +1,4 @@ What does Wox.Core do? * Handle Query -* Loading Plugins \ No newline at end of file +* Loading Plugins (including system plugin and user plugin) \ No newline at end of file diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj index 34f0938d78..ec5cf28ca2 100644 --- a/Wox.Core/Wox.Core.csproj +++ b/Wox.Core/Wox.Core.csproj @@ -18,7 +18,7 @@ true full false - bin\Debug\ + ..\Output\Debug\ DEBUG;TRACE prompt 4 @@ -38,12 +38,17 @@ + + + + + diff --git a/Wox.Infrastructure/ChineseToPinYin.cs b/Wox.Infrastructure/ChineseToPinYin.cs deleted file mode 100644 index 1f59d7c282..0000000000 --- a/Wox.Infrastructure/ChineseToPinYin.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Wox.Infrastructure -{ - public static class ChineseToPinYin - { - [Obsolete] - public static string ToPinYin(string txt) - { - return txt.Unidecode(); - } - } -} diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index c50978f96d..e3cfa6398a 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -67,21 +67,18 @@ + + + + - - - - - - - diff --git a/Wox.Plugin.SystemPlugins/Program/ProgramSetting.xaml b/Wox.Plugin.SystemPlugins/Program/ProgramSetting.xaml index ded91a25c2..6f00f4cd5c 100644 --- a/Wox.Plugin.SystemPlugins/Program/ProgramSetting.xaml +++ b/Wox.Plugin.SystemPlugins/Program/ProgramSetting.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:infrastructure="clr-namespace:Wox.Infrastructure;assembly=Wox.Infrastructure" + xmlns:program="clr-namespace:Wox.Plugin.SystemPlugins.Program" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="600"> @@ -26,7 +27,7 @@ - + diff --git a/Wox.Infrastructure/StringEmptyConverter.cs b/Wox.Plugin.SystemPlugins/Program/StringEmptyConverter.cs similarity index 87% rename from Wox.Infrastructure/StringEmptyConverter.cs rename to Wox.Plugin.SystemPlugins/Program/StringEmptyConverter.cs index f553695737..c2d5366306 100644 --- a/Wox.Infrastructure/StringEmptyConverter.cs +++ b/Wox.Plugin.SystemPlugins/Program/StringEmptyConverter.cs @@ -1,11 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Windows.Data; using System.Windows.Markup; -namespace Wox.Infrastructure +namespace Wox.Plugin.SystemPlugins.Program { public class StringEmptyConverter : MarkupExtension, IValueConverter { diff --git a/Wox.Plugin.SystemPlugins/ThirdpartyPluginIndicator.cs b/Wox.Plugin.SystemPlugins/UserPluginIndicator.cs similarity index 97% rename from Wox.Plugin.SystemPlugins/ThirdpartyPluginIndicator.cs rename to Wox.Plugin.SystemPlugins/UserPluginIndicator.cs index 31e3ab0acf..cc1d492a3b 100644 --- a/Wox.Plugin.SystemPlugins/ThirdpartyPluginIndicator.cs +++ b/Wox.Plugin.SystemPlugins/UserPluginIndicator.cs @@ -8,7 +8,7 @@ using Wox.Infrastructure.Storage.UserSettings; namespace Wox.Plugin.SystemPlugins { - public class ThirdpartyPluginIndicator : BaseSystemPlugin + public class UserPluginIndicator : BaseSystemPlugin { private List allPlugins = new List(); private PluginInitContext context; diff --git a/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj b/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj index 7fb13e044d..75604f9377 100644 --- a/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj +++ b/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj @@ -86,6 +86,7 @@ ProgramSuffixes.xaml + @@ -102,7 +103,7 @@ - + diff --git a/Wox.Plugin/IPublicAPI.cs b/Wox.Plugin/IPublicAPI.cs index 64ff13ab08..5ae94e0a40 100644 --- a/Wox.Plugin/IPublicAPI.cs +++ b/Wox.Plugin/IPublicAPI.cs @@ -6,7 +6,12 @@ namespace Wox.Plugin { public interface IPublicAPI { - + /// + /// Push result to query window + /// + /// + /// + /// void PushResults(Query query,PluginMetadata plugin, List results); bool ShellRun(string cmd, bool runAsAdministrator = false); diff --git a/Wox.Plugin/PluginType.cs b/Wox.Plugin/PluginType.cs index a36cc50b27..d046b579f0 100644 --- a/Wox.Plugin/PluginType.cs +++ b/Wox.Plugin/PluginType.cs @@ -8,6 +8,6 @@ namespace Wox.Plugin public enum PluginType { System, - ThirdParty + User } } diff --git a/Wox/CommandArgs/ReloadPluginCommandArg.cs b/Wox/CommandArgs/ReloadPluginCommandArg.cs index 825f4439f6..f287e08c85 100644 --- a/Wox/CommandArgs/ReloadPluginCommandArg.cs +++ b/Wox/CommandArgs/ReloadPluginCommandArg.cs @@ -15,7 +15,7 @@ namespace Wox.CommandArgs public void Execute(IList args) { - PluginManager.Init(); + PluginManager.Init(App.Window); } } } diff --git a/Wox/Commands/BaseCommand.cs b/Wox/Commands/BaseCommand.cs deleted file mode 100644 index 8a5283e77a..0000000000 --- a/Wox/Commands/BaseCommand.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Wox.Plugin; - -namespace Wox.Commands -{ - public abstract class BaseCommand - { - public abstract void Dispatch(Query query); - - protected void UpdateResultView(List results) - { - App.Window.OnUpdateResultView(results); - } - } -} diff --git a/Wox/Commands/CommandFactory.cs b/Wox/Commands/CommandFactory.cs deleted file mode 100644 index b7b2eb9c20..0000000000 --- a/Wox/Commands/CommandFactory.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Wox.Core.Plugin; -using Wox.Helper; -using Wox.Plugin; - -namespace Wox.Commands -{ - internal static class CommandFactory - { - private static PluginCommand pluginCmd = new PluginCommand(); - private static SystemCommand systemCmd = new SystemCommand(); - - public static void DispatchCommand(Query query) - { - if (PluginManager.HitThirdpartyKeyword(query)) - { - pluginCmd.Dispatch(query); - } - else - { - systemCmd.Dispatch(query); - } - } - } -} diff --git a/Wox/Helper/PluginInstaller.cs b/Wox/Helper/PluginInstaller.cs index ed66f5eb24..5cc0a9568a 100644 --- a/Wox/Helper/PluginInstaller.cs +++ b/Wox/Helper/PluginInstaller.cs @@ -116,7 +116,7 @@ namespace Wox.Helper try { metadata = JsonConvert.DeserializeObject(File.ReadAllText(configPath)); - metadata.PluginType = PluginType.ThirdParty; + metadata.PluginType = PluginType.User; metadata.PluginDirectory = pluginDirectory; } catch (Exception) diff --git a/Wox/ImageLoader/ImageCacheStroage.cs b/Wox/ImageLoader/ImageCacheStroage.cs index 88526e3e45..a090d95cf9 100644 --- a/Wox/ImageLoader/ImageCacheStroage.cs +++ b/Wox/ImageLoader/ImageCacheStroage.cs @@ -9,8 +9,8 @@ namespace Wox.ImageLoader [Serializable] public class ImageCacheStroage : BinaryStorage { - public int counter = 0; - public const int maxCached = 200; + private int counter = 0; + private const int maxCached = 200; public Dictionary TopUsedImages = new Dictionary(); protected override string ConfigName diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 3fe95171dc..79befea4d8 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -14,7 +14,6 @@ using WindowsInput; using WindowsInput.Native; using NHotkey; using NHotkey.Wpf; -using Wox.Commands; using Wox.Core.Plugin; using Wox.Helper; using Wox.Infrastructure; @@ -22,6 +21,7 @@ using Wox.Infrastructure.Hotkey; using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage.UserSettings; using Wox.Plugin; +using Wox.Storage; using Wox.Update; using Application = System.Windows.Application; using Brushes = System.Windows.Media.Brushes; @@ -127,7 +127,7 @@ namespace Wox public void ReloadPlugins() { - Dispatcher.Invoke(new Action(PluginManager.Init)); + Dispatcher.Invoke(new Action(()=> PluginManager.Init(this))); } public List GetAllPlugins() @@ -192,7 +192,7 @@ namespace Wox ThreadPool.QueueUserWorkItem(o => { Thread.Sleep(50); - PluginManager.Init(); + PluginManager.Init(this); }); ThreadPool.QueueUserWorkItem(o => { @@ -357,9 +357,9 @@ namespace Wox }, TimeSpan.FromMilliseconds(100), null); queryHasReturn = false; var q = new Query(lastQuery); - CommandFactory.DispatchCommand(q); + PluginManager.Query(q); BackToResultMode(); - if (PluginManager.HitThirdpartyKeyword(q)) + if (PluginManager.IsUserPluginQuery(q)) { Dispatcher.DelayInvoke("ShowProgressbar", originQuery => { diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index a356bdec9c..c8ae9cd0b3 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -195,7 +195,7 @@ namespace Wox new CollectionContainer { Collection = - PluginManager.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.ThirdParty) + PluginManager.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.User) } }; lbPlugins.ItemsSource = plugins; diff --git a/Wox.Infrastructure/Storage/UserSelectedRecordStorage.cs b/Wox/Storage/UserSelectedRecordStorage.cs similarity index 88% rename from Wox.Infrastructure/Storage/UserSelectedRecordStorage.cs rename to Wox/Storage/UserSelectedRecordStorage.cs index 0b21e320e7..2b6c4d217c 100644 --- a/Wox.Infrastructure/Storage/UserSelectedRecordStorage.cs +++ b/Wox/Storage/UserSelectedRecordStorage.cs @@ -1,12 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using Newtonsoft.Json; using Wox.Infrastructure.Storage; using Wox.Plugin; -namespace Wox.Infrastructure.Storage +namespace Wox.Storage { public class UserSelectedRecordStorage : JsonStrorage { diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 66bb922123..dc218d536d 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -105,6 +105,7 @@ + NewVersionWindow.xaml @@ -124,10 +125,6 @@ - - - -