diff --git a/.gitattributes b/.gitattributes index 1ff0c42304..4f81094560 100644 --- a/.gitattributes +++ b/.gitattributes @@ -61,3 +61,5 @@ #*.PDF diff=astextplain #*.rtf diff=astextplain #*.RTF diff=astextplain + +PythonHome/* linguist-vendored \ No newline at end of file diff --git a/.gitignore b/.gitignore index fc8205cacb..57103cd78b 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 67f8ea046e..0000000000 --- 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 c296edf177..0000000000 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 83fe906016..0000000000 --- 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/Deploy/Nuget/pack.ps1 b/Deploy/Nuget/pack.ps1 index 27fd679165..c60839202f 100644 --- a/Deploy/Nuget/pack.ps1 +++ b/Deploy/Nuget/pack.ps1 @@ -1,13 +1,7 @@ -$root = (split-path -parent $MyInvocation.MyCommand.Definition) + '\..\..' -Write-Host $root -$version = [System.Reflection.Assembly]::LoadFile("$root\Output\Release\Wox.Plugin.dll").GetName().Version -$versionStr = "{0}.{1}.{2}.{3}" -f ($version.Major, $version.Minor, $version.Build, $version.Revision) +$path = $env:APPVEYOR_BUILD_FOLDER + "\Deploy\Nuget\wox.plugin.nuspec" -Write-Host "Setting .nuspec version tag to $versionStr" +$current_path = Convert-Path . +Write-Host "Current path: " + $current_path +Write-Host "Target path: " + $path -$content = (Get-Content $root\Deploy\NuGet\wox.plugin.nuspec) -$content = $content -replace '\$version\$',$versionStr - -$content | Out-File $root\deploy\nuget\wox.plugin.nuspec - -& $root\.nuget\NuGet.exe pack $root\deploy\nuget\wox.plugin.nuspec +& nuget pack $path -Version $env:APPVEYOR_BUILD_VERSION diff --git a/Deploy/UpdateGenerator/build.bat b/Deploy/UpdateGenerator/build.bat deleted file mode 100644 index f51873e12d..0000000000 --- a/Deploy/UpdateGenerator/build.bat +++ /dev/null @@ -1,2 +0,0 @@ -cd /d %~dp0 -%~dp0Wox.UpdateFeedGenerator.exe diff --git a/Deploy/UpdateGenerator/build.ps1 b/Deploy/UpdateGenerator/build.ps1 new file mode 100644 index 0000000000..b8a3397efc --- /dev/null +++ b/Deploy/UpdateGenerator/build.ps1 @@ -0,0 +1,9 @@ +$path = $env:APPVEYOR_BUILD_FOLDER + "\Deploy\UpdateGenerator" + +$current_path = Convert-Path . +Write-Host "Current path: " + $current_path +Write-Host "Target path: " + $path + +Set-Location $path +& ".\Wox.UpdateFeedGenerator.exe" +Set-Location $current_path \ No newline at end of file diff --git a/LICENSE b/LICENSE index f12e92657f..cb4b563c0a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013 qianlifeng +Copyright (c) 2015 Wox Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/Plugins/Wox.Plugin.CMD/CMD.cs b/Plugins/Wox.Plugin.CMD/CMD.cs index e95b11d711..de76413c52 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 1d719d17cd..ece62a06ad 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 b64f79fc27..2b7280a2b5 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 949a499983..329dcd02c6 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 f564925281..907c4ff929 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 8a0428fad2..847df6d016 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 9d4cb13c89..86f8a2c2a8 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 1970e39a7c..bbb0d33753 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 4318485e6e..1a6ed8c6bb 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 3617934043..1b8afe4139 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 f4fdc6d15a..0000000000 --- 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 d0fd2f7e91..2699044674 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 e22d560983..815643c9d8 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 60d98225c4..748cd7c6d8 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 fe0a2a8f40..e247436eb8 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 b0b463c006..e57ab20a8d 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 40f5963224..27c7acabf5 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 cc1174c98f..8508c4e317 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 c93df57d13..45fa4f44c4 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 c6f6ec5469..4d258e74fc 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/Languages/zh-cn.xaml b/Plugins/Wox.Plugin.Program/Languages/zh-cn.xaml index ee397b26be..16e4639317 100644 --- a/Plugins/Wox.Plugin.Program/Languages/zh-cn.xaml +++ b/Plugins/Wox.Plugin.Program/Languages/zh-cn.xaml @@ -10,8 +10,8 @@ 索引文件后缀 重新索引 索引中 - 指数开始菜单 - 指数注册 + 索引开始菜单 + 索引注册表 后缀 最大深度 diff --git a/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs index 5b50d72df1..16e0961b3d 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 b1ef2dcd4c..cb0cf7e765 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 a274237f87..d533443f01 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 d6a3a35183..8e2349e435 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 70e612ac2a..0f6c4c5660 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 2a1c20e7e1..34fc2868db 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/Images/sleep.png b/Plugins/Wox.Plugin.Sys/Images/sleep.png new file mode 100644 index 0000000000..c7668e7f29 Binary files /dev/null and b/Plugins/Wox.Plugin.Sys/Images/sleep.png differ diff --git a/Plugins/Wox.Plugin.Sys/Languages/en.xaml b/Plugins/Wox.Plugin.Sys/Languages/en.xaml index a80f951b72..be6dbbbd72 100644 --- a/Plugins/Wox.Plugin.Sys/Languages/en.xaml +++ b/Plugins/Wox.Plugin.Sys/Languages/en.xaml @@ -11,6 +11,7 @@ Close Wox Restart Wox Tweak this app + Put computer to sleep System Commands Provide System related commands. e.g. shutdown,lock,setting etc. diff --git a/Plugins/Wox.Plugin.Sys/Languages/zh-cn.xaml b/Plugins/Wox.Plugin.Sys/Languages/zh-cn.xaml index d9e10231f8..099003ebb1 100644 --- a/Plugins/Wox.Plugin.Sys/Languages/zh-cn.xaml +++ b/Plugins/Wox.Plugin.Sys/Languages/zh-cn.xaml @@ -11,6 +11,7 @@ 退出Wox 重启Wox 设置 + 休眠这台电脑 系统命令 系统系统相关的命令。例如,关机,锁定,设置等 diff --git a/Plugins/Wox.Plugin.Sys/Languages/zh-tw.xaml b/Plugins/Wox.Plugin.Sys/Languages/zh-tw.xaml index 75c93a0d1a..0fa2694af7 100644 --- a/Plugins/Wox.Plugin.Sys/Languages/zh-tw.xaml +++ b/Plugins/Wox.Plugin.Sys/Languages/zh-tw.xaml @@ -11,6 +11,7 @@ 退出Wox 重啟Wox 設置 + 休眠这台电脑 系統命令 系統系統相關的命令。例如,關機,鎖定,設置等 diff --git a/Plugins/Wox.Plugin.Sys/Sys.cs b/Plugins/Wox.Plugin.Sys/Sys.cs index f547e86e57..bc3db80b63 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 @@ -95,7 +93,7 @@ namespace Wox.Plugin.Sys new Result { Title = "Sleep", - SubTitle = "Put computer to sleep", + SubTitle = context.API.GetTranslation("wox_plugin_sys_sleep"), Score = 100, IcoPath = "Images\\sleep.png", Action = (c) => Application.SetSuspendState(PowerState.Suspend, false, false) diff --git a/Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj b/Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj index 271194ab0a..2bfb924a5c 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 @@ - @@ -65,6 +63,9 @@ + + PreserveNewest + MSBuild:Compile Designer @@ -121,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 ae871d2b23..51c8f2ed95 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 aabcb45255..23e5ac1a8f 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 78cfb5d6e5..49c31e63d3 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 7f4412f3d3..9fc1b9ec45 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 2a75abe201..a91a59198e 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 b4751d37bb..905e83a141 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/README.md b/README.md index 53e7eff0ee..cc0350f1c1 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -Wox [![Build status](https://ci.appveyor.com/api/projects/status/bfktntbivg32e103)](https://ci.appveyor.com/project/qianlifeng/wox) [![Bountysource](https://www.bountysource.com/badge/team?team_id=39433&style=raised)](https://www.bountysource.com/teams/wox?utm_source=Wox&utm_medium=shield&utm_campaign=raised) [![Alipay](https://i.alipayobjects.com/i/localhost/png/201406/2m8C9z7xQ5_src.png)](http://meiweihezi.com/dashang/dashang.php?id=ZGsyNDI=) +Wox [![Build status](https://ci.appveyor.com/api/projects/status/bfktntbivg32e103)](https://ci.appveyor.com/project/qianlifeng/wox) [![Bountysource](https://www.bountysource.com/badge/team?team_id=39433&style=raised)](https://www.bountysource.com/teams/wox?utm_source=Wox&utm_medium=shield&utm_campaign=raised) ========= -[Wox](http://www.getwox.com) is a launcher for windows, which was inspired by [Alfred](http://www.alfredapp.com/) and [Launchy](http://www.launchy.net/). Wox provide an entry to search everything you want. +[Wox](http://www.getwox.com) is a launcher for windows, inspired by [Alfred](http://www.alfredapp.com/) and [Launchy](http://www.launchy.net/). Wox indexes your programs, your documents, project files, folders, and bookmarks. You can launch everything with just a few keystrokes!. Features ========= -1. Search applications, files and browser bookmarks (via plugin) -2. Search web contents with shortcuts (e.g. search google with `g keyword` or `youtube keyword`) +1. Search for applications, folders, files and in the browser bookmarks (using a plugin) +2. Search the web using shortcuts (e.g. search google with `g keyword` or Youtube `youtube keyword`) 3. Themes support, get more themes from [http://www.getwox.com/theme/builder](http://www.getwox.com/theme/builder) 4. Plugin support, get more plugins from [http://www.getwox.com/plugin](http://www.getwox.com/plugin) @@ -15,27 +15,38 @@ Screenshot More screenshot -Download +Installation ========= -Download from [release page](https://github.com/qianlifeng/Wox/releases). +1. Download + 1. Latest stable version: [release page](https://github.com/qianlifeng/Wox/releases). + 2. Latest build: [history](https://ci.appveyor.com/project/qianlifeng/wox/history) + (top green build -> artifacts -> release-binary.zip). +2. Unzip it and put it into your user directory (`C:\Users\YOUUSERNAME` or `%userprofile%`) +3. Windows 10 user, please have a look at https://github.com/Wox-launcher/Wox/issues/279 + + +Simple Usage +========= +- Launch: Alt+Space +- Install/Uninstall plugin: type `wpm install/uninstall` +- Remember type `restart` to restarat Wox after installation of a plugin Contribute ========= -If you are a developer, feel free to send a pull request to **Dev** branch. We still have a lot functions and bugs need to do now. Just pick one from [issues page](https://github.com/qianlifeng/Wox/issues) that you think you can fix. +If you are a developer, feel free to send a pull request to the **Dev** branch. We still have a lot of features and bugs to resolve. Take a look at [issues page](https://github.com/qianlifeng/Wox/issues) if you want to contribute :) -If you are not a developer, you can also help Wox by contributing the [Wox doc](http://doc.getwox.com). +If you are not a developer, you can still contribute to the project. Install the beta version, test things and help us with new entries and corrections to the docs [Wox doc](http://doc.getwox.com). Feedback is always welcome! - - -Doc +Docs ========= -If you have any questions about how to use Wox, please read [Wox Documentation](http://doc.getwox.com) first. Wox documentation is a good place for users to understand Wox. +Full documentation can be found here [Wox Documentation](http://doc.getwox.com). This is a good place to start if you are installing Wox for the first time. Feel free to contribute if you want to improve, correct or translate the documentation. +In the future, all of the documentation will be moved back to Github wiki. Discussion ========= -We build a [Wox Fourms](http://discussion.getwox.com), so users can talk about everything about Wox there. +Do you have a question or an idea for a killer feature? Discuss things with our community at the [Wox Fourms](http://discussion.getwox.com). diff --git a/References/NAppUpdate.Framework.dll b/References/NAppUpdate.Framework.dll deleted file mode 100644 index 398d46b810..0000000000 Binary files a/References/NAppUpdate.Framework.dll and /dev/null differ diff --git a/Wox.Core/APIServer.cs b/Wox.Core/APIServer.cs index 8aec75068e..7830d091ae 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 ac972ff556..0000000000 --- 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 7db7b07a03..d4e8beb8a8 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 76aea3dea6..cf840f9b19 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 e095c78995..72b62df988 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 1134460321..e435be5cdd 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 877ff10e9b..6f65d78c93 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 0bf35979c9..d4b2a4f90a 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 f47e1dac01..2b89a9653e 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 77577aa9b1..b26254576f 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 b681463f47..1fb302882b 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 20487de0a2..bf1edb4c16 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 6c5c562c8c..0000000000 --- a/Wox.Core/Plugin/QueryDispatcher/BaseQueryDispatcher.cs +++ /dev/null @@ -1,39 +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; - -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)) - { - 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 d0923c34c1..0000000000 --- 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 5c53c556b8..0000000000 --- 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 c5312a0332..0000000000 --- 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 5d2062b48e..0000000000 --- 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 dd5baa0e63..0ca99a503a 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 55bfccb21d..34409068e6 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 b20e95cdd0..114b5742c7 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 a5dc1a2f9f..3ad8a0d7d7 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 a1e398a25c..99d89551a6 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 542200ede2..818f3073b0 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 f93f9a3487..65778896a0 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 20b66e2f66..192bf9d2bc 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 c01538e623..3af1911324 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 { @@ -86,6 +84,9 @@ namespace Wox.Core.UserSettings [JsonProperty] public bool RememberLastLaunchLocation { get; set; } + [JsonProperty] + public bool IgnoreHotkeysOnFullscreen { get; set; } + [JsonProperty] public string ProxyServer { get; set; } diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj index fa06e3840f..c7e8072a24 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 e31636b7e1..0000000000 --- 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 0da5c89a5e..31280ad9de 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 e80501936f..c979cca6d1 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 8cfbc52bd5..8abaf16a4f 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 9dcf31def0..896abfdf6c 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 edf2b7087a..f942370cac 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 3db9bfee70..4ddee08ada 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 9ad13bfafb..fb49507ec0 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 bb94306f1c..9f305804dd 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 ca6c0fea09..b01f7277b5 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 4d3d9dd5ae..6261d9a067 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 14dd1f62c0..1e804fc2bf 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 ea1f56ef5f..a81247fd6b 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 ba5d2673ab..9a638a6cc5 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 { @@ -146,7 +144,7 @@ namespace Wox.Infrastructure startInfo.WindowStyle = global::System.Diagnostics.ProcessWindowStyle.Normal; startInfo.ErrorDialog = (dwSeclFlags | ShellExecCmdLineFlags.SECL_NO_UI) == 0; startInfo.ErrorDialogParentHandle = hwnd; - + startInfo.WorkingDirectory = startDir; try { global::System.Diagnostics.Process.Start(startInfo); diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index 80a96bc322..a5ef083e79 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 bdc6a30f3a..28f0c6c0b1 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 62953a2a63..d2b3f274e6 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 2752c0e04e..8801cc14a6 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 7a13476a54..9661aa0af8 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 4fa7835613..d50b7e3b37 100644 --- a/Wox.sln +++ b/Wox.sln @@ -1,9 +1,12 @@  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}" + ProjectSection(ProjectDependencies) = postProject + {DB90F671-D861-46BB-93A3-F1304F5BA1C5} = {DB90F671-D861-46BB-93A3-F1304F5BA1C5} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin", "Wox.Plugin\Wox.Plugin.csproj", "{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}" EndProject @@ -16,7 +19,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox", "Wox\Wox.csproj", "{D {1EE20B48-82FB-48A2-8086-675D6DDAB4F0} = {1EE20B48-82FB-48A2-8086-675D6DDAB4F0} {0B9DE348-9361-4940-ADB6-F5953BFFCCEC} = {0B9DE348-9361-4940-ADB6-F5953BFFCCEC} {FDB3555B-58EF-4AE6-B5F1-904719637AB4} = {FDB3555B-58EF-4AE6-B5F1-904719637AB4} - {FF742965-9A80-41A5-B042-D6C7D3A21708} = {FF742965-9A80-41A5-B042-D6C7D3A21708} {59BD9891-3837-438A-958D-ADC7F91F6F7E} = {59BD9891-3837-438A-958D-ADC7F91F6F7E} {C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} = {C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} {787B8AA6-CA93-4C84-96FE-DF31110AD1C4} = {787B8AA6-CA93-4C84-96FE-DF31110AD1C4} diff --git a/Wox/ActionKeyword.xaml.cs b/Wox/ActionKeyword.xaml.cs index bc74e381e8..03beac0ee0 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 449be94262..2f32256d20 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 d1b7f5f69b..3e5f2b3f18 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 1e0f3a0dca..7f2fdfc98b 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 b8ed670632..1918858b1f 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 be6391ce02..11db545571 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 e69d20a633..524115b4d6 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 dab93500f8..0000000000 --- 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 7e58ace4e2..22f0443528 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 f287e08c85..aec5724c11 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 743a3e8874..623648e311 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 20843a6864..eb92e62514 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/Converters/StringNullOrEmptyToVisibilityConverter.cs b/Wox/Converters/StringNullOrEmptyToVisibilityConverter.cs index f536e74735..543fecd322 100644 --- a/Wox/Converters/StringNullOrEmptyToVisibilityConverter.cs +++ b/Wox/Converters/StringNullOrEmptyToVisibilityConverter.cs @@ -8,6 +8,8 @@ namespace Wox.Converters { public class StringNullOrEmptyToVisibilityConverter : ConvertorBase { + public StringNullOrEmptyToVisibilityConverter() { } + public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return string.IsNullOrEmpty(value as string) ? Visibility.Collapsed : Visibility.Visible; diff --git a/Wox/Helper/DWMDropShadow.cs b/Wox/Helper/DWMDropShadow.cs index 60253f8c06..d1fd92757e 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 7e474bd4b2..61922d29df 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 2ea304a2ed..72880e2ebf 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 d1de5c9822..e7b5a81fb9 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 393b236731..2b49503981 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 e7caf8560a..fc1bf50892 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/Helper/WindowIntelopHelper.cs b/Wox/Helper/WindowIntelopHelper.cs index 2e5179b7b4..4a0223a19e 100644 --- a/Wox/Helper/WindowIntelopHelper.cs +++ b/Wox/Helper/WindowIntelopHelper.cs @@ -1,9 +1,9 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Drawing; using System.Runtime.InteropServices; using System.Windows; +using System.Windows.Forms; +using System.Windows.Interop; namespace Wox.Helper { @@ -11,6 +11,25 @@ namespace Wox.Helper { private const int GWL_STYLE = -16; //WPF's Message code for Title Bar's Style private const int WS_SYSMENU = 0x80000; //WPF's Message code for System Menu + private static IntPtr _hwnd_shell; + private static IntPtr _hwnd_desktop; + + //Accessors for shell and desktop handlers + //Will set the variables once and then will return them + private static IntPtr HWND_SHELL + { + get + { + return _hwnd_shell != IntPtr.Zero ? _hwnd_shell : _hwnd_shell = GetShellWindow(); + } + } + private static IntPtr HWND_DESKTOP + { + get + { + return _hwnd_desktop != IntPtr.Zero ? _hwnd_desktop : _hwnd_desktop = GetDesktopWindow(); + } + } [DllImport("user32.dll", SetLastError = true)] private static extern int GetWindowLong(IntPtr hWnd, int nIndex); @@ -18,14 +37,56 @@ namespace Wox.Helper [DllImport("user32.dll")] private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); + [DllImport("user32.dll")] + private static extern IntPtr GetForegroundWindow(); + + [DllImport("user32.dll")] + private static extern IntPtr GetDesktopWindow(); + + [DllImport("user32.dll")] + private static extern IntPtr GetShellWindow(); + + [DllImport("user32.dll", SetLastError = true)] + private static extern int GetWindowRect(IntPtr hwnd, out RECT rc); + + public static bool IsWindowFullscreen() + { + RECT foreWinBounds; + Rectangle screenBounds; + var hWnd = GetForegroundWindow(); + if (!hWnd.Equals(IntPtr.Zero)) + { + if (!(hWnd.Equals(HWND_DESKTOP) || hWnd.Equals(HWND_SHELL))) + { + GetWindowRect(hWnd, out foreWinBounds); + screenBounds = Screen.FromHandle(hWnd).Bounds; + if ((foreWinBounds.Bottom - foreWinBounds.Top) == screenBounds.Height && (foreWinBounds.Right - foreWinBounds.Left) == screenBounds.Width) + { + return true; + } + } + } + + return false; + } + /// - /// disable windows toolbar's control box - /// this will also disable system menu with Alt+Space hotkey + /// disable windows toolbar's control box + /// this will also disable system menu with Alt+Space hotkey /// public static void DisableControlBox(Window win) { - var hwnd = new System.Windows.Interop.WindowInteropHelper(win).Handle; + var hwnd = new WindowInteropHelper(win).Handle; SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU); } + + [StructLayout(LayoutKind.Sequential)] + public struct RECT + { + public int Left; + public int Top; + public int Right; + public int Bottom; + } } -} +} \ No newline at end of file diff --git a/Wox/HotkeyControl.xaml.cs b/Wox/HotkeyControl.xaml.cs index 73b16f033b..783e3e59da 100644 --- a/Wox/HotkeyControl.xaml.cs +++ b/Wox/HotkeyControl.xaml.cs @@ -53,7 +53,7 @@ namespace Wox } Dispatcher.DelayInvoke("HotkeyAvailabilityTest", - o => + () => { SetHotkey(hotkeyModel); }, @@ -108,5 +108,10 @@ namespace Wox return false; } + + public new bool IsFocused + { + get { return tbHotkey.IsFocused; } + } } } diff --git a/Wox/ImageLoader/ImageCacheStroage.cs b/Wox/ImageLoader/ImageCacheStroage.cs index 21dd028d66..9c13aab06b 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 8fa9f9c5d8..18a5a91d09 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/Languages/en.xaml b/Wox/Languages/en.xaml index 262e57555a..fe252ebb98 100644 --- a/Wox/Languages/en.xaml +++ b/Wox/Languages/en.xaml @@ -22,8 +22,9 @@ Don't show upgrade msg if new version available Remember last launch location Language + Maximum show results + Ignore hotkeys if window is fullscreen - Plugin Browse more plugins diff --git a/Wox/Languages/ru.xaml b/Wox/Languages/ru.xaml new file mode 100644 index 0000000000..e09aa9bc73 --- /dev/null +++ b/Wox/Languages/ru.xaml @@ -0,0 +1,128 @@ + + + Регистрация хоткея {0} не удалась + Не удалось запустить {0} + Неверный формат файла wox плагина + Отображать это окно выше всех при этом запросе + Не отображать это окно выше всех при этом запросе + Выполнить запрос:{0} + Последний раз выполнен в:{0} + Открыть + Настройки + О Wox + Закрыть + + + Настройки Wox + Общие + Запускать Wox при запуске системы + Скрывать Wox если потерян фокус + Не отображать сообщение об обновлении когда доступна новая версия + Запомнить последнее место запуска + Язык + Максимальное количество результатов + Игнорировать горячие клавиши, если окно в полноэкранном режиме + + + Плагины + Найти больше плагинов + Отключить + Ключевое слово + Папка + Автор + Инициализация: {0}ms + Запрос: {0}ms + + + Темы + Найти больше тем + Привет Wox + Шрифт запросов + Шрифт результатов + Оконный режим + Прозрачность + + + Горячие клавиши + Горячая клавиша Wox + Задаваемые горячие клавиши для запросов + Удалить + Изменить + Добавить + Сначала выберите элемент + Вы уверены что хотите удалить горячую клавишу для плагина {0}? + + + Прокси + Включить прокси + Сервер + Порт + Логин + Пароль + Проверить + Сохранить + Необходимо задать сервер + Необходимо задать порт + Неверный формат порта + Прокси успешно сохранён + Прокси сервер задан правильно + Подключение к прокси серверу не удалось + + + О Wox + Сайт + Версия + Вы воспользовались Wox уже {0} раз + + + Текущая горячая клавиша + Новая горячая клавиша + Отменить + Подтвердить + Не удалось найти заданный плагин + Новая горячая клавиша не может быть пустой + Новая горячая клавиша уже используется другим плагином. Пожалуйста, зайдайте новую + Сохранено + Используйте * в случае, если вы не хотите задавать конкретную горячую клавишу + + + + Проверить + Горячая клавиша недоступна. Пожалуйста, зайдайте новую + Недействительная горячая клавиша плагина + Изменить + + + Горячая клавиша недоступна + + + + Версия + Время + Пожалуйста, сообщите что произошло когда произошёл сбой в приложении, чтобы мы могли его исправить + Отправить отчёт + Отмена + Общие + Исключения + Тип исключения + Источник + Трессировка стека + Отправляем + Отчёт успешно отправлен + Не удалось отправить отчёт + Произошёл сбой в Wox + + + Доступна новая версия Wox V{0} + Произошла ошибка при попытке установить обновление + Обновить + Отмена + Это обновление перезапустит Wox + Следующие файлы будут обновлены + Обновить файлы + Описание обновления + + + \ No newline at end of file diff --git a/Wox/Languages/zh-cn.xaml b/Wox/Languages/zh-cn.xaml index a0614e2385..7e00547603 100644 --- a/Wox/Languages/zh-cn.xaml +++ b/Wox/Languages/zh-cn.xaml @@ -22,6 +22,8 @@ 不显示新版本提示 记住上次启动位置 语言 + 最大结果显示个数 + Ignore hotkeys if foreground window is TopMost 插件 @@ -30,8 +32,8 @@ 触发关键字 插件目录 作者 - 加载耗时:{0}ms - 查询耗时:{0}ms + 加载耗时 {0}ms + 查询耗时 {0}ms 主题 diff --git a/Wox/Languages/zh-tw.xaml b/Wox/Languages/zh-tw.xaml index 0c07eed870..0f1ab8f9c4 100644 --- a/Wox/Languages/zh-tw.xaml +++ b/Wox/Languages/zh-tw.xaml @@ -22,6 +22,8 @@ 不顯示新版本提示 记住上次启动位置 語言 + 最大結果顯示個數 + Ignore hotkeys if foreground window is TopMost 插件 diff --git a/Wox/MainWindow.xaml b/Wox/MainWindow.xaml index bfc5b9871f..4b5a315fed 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 35e7df4965..ee3044e4bc 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); @@ -356,6 +339,20 @@ namespace Wox } } + /// + /// Checks if Wox should ignore any hotkeys + /// + /// + private bool ShouldIgnoreHotkeys() + { + //double if to omit calling win32 function + if (UserSettingStorage.Instance.IgnoreHotkeysOnFullscreen) + if (WindowIntelopHelper.IsWindowFullscreen()) + return true; + + return false; + } + private void SetCustomPluginHotkey() { if (UserSettingStorage.Instance.CustomPluginHotkeys == null) return; @@ -364,6 +361,7 @@ namespace Wox CustomPluginHotkey hotkey1 = hotkey; SetHotkey(hotkey.Hotkey, delegate { + if (ShouldIgnoreHotkeys()) return; ShowApp(); ChangeQuery(hotkey1.ActionKeyword, true); }); @@ -372,6 +370,7 @@ namespace Wox private void OnHotkey(object sender, HotkeyEventArgs e) { + if (ShouldIgnoreHotkeys()) return; ToggleWox(); e.Handled = true; } @@ -440,69 +439,52 @@ 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)) + var query = PluginManager.QueryInit(text); + if (query != null) { - DebugHelper.WriteLine("execute query without delay"); - return 0; + lastQuery = query.RawQuery; + PluginManager.QueryForAllPlugins(query); } - - DebugHelper.WriteLine("execute query with 200ms delay"); - return 200; - } - - private void Query(Query q) - { - PluginManager.Query(q); StopProgress(); } diff --git a/Wox/Msg.xaml.cs b/Wox/Msg.xaml.cs index 9f9801cf30..2dd1d500d7 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 eec796d99d..7c44bf36bd 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 b/Wox/SettingWindow.xaml index 07ab2b8a8e..b322cf16d5 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -11,7 +11,7 @@ Title="{DynamicResource woxsettings}" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" - Height="600" Width="800"> + Height="600" Width="800" PreviewKeyDown="Window_PreviewKeyDown"> - + @@ -35,17 +35,20 @@ + + + - + - - + + - + @@ -99,16 +102,16 @@ - + - + - - - + + + @@ -121,7 +124,7 @@ - + @@ -201,7 +204,7 @@ - + diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index 5395de12ba..e78ce1b40a 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 { @@ -49,7 +40,6 @@ namespace Wox private void Setting_Loaded(object sender, RoutedEventArgs ev) { #region General - cbHideWhenDeactive.Checked += (o, e) => { UserSettingStorage.Instance.HideWhenDeactive = true; @@ -86,6 +76,20 @@ namespace Wox UserSettingStorage.Instance.Save(); }; + cbIgnoreHotkeysOnFullscreen.Checked += (o, e) => + { + UserSettingStorage.Instance.IgnoreHotkeysOnFullscreen = true; + UserSettingStorage.Instance.Save(); + }; + + + cbIgnoreHotkeysOnFullscreen.Unchecked += (o, e) => + { + UserSettingStorage.Instance.IgnoreHotkeysOnFullscreen = false; + UserSettingStorage.Instance.Save(); + }; + + cbStartWithWindows.IsChecked = CheckApplicationIsStartupWithWindow(); comboMaxResultsToShow.SelectionChanged += (o, e) => { @@ -97,6 +101,7 @@ namespace Wox cbHideWhenDeactive.IsChecked = UserSettingStorage.Instance.HideWhenDeactive; cbDontPromptUpdateMsg.IsChecked = UserSettingStorage.Instance.DontPromptUpdateMsg; cbRememberLastLocation.IsChecked = UserSettingStorage.Instance.RememberLastLaunchLocation; + cbIgnoreHotkeysOnFullscreen.IsChecked = UserSettingStorage.Instance.IgnoreHotkeysOnFullscreen; LoadLanguages(); comboMaxResultsToShow.ItemsSource = Enumerable.Range(2, 16); @@ -111,7 +116,9 @@ namespace Wox cbEnableProxy.Unchecked += (o, e) => DisableProxy(); cbEnableProxy.IsChecked = UserSettingStorage.Instance.ProxyEnabled; tbProxyServer.Text = UserSettingStorage.Instance.ProxyServer; - tbProxyPort.Text = UserSettingStorage.Instance.ProxyPort.ToString(); + if (UserSettingStorage.Instance.ProxyPort != 0) { + tbProxyPort.Text = UserSettingStorage.Instance.ProxyPort.ToString(); + } tbProxyUserName.Text = UserSettingStorage.Instance.ProxyUserName; tbProxyPassword.Password = UserSettingStorage.Instance.ProxyPassword; if (UserSettingStorage.Instance.ProxyEnabled) @@ -162,6 +169,25 @@ namespace Wox } } + private void settingTab_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + // Update controls inside the selected tab + if (e.OriginalSource != settingTab) return; + + if (tabPlugin.IsSelected) + { + OnPluginTabSelected(); + } + else if (tabTheme.IsSelected) + { + OnThemeTabSelected(); + } + else if (tabHotkey.IsSelected) + { + OnHotkeyTabSelected(); + } + } + #region General private void LoadLanguages() @@ -241,17 +267,6 @@ namespace Wox } } - - private void TabHotkey_OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) - { - var tabItem = sender as TabItem; - var clickingBody = (tabItem.Content as UIElement).IsMouseOver; - if (!clickingBody) - { - OnHotkeyTabSelected(); - } - } - private void OnHotkeyTabSelected() { ctlHotkey.HotkeyChanged += ctlHotkey_OnHotkeyChanged; @@ -420,16 +435,6 @@ namespace Wox } - private void TabTheme_OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) - { - var tabItem = sender as TabItem; - var clickingBody = (tabItem.Content as UIElement).IsMouseOver; - if (!clickingBody) - { - OnThemeTabSelected(); - } - } - private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { string themeName = themeComboBox.SelectedItem.ToString(); @@ -450,7 +455,7 @@ namespace Wox private void DelayChangeTheme() { - Dispatcher.DelayInvoke("delayChangeTheme", o => + Dispatcher.DelayInvoke("delayChangeTheme", () => { ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme); }, TimeSpan.FromMilliseconds(100)); @@ -664,17 +669,6 @@ namespace Wox lbPlugins.SelectedIndex = 0; } - private void TabPlugin_OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) - { - var tabItem = sender as TabItem; - var clickingBody = (tabItem.Content as UIElement).IsMouseOver; - if (!clickingBody) - { - OnPluginTabSelected(); - } - } - - #endregion #region Proxy @@ -786,5 +780,14 @@ namespace Wox } #endregion + + private void Window_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + // Hide window with ESC, but make sure it is not pressed as a hotkey + if (e.Key == Key.Escape && !ctlHotkey.IsFocused) + { + Close(); + } + } } } diff --git a/Wox/Storage/TopMostRecordStorage.cs b/Wox/Storage/TopMostRecordStorage.cs index dc56ed550c..a1774a9fdd 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 7afa73c814..3f6ac51ca3 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 238aa8ef11..bcf2772d78 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 @@ - @@ -214,6 +197,11 @@ Designer PreserveNewest + + MSBuild:Compile + Designer + PreserveNewest + MSBuild:Compile Designer @@ -357,7 +345,6 @@ - xcopy /Y $(ProjectDir)Themes\* $(TargetDir)Themes\ xcopy /Y /E $(ProjectDir)Images\* $(TargetDir)Images\ @@ -387,4 +374,5 @@ cd "$(TargetDir)Plugins" & del /s /q WindowsInput.dll --> - \ No newline at end of file + + diff --git a/appveyor.yml b/appveyor.yml index 90e4a35507..935d638447 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,35 +1,33 @@ version: 1.2.0.{build} -configuration: - Release - +os: Visual Studio 2015 +configuration: Release +platform: Any CPU assembly_info: - patch: true - file: AssemblyInfo.* - assembly_version: "{version}" - assembly_file_version: "{version}" - assembly_informational_version: "{version}" - + patch: true + file: AssemblyInfo.* + assembly_version: '{version}' + assembly_file_version: '{version}' + assembly_informational_version: '{version}-$(APPVEYOR_REPO_COMMIT)' +before_build: +- ps: nuget restore build: - project: Wox.sln - + project: Wox.sln after_test: - - ps: .\deploy\nuget\pack.ps1 - - cmd: .\deploy\UpdateGenerator\build.bat - -deploy: - provider: NuGet - api_key: - secure: yybUOFgBuGVpbmOVZxsurC8OpkClzt9dR+/54WpMWcq6b6oyMatciaelRPnXsjRn - artifact: nugetpackage - on: - branch: master +- ps: >- + .\Deploy\UpdateGenerator\build.ps1 + .\Deploy\Nuget\pack.ps1 artifacts: - - path: Output\Release - name: release-binary - - - path: '*.nupkg' - name: nugetpackage - - - path: Output\Update - name: update-binary +- path: Output\Release + name: release-binary +- path: '*.nupkg' + name: nugetpackage +- path: Output\Update + name: update-binary +deploy: +- provider: NuGet + api_key: + secure: yybUOFgBuGVpbmOVZxsurC8OpkClzt9dR+/54WpMWcq6b6oyMatciaelRPnXsjRn + artifact: nugetpackage + on: + branch: api