diff --git a/.gitignore b/.gitignore index fc8205cac..57103cd78 100644 --- a/.gitignore +++ b/.gitignore @@ -121,3 +121,4 @@ Wox/Wox.csproj *.sublime-* *.dgml +migrateToAutomaticPackageRestore.ps1 diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config deleted file mode 100644 index 67f8ea046..000000000 --- a/.nuget/NuGet.Config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe deleted file mode 100644 index c296edf17..000000000 Binary files a/.nuget/NuGet.exe and /dev/null differ diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets deleted file mode 100644 index 83fe90601..000000000 --- a/.nuget/NuGet.targets +++ /dev/null @@ -1,136 +0,0 @@ - - - - $(MSBuildProjectDirectory)\..\ - - - false - - - false - - - true - - - false - - - - - - - - - - - $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) - $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) - - - - - $(SolutionDir).nuget - packages.config - - - - - $(NuGetToolsPath)\NuGet.exe - @(PackageSource) - - "$(NuGetExePath)" - mono --runtime=v4.0.30319 $(NuGetExePath) - - $(TargetDir.Trim('\\')) - - -RequireConsent - -NonInteractive - - "$(SolutionDir) " - "$(SolutionDir)" - - - $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) - $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols - - - - RestorePackages; - $(BuildDependsOn); - - - - - $(BuildDependsOn); - BuildPackage; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/Wox.Plugin.CMD/CMD.cs b/Plugins/Wox.Plugin.CMD/CMD.cs index e95b11d71..de76413c5 100644 --- a/Plugins/Wox.Plugin.CMD/CMD.cs +++ b/Plugins/Wox.Plugin.CMD/CMD.cs @@ -1,15 +1,13 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Windows.Forms; using WindowsInput; using WindowsInput.Native; -using Wox.Infrastructure; using Wox.Infrastructure.Hotkey; -using Wox.Plugin.Features; +using Wox.Infrastructure.Logger; using Control = System.Windows.Controls.Control; namespace Wox.Plugin.CMD @@ -24,14 +22,13 @@ namespace Wox.Plugin.CMD { List results = new List(); List pushedResults = new List(); - if (query.Search == ">") + string cmd = query.Search; + if (string.IsNullOrEmpty(cmd)) { return GetAllHistoryCmds(); } - - if (query.Search.StartsWith(">") && query.Search.Length > 1) + else { - string cmd = query.Search.Substring(1); var queryCmd = GetCurrentCmd(cmd); context.API.PushResults(query, context.CurrentPluginMetadata, new List() { queryCmd }); pushedResults.Add(queryCmd); @@ -51,7 +48,7 @@ namespace Wox.Plugin.CMD basedir = excmd; dir = cmd; } - else if (Directory.Exists(Path.GetDirectoryName(excmd))) + else if (Directory.Exists(Path.GetDirectoryName(excmd) ?? string.Empty)) { basedir = Path.GetDirectoryName(excmd); var dirn = Path.GetDirectoryName(cmd); @@ -74,10 +71,12 @@ namespace Wox.Plugin.CMD })); } } - catch (Exception) { } - + catch (Exception e) + { + Log.Error(e); + } + return results; } - return results; } private List GetHistoryCmds(string cmd, Result result) @@ -201,11 +200,7 @@ namespace Wox.Plugin.CMD return context.API.GetTranslation("wox_plugin_cmd_plugin_description"); } - public bool IsInstantQuery(string query) - { - if (query.StartsWith(">")) return true; - return false; - } + public bool IsInstantQuery(string query) => false; public bool IsExclusiveQuery(Query query) { diff --git a/Plugins/Wox.Plugin.CMD/CMDStorage.cs b/Plugins/Wox.Plugin.CMD/CMDStorage.cs index 1d719d17c..ece62a06a 100644 --- a/Plugins/Wox.Plugin.CMD/CMDStorage.cs +++ b/Plugins/Wox.Plugin.CMD/CMDStorage.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; +using System.IO; using System.Reflection; using Newtonsoft.Json; using Wox.Infrastructure.Storage; -using System.IO; namespace Wox.Plugin.CMD { diff --git a/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj b/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj index b64f79fc2..2b7280a2b 100644 --- a/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj +++ b/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj @@ -12,7 +12,6 @@ v3.5 512 ..\..\ - true @@ -44,7 +43,6 @@ - @@ -105,13 +103,6 @@ - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - \ No newline at end of file + + diff --git a/Plugins/Wox.Plugin.CMD/plugin.json b/Plugins/Wox.Plugin.CMD/plugin.json index 949a49998..329dcd02c 100644 --- a/Plugins/Wox.Plugin.CMD/plugin.json +++ b/Plugins/Wox.Plugin.CMD/plugin.json @@ -1,6 +1,6 @@ { "ID":"D409510CD0D2481F853690A07E6DC426", - "ActionKeyword":"*", + "ActionKeyword":">", "Name":"Shell", "Description":"Provide executing commands from Wox. Commands should start with >", "Author":"qianlifeng", diff --git a/Plugins/Wox.Plugin.Caculator/Wox.Plugin.Caculator.csproj b/Plugins/Wox.Plugin.Caculator/Wox.Plugin.Caculator.csproj index f56492528..907c4ff92 100644 --- a/Plugins/Wox.Plugin.Caculator/Wox.Plugin.Caculator.csproj +++ b/Plugins/Wox.Plugin.Caculator/Wox.Plugin.Caculator.csproj @@ -1,116 +1,100 @@ - - - - - Debug - AnyCPU - {59BD9891-3837-438A-958D-ADC7F91F6F7E} - Library - Properties - Wox.Plugin.Caculator - Wox.Plugin.Caculator - v3.5 - 512 - ..\..\ - true - - - - true - full - false - ..\..\Output\Debug\Plugins\Wox.Plugin.Caculator\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - ..\..\Output\Release\Plugins\Wox.Plugin.Caculator\ - TRACE - prompt - 4 - false - - - - - - - - - - - - False - ..\..\packages\YAMP.1.4.0\lib\net35\YAMP.dll - - - - - - - - - - PreserveNewest - - - - - {4fd29318-a8ab-4d8f-aa47-60bc241b8da3} - Wox.Infrastructure - - - {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} - Wox.Plugin - - - - - PreserveNewest - - - - - MSBuild:Compile - Designer - PreserveNewest - - - - - MSBuild:Compile - Designer - PreserveNewest - - - - - MSBuild:Compile - Designer - PreserveNewest - - - - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - - - - + + + + + Debug + AnyCPU + {59BD9891-3837-438A-958D-ADC7F91F6F7E} + Library + Properties + Wox.Plugin.Caculator + Wox.Plugin.Caculator + v3.5 + 512 + ..\..\ + + + + true + full + false + ..\..\Output\Debug\Plugins\Wox.Plugin.Caculator\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + ..\..\Output\Release\Plugins\Wox.Plugin.Caculator\ + TRACE + prompt + 4 + false + + + + + + + + False + ..\..\packages\YAMP.1.4.0\lib\net35\YAMP.dll + + + + + + + + + + PreserveNewest + + + + + {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} + Wox.Plugin + + + + + PreserveNewest + + + + + MSBuild:Compile + Designer + PreserveNewest + + + + + MSBuild:Compile + Designer + PreserveNewest + + + + + MSBuild:Compile + Designer + PreserveNewest + + + + + + + + --> \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj b/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj index 8a0428fad..847df6d01 100644 --- a/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj +++ b/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj @@ -34,14 +34,8 @@ - - - - - - diff --git a/Plugins/Wox.Plugin.ControlPanel/Wox.Plugin.ControlPanel.csproj b/Plugins/Wox.Plugin.ControlPanel/Wox.Plugin.ControlPanel.csproj index 9d4cb13c8..86f8a2c2a 100644 --- a/Plugins/Wox.Plugin.ControlPanel/Wox.Plugin.ControlPanel.csproj +++ b/Plugins/Wox.Plugin.ControlPanel/Wox.Plugin.ControlPanel.csproj @@ -33,14 +33,9 @@ false - - - - - diff --git a/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs b/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs index 1970e39a7..bbb0d3375 100644 --- a/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs +++ b/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs @@ -1,11 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Newtonsoft.Json; -using Wox.Infrastructure.Storage; +using System.Collections.Generic; using System.IO; using System.Reflection; +using Newtonsoft.Json; +using Wox.Infrastructure.Storage; namespace Wox.Plugin.Everything { diff --git a/Plugins/Wox.Plugin.Everything/Main.cs b/Plugins/Wox.Plugin.Everything/Main.cs index 4318485e6..1a6ed8c6b 100644 --- a/Plugins/Wox.Plugin.Everything/Main.cs +++ b/Plugins/Wox.Plugin.Everything/Main.cs @@ -3,11 +3,10 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; using System.ServiceProcess; using Wox.Infrastructure; -using System.Reflection; using Wox.Plugin.Everything.Everything; -using Wox.Plugin.Features; namespace Wox.Plugin.Everything { diff --git a/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj b/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj index 361793404..1b8afe413 100644 --- a/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj +++ b/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj @@ -12,7 +12,6 @@ v3.5 512 ..\Wox\ - true true @@ -41,14 +40,9 @@ ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll - - - - - @@ -136,13 +130,6 @@ - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - \ No newline at end of file + + diff --git a/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.sln b/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.sln deleted file mode 100644 index f4fdc6d15..000000000 --- a/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.sln +++ /dev/null @@ -1,29 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Everything", "Wox.Plugin.Everything.csproj", "{230AE83F-E92E-4E69-8355-426B305DA9C0}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{9BEA8C30-8CC3-48FE-87FD-8D7E65898C1A}" - ProjectSection(SolutionItems) = preProject - .nuget\NuGet.Config = .nuget\NuGet.Config - .nuget\NuGet.exe = .nuget\NuGet.exe - .nuget\NuGet.targets = .nuget\NuGet.targets - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {230AE83F-E92E-4E69-8355-426B305DA9C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {230AE83F-E92E-4E69-8355-426B305DA9C0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {230AE83F-E92E-4E69-8355-426B305DA9C0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {230AE83F-E92E-4E69-8355-426B305DA9C0}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs index 622acac0d..21c2875e8 100644 --- a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs +++ b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs @@ -5,7 +5,7 @@ using System.IO; using System.Linq; using System.Reflection; using System.Windows; -using Control = System.Windows.Controls.Control; +using System.Windows.Controls; namespace Wox.Plugin.Folder { diff --git a/Plugins/Wox.Plugin.Folder/FolderStorage.cs b/Plugins/Wox.Plugin.Folder/FolderStorage.cs index e22d56098..815643c9d 100644 --- a/Plugins/Wox.Plugin.Folder/FolderStorage.cs +++ b/Plugins/Wox.Plugin.Folder/FolderStorage.cs @@ -1,11 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; +using System.IO; using System.Reflection; -using System.Text; using Newtonsoft.Json; using Wox.Infrastructure.Storage; -using System.IO; namespace Wox.Plugin.Folder { diff --git a/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj b/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj index 60d98225c..748cd7c6d 100644 --- a/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj +++ b/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj @@ -12,7 +12,6 @@ v3.5 512 ..\..\ - true @@ -44,7 +43,6 @@ - @@ -106,13 +104,6 @@ - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - \ No newline at end of file + + diff --git a/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs b/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs index fe0a2a8f4..e247436eb 100644 --- a/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs +++ b/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs @@ -17,7 +17,7 @@ namespace Wox.Plugin.PluginIndicator List results = new List(); if (allPlugins.Count == 0) { - allPlugins = context.API.GetAllPlugins().Where(o => !PluginManager.IsGenericPlugin(o.Metadata)).ToList(); + allPlugins = context.API.GetAllPlugins().Where(o => !PluginManager.IsSystemPlugin(o.Metadata)).ToList(); } foreach (PluginMetadata metadata in allPlugins.Select(o => o.Metadata)) diff --git a/Plugins/Wox.Plugin.PluginIndicator/Wox.Plugin.PluginIndicator.csproj b/Plugins/Wox.Plugin.PluginIndicator/Wox.Plugin.PluginIndicator.csproj index b0b463c00..e57ab20a8 100644 --- a/Plugins/Wox.Plugin.PluginIndicator/Wox.Plugin.PluginIndicator.csproj +++ b/Plugins/Wox.Plugin.PluginIndicator/Wox.Plugin.PluginIndicator.csproj @@ -33,13 +33,7 @@ false - - - - - - diff --git a/Plugins/Wox.Plugin.PluginManagement/HttpRequest.cs b/Plugins/Wox.Plugin.PluginManagement/HttpRequest.cs index 40f596322..27c7acabf 100644 --- a/Plugins/Wox.Plugin.PluginManagement/HttpRequest.cs +++ b/Plugins/Wox.Plugin.PluginManagement/HttpRequest.cs @@ -1,7 +1,6 @@ using System; using System.Net; - namespace Wox.Plugin.PluginManagement { public class HttpRequest diff --git a/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj b/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj index cc1174c98..8508c4e31 100644 --- a/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj +++ b/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj @@ -12,7 +12,6 @@ v3.5 512 ..\..\ - true @@ -39,14 +38,9 @@ ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll True - - - - - @@ -97,13 +91,6 @@ - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - \ No newline at end of file + + diff --git a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs index c93df57d1..45fa4f44c 100644 --- a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs +++ b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs @@ -1,16 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; +using System.Windows; namespace Wox.Plugin.Program { diff --git a/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs b/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs index c6f6ec546..4d258e74f 100644 --- a/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs +++ b/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs @@ -2,7 +2,6 @@ using System.Diagnostics; using System.IO; using System.Threading; -using Wox.Infrastructure; namespace Wox.Plugin.Program { @@ -16,7 +15,7 @@ namespace Wox.Plugin.Program if (watchedPath.Contains(path)) return; if (!Directory.Exists(path)) { - DebugHelper.WriteLine(string.Format("FileChangeWatcher: {0} doesn't exist", path)); + Debug.WriteLine(string.Format("FileChangeWatcher: {0} doesn't exist", path)); return; } diff --git a/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs index 5b50d72df..16e0961b3 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs @@ -1,21 +1,21 @@ using System; using System.Collections.Generic; +using Wox.Infrastructure.Logger; namespace Wox.Plugin.Program.ProgramSources { [Serializable] - [global::System.ComponentModel.Browsable(false)] - public class AppPathsProgramSource: AbstractProgramSource + [System.ComponentModel.Browsable(false)] + public class AppPathsProgramSource : AbstractProgramSource { public AppPathsProgramSource() { - this.BonusPoints = -10; + BonusPoints = -10; } - public AppPathsProgramSource(ProgramSource source) - : this() + public AppPathsProgramSource(ProgramSource source) : this() { - this.BonusPoints = source.BonusPoints; + BonusPoints = source.BonusPoints; } public override List LoadPrograms() @@ -33,17 +33,31 @@ namespace Wox.Plugin.Program.ProgramSources if (root == null) return; foreach (var item in root.GetSubKeyNames()) { - using (var key = root.OpenSubKey(item)) + try { - object path = key.GetValue(""); - if (path is string && global::System.IO.File.Exists((string)path)) + using (var key = root.OpenSubKey(item)) { - var entry = CreateEntry((string)path); + string path = key.GetValue("") as string; + if (path == null) continue; + + // fix path like this ""\"C:\\folder\\executable.exe\""" + const int begin = 0; + int end = path.Length - 1; + const char quotationMark = '"'; + if (path[begin] == quotationMark && path[end] == quotationMark) + { + path = path.Substring(begin + 1, path.Length - 2); + } + + if (!System.IO.File.Exists(path)) continue; + var entry = CreateEntry(path); entry.ExecuteName = item; list.Add(entry); } - - key.Close(); + } + catch (Exception e) + { + Log.Error(e.StackTrace); } } } diff --git a/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs index b1ef2dcd4..cb0cf7e76 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Log = Wox.Infrastructure.Logger.Log; +using Wox.Infrastructure.Logger; namespace Wox.Plugin.Program.ProgramSources { diff --git a/Plugins/Wox.Plugin.Program/ProgramStorage.cs b/Plugins/Wox.Plugin.Program/ProgramStorage.cs index a274237f8..d533443f0 100644 --- a/Plugins/Wox.Plugin.Program/ProgramStorage.cs +++ b/Plugins/Wox.Plugin.Program/ProgramStorage.cs @@ -1,12 +1,9 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; +using System.ComponentModel; using System.IO; -using System.Linq; using System.Reflection; -using System.Text; using Newtonsoft.Json; using Wox.Infrastructure.Storage; -using System.ComponentModel; namespace Wox.Plugin.Program { diff --git a/Plugins/Wox.Plugin.Program/Programs.cs b/Plugins/Wox.Plugin.Program/Programs.cs index d6a3a3518..8e2349e43 100644 --- a/Plugins/Wox.Plugin.Program/Programs.cs +++ b/Plugins/Wox.Plugin.Program/Programs.cs @@ -4,12 +4,10 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; -using System.Threading; using System.Windows; +using IWshRuntimeLibrary; using Wox.Infrastructure; using Wox.Plugin.Program.ProgramSources; -using IWshRuntimeLibrary; -using Wox.Plugin.Features; namespace Wox.Plugin.Program { @@ -76,7 +74,7 @@ namespace Wox.Plugin.Program { programs = ProgramCacheStorage.Instance.Programs; } - DebugHelper.WriteLine(string.Format("Preload {0} programs from cache", programs.Count)); + Debug.WriteLine(string.Format("Preload {0} programs from cache", programs.Count)); using (new Timeit("Program Index")) { IndexPrograms(); diff --git a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj index 70e612ac2..0f6c4c566 100644 --- a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj +++ b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj @@ -12,7 +12,6 @@ v3.5 512 ..\..\ - true @@ -139,13 +138,6 @@ - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - \ No newline at end of file + + diff --git a/Plugins/Wox.Plugin.QueryHistory/Wox.Plugin.QueryHistory.csproj b/Plugins/Wox.Plugin.QueryHistory/Wox.Plugin.QueryHistory.csproj index 2a1c20e7e..34fc2868d 100644 --- a/Plugins/Wox.Plugin.QueryHistory/Wox.Plugin.QueryHistory.csproj +++ b/Plugins/Wox.Plugin.QueryHistory/Wox.Plugin.QueryHistory.csproj @@ -12,7 +12,6 @@ v3.5 512 ..\..\ - true true @@ -75,13 +74,6 @@ - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - \ No newline at end of file + + diff --git a/Plugins/Wox.Plugin.Sys/Sys.cs b/Plugins/Wox.Plugin.Sys/Sys.cs index 374bd2a64..bc3db80b6 100644 --- a/Plugins/Wox.Plugin.Sys/Sys.cs +++ b/Plugins/Wox.Plugin.Sys/Sys.cs @@ -5,8 +5,6 @@ using System.Reflection; using System.Runtime.InteropServices; using System.Windows.Forms; using Wox.Infrastructure; -using System.Runtime.InteropServices; -using System.Windows.Forms; using Control = System.Windows.Controls.Control; namespace Wox.Plugin.Sys diff --git a/Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj b/Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj index d40486dbe..2bfb924a5 100644 --- a/Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj +++ b/Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj @@ -12,7 +12,6 @@ v3.5 512 ..\..\ - true @@ -40,7 +39,6 @@ - @@ -124,13 +122,6 @@ - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - \ No newline at end of file + + diff --git a/Plugins/Wox.Plugin.Url/UrlPlugin.cs b/Plugins/Wox.Plugin.Url/UrlPlugin.cs index ae871d2b2..51c8f2ed9 100644 --- a/Plugins/Wox.Plugin.Url/UrlPlugin.cs +++ b/Plugins/Wox.Plugin.Url/UrlPlugin.cs @@ -4,7 +4,6 @@ using System.Diagnostics; using System.IO; using System.Reflection; using System.Text.RegularExpressions; -using System.Windows; namespace Wox.Plugin.Url { diff --git a/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj b/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj index aabcb4525..23e5ac1a8 100644 --- a/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj +++ b/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj @@ -33,16 +33,8 @@ false - - - - - - - - diff --git a/Plugins/Wox.Plugin.WebSearch/EasyTimer.cs b/Plugins/Wox.Plugin.WebSearch/EasyTimer.cs index 78cfb5d6e..49c31e63d 100644 --- a/Plugins/Wox.Plugin.WebSearch/EasyTimer.cs +++ b/Plugins/Wox.Plugin.WebSearch/EasyTimer.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Wox.Plugin.WebSearch { diff --git a/Plugins/Wox.Plugin.WebSearch/WebQueryPlugin.cs b/Plugins/Wox.Plugin.WebSearch/WebQueryPlugin.cs index 7f4412f3d..9fc1b9ec4 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebQueryPlugin.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebQueryPlugin.cs @@ -4,9 +4,6 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; -using System.Timers; -using System.Windows.Threading; -using Wox.Plugin.Features; using Wox.Plugin.WebSearch.SuggestionSources; namespace Wox.Plugin.WebSearch @@ -123,19 +120,16 @@ namespace Wox.Plugin.WebSearch return context.API.GetTranslation("wox_plugin_websearch_plugin_description"); } - public bool IsInstantQuery(string query) + public bool IsInstantQuery(string query) => false; + + public bool IsExclusiveQuery(Query query) { - var strings = query.Split(' '); + var strings = query.RawQuery.Split(' '); if (strings.Length > 1) { return WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == strings[0] && o.Enabled); } return false; } - - public bool IsExclusiveQuery(Query query) - { - return IsInstantQuery(query.RawQuery); - } } } diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs index 2a75abe20..a91a59198 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; -using System.Linq; using System.Reflection; -using System.Text; using Newtonsoft.Json; using Wox.Infrastructure.Storage; diff --git a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj index b4751d37b..905e83a14 100644 --- a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj +++ b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj @@ -12,7 +12,6 @@ v3.5 512 ..\..\ - true @@ -43,7 +42,6 @@ - @@ -130,13 +128,6 @@ - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - \ No newline at end of file + + diff --git a/References/NAppUpdate.Framework.dll b/References/NAppUpdate.Framework.dll deleted file mode 100644 index 398d46b81..000000000 Binary files a/References/NAppUpdate.Framework.dll and /dev/null differ diff --git a/Wox.Core/APIServer.cs b/Wox.Core/APIServer.cs index 8aec75068..7830d091a 100644 --- a/Wox.Core/APIServer.cs +++ b/Wox.Core/APIServer.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Wox.Core +namespace Wox.Core { public static class APIServer { diff --git a/Wox.Core/AssemblyHelper.cs b/Wox.Core/AssemblyHelper.cs deleted file mode 100644 index ac972ff55..000000000 --- a/Wox.Core/AssemblyHelper.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using Wox.Core.Plugin; -using Wox.Infrastructure.Logger; -using Wox.Plugin; - -namespace Wox.Core -{ - internal class AssemblyHelper - { - public static List> LoadPluginInterfaces() where T : class - { - List> results = new List>(); - foreach (PluginPair pluginPair in PluginManager.AllPlugins) - { - //need to load types from AllPlugins - //PluginInitContext is only available in this instance - T type = pluginPair.Plugin as T; - if (type != null) - { - results.Add(new KeyValuePair(pluginPair,type)); - } - } - return results; - } - - public static List LoadInterfacesFromAppDomain() where T : class - { - var interfaceObjects = AppDomain.CurrentDomain.GetAssemblies() - .SelectMany(s => s.GetTypes()) - .Where(p => p.IsClass && !p.IsAbstract && p.GetInterfaces().Contains(typeof(T))); - - return interfaceObjects.Select(interfaceObject => (T) Activator.CreateInstance(interfaceObject)).ToList(); - } - } -} diff --git a/Wox.Core/Exception/ExceptionFormatter.cs b/Wox.Core/Exception/ExceptionFormatter.cs index 7db7b07a0..d4e8beb8a 100644 --- a/Wox.Core/Exception/ExceptionFormatter.cs +++ b/Wox.Core/Exception/ExceptionFormatter.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Text; using System.Xml; diff --git a/Wox.Core/Exception/WoxCritialException.cs b/Wox.Core/Exception/WoxCritialException.cs index 76aea3dea..cf840f9b1 100644 --- a/Wox.Core/Exception/WoxCritialException.cs +++ b/Wox.Core/Exception/WoxCritialException.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Wox.Core.Exception +namespace Wox.Core.Exception { /// /// Represent exceptions that wox can't handle and MUST close running Wox. diff --git a/Wox.Core/Exception/WoxI18nException.cs b/Wox.Core/Exception/WoxI18nException.cs index e095c7899..72b62df98 100644 --- a/Wox.Core/Exception/WoxI18nException.cs +++ b/Wox.Core/Exception/WoxI18nException.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Wox.Core.Exception +namespace Wox.Core.Exception { public class WoxI18nException:WoxException { diff --git a/Wox.Core/Exception/WoxPluginException.cs b/Wox.Core/Exception/WoxPluginException.cs index 113446032..e435be5cd 100644 --- a/Wox.Core/Exception/WoxPluginException.cs +++ b/Wox.Core/Exception/WoxPluginException.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Wox.Core.Exception +namespace Wox.Core.Exception { public class WoxPluginException : WoxException { diff --git a/Wox.Core/Plugin/JsonRPCPlugin.cs b/Wox.Core/Plugin/JsonRPCPlugin.cs index 877ff10e9..6f65d78c9 100644 --- a/Wox.Core/Plugin/JsonRPCPlugin.cs +++ b/Wox.Core/Plugin/JsonRPCPlugin.cs @@ -1,14 +1,13 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Threading; using System.Windows.Forms; using Newtonsoft.Json; +using Wox.Core.Exception; using Wox.Infrastructure.Logger; using Wox.Plugin; -using Wox.Core.Exception; namespace Wox.Core.Plugin { diff --git a/Wox.Core/Plugin/JsonRPCPluginLoader.cs b/Wox.Core/Plugin/JsonRPCPluginLoader.cs index 0bf35979c..d4b2a4f90 100644 --- a/Wox.Core/Plugin/JsonRPCPluginLoader.cs +++ b/Wox.Core/Plugin/JsonRPCPluginLoader.cs @@ -6,7 +6,7 @@ namespace Wox.Core.Plugin { internal class JsonRPCPluginLoader : IPluginLoader where T : JsonRPCPlugin, new() { - public virtual IEnumerable LoadPlugin(List pluginMetadatas) + public IEnumerable LoadPlugin(List pluginMetadatas) { T jsonRPCPlugin = new T(); List jsonRPCPluginMetadatas = pluginMetadatas.Where(o => o.Language.ToUpper() == jsonRPCPlugin.SupportedLanguage.ToUpper()).ToList(); diff --git a/Wox.Core/Plugin/PluginConfig.cs b/Wox.Core/Plugin/PluginConfig.cs index f47e1dac0..2b89a9653 100644 --- a/Wox.Core/Plugin/PluginConfig.cs +++ b/Wox.Core/Plugin/PluginConfig.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using Newtonsoft.Json; using Wox.Core.Exception; using Wox.Core.UserSettings; @@ -30,11 +28,6 @@ namespace Wox.Core.Plugin ParsePluginConfigs(pluginDirectory); } - if (PluginManager.DebuggerMode != null) - { - PluginMetadata metadata = GetPluginMetadata(PluginManager.DebuggerMode); - if (metadata != null) pluginMetadatas.Add(metadata); - } return pluginMetadatas; } diff --git a/Wox.Core/Plugin/PluginInstaller.cs b/Wox.Core/Plugin/PluginInstaller.cs index 77577aa9b..b26254576 100644 --- a/Wox.Core/Plugin/PluginInstaller.cs +++ b/Wox.Core/Plugin/PluginInstaller.cs @@ -1,12 +1,10 @@ using System; using System.Diagnostics; using System.IO; -using System.Windows; using System.Windows.Forms; using ICSharpCode.SharpZipLib.Zip; using Newtonsoft.Json; using Wox.Plugin; -using MessageBox = System.Windows.Forms.MessageBox; namespace Wox.Core.Plugin { diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index b681463f4..1fb302882 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -1,19 +1,17 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Threading; +using System.Windows.Documents; using Wox.Core.Exception; using Wox.Core.i18n; using Wox.Core.UI; using Wox.Core.UserSettings; using Wox.Infrastructure; -using Wox.Infrastructure.Http; using Wox.Infrastructure.Logger; using Wox.Plugin; -using Wox.Plugin.Features; namespace Wox.Core.Plugin { @@ -22,33 +20,37 @@ namespace Wox.Core.Plugin /// public static class PluginManager { - public const string ActionKeywordWildcardSign = "*"; + public const string DirectoryName = "Plugins"; private static List pluginMetadatas; - private static List> instantSearches; - private static List> exclusiveSearchPlugins; - private static List> contextMenuPlugins; - - public static String DebuggerMode { get; private set; } - public static IPublicAPI API { get; private set; } - - private static List plugins = new List(); + private static IEnumerable instantQueryPlugins; + private static IEnumerable exclusiveSearchPlugins; + private static IEnumerable contextMenuPlugins; + private static List plugins; /// /// Directories that will hold Wox plugin directory /// private static List pluginDirectories = new List(); + public static IEnumerable AllPlugins + { + get { return plugins; } + private set { plugins = value.OrderBy(o => o.Metadata.Name).ToList(); } + } + + public static IPublicAPI API { private set; get; } + + public static string PluginDirectory + { + get { return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), DirectoryName); } + } + private static void SetupPluginDirectories() { pluginDirectories.Add(PluginDirectory); MakesurePluginDirectoriesExist(); } - public static string PluginDirectory - { - get { return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Plugins"); } - } - private static void MakesurePluginDirectoriesExist() { foreach (string pluginDirectory in pluginDirectories) @@ -76,38 +78,38 @@ namespace Wox.Core.Plugin SetupPluginDirectories(); API = api; - plugins.Clear(); pluginMetadatas = PluginConfig.Parse(pluginDirectories); - plugins.AddRange(new CSharpPluginLoader().LoadPlugin(pluginMetadatas)); - plugins.AddRange(new JsonRPCPluginLoader().LoadPlugin(pluginMetadatas)); + AllPlugins = (new CSharpPluginLoader().LoadPlugin(pluginMetadatas)). + Concat(new JsonRPCPluginLoader().LoadPlugin(pluginMetadatas)); //load plugin i18n languages ResourceMerger.ApplyPluginLanguages(); - foreach (PluginPair pluginPair in plugins) + foreach (PluginPair pluginPair in AllPlugins) { PluginPair pair = pluginPair; ThreadPool.QueueUserWorkItem(o => { - Stopwatch sw = new Stopwatch(); - sw.Start(); - pair.Plugin.Init(new PluginInitContext() + using (var time = new Timeit($"Plugin init: {pair.Metadata.Name}")) { - CurrentPluginMetadata = pair.Metadata, - Proxy = HttpProxy.Instance, - API = API - }); - sw.Stop(); - DebugHelper.WriteLine(string.Format("Plugin init:{0} - {1}", pair.Metadata.Name, sw.ElapsedMilliseconds)); - pair.InitTime = sw.ElapsedMilliseconds; + pair.Plugin.Init(new PluginInitContext + { + CurrentPluginMetadata = pair.Metadata, + Proxy = HttpProxy.Instance, + API = API + }); + pair.InitTime = time.Current; + } InternationalizationManager.Instance.UpdatePluginMetadataTranslations(pair); }); } ThreadPool.QueueUserWorkItem(o => { - LoadInstantSearches(); + instantQueryPlugins = GetPlugins(); + exclusiveSearchPlugins = GetPlugins(); + contextMenuPlugins = GetPlugins(); }); } @@ -116,97 +118,71 @@ namespace Wox.Core.Plugin PluginInstaller.Install(path); } - public static void Query(Query query) + public static Query QueryInit(string text) //todo is that possible to move it into type Query? { - if (!string.IsNullOrEmpty(query.RawQuery.Trim())) + // replace multiple white spaces with one white space + var terms = text.Split(new[] { Query.Seperater }, StringSplitOptions.RemoveEmptyEntries); + var rawQuery = string.Join(Query.Seperater, terms.ToArray()); + var actionKeyword = string.Empty; + var search = rawQuery; + IEnumerable actionParameters = terms; + if (terms.Length == 0) return null; + if (IsVailldActionKeyword(terms[0])) { - query.Search = IsActionKeywordQuery(query) ? query.RawQuery.Substring(query.RawQuery.IndexOf(' ') + 1) : query.RawQuery; - QueryDispatcher.QueryDispatcher.Dispatch(query); + actionKeyword = terms[0]; } - } - - public static List AllPlugins - { - get + if (!string.IsNullOrEmpty(actionKeyword)) { - return plugins.OrderBy(o => o.Metadata.Name).ToList(); + actionParameters = terms.Skip(1); + search = string.Join(Query.Seperater, actionParameters.ToArray()); } - } - - /// - /// Check if a query contains valid action keyword - /// - /// - /// - public static bool IsActionKeywordQuery(Query query) - { - if (string.IsNullOrEmpty(query.RawQuery)) return false; - var strings = query.RawQuery.Split(' '); - if (strings.Length == 1) return false; - - var actionKeyword = strings[0].Trim(); - if (string.IsNullOrEmpty(actionKeyword)) return false; - - PluginPair pair = plugins.FirstOrDefault(o => o.Metadata.ActionKeyword == actionKeyword); - if (pair != null) + return new Query { - var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == pair.Metadata.ID); - if (customizedPluginConfig != null && customizedPluginConfig.Disabled) - { - return false; - } - - return true; - } - - return false; + Terms = terms, RawQuery = rawQuery, ActionKeyword = actionKeyword, Search = search, + // Obsolete value initialisation + ActionName = actionKeyword, ActionParameters = actionParameters.ToList() + }; } - public static bool IsGenericPlugin(PluginMetadata metadata) + public static void QueryForAllPlugins(Query query) { - return metadata.ActionKeyword == ActionKeywordWildcardSign; - } - - public static void ActivatePluginDebugger(string path) - { - DebuggerMode = path; - } - - public static bool IsInstantQuery(string query) - { - return LoadInstantSearches().Any(o => o.Value.IsInstantQuery(query)); - } - - public static bool IsInstantSearchPlugin(PluginMetadata pluginMetadata) - { - //todo:to improve performance, any instant search plugin that takes long than 200ms will not consider a instant plugin anymore - return pluginMetadata.Language.ToUpper() == AllowedLanguage.CSharp && - LoadInstantSearches().Any(o => o.Key.Metadata.ID == pluginMetadata.ID); - } - - internal static void ExecutePluginQuery(PluginPair pair, Query query) - { - try + var pluginPairs = GetNonSystemPlugin(query) != null ? + new List { GetNonSystemPlugin(query) } : GetSystemPlugins(); + foreach (var plugin in pluginPairs) { - Stopwatch sw = new Stopwatch(); - sw.Start(); - List results = pair.Plugin.Query(query) ?? new List(); - results.ForEach(o => + var customizedPluginConfig = UserSettingStorage.Instance. + CustomizedPluginConfigs.FirstOrDefault(o => o.ID == plugin.Metadata.ID); + if (customizedPluginConfig != null && customizedPluginConfig.Disabled) return; + if (IsInstantQueryPlugin(plugin)) { - o.PluginID = pair.Metadata.ID; - }); - sw.Stop(); - DebugHelper.WriteLine(string.Format("Plugin query: {0} - {1}", pair.Metadata.Name, sw.ElapsedMilliseconds)); - pair.QueryCount += 1; - if (pair.QueryCount == 1) - { - pair.AvgQueryTime = sw.ElapsedMilliseconds; + using (new Timeit($"Plugin {plugin.Metadata.Name} is executing instant search")) + { + QueryForPlugin(plugin, query); + } } else { - pair.AvgQueryTime = (pair.AvgQueryTime + sw.ElapsedMilliseconds) / 2; + ThreadPool.QueueUserWorkItem(state => + { + QueryForPlugin(plugin, query); + }); + } + } + } + + private static void QueryForPlugin(PluginPair pair, Query query) + { + try + { + using (var time = new Timeit($"Query For {pair.Metadata.Name}")) + { + var results = pair.Plugin.Query(query) ?? new List(); + results.ForEach(o => { o.PluginID = pair.Metadata.ID; }); + var seconds = time.Current; + pair.QueryCount += 1; + pair.AvgQueryTime = pair.QueryCount == 1 ? seconds : (pair.AvgQueryTime + seconds) / 2; + API.PushResults(query, pair.Metadata, results); } - API.PushResults(query, pair.Metadata, results); } catch (System.Exception e) { @@ -214,13 +190,32 @@ namespace Wox.Core.Plugin } } - private static List> LoadInstantSearches() + /// + /// Check if a query contains valid action keyword + /// + /// + /// + private static bool IsVailldActionKeyword(string actionKeyword) { - if (instantSearches != null) return instantSearches; + if (string.IsNullOrEmpty(actionKeyword) || actionKeyword == Query.WildcardSign) return false; + PluginPair pair = AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == actionKeyword); + if (pair == null) return false; + var customizedPluginConfig = UserSettingStorage.Instance. + CustomizedPluginConfigs.FirstOrDefault(o => o.ID == pair.Metadata.ID); + return customizedPluginConfig == null || !customizedPluginConfig.Disabled; + } - instantSearches = AssemblyHelper.LoadPluginInterfaces(); + public static bool IsSystemPlugin(PluginMetadata metadata) + { + return metadata.ActionKeyword == Query.WildcardSign; + } - return instantSearches; + 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); } /// @@ -233,63 +228,46 @@ namespace Wox.Core.Plugin return AllPlugins.FirstOrDefault(o => o.Metadata.ID == id); } - internal static List> LoadExclusiveSearchPlugins() + public static IEnumerable GetPlugins() where T : IFeatures { - if (exclusiveSearchPlugins != null) return exclusiveSearchPlugins; - exclusiveSearchPlugins = AssemblyHelper.LoadPluginInterfaces(); - return exclusiveSearchPlugins; + return AllPlugins.Where(p => p.Plugin is T); } - internal static PluginPair GetExclusivePlugin(Query query) + private static PluginPair GetExclusivePlugin(Query query) { - KeyValuePair plugin = LoadExclusiveSearchPlugins().FirstOrDefault(o => o.Value.IsExclusiveQuery((query))); - return plugin.Key; + return exclusiveSearchPlugins.FirstOrDefault(p => ((IExclusiveQuery)p.Plugin).IsExclusiveQuery(query)); } - internal static PluginPair GetActionKeywordPlugin(Query query) + private static PluginPair GetActionKeywordPlugin(Query query) { - //if a query doesn't contain at least one space, it should not be a action keword plugin query - if (!query.RawQuery.Contains(" ")) return null; - - PluginPair actionKeywordPluginPair = AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.GetActionKeyword()); - if (actionKeywordPluginPair != null) - { - var customizedPluginConfig = UserSettingStorage.Instance. - CustomizedPluginConfigs.FirstOrDefault(o => o.ID == actionKeywordPluginPair.Metadata.ID); - if (customizedPluginConfig != null && customizedPluginConfig.Disabled) - { - return null; - } - - return actionKeywordPluginPair; - } - - return null; + //if a query doesn't contain a vaild action keyword, it should not be a action keword plugin query + if (string.IsNullOrEmpty(query.ActionKeyword)) return null; + return AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.ActionKeyword); } - internal static bool IsExclusivePluginQuery(Query query) + private static PluginPair GetNonSystemPlugin(Query query) { - return GetExclusivePlugin(query) != null || GetActionKeywordPlugin(query) != null; + return GetExclusivePlugin(query) ?? GetActionKeywordPlugin(query); + } + + private static List GetSystemPlugins() + { + return AllPlugins.Where(o => IsSystemPlugin(o.Metadata)).ToList(); } public static List GetPluginContextMenus(Result result) { - List contextContextMenus = new List(); - if (contextMenuPlugins == null) - { - contextMenuPlugins = AssemblyHelper.LoadPluginInterfaces(); - } - - var contextMenuPlugin = contextMenuPlugins.FirstOrDefault(o => o.Key.Metadata.ID == result.PluginID); - if (contextMenuPlugin.Value != null) + var pluginPair = contextMenuPlugins.FirstOrDefault(o => o.Metadata.ID == result.PluginID); + var plugin = (IContextMenu)pluginPair?.Plugin; + if (plugin != null) { try { - return contextMenuPlugin.Value.LoadContextMenus(result); + return plugin.LoadContextMenus(result); } catch (System.Exception e) { - Log.Error(string.Format("Couldn't load plugin context menus {0}: {1}", contextMenuPlugin.Key.Metadata.Name, e.Message)); + Log.Error($"Couldn't load plugin context menus {pluginPair.Metadata.Name}: {e.Message}"); #if (DEBUG) { throw; @@ -298,7 +276,7 @@ namespace Wox.Core.Plugin } } - return contextContextMenus; + return new List(); } } } diff --git a/Wox.Core/Plugin/PythonPlugin.cs b/Wox.Core/Plugin/PythonPlugin.cs index 20487de0a..bf1edb4c1 100644 --- a/Wox.Core/Plugin/PythonPlugin.cs +++ b/Wox.Core/Plugin/PythonPlugin.cs @@ -2,7 +2,6 @@ using System.IO; using System.Reflection; using Wox.Core.UserSettings; -using Wox.Infrastructure.Http; using Wox.Plugin; namespace Wox.Core.Plugin diff --git a/Wox.Core/Plugin/QueryDispatcher/BaseQueryDispatcher.cs b/Wox.Core/Plugin/QueryDispatcher/BaseQueryDispatcher.cs deleted file mode 100644 index b17875b6e..000000000 --- a/Wox.Core/Plugin/QueryDispatcher/BaseQueryDispatcher.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading; -using Wox.Infrastructure; -using Wox.Plugin; -using Wox.Core.UserSettings; - -namespace Wox.Core.Plugin.QueryDispatcher -{ - public abstract class BaseQueryDispatcher : IQueryDispatcher - { - protected abstract List GetPlugins(Query query); - - public void Dispatch(Query query) - { - foreach (PluginPair pair in GetPlugins(query)) - { - var customizedPluginConfig = UserSettingStorage.Instance. - CustomizedPluginConfigs.FirstOrDefault(o => o.ID == pair.Metadata.ID); - if (customizedPluginConfig != null && customizedPluginConfig.Disabled) - { - return; - } - PluginPair localPair = pair; - if (query.IsIntantQuery && PluginManager.IsInstantSearchPlugin(pair.Metadata)) - { - DebugHelper.WriteLine(string.Format("Plugin {0} is executing instant search.", pair.Metadata.Name)); - using (new Timeit(" => instant search took: ")) - { - PluginManager.ExecutePluginQuery(localPair, query); - } - } - else - { - ThreadPool.QueueUserWorkItem(state => - { - PluginManager.ExecutePluginQuery(localPair, query); - }); - } - } - } - } -} diff --git a/Wox.Core/Plugin/QueryDispatcher/ExclusiveQueryDispatcher.cs b/Wox.Core/Plugin/QueryDispatcher/ExclusiveQueryDispatcher.cs deleted file mode 100644 index d0923c34c..000000000 --- a/Wox.Core/Plugin/QueryDispatcher/ExclusiveQueryDispatcher.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using Wox.Core.Exception; -using Wox.Core.UserSettings; -using Wox.Infrastructure.Logger; -using Wox.Plugin; - -namespace Wox.Core.Plugin.QueryDispatcher -{ - public class ExclusiveQueryDispatcher : BaseQueryDispatcher - { - protected override List GetPlugins(Query query) - { - List pluginPairs = new List(); - var exclusivePluginPair = PluginManager.GetExclusivePlugin(query) ?? - PluginManager.GetActionKeywordPlugin(query); - if (exclusivePluginPair != null) - { - pluginPairs.Add(exclusivePluginPair); - } - - return pluginPairs; - } - - - - } -} diff --git a/Wox.Core/Plugin/QueryDispatcher/GenericQueryDispatcher.cs b/Wox.Core/Plugin/QueryDispatcher/GenericQueryDispatcher.cs deleted file mode 100644 index 5c53c556b..000000000 --- a/Wox.Core/Plugin/QueryDispatcher/GenericQueryDispatcher.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using Wox.Core.Exception; -using Wox.Core.UserSettings; -using Wox.Infrastructure.Logger; -using Wox.Plugin; - -namespace Wox.Core.Plugin.QueryDispatcher -{ - public class GenericQueryDispatcher : BaseQueryDispatcher - { - protected override List GetPlugins(Query query) - { - return PluginManager.AllPlugins.Where(o => PluginManager.IsGenericPlugin(o.Metadata)).ToList(); - } - } -} \ No newline at end of file diff --git a/Wox.Core/Plugin/QueryDispatcher/IQueryDispatcher.cs b/Wox.Core/Plugin/QueryDispatcher/IQueryDispatcher.cs deleted file mode 100644 index c5312a033..000000000 --- a/Wox.Core/Plugin/QueryDispatcher/IQueryDispatcher.cs +++ /dev/null @@ -1,7 +0,0 @@ -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 deleted file mode 100644 index 5d2062b48..000000000 --- a/Wox.Core/Plugin/QueryDispatcher/QueryDispatcher.cs +++ /dev/null @@ -1,24 +0,0 @@ - -using System.Threading; -using Wox.Plugin; - -namespace Wox.Core.Plugin.QueryDispatcher -{ - internal static class QueryDispatcher - { - private static readonly IQueryDispatcher exclusivePluginDispatcher = new ExclusiveQueryDispatcher(); - private static readonly IQueryDispatcher genericQueryDispatcher = new GenericQueryDispatcher(); - - public static void Dispatch(Query query) - { - if (PluginManager.IsExclusivePluginQuery(query)) - { - exclusivePluginDispatcher.Dispatch(query); - } - else - { - genericQueryDispatcher.Dispatch(query); - } - } - } -} diff --git a/Wox.Core/Properties/AssemblyInfo.cs b/Wox.Core/Properties/AssemblyInfo.cs index dd5baa0e6..0ca99a503 100644 --- a/Wox.Core/Properties/AssemblyInfo.cs +++ b/Wox.Core/Properties/AssemblyInfo.cs @@ -8,9 +8,9 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle("Wox.Core")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Oracle Corporation")] +[assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Wox.Core")] -[assembly: AssemblyCopyright("Copyright © Oracle Corporation 2014")] +[assembly: AssemblyCopyright("The MIT License (MIT)")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Wox.Core/Theme/ITheme.cs b/Wox.Core/Theme/ITheme.cs index 55bfccb21..34409068e 100644 --- a/Wox.Core/Theme/ITheme.cs +++ b/Wox.Core/Theme/ITheme.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; namespace Wox.Core.Theme { diff --git a/Wox.Core/Theme/Theme.cs b/Wox.Core/Theme/Theme.cs index b20e95cdd..114b5742c 100644 --- a/Wox.Core/Theme/Theme.cs +++ b/Wox.Core/Theme/Theme.cs @@ -14,11 +14,12 @@ namespace Wox.Core.Theme { public class Theme : IUIResource,ITheme { + public const string DirectoryName = "Themes"; private static List themeDirectories = new List(); static Theme() { - themeDirectories.Add(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Themes")); + themeDirectories.Add(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), DirectoryName)); MakesureThemeDirectoriesExist(); } @@ -55,7 +56,7 @@ namespace Wox.Core.Theme UserSettingStorage.Instance.Theme = themeName; UserSettingStorage.Instance.Save(); - ResourceMerger.ApplyResources(); + ResourceMerger.ApplyThemeResource(this); } public ResourceDictionary GetResourceDictionary() diff --git a/Wox.Core/Theme/ThemeManager.cs b/Wox.Core/Theme/ThemeManager.cs index a5dc1a2f9..3ad8a0d7d 100644 --- a/Wox.Core/Theme/ThemeManager.cs +++ b/Wox.Core/Theme/ThemeManager.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Wox.Core.Theme +namespace Wox.Core.Theme { public class ThemeManager { diff --git a/Wox.Core/UI/IUIResource.cs b/Wox.Core/UI/IUIResource.cs index a1e398a25..99d89551a 100644 --- a/Wox.Core/UI/IUIResource.cs +++ b/Wox.Core/UI/IUIResource.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using Wox.Core.i18n; +using System.Windows; namespace Wox.Core.UI { diff --git a/Wox.Core/UI/ResourceMerger.cs b/Wox.Core/UI/ResourceMerger.cs index 542200ede..818f3073b 100644 --- a/Wox.Core/UI/ResourceMerger.cs +++ b/Wox.Core/UI/ResourceMerger.cs @@ -1,48 +1,53 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Windows; using Wox.Core.i18n; using Wox.Core.Plugin; -using Wox.Core.Theme; using Wox.Plugin; namespace Wox.Core.UI { - public class ResourceMerger + public static class ResourceMerger { - internal static void ApplyResources() + private static void RemoveResource(string resourceDirectoryName) { - Application.Current.Resources.MergedDictionaries.Clear(); - ApplyPluginLanguages(); - ApplyThemeAndLanguageResources(); - } - - internal static void ApplyThemeAndLanguageResources() - { - var UIResources = AssemblyHelper.LoadInterfacesFromAppDomain(); - foreach (var uiResource in UIResources) + var mergedDictionaries = Application.Current.Resources.MergedDictionaries; + foreach (var resource in mergedDictionaries) { - Application.Current.Resources.MergedDictionaries.Add(uiResource.GetResourceDictionary()); - } - } - - internal static void ApplyPluginLanguages() - { - var pluginI18ns = AssemblyHelper.LoadInterfacesFromAppDomain(); - foreach (var pluginI18n in pluginI18ns) - { - string languageFile = InternationalizationManager.Instance.GetLanguageFile(pluginI18n.GetLanguagesFolder()); - if (!string.IsNullOrEmpty(languageFile)) + int directoryPosition = resource.Source.Segments.Length - 2; + string currentDirectoryName = resource.Source.Segments[directoryPosition]; + if (currentDirectoryName == resourceDirectoryName) { - Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary - { - Source = new Uri(languageFile, UriKind.Absolute) - }); + mergedDictionaries.Remove(resource); + break; } } } - + public static void ApplyThemeResource(Theme.Theme t) + { + RemoveResource(Theme.Theme.DirectoryName); + Application.Current.Resources.MergedDictionaries.Add(t.GetResourceDictionary()); + } + + public static void ApplyLanguageResources(Internationalization i) + { + RemoveResource(Internationalization.DirectoryName); + Application.Current.Resources.MergedDictionaries.Add(i.GetResourceDictionary()); + } + + internal static void ApplyPluginLanguages() + { + RemoveResource(PluginManager.DirectoryName); + foreach (var languageFile in PluginManager.GetPlugins(). + Select(plugin => InternationalizationManager.Instance.GetLanguageFile(((IPluginI18n)plugin.Plugin).GetLanguagesFolder())). + Where(file => !string.IsNullOrEmpty(file))) + { + Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary + { + Source = new Uri(languageFile, UriKind.Absolute) + }); + } + } } } \ No newline at end of file diff --git a/Wox.Core/Updater/UpdaterManager.cs b/Wox.Core/Updater/UpdaterManager.cs index f93f9a348..65778896a 100644 --- a/Wox.Core/Updater/UpdaterManager.cs +++ b/Wox.Core/Updater/UpdaterManager.cs @@ -1,11 +1,8 @@ using System; using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; using System.Reflection; +using System.Threading; using System.Windows.Forms; -using System.Windows.Threading; using NAppUpdate.Framework; using NAppUpdate.Framework.Common; using NAppUpdate.Framework.Sources; @@ -15,7 +12,6 @@ using Wox.Core.i18n; using Wox.Core.UserSettings; using Wox.Infrastructure.Http; using Wox.Infrastructure.Logger; -using System.Threading; namespace Wox.Core.Updater { diff --git a/Wox.Core/Updater/WoxUpdateSource.cs b/Wox.Core/Updater/WoxUpdateSource.cs index 20b66e2f6..192bf9d2b 100644 --- a/Wox.Core/Updater/WoxUpdateSource.cs +++ b/Wox.Core/Updater/WoxUpdateSource.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; -using System.Text; using NAppUpdate.Framework.Common; using NAppUpdate.Framework.Sources; using NAppUpdate.Framework.Utils; diff --git a/Wox.Core/UserSettings/UserSettingStorage.cs b/Wox.Core/UserSettings/UserSettingStorage.cs index 632aaaa50..3af191132 100644 --- a/Wox.Core/UserSettings/UserSettingStorage.cs +++ b/Wox.Core/UserSettings/UserSettingStorage.cs @@ -1,12 +1,10 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.IO; -using System.Windows.Forms; +using System.Reflection; using Newtonsoft.Json; using Wox.Infrastructure.Storage; -using Wox.Plugin; -using System.Drawing; -using System.Reflection; namespace Wox.Core.UserSettings { diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj index fa06e3840..c7e8072a2 100644 --- a/Wox.Core/Wox.Core.csproj +++ b/Wox.Core/Wox.Core.csproj @@ -12,7 +12,6 @@ v3.5 512 ..\ - true @@ -39,9 +38,9 @@ False ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll - - False - ..\References\NAppUpdate.Framework.dll + + ..\packages\NAppUpdate.Framework.0.3.2.0\lib\net20\NAppUpdate.Framework.dll + True False @@ -53,10 +52,6 @@ - - - - @@ -69,8 +64,6 @@ - - @@ -85,10 +78,6 @@ - - - - @@ -121,7 +110,6 @@ - - \ No newline at end of file + + diff --git a/Wox.Infrastructure/DebugHelper.cs b/Wox.Infrastructure/DebugHelper.cs deleted file mode 100644 index e31636b7e..000000000 --- a/Wox.Infrastructure/DebugHelper.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; - -namespace Wox.Infrastructure -{ - public static class DebugHelper - { - public static void WriteLine(string msg) - { - return; - Debug.WriteLine(msg); - } - } -} diff --git a/Wox.Infrastructure/FuzzyMatcher.cs b/Wox.Infrastructure/FuzzyMatcher.cs index 0da5c89a5..31280ad9d 100644 --- a/Wox.Infrastructure/FuzzyMatcher.cs +++ b/Wox.Infrastructure/FuzzyMatcher.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; +using System.Text; namespace Wox.Infrastructure { diff --git a/Wox.Infrastructure/Http/HttpRequest.cs b/Wox.Infrastructure/Http/HttpRequest.cs index e80501936..c979cca6d 100644 --- a/Wox.Infrastructure/Http/HttpRequest.cs +++ b/Wox.Infrastructure/Http/HttpRequest.cs @@ -1,5 +1,4 @@ using System; -using System.Drawing; using System.IO; using System.Net; using System.Text; diff --git a/Wox.Infrastructure/Logger/Log.cs b/Wox.Infrastructure/Logger/Log.cs index 8cfbc52bd..8abaf16a4 100644 --- a/Wox.Infrastructure/Logger/Log.cs +++ b/Wox.Infrastructure/Logger/Log.cs @@ -1,5 +1,4 @@ using System; -using System.Reflection; using NLog; namespace Wox.Infrastructure.Logger diff --git a/Wox.Infrastructure/NLog.config b/Wox.Infrastructure/NLog.config index 9dcf31def..896abfdf6 100644 --- a/Wox.Infrastructure/NLog.config +++ b/Wox.Infrastructure/NLog.config @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/Wox.Infrastructure/Logger/NLog.xsd b/Wox.Infrastructure/NLog.xsd similarity index 89% rename from Wox.Infrastructure/Logger/NLog.xsd rename to Wox.Infrastructure/NLog.xsd index edf2b7087..f942370ca 100644 --- a/Wox.Infrastructure/Logger/NLog.xsd +++ b/Wox.Infrastructure/NLog.xsd @@ -126,6 +126,11 @@ Ignore further rules if this one matches. + + + Enable or disable logging rule. Disabled rules are ignored. + + @@ -147,6 +152,15 @@ + + + + + + + + + @@ -226,58 +240,6 @@ - - - - - - - - - - - - Name of the target. - - - - - Maximum number of log events that the buffer can keep. - - - - - Number of log events to be buffered. - - - - - Indicates whether buffer should grow as needed. - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - @@ -540,6 +502,7 @@ + @@ -567,6 +530,11 @@ Indicates whether to use default row highlighting rules. + + + The encoding for writing messages to the . + + Indicates whether the error stream (stderr) should be used instead of the output stream (stdout). @@ -667,6 +635,7 @@ + @@ -693,6 +662,11 @@ Indicates whether to send the log messages to the standard error instead of the standard output. + + + The encoding for writing messages to the . + + @@ -709,7 +683,6 @@ - @@ -762,11 +735,6 @@ Indicates whether to keep the database connection open between the log events. - - - Indicates whether to use database transactions. Some data providers require this. - - Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used. @@ -855,7 +823,7 @@ - + @@ -917,7 +885,8 @@ - + + @@ -949,11 +918,16 @@ Name of the machine on which Event Log service is running. - + Value to be used as the event Source. + + + Optional entrytype. When not set, or when not convertable to then determined by + + @@ -986,30 +960,32 @@ - + + - + - + + - - + + @@ -1036,11 +1012,16 @@ File encoding. - + Line ending mode. + + + Maximum number of archive files that should be kept. + + Way file archives are numbered. @@ -1058,17 +1039,17 @@ - Size in bytes above which log files will be automatically archived. + Size in bytes above which log files will be automatically archived. Warning: combining this with isn't supported. We cannot create multiple archive files, if they should have the same name. Choose: - + - Maximum number of archive files that should be kept. + Indicates whether to compress archive files into the zip archive format. - Gets ors set a value indicating whether a managed file stream is forced, instead of used the native implementation. + Gets or set a value indicating whether a managed file stream is forced, instead of used the native implementation. @@ -1081,11 +1062,6 @@ Indicates whether to replace file contents on each write instead of appending log message at the end. - - - Indicates whether to delete old log file on startup. - - Name of the file to write to. @@ -1103,7 +1079,12 @@ - Indicates whether to create directories if they don't exist. + Indicates whether to create directories if they do not exist. + + + + + Indicates whether to delete old log file on startup. @@ -1121,6 +1102,11 @@ Indicates whether concurrent writes to the log file by multiple processes on different network hosts. + + + Maximum number of log filenames that should be stored as existing. + + Indicates whether to keep log file open instead of opening and closing it on each logging event. @@ -1141,9 +1127,9 @@ Delay in milliseconds to wait before attempting to write to the file again. - + - Log file buffer size in bytes. + Indicates whether to automatically flush the file buffers after each log message. @@ -1151,23 +1137,14 @@ Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger). - + - Indicates whether to automatically flush the file buffers after each log message. + Log file buffer size in bytes. - - - - - - - - - @@ -1226,50 +1203,6 @@ - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - Indicates whether log text should be appended to the text of the control instead of overwriting it. - - - - - Name of control to which NLog will log write log text. - - - - - Name of the Form on which the control is located. - - - - - Whether new log entry are added to the start or the end of the control - - - - - @@ -1356,6 +1289,7 @@ + @@ -1376,6 +1310,11 @@ Name of the endpoint configuration in WCF configuration file. + + + Indicates whether to use a WCF service contract that is one way (fire and forget) or two way (request-reply) + + Client ID. @@ -1402,7 +1341,7 @@ - Layout that should be use to calcuate the value for the parameter. + Layout that should be use to calculate the value for the parameter. @@ -1427,9 +1366,9 @@ - - + + @@ -1443,6 +1382,8 @@ + + @@ -1479,9 +1420,9 @@ Indicates whether to add new lines between log entries. - + - BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). @@ -1489,9 +1430,9 @@ Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - + - CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). @@ -1559,6 +1500,16 @@ Indicates whether the default Settings from System.Net.MailSettings should be used. + + + Folder where applications save mail messages to be processed by the local SMTP server. + + + + + Specifies how outgoing email messages will be handled. + + @@ -1569,6 +1520,13 @@ + + + + + + + @@ -1589,32 +1547,6 @@ - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - Message box title. - - - - - @@ -1939,6 +1871,7 @@ + @@ -1971,6 +1904,11 @@ Performance counter type. + + + The value by which to increment the counter. + + Performance counter instance name. @@ -2108,165 +2046,6 @@ - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - Indicates whether scroll bar will be moved automatically to show most recent log entries. - - - - - Name of RichTextBox to which Nlog will write. - - - - - Name of the Form on which the control is located. If there is no open form of a specified name than NLog will create a new one. - - - - - Initial height of the form with rich text box. - - - - - Maximum number of lines the rich text box will store (or 0 to disable this feature). - - - - - Indicates whether the created form will be initially minimized. - - - - - Indicates whether the created window will be a tool window. - - - - - Initial width of the form with rich text box. - - - - - Indicates whether to use default coloring rules. - - - - - - - - - - - - - - - - - - - - - - - - Condition that must be met in order to set the specified font color. - - - - - Background color. - - - - - Font color. - - - - - Font style of matched text. - - - - - - - - - - - - - - - - Indicates whether to ignore case when comparing texts. - - - - - Regular expression to be matched. You must specify either text or regex. - - - - - Text to be matched. You must specify either text or regex. - - - - - Indicates whether to match whole words only. - - - - - Background color. Names are identical with KnownColor enum extended with Empty value which means that background color won't be changed. - - - - - Font color. Names are identical with KnownColor enum extended with Empty value which means that font color won't be changed. - - - - - Font style of matched text. Possible values are the same as in FontStyle enum in System.Drawing. - - - @@ -2320,6 +2099,7 @@ + @@ -2332,6 +2112,11 @@ Name of the target. + + + Should we include the BOM (Byte-order-mark) for UTF? Influences the property. This will only work for UTF-8. + + Encoding. @@ -2339,12 +2124,12 @@ - Web service method name. + Web service method name. Only used with Soap. - Web service namespace. + Web service namespace. Only used with Soap. @@ -2459,6 +2244,43 @@ + + + + + + + + + + Option to suppress the extra spaces in the output json + + + + + + + + + + + + + + Determines wether or not this attribute will be Json encoded. + + + + + Layout that will be rendered as the attribute's value. + + + + + Name of the attribute. + + + diff --git a/Wox.Infrastructure/Storage/BaseStorage.cs b/Wox.Infrastructure/Storage/BaseStorage.cs index 3db9bfee7..4ddee08ad 100644 --- a/Wox.Infrastructure/Storage/BaseStorage.cs +++ b/Wox.Infrastructure/Storage/BaseStorage.cs @@ -1,12 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices.ComTypes; -using System.Text; -using System.Windows.Forms; -using Newtonsoft.Json; namespace Wox.Infrastructure.Storage { diff --git a/Wox.Infrastructure/Storage/BinaryStorage.cs b/Wox.Infrastructure/Storage/BinaryStorage.cs index 9ad13bfaf..fb49507ec 100644 --- a/Wox.Infrastructure/Storage/BinaryStorage.cs +++ b/Wox.Infrastructure/Storage/BinaryStorage.cs @@ -1,11 +1,8 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Reflection; using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Formatters.Binary; -using System.Text; using System.Threading; using Wox.Infrastructure.Logger; diff --git a/Wox.Infrastructure/Storage/IStorage.cs b/Wox.Infrastructure/Storage/IStorage.cs index bb94306f1..9f305804d 100644 --- a/Wox.Infrastructure/Storage/IStorage.cs +++ b/Wox.Infrastructure/Storage/IStorage.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Wox.Infrastructure.Storage +namespace Wox.Infrastructure.Storage { public interface IStorage { diff --git a/Wox.Infrastructure/Storage/JsonStorage.cs b/Wox.Infrastructure/Storage/JsonStorage.cs index ca6c0fea0..b01f7277b 100644 --- a/Wox.Infrastructure/Storage/JsonStorage.cs +++ b/Wox.Infrastructure/Storage/JsonStorage.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; using System.Threading; using Newtonsoft.Json; diff --git a/Wox.Infrastructure/StringMatcher.cs b/Wox.Infrastructure/StringMatcher.cs index 4d3d9dd5a..6261d9a06 100644 --- a/Wox.Infrastructure/StringMatcher.cs +++ b/Wox.Infrastructure/StringMatcher.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Wox.Infrastructure +namespace Wox.Infrastructure { public class StringMatcher { diff --git a/Wox.Infrastructure/Timeit.cs b/Wox.Infrastructure/Timeit.cs index 14dd1f62c..1e804fc2b 100644 --- a/Wox.Infrastructure/Timeit.cs +++ b/Wox.Infrastructure/Timeit.cs @@ -1,26 +1,38 @@ using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Text; +using Wox.Infrastructure.Logger; namespace Wox.Infrastructure { public class Timeit : IDisposable { - private Stopwatch stopwatch = new Stopwatch(); - private string name; + private readonly Stopwatch _stopwatch = new Stopwatch(); + private readonly string _name; public Timeit(string name) { - this.name = name; - stopwatch.Start(); + _name = name; + _stopwatch.Start(); } + public long Current + { + get + { + _stopwatch.Stop(); + long seconds = _stopwatch.ElapsedMilliseconds; + _stopwatch.Start(); + return seconds; + } + } + + public void Dispose() { - stopwatch.Stop(); - DebugHelper.WriteLine(name + ":" + stopwatch.ElapsedMilliseconds + "ms"); + _stopwatch.Stop(); + string info = _name + " : " + _stopwatch.ElapsedMilliseconds + "ms"; + Debug.WriteLine(info); + Log.Info(info); } } } diff --git a/Wox.Infrastructure/Unidecoder.cs b/Wox.Infrastructure/Unidecoder.cs index ea1f56ef5..a81247fd6 100644 --- a/Wox.Infrastructure/Unidecoder.cs +++ b/Wox.Infrastructure/Unidecoder.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; namespace Wox.Infrastructure { diff --git a/Wox.Infrastructure/WindowsShellRun.cs b/Wox.Infrastructure/WindowsShellRun.cs index c0d8f23a8..9a638a6cc 100644 --- a/Wox.Infrastructure/WindowsShellRun.cs +++ b/Wox.Infrastructure/WindowsShellRun.cs @@ -1,9 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Runtime.InteropServices; using System.IO; +using System.Runtime.InteropServices; +using System.Text; namespace Wox.Infrastructure { diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index 80a96bc32..a5ef083e7 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -12,7 +12,6 @@ v3.5 512 ..\ - true @@ -37,28 +36,19 @@ false - False ..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll - - ..\packages\NLog.3.2.0.0\lib\net35\NLog.dll + + ..\packages\NLog.4.2.0\lib\net35\NLog.dll + True - - - - - - - - - @@ -88,13 +78,12 @@ Always - + Designer - - \ No newline at end of file + + diff --git a/Wox.UpdateFeedGenerator/ConfigStorage.cs b/Wox.UpdateFeedGenerator/ConfigStorage.cs index bdc6a30f3..28f0c6c0b 100644 --- a/Wox.UpdateFeedGenerator/ConfigStorage.cs +++ b/Wox.UpdateFeedGenerator/ConfigStorage.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; +using System.IO; using System.Reflection; -using System.Text; using Newtonsoft.Json; using Wox.Infrastructure.Storage; diff --git a/Wox.UpdateFeedGenerator/Program.cs b/Wox.UpdateFeedGenerator/Program.cs index 62953a2a6..d2b3f274e 100644 --- a/Wox.UpdateFeedGenerator/Program.cs +++ b/Wox.UpdateFeedGenerator/Program.cs @@ -1,14 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading; -using System.Xml; - -namespace Wox.UpdateFeedGenerator +namespace Wox.UpdateFeedGenerator { class Program { diff --git a/Wox.UpdateFeedGenerator/Wox.UpdateFeedGenerator.csproj b/Wox.UpdateFeedGenerator/Wox.UpdateFeedGenerator.csproj index 2752c0e04..8801cc14a 100644 --- a/Wox.UpdateFeedGenerator/Wox.UpdateFeedGenerator.csproj +++ b/Wox.UpdateFeedGenerator/Wox.UpdateFeedGenerator.csproj @@ -12,7 +12,6 @@ v3.5 512 ..\ - true AnyCPU @@ -34,8 +33,9 @@ 4 - - ..\References\NAppUpdate.Framework.dll + + ..\packages\NAppUpdate.Framework.0.3.2.0\lib\net20\NAppUpdate.Framework.dll + True False @@ -67,13 +67,6 @@ - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - \ No newline at end of file + + diff --git a/Wox.UpdateFeedGenerator/packages.config b/Wox.UpdateFeedGenerator/packages.config index 7a13476a5..9661aa0af 100644 --- a/Wox.UpdateFeedGenerator/packages.config +++ b/Wox.UpdateFeedGenerator/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/Wox.sln b/Wox.sln index 4fa783561..1bffc62f8 100644 --- a/Wox.sln +++ b/Wox.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Test", "Wox.Test\Wox.Test.csproj", "{FF742965-9A80-41A5-B042-D6C7D3A21708}" EndProject @@ -60,6 +60,9 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Everything", "Plugins\Wox.Plugin.Everything\Wox.Plugin.Everything.csproj", "{230AE83F-E92E-4E69-8355-426B305DA9C0}" EndProject Global + GlobalSection(Performance) = preSolution + HasPerformanceSessions = true + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU diff --git a/Wox/ActionKeyword.xaml.cs b/Wox/ActionKeyword.xaml.cs index bc74e381e..03beac0ee 100644 --- a/Wox/ActionKeyword.xaml.cs +++ b/Wox/ActionKeyword.xaml.cs @@ -1,21 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Linq; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Forms; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; using Wox.Core.i18n; using Wox.Core.Plugin; using Wox.Core.UserSettings; using Wox.Plugin; -using MessageBox = System.Windows.MessageBox; namespace Wox { @@ -57,7 +45,7 @@ namespace Wox } //check new action keyword didn't used by other plugin - if (tbAction.Text.Trim() != PluginManager.ActionKeywordWildcardSign && PluginManager.AllPlugins.Exists(o => o.Metadata.ActionKeyword == tbAction.Text.Trim())) + if (tbAction.Text.Trim() != Query.WildcardSign && PluginManager.AllPlugins.Any(o => o.Metadata.ActionKeyword == tbAction.Text.Trim())) { MessageBox.Show(InternationalizationManager.Instance.GetTranslation("newActionKeywordHasBeenAssigned")); return; diff --git a/Wox/App.xaml b/Wox/App.xaml index 449be9426..2f32256d2 100644 --- a/Wox/App.xaml +++ b/Wox/App.xaml @@ -5,8 +5,8 @@ - - + + diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index d1b7f5f69..8808ef187 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Threading; +using System.Windows; using Wox.CommandArgs; +using Wox.Core.Plugin; using Wox.Helper; -using Application = System.Windows.Application; -using MessageBox = System.Windows.MessageBox; -using StartupEventArgs = System.Windows.StartupEventArgs; +using Wox.Infrastructure; namespace Wox { @@ -30,12 +29,18 @@ namespace Wox protected override void OnStartup(StartupEventArgs e) { - base.OnStartup(e); - DispatcherUnhandledException += ErrorReporting.DispatcherUnhandledException; - AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandle; + using (new Timeit("Startup Time")) + { + base.OnStartup(e); + DispatcherUnhandledException += ErrorReporting.DispatcherUnhandledException; + AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandle; + + //ThreadPool.QueueUserWorkItem(o => { ImageLoader.ImageLoader.PreloadImages(); }); + Window = new MainWindow(); + PluginManager.Init(Window); + CommandArgsFactory.Execute(e.Args.ToList()); + } - Window = new MainWindow(); - CommandArgsFactory.Execute(e.Args.ToList()); } public bool OnActivate(IList args) diff --git a/Wox/CommandArgs/CommandArgsFactory.cs b/Wox/CommandArgs/CommandArgsFactory.cs index 1e0f3a0dc..7f2fdfc98 100644 --- a/Wox/CommandArgs/CommandArgsFactory.cs +++ b/Wox/CommandArgs/CommandArgsFactory.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Text; -using System.Windows.Input; namespace Wox.CommandArgs { diff --git a/Wox/CommandArgs/HideStartCommandArg.cs b/Wox/CommandArgs/HideStartCommandArg.cs index b8ed67063..1918858b1 100644 --- a/Wox/CommandArgs/HideStartCommandArg.cs +++ b/Wox/CommandArgs/HideStartCommandArg.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; namespace Wox.CommandArgs { diff --git a/Wox/CommandArgs/ICommandArg.cs b/Wox/CommandArgs/ICommandArg.cs index be6391ce0..11db54557 100644 --- a/Wox/CommandArgs/ICommandArg.cs +++ b/Wox/CommandArgs/ICommandArg.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; namespace Wox.CommandArgs { diff --git a/Wox/CommandArgs/InstallPluginCommandArg.cs b/Wox/CommandArgs/InstallPluginCommandArg.cs index e69d20a63..524115b4d 100644 --- a/Wox/CommandArgs/InstallPluginCommandArg.cs +++ b/Wox/CommandArgs/InstallPluginCommandArg.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; using System.Windows; using Wox.Core.Plugin; -using Wox.Helper; namespace Wox.CommandArgs { diff --git a/Wox/CommandArgs/PluginDebuggerCommandArg.cs b/Wox/CommandArgs/PluginDebuggerCommandArg.cs deleted file mode 100644 index dab93500f..000000000 --- a/Wox/CommandArgs/PluginDebuggerCommandArg.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Input; -using Wox.Core.Plugin; - -namespace Wox.CommandArgs -{ - public class PluginDebuggerCommandArg : ICommandArg - { - public string Command - { - get { return "plugindebugger"; } - } - - public void Execute(IList args) - { - if (args.Count > 0) - { - var pluginFolderPath = args[0]; - PluginManager.ActivatePluginDebugger(pluginFolderPath); - } - } - } -} diff --git a/Wox/CommandArgs/QueryCommandArg.cs b/Wox/CommandArgs/QueryCommandArg.cs index 7e58ace4e..22f044352 100644 --- a/Wox/CommandArgs/QueryCommandArg.cs +++ b/Wox/CommandArgs/QueryCommandArg.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Wox.CommandArgs { diff --git a/Wox/CommandArgs/ReloadPluginCommandArg.cs b/Wox/CommandArgs/ReloadPluginCommandArg.cs index f287e08c8..aec5724c1 100644 --- a/Wox/CommandArgs/ReloadPluginCommandArg.cs +++ b/Wox/CommandArgs/ReloadPluginCommandArg.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using Wox.Core.Plugin; namespace Wox.CommandArgs diff --git a/Wox/CommandArgs/ToggleCommandArg.cs b/Wox/CommandArgs/ToggleCommandArg.cs index 743a3e887..623648e31 100644 --- a/Wox/CommandArgs/ToggleCommandArg.cs +++ b/Wox/CommandArgs/ToggleCommandArg.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; namespace Wox.CommandArgs { diff --git a/Wox/Converters/ImagePathConverter.cs b/Wox/Converters/ImagePathConverter.cs index 20843a686..eb92e6251 100644 --- a/Wox/Converters/ImagePathConverter.cs +++ b/Wox/Converters/ImagePathConverter.cs @@ -1,11 +1,7 @@ using System; -using System.Diagnostics; using System.Globalization; -using System.IO; using System.Windows; using System.Windows.Data; -using System.Windows.Media.Imaging; -using Wox.Helper; namespace Wox.Converters { diff --git a/Wox/Helper/DWMDropShadow.cs b/Wox/Helper/DWMDropShadow.cs index 60253f8c0..d1fd92757 100644 --- a/Wox/Helper/DWMDropShadow.cs +++ b/Wox/Helper/DWMDropShadow.cs @@ -3,7 +3,6 @@ using System.Drawing.Printing; using System.Runtime.InteropServices; using System.Windows; using System.Windows.Interop; -using System.Windows.Media; namespace Wox.Helper { diff --git a/Wox/Helper/DataWebRequestFactory.cs b/Wox/Helper/DataWebRequestFactory.cs index 7e474bd4b..61922d29d 100644 --- a/Wox/Helper/DataWebRequestFactory.cs +++ b/Wox/Helper/DataWebRequestFactory.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; -using System.Text; namespace Wox.Helper { diff --git a/Wox/Helper/DispatcherExtensions.cs b/Wox/Helper/DispatcherExtensions.cs index 2ea304a2e..72880e2eb 100644 --- a/Wox/Helper/DispatcherExtensions.cs +++ b/Wox/Helper/DispatcherExtensions.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Windows.Threading; namespace Wox @@ -12,20 +10,13 @@ namespace Wox new Dictionary(); private static readonly object syncRoot = new object(); - public static string DelayInvoke(this Dispatcher dispatcher, string namedInvocation, - Action action, TimeSpan delay, - DispatcherPriority priority = DispatcherPriority.Normal) - { - return DelayInvoke(dispatcher, namedInvocation, action, delay, string.Empty, priority); - } - - public static string DelayInvoke(this Dispatcher dispatcher, string namedInvocation, - Action action, TimeSpan delay, string arg, + public static void DelayInvoke(this Dispatcher dispatcher, string namedInvocation, + Action action, TimeSpan delay, DispatcherPriority priority = DispatcherPriority.Normal) { lock (syncRoot) { - if (String.IsNullOrEmpty(namedInvocation)) + if (string.IsNullOrEmpty(namedInvocation)) { namedInvocation = Guid.NewGuid().ToString(); } @@ -36,11 +27,10 @@ namespace Wox var timer = new DispatcherTimer(delay, priority, (s, e) => { RemoveTimer(namedInvocation); - action(arg); + action(); }, dispatcher); timer.Start(); timers.Add(namedInvocation, timer); - return namedInvocation; } } diff --git a/Wox/Helper/ErrorReporting.cs b/Wox/Helper/ErrorReporting.cs index d1de5c982..e7b5a81fb 100644 --- a/Wox/Helper/ErrorReporting.cs +++ b/Wox/Helper/ErrorReporting.cs @@ -1,11 +1,7 @@ using System; -using System.Diagnostics; -using System.Windows; -using System.Windows.Forms; using System.Windows.Threading; using Wox.Core.Exception; using Wox.Infrastructure.Logger; -using MessageBox = System.Windows.MessageBox; namespace Wox.Helper { diff --git a/Wox/Helper/SingletonWindowOpener.cs b/Wox/Helper/SingletonWindowOpener.cs index 393b23673..2b4950398 100644 --- a/Wox/Helper/SingletonWindowOpener.cs +++ b/Wox/Helper/SingletonWindowOpener.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using System.Windows; namespace Wox.Helper diff --git a/Wox/Helper/SyntaxSugars.cs b/Wox/Helper/SyntaxSugars.cs index e7caf8560..fc1bf5089 100644 --- a/Wox/Helper/SyntaxSugars.cs +++ b/Wox/Helper/SyntaxSugars.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Wox.Helper { diff --git a/Wox/HotkeyControl.xaml.cs b/Wox/HotkeyControl.xaml.cs index 135769c74..783e3e59d 100644 --- a/Wox/HotkeyControl.xaml.cs +++ b/Wox/HotkeyControl.xaml.cs @@ -53,7 +53,7 @@ namespace Wox } Dispatcher.DelayInvoke("HotkeyAvailabilityTest", - o => + () => { SetHotkey(hotkeyModel); }, diff --git a/Wox/ImageLoader/ImageCacheStroage.cs b/Wox/ImageLoader/ImageCacheStroage.cs index 21dd028d6..9c13aab06 100644 --- a/Wox/ImageLoader/ImageCacheStroage.cs +++ b/Wox/ImageLoader/ImageCacheStroage.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; -using System.Text; using Wox.Infrastructure.Storage; namespace Wox.ImageLoader diff --git a/Wox/ImageLoader/ImageLoader.cs b/Wox/ImageLoader/ImageLoader.cs index 8fa9f9c5d..18a5a91d0 100644 --- a/Wox/ImageLoader/ImageLoader.cs +++ b/Wox/ImageLoader/ImageLoader.cs @@ -70,7 +70,7 @@ namespace Wox.ImageLoader if (!imageCache.ContainsKey(image.Key)) { KeyValuePair copyedImg = image; - App.Window.Dispatcher.Invoke(new Action(() => imageCache.Add(copyedImg.Key, img))); + imageCache.Add(copyedImg.Key, img); } } } @@ -80,50 +80,47 @@ namespace Wox.ImageLoader public static ImageSource Load(string path, bool addToCache = true) { - Stopwatch sw = new Stopwatch(); - sw.Start(); - - if (string.IsNullOrEmpty(path)) return null; - if (addToCache) + using (new Timeit($"Loading image path: {path}")) { - ImageCacheStroage.Instance.Add(path); - } - - ImageSource img = null; - if (imageCache.ContainsKey(path)) - { - img = imageCache[path]; - } - else - { - string ext = Path.GetExtension(path).ToLower(); - - if (path.StartsWith("data:", StringComparison.OrdinalIgnoreCase)) + if (string.IsNullOrEmpty(path)) return null; + if (addToCache) { - img = new BitmapImage(new Uri(path)); - } - else if (selfExts.Contains(ext) && File.Exists(path)) - { - img = GetIcon(path); - } - else if (!string.IsNullOrEmpty(path) && imageExts.Contains(ext) && File.Exists(path)) - { - img = new BitmapImage(new Uri(path)); + ImageCacheStroage.Instance.Add(path); } - - if (img != null && addToCache) + ImageSource img = null; + if (imageCache.ContainsKey(path)) { - if (!imageCache.ContainsKey(path)) + img = imageCache[path]; + } + else + { + string ext = Path.GetExtension(path).ToLower(); + + if (path.StartsWith("data:", StringComparison.OrdinalIgnoreCase)) { - imageCache.Add(path, img); + img = new BitmapImage(new Uri(path)); + } + else if (selfExts.Contains(ext) && File.Exists(path)) + { + img = GetIcon(path); + } + else if (!string.IsNullOrEmpty(path) && imageExts.Contains(ext) && File.Exists(path)) + { + img = new BitmapImage(new Uri(path)); + } + + + if (img != null && addToCache) + { + if (!imageCache.ContainsKey(path)) + { + imageCache.Add(path, img); + } } } + return img; } - - sw.Stop(); - DebugHelper.WriteLine(string.Format("Loading image path: {0} - {1}ms",path,sw.ElapsedMilliseconds)); - return img; } // http://blogs.msdn.com/b/oldnewthing/archive/2011/01/27/10120844.aspx diff --git a/Wox/MainWindow.xaml b/Wox/MainWindow.xaml index bfc5b9871..4b5a315fe 100644 --- a/Wox/MainWindow.xaml +++ b/Wox/MainWindow.xaml @@ -20,7 +20,7 @@ + x:Name="tbQuery" PreviewKeyDown="TbQuery_OnPreviewKeyDown" TextChanged="TbQuery_OnTextChanged" /> diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 9e305ff40..04f29a60b 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -24,7 +24,6 @@ using Wox.Helper; using Wox.Infrastructure; using Wox.Infrastructure.Hotkey; using Wox.Plugin; -using Wox.ShellContext; using Wox.Storage; using ContextMenu = System.Windows.Forms.ContextMenu; using DataFormats = System.Windows.DataFormats; @@ -64,7 +63,7 @@ namespace Wox tbQuery.CaretIndex = tbQuery.Text.Length; if (requery) { - TextBoxBase_OnTextChanged(null, null); + TbQuery_OnTextChanged(null, null); } })); } @@ -148,7 +147,7 @@ namespace Wox public List GetAllPlugins() { - return PluginManager.AllPlugins; + return PluginManager.AllPlugins.ToList(); } public event WoxKeyDownEventHandler BackKeyDownEvent; @@ -207,18 +206,7 @@ namespace Wox InitialTray(); Closing += MainWindow_Closing; - //since MainWIndow implement IPublicAPI, so we need to finish ctor MainWindow object before - //PublicAPI invoke in plugin init methods. E.g FolderPlugin - ThreadPool.QueueUserWorkItem(o => - { - Thread.Sleep(50); - PluginManager.Init(this); - }); - ThreadPool.QueueUserWorkItem(o => - { - Thread.Sleep(50); - PreLoadImages(); - }); + } void pnlResult_ItemDropEvent(Result result, IDataObject dropDataObject, DragEventArgs args) @@ -245,11 +233,6 @@ namespace Wox return true; } - private void PreLoadImages() - { - ImageLoader.ImageLoader.PreloadImages(); - } - void pnlResult_RightMouseClickEvent(Result result) { ShowContextMenu(result); @@ -364,7 +347,7 @@ namespace Wox { //double if to omit calling win32 function if (UserSettingStorage.Instance.IgnoreHotkeysOnFullscreen) - if(WindowIntelopHelper.IsWindowFullscreen()) + if (WindowIntelopHelper.IsWindowFullscreen()) return true; return false; @@ -456,69 +439,49 @@ namespace Wox } } - private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e) + private void TbQuery_OnTextChanged(object sender, TextChangedEventArgs e) { if (ignoreTextChange) { ignoreTextChange = false; return; } toolTip.IsOpen = false; pnlResult.Dirty = true; - if (IsInContextMenuMode) { QueryContextMenu(); return; } - lastQuery = tbQuery.Text; - int searchDelay = GetSearchDelay(lastQuery); + queryHasReturn = false; - Dispatcher.DelayInvoke("UpdateSearch", - o => + Dispatcher.DelayInvoke("ClearResults", () => + { + // Delay the invocation of clear method of pnlResult, minimize the time-span between clear results and add new results. + // So this will reduce splash issues. After waiting 100ms, if there still no results added, we + // must clear the result. otherwise, it will be confused why the query changed, but the results + // didn't. + if (pnlResult.Dirty) pnlResult.Clear(); + }, TimeSpan.FromMilliseconds(100)); + Query(tbQuery.Text); + Dispatcher.DelayInvoke("ShowProgressbar", () => + { + if (!queryHasReturn && !string.IsNullOrEmpty(lastQuery)) { - Dispatcher.DelayInvoke("ClearResults", i => - { - // first try to use clear method inside pnlResult, which is more closer to the add new results - // and this will not bring splash issues.After waiting 100ms, if there still no results added, we - // must clear the result. otherwise, it will be confused why the query changed, but the results - // didn't. - if (pnlResult.Dirty) pnlResult.Clear(); - }, TimeSpan.FromMilliseconds(100), null); - queryHasReturn = false; - Query query = new Query(lastQuery); - query.IsIntantQuery = searchDelay == 0; - Query(query); - Dispatcher.DelayInvoke("ShowProgressbar", originQuery => - { - if (!queryHasReturn && originQuery == tbQuery.Text && !string.IsNullOrEmpty(lastQuery)) - { - StartProgress(); - } - }, TimeSpan.FromMilliseconds(150), tbQuery.Text); - //reset query history index after user start new query - ResetQueryHistoryIndex(); - }, TimeSpan.FromMilliseconds(searchDelay)); + StartProgress(); + } + }, TimeSpan.FromMilliseconds(150)); + //reset query history index after user start new query + ResetQueryHistoryIndex(); } private void ResetQueryHistoryIndex() { QueryHistoryStorage.Instance.Reset(); } - - private int GetSearchDelay(string query) + private void Query(string text) { - if (!string.IsNullOrEmpty(query) && PluginManager.IsInstantQuery(query)) - { - DebugHelper.WriteLine("execute query without delay"); - return 0; - } - - DebugHelper.WriteLine("execute query with 200ms delay"); - return 200; - } - - private void Query(Query q) - { - PluginManager.Query(q); + var query = PluginManager.QueryInit(text); + lastQuery = query?.RawQuery; + PluginManager.QueryForAllPlugins(query); StopProgress(); } diff --git a/Wox/Msg.xaml.cs b/Wox/Msg.xaml.cs index 9f9801cf3..2dd1d500d 100644 --- a/Wox/Msg.xaml.cs +++ b/Wox/Msg.xaml.cs @@ -1,19 +1,10 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Forms; using System.Windows.Input; -using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; -using System.Windows.Shapes; -using Timer = System.Threading.Timer; namespace Wox { public partial class Msg : Window { @@ -71,11 +62,11 @@ namespace Wox { Show(); Dispatcher.DelayInvoke("ShowMsg", - o => { - if (!closing) { - closing = true; - Dispatcher.Invoke(new Action(fadeOutStoryboard.Begin)); - } + () => { + if (!closing) { + closing = true; + Dispatcher.Invoke(new Action(fadeOutStoryboard.Begin)); + } }, TimeSpan.FromSeconds(3)); } } diff --git a/Wox/ResultPanel.xaml.cs b/Wox/ResultPanel.xaml.cs index eec796d99..7c44bf36b 100644 --- a/Wox/ResultPanel.xaml.cs +++ b/Wox/ResultPanel.xaml.cs @@ -7,7 +7,6 @@ using System.Windows.Media; using Wox.Core.UserSettings; using Wox.Plugin; using Wox.Storage; -using UserControl = System.Windows.Controls.UserControl; namespace Wox { @@ -225,7 +224,7 @@ namespace Wox if (e.AddedItems.Count > 0 && e.AddedItems[0] != null) { lbResults.ScrollIntoView(e.AddedItems[0]); - Dispatcher.DelayInvoke("UpdateItemNumber", o => + Dispatcher.DelayInvoke("UpdateItemNumber", () => { UpdateItemNumber(); }, TimeSpan.FromMilliseconds(3)); diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index 5520b4c53..e78ce1b40 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -1,34 +1,25 @@ using System; using System.Collections.Generic; -using System.Configuration; using System.Diagnostics; using System.IO; using System.Linq; using System.Net; -using System.Threading; using System.Windows; using System.Windows.Controls; +using System.Windows.Data; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; -using Wox.Core.Plugin; -using Wox.Plugin; -using Wox.Helper; -using Application = System.Windows.Forms.Application; -using File = System.IO.File; -using MessageBox = System.Windows.MessageBox; -using System.Windows.Data; -using System.Windows.Forms; using Microsoft.Win32; using Wox.Core.i18n; +using Wox.Core.Plugin; using Wox.Core.Theme; using Wox.Core.Updater; using Wox.Core.UserSettings; +using Wox.Helper; using Wox.Infrastructure; -using CheckBox = System.Windows.Controls.CheckBox; -using Control = System.Windows.Controls.Control; -using Cursors = System.Windows.Input.Cursors; -using HorizontalAlignment = System.Windows.HorizontalAlignment; +using Wox.Plugin; +using Application = System.Windows.Forms.Application; namespace Wox { @@ -464,7 +455,7 @@ namespace Wox private void DelayChangeTheme() { - Dispatcher.DelayInvoke("delayChangeTheme", o => + Dispatcher.DelayInvoke("delayChangeTheme", () => { ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme); }, TimeSpan.FromMilliseconds(100)); diff --git a/Wox/Storage/TopMostRecordStorage.cs b/Wox/Storage/TopMostRecordStorage.cs index dc56ed550..a1774a9fd 100644 --- a/Wox/Storage/TopMostRecordStorage.cs +++ b/Wox/Storage/TopMostRecordStorage.cs @@ -1,9 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; -using System.Text; using Wox.Infrastructure.Storage; namespace Wox.Storage diff --git a/Wox/Storage/UserSelectedRecordStorage.cs b/Wox/Storage/UserSelectedRecordStorage.cs index 7afa73c81..3f6ac51ca 100644 --- a/Wox/Storage/UserSelectedRecordStorage.cs +++ b/Wox/Storage/UserSelectedRecordStorage.cs @@ -1,10 +1,9 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; +using System.IO; +using System.Reflection; using Newtonsoft.Json; using Wox.Infrastructure.Storage; using Wox.Plugin; -using System.IO; -using System.Reflection; namespace Wox.Storage { diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 3a83ac2cf..bcf2772d7 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -14,7 +14,6 @@ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 ..\ - true 发布\ true @@ -61,19 +60,10 @@ Wox.App - False ..\packages\Exceptionless.1.5.2121\lib\net35\Exceptionless.dll - - False - ..\packages\Exceptionless.1.5.2121\lib\net35\Exceptionless.Models.dll - - - False - ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll - ..\packages\MarkdownSharp.1.13.0.0\lib\35\MarkdownSharp.dll @@ -89,7 +79,6 @@ ..\packages\NHotkey.Wpf.1.2.1\lib\net35\NHotkey.Wpf.dll True - @@ -100,7 +89,6 @@ - @@ -110,10 +98,6 @@ - - False - ..\packages\InputSimulator.1.0.4.0\lib\net20\WindowsInput.dll - @@ -149,7 +133,6 @@ - @@ -362,7 +345,6 @@ - xcopy /Y $(ProjectDir)Themes\* $(TargetDir)Themes\ xcopy /Y /E $(ProjectDir)Images\* $(TargetDir)Images\ @@ -392,4 +374,5 @@ cd "$(TargetDir)Plugins" & del /s /q WindowsInput.dll --> - \ No newline at end of file + +