From 98cb0f978ea15203f3f5d9acdba17f1c307b7a3a Mon Sep 17 00:00:00 2001 From: bao-qian Date: Mon, 9 May 2016 03:49:40 +0100 Subject: [PATCH 01/12] Finally 1.3 !!!! --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index a8c2e4fe3..b323805e0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 1.2.{build} +version: 1.3.{build} os: Visual Studio 2015 configuration: Release platform: Any CPU From 52fe91f8bce3cb12b18b3876f9e4d4c5da004246 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Mon, 9 May 2016 04:05:18 +0100 Subject: [PATCH 02/12] Update README.md --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 003ad1111..1aead335e 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,8 @@ Wox is a launcher for Windows, an alternative to [Alfred](https://www.alfredapp. # Installation - -1. Download - 1. Latest stable version: [release page](https://github.com/Wox-launcher/Wox/releases). - 2. Latest build: [English guide](https://github.com/Wox-launcher/Wox/wiki/FAQ-English#how-to-install-latest-build), [中文说明](https://github.com/Wox-launcher/Wox/wiki/FAQ-%E4%B8%AD%E6%96%87#%E5%A6%82%E4%BD%95%E5%AE%89%E8%A3%85%E6%9C%80%E6%96%B0-build) -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 +1. Latest stable version: [release page](https://github.com/Wox-launcher/Wox/releases). +2. Latest build: [English guide](https://github.com/Wox-launcher/Wox/wiki/FAQ-English#how-to-install-latest-build), [中文说明](https://github.com/Wox-launcher/Wox/wiki/FAQ-%E4%B8%AD%E6%96%87#%E5%A6%82%E4%BD%95%E5%AE%89%E8%A3%85%E6%9C%80%E6%96%B0-build) # Simple Usage @@ -50,6 +46,6 @@ In the future, all of the documentation will be moved back to Github wiki. - [x] unified directory `%APPDATA%` for all storage - [ ] bring unitest for wox back -- [ ] add autoupdate / installer +- [x] add autoupdate / installer - [ ] disable plugin properly From c2f07d14f3a756fcabb1b477d0ea805528e67d4b Mon Sep 17 00:00:00 2001 From: bao-qian Date: Mon, 9 May 2016 04:32:05 +0100 Subject: [PATCH 03/12] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1aead335e..48af472cf 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,8 @@ Wox is a launcher for Windows, an alternative to [Alfred](https://www.alfredapp. # Installation -1. Latest stable version: [release page](https://github.com/Wox-launcher/Wox/releases). -2. Latest build: [English guide](https://github.com/Wox-launcher/Wox/wiki/FAQ-English#how-to-install-latest-build), [中文说明](https://github.com/Wox-launcher/Wox/wiki/FAQ-%E4%B8%AD%E6%96%87#%E5%A6%82%E4%BD%95%E5%AE%89%E8%A3%85%E6%9C%80%E6%96%B0-build) +1. Latest stable version: [releases](https://github.com/Wox-launcher/Wox/releases). +2. Latest beta version: try **Pre-release** labeled release in [releases](https://github.com/Wox-launcher/Wox/releases) # Simple Usage From 6d02617422e100ba7a7cf1dd9f803cae4de4976e Mon Sep 17 00:00:00 2001 From: bao-qian Date: Mon, 9 May 2016 05:04:29 +0100 Subject: [PATCH 04/12] Add hello world csharp example --- Plugins/HelloWorldCSharp/App.config | 6 ++ .../HelloWorldCSharp/HelloWorldCSharp.csproj | 74 +++++++++++++++++++ Plugins/HelloWorldCSharp/Main.cs | 28 +++++++ .../Properties/AssemblyInfo.cs | 36 +++++++++ Plugins/HelloWorldCSharp/plugin.json | 12 +++ Wox.sln | 15 ++++ 6 files changed, 171 insertions(+) create mode 100644 Plugins/HelloWorldCSharp/App.config create mode 100644 Plugins/HelloWorldCSharp/HelloWorldCSharp.csproj create mode 100644 Plugins/HelloWorldCSharp/Main.cs create mode 100644 Plugins/HelloWorldCSharp/Properties/AssemblyInfo.cs create mode 100644 Plugins/HelloWorldCSharp/plugin.json diff --git a/Plugins/HelloWorldCSharp/App.config b/Plugins/HelloWorldCSharp/App.config new file mode 100644 index 000000000..88fa4027b --- /dev/null +++ b/Plugins/HelloWorldCSharp/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Plugins/HelloWorldCSharp/HelloWorldCSharp.csproj b/Plugins/HelloWorldCSharp/HelloWorldCSharp.csproj new file mode 100644 index 000000000..cfa2f977f --- /dev/null +++ b/Plugins/HelloWorldCSharp/HelloWorldCSharp.csproj @@ -0,0 +1,74 @@ + + + + + Debug + AnyCPU + {03FFA443-5F50-48D5-8869-F3DF316803AA} + Library + Properties + HelloWorldCSharp + HelloWorldCSharp + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + ..\..\Output\Debug\Plugins\HelloWorldCSharp\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + ..\..\Output\Release\Plugins\HelloWorldCSharp\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80} + Wox.Plugin + + + + + \ No newline at end of file diff --git a/Plugins/HelloWorldCSharp/Main.cs b/Plugins/HelloWorldCSharp/Main.cs new file mode 100644 index 000000000..27dce731d --- /dev/null +++ b/Plugins/HelloWorldCSharp/Main.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Wox.Plugin; + +namespace HelloWorldCSharp +{ + class Main : IPlugin + { + public List Query(Query query) + { + var result = new Result + { + Title = "Hello Word from CSharp", + SubTitle = $"Query: {query.Search}", + IcoPath = "app.png" + }; + return new List {result}; + } + + public void Init(PluginInitContext context) + { + + } + } +} diff --git a/Plugins/HelloWorldCSharp/Properties/AssemblyInfo.cs b/Plugins/HelloWorldCSharp/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..39677ff22 --- /dev/null +++ b/Plugins/HelloWorldCSharp/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("HelloWorldCSharp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("HelloWorldCSharp")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("03ffa443-5f50-48d5-8869-f3df316803aa")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Plugins/HelloWorldCSharp/plugin.json b/Plugins/HelloWorldCSharp/plugin.json new file mode 100644 index 000000000..c50928684 --- /dev/null +++ b/Plugins/HelloWorldCSharp/plugin.json @@ -0,0 +1,12 @@ +{ + "ID":"CEA0FDFC6D3B4085823D60DC76F28844", + "ActionKeyword":"hc", + "Name":"Hello World CSharp", + "Description":"Hello World CSharp", + "Author":"happlebao", + "Version":"1.0.0", + "Language":"csharp", + "Website":"https://github.com/Wox-launcher/Wox", + "ExecuteFileName":"HelloWorldCSharp.dll", + "IcoPath":"app.png" +} \ No newline at end of file diff --git a/Wox.sln b/Wox.sln index aa37b5d88..c16ef430e 100644 --- a/Wox.sln +++ b/Wox.sln @@ -85,6 +85,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PreSolutionBuild", "PreSolutionBuild\PreSolutionBuild.vcxproj", "{88731DA8-C020-476E-B79A-3ADEF65ACA9F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorldCSharp", "Plugins\HelloWorldCSharp\HelloWorldCSharp.csproj", "{03FFA443-5F50-48D5-8869-F3DF316803AA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -324,6 +326,18 @@ Global {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|x64.Build.0 = Release|x64 {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|x86.ActiveCfg = Release|Win32 {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|x86.Build.0 = Release|Win32 + {03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|x64.ActiveCfg = Debug|Any CPU + {03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|x64.Build.0 = Debug|Any CPU + {03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|x86.ActiveCfg = Debug|Any CPU + {03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|x86.Build.0 = Debug|Any CPU + {03FFA443-5F50-48D5-8869-F3DF316803AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03FFA443-5F50-48D5-8869-F3DF316803AA}.Release|Any CPU.Build.0 = Release|Any CPU + {03FFA443-5F50-48D5-8869-F3DF316803AA}.Release|x64.ActiveCfg = Release|Any CPU + {03FFA443-5F50-48D5-8869-F3DF316803AA}.Release|x64.Build.0 = Release|Any CPU + {03FFA443-5F50-48D5-8869-F3DF316803AA}.Release|x86.ActiveCfg = Release|Any CPU + {03FFA443-5F50-48D5-8869-F3DF316803AA}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -341,5 +355,6 @@ Global {A3DCCBCA-ACC1-421D-B16E-210896234C26} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} {F35190AA-4758-4D9E-A193-E3BDF6AD3567} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} {230AE83F-E92E-4E69-8355-426B305DA9C0} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} + {03FFA443-5F50-48D5-8869-F3DF316803AA} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} EndGlobalSection EndGlobal From 4eae5be995275798bcc6727562f17a12dd26e92b Mon Sep 17 00:00:00 2001 From: bao-qian Date: Mon, 9 May 2016 22:05:38 +0100 Subject: [PATCH 05/12] Update README.md --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 48af472cf..8a0cda8cb 100644 --- a/README.md +++ b/README.md @@ -32,15 +32,14 @@ Wox is a launcher for Windows, an alternative to [Alfred](https://www.alfredapp. # Contribute -If you are a developer, please 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/Wox-launcher/Wox/issues), especially for [help_needed](https://github.com/Wox-launcher/Wox/issues?q=is%3Aopen+is%3Aissue+label%3Ahelp_needed) labeled issue. :) - -If you are not a developer, please try **Pre-release** in [Releases](https://github.com/Wox-launcher/Wox/releases) and report bugs. +- Send PR to **dev** branch +- I'd appreciate if you could solve [help_needed](https://github.com/Wox-launcher/Wox/issues?q=is%3Aopen+is%3Aissue+label%3Ahelp_needed) +- Don't hesitate to ask questions in the [issues](https://github.com/Wox-launcher/Wox/issues) # Docs -Full documentation can be found here [Wox doc](http://doc.getwox.com). This is a good place to start if you are installing Wox for the first time. - -In the future, all of the documentation will be moved back to Github wiki. +Outdated doc: [Wox doc](http://doc.getwox.com). +Just ask questions in the [issues](https://github.com/Wox-launcher/Wox/issues) # Development / Author Status From 06fa171f7a70baa64d532acdfaf7a552fecda1f2 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Mon, 9 May 2016 22:08:55 +0100 Subject: [PATCH 06/12] Update README.md --- README.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8a0cda8cb..49e1ccef2 100644 --- a/README.md +++ b/README.md @@ -5,20 +5,19 @@ ========= -Wox is a launcher for Windows, an alternative to [Alfred](https://www.alfredapp.com/) and [Launchy](http://www.launchy.net/). You can launch everything with just a few keystrokes! +Launcher for Windows, an alternative to [Alfred](https://www.alfredapp.com/) and [Launchy](http://www.launchy.net/). # Demo - ![demo](http://i.imgur.com/DtxNBJi.gif) # Features -1. Search all applications, folders, files. -2. Search Web using keyword (e.g. search google with `g search_term`) -3. Build custom themes in [http://www.getwox.com/theme/builder](http://www.getwox.com/theme/builder) -4. Install plugins from [http://www.getwox.com/plugin](http://www.getwox.com/plugin) -5. Use **pinyin** to search programs / 支持用 **拼音** 搜索程序 e.g. yyy / wangyiyun -> 网易云音乐 +- Search all applications, folders, files. +- Search Web using keyword (e.g. search google with `g search_term`) +- Build custom themes in [http://www.getwox.com/theme/builder](http://www.getwox.com/theme/builder) +- Install plugins from [http://www.getwox.com/plugin](http://www.getwox.com/plugin) +- Use **pinyin** to search programs / 支持用 **拼音** 搜索程序 e.g. yyy / wangyiyun -> 网易云音乐 # Installation @@ -26,14 +25,14 @@ Wox is a launcher for Windows, an alternative to [Alfred](https://www.alfredapp. 2. Latest beta version: try **Pre-release** labeled release in [releases](https://github.com/Wox-launcher/Wox/releases) -# Simple Usage +# Usage - Launch: Alt+Space - Install/Uninstall plugin: type `wpm install/uninstall` # Contribute - Send PR to **dev** branch -- I'd appreciate if you could solve [help_needed](https://github.com/Wox-launcher/Wox/issues?q=is%3Aopen+is%3Aissue+label%3Ahelp_needed) +- I'd appreciate if you could solve [help_needed](https://github.com/Wox-launcher/Wox/issues?q=is%3Aopen+is%3Aissue+label%3Ahelp_needed) labeled issue - Don't hesitate to ask questions in the [issues](https://github.com/Wox-launcher/Wox/issues) # Docs From 05adf6f9070c2c8144a22b2dda834d4efe33727c Mon Sep 17 00:00:00 2001 From: bao-qian Date: Mon, 9 May 2016 22:10:20 +0100 Subject: [PATCH 07/12] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 49e1ccef2..01fb2e925 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,8 @@ Launcher for Windows, an alternative to [Alfred](https://www.alfredapp.com/) and - Use **pinyin** to search programs / 支持用 **拼音** 搜索程序 e.g. yyy / wangyiyun -> 网易云音乐 # Installation - -1. Latest stable version: [releases](https://github.com/Wox-launcher/Wox/releases). -2. Latest beta version: try **Pre-release** labeled release in [releases](https://github.com/Wox-launcher/Wox/releases) - +- Latest stable version: [releases](https://github.com/Wox-launcher/Wox/releases). +- Latest beta version: try **Pre-release** labeled release in [releases](https://github.com/Wox-launcher/Wox/releases) # Usage - Launch: Alt+Space From 21285f02b81620af10cc264dd035db77a99ac78b Mon Sep 17 00:00:00 2001 From: bao-qian Date: Mon, 9 May 2016 20:40:59 +0100 Subject: [PATCH 08/12] Refactoring updater 1. move into a separate class 2. remove unused nuget package --- Wox.Core/Updater.cs | 86 +++++++++++++++++++++++++++++++++++++++ Wox.Core/Wox.Core.csproj | 45 ++++++++++++++++++-- Wox.Core/packages.config | 5 ++- Wox/App.xaml.cs | 30 +------------- Wox/SettingWindow.xaml.cs | 83 +++---------------------------------- 5 files changed, 138 insertions(+), 111 deletions(-) create mode 100644 Wox.Core/Updater.cs diff --git a/Wox.Core/Updater.cs b/Wox.Core/Updater.cs new file mode 100644 index 000000000..77550c2e2 --- /dev/null +++ b/Wox.Core/Updater.cs @@ -0,0 +1,86 @@ +using System; +using System.Diagnostics; +using System.Net; +using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Squirrel; +using Wox.Core.UserSettings; +using Wox.Infrastructure.Http; +using Wox.Infrastructure.Logger; + +namespace Wox.Core +{ + public static class Updater + { + [Conditional("RELEASE")] + public static async void UpdateApp() + { + try + { + // todo 5/9 the return value of UpdateApp() is NULL, fucking useless! + using (var updater= await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github)) + { + await updater.UpdateApp(); + } + } + catch (WebException ex) + { + Log.Error(ex); + } + catch (Exception exception) + { + const string info = "Update.exe not found, not a Squirrel-installed app?"; + if (exception.Message == info) + { + Log.Warn(info); + } + else + { + throw; + } + } + } + + public static async Task NewVersion() + { + const string githubAPI = @"https://api.github.com/repos/wox-launcher/wox/releases/latest"; + var response = await HttpRequest.Get(githubAPI, HttpProxy.Instance); + + if (!string.IsNullOrEmpty(response)) + { + JContainer json; + try + { + json = (JContainer)JsonConvert.DeserializeObject(response); + } + catch (JsonSerializationException e) + { + Log.Error(e); + return string.Empty; + } + var version = json?["tag_name"]?.ToString(); + if (!string.IsNullOrEmpty(version)) + { + return version; + } + else + { + Log.Warn("Can't find tag_name from Github API response"); + return string.Empty; + } + } + else + { + Log.Warn("Can't get response from Github API"); + return string.Empty; + } + } + + public static int NumericVersion(string version) + { + var newVersion = version.Replace("v", ".").Replace(".", "").Replace("*", ""); + return int.Parse(newVersion); + } + } +} diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj index 92b58b27c..2ce8b4164 100644 --- a/Wox.Core/Wox.Core.csproj +++ b/Wox.Core/Wox.Core.csproj @@ -34,24 +34,60 @@ false - - ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll + + ..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.dll + True + + + ..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.MsDelta.dll + True + + + ..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.PatchApi.dll + True + + + ..\packages\squirrel.windows.1.4.0\lib\Net45\ICSharpCode.SharpZipLib.dll True ..\packages\JetBrains.Annotations.10.1.4\lib\net20\JetBrains.Annotations.dll True - - ..\packages\NAppUpdate.Framework.0.3.2.0\lib\net20\NAppUpdate.Framework.dll + + ..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll + True + + + ..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Mdb.dll + True + + + ..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Pdb.dll + True + + + ..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Rocks.dll True ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll True + + ..\packages\squirrel.windows.1.4.0\lib\Net45\NuGet.Squirrel.dll + True + + + ..\packages\Splat.1.6.2\lib\Net45\Splat.dll + True + + + ..\packages\squirrel.windows.1.4.0\lib\Net45\Squirrel.dll + True + @@ -66,6 +102,7 @@ + diff --git a/Wox.Core/packages.config b/Wox.Core/packages.config index 4061bf7b4..ebbc95d4a 100644 --- a/Wox.Core/packages.config +++ b/Wox.Core/packages.config @@ -1,8 +1,11 @@  + - + + + \ No newline at end of file diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index 2412eb3d9..c4eac247f 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -1,14 +1,12 @@ using System; using System.Diagnostics; -using System.Net; using System.Windows; -using Squirrel; +using Wox.Core; using Wox.Core.Plugin; using Wox.Helper; using Wox.Infrastructure.Image; using Wox.ViewModel; using Stopwatch = Wox.Infrastructure.Stopwatch; -using Wox.Infrastructure.Logger; namespace Wox { @@ -18,7 +16,6 @@ namespace Wox public static MainWindow Window { get; private set; } public static PublicAPIInstance API { get; private set; } private static bool _disposed; - public static UpdateManager Updater; [STAThread] public static void Main() @@ -56,29 +53,7 @@ namespace Wox private async void OnActivated(object sender, EventArgs e) { - try - { - using (Updater = await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github)) - { - await Updater.UpdateApp(); - } - } - catch (WebException ex) - { - Log.Error(ex); - } - catch (Exception exception) - { - const string info = "Update.exe not found, not a Squirrel-installed app?"; - if (exception.Message == info) - { - Log.Warn(info); - } - else - { - throw; - } - } + Updater.UpdateApp(); } private void RegisterExitEvents() @@ -123,7 +98,6 @@ namespace Wox if (!_disposed) { Save(); - Updater?.Dispose(); SingleInstance.Cleanup(); } } diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index 46d8128eb..95070080c 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -4,8 +4,6 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Net; -using System.Reflection; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -15,19 +13,15 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using Microsoft.Win32; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using NHotkey; using NHotkey.Wpf; -using Squirrel; +using Wox.Core; using Wox.Core.Plugin; using Wox.Core.Resource; using Wox.Core.UserSettings; using Wox.Helper; using Wox.Infrastructure.Hotkey; -using Wox.Infrastructure.Http; using Wox.Infrastructure.Image; -using Wox.Infrastructure.Logger; using Wox.Plugin; using Wox.ViewModel; using Application = System.Windows.Forms.Application; @@ -834,15 +828,6 @@ namespace Wox #endregion - #region About - - private void tbWebsite_MouseUp(object sender, MouseButtonEventArgs e) - { - Process.Start(Infrastructure.Wox.Github); - } - - #endregion - private void Window_PreviewKeyDown(object sender, KeyEventArgs e) { // Hide window with ESC, but make sure it is not pressed as a hotkey @@ -854,78 +839,20 @@ namespace Wox private async void OnCheckUpdates(object sender, RoutedEventArgs e) { - var version = await NewVersion(); + var version = await Updater.NewVersion(); if (!string.IsNullOrEmpty(version)) { - var newVersion = NumericVersion(version); - var oldVersion = NumericVersion(Infrastructure.Wox.Version); + var newVersion = Updater.NumericVersion(version); + var oldVersion = Updater.NumericVersion(Infrastructure.Wox.Version); if (newVersion > oldVersion) { NewVersionTips.Text = string.Format(NewVersionTips.Text, version); NewVersionTips.Visibility = Visibility.Visible; - UpdateApp(); + Updater.UpdateApp(); } } } - private async void UpdateApp() - { - try - { - using (var updater = await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github)) - { - // todo 5/9 the return value of UpdateApp() is NULL, fucking useless! - await updater.UpdateApp(); - } - } - catch (WebException ex) - { - Log.Error(ex); - } - catch (Exception ex) - { - Log.Error(ex); - } - } - private async Task NewVersion() - { - const string githubAPI = @"https://api.github.com/repos/wox-launcher/wox/releases/latest"; - var response = await HttpRequest.Get(githubAPI, HttpProxy.Instance); - - if (!string.IsNullOrEmpty(response)) - { - JContainer json; - try - { - json = (JContainer)JsonConvert.DeserializeObject(response); - } - catch (JsonSerializationException e) - { - Log.Error(e); - return string.Empty; - } - var version = json?["tag_name"]?.ToString(); - if (!string.IsNullOrEmpty(version)) - { - return version; - } - else - { - return string.Empty; - } - } - else - { - return string.Empty; - } - } - - private - int NumericVersion(string version) - { - var newVersion = version.Replace("v", ".").Replace(".", "").Replace("*", ""); - return int.Parse(newVersion); - } private void OnRequestNavigate(object sender, RequestNavigateEventArgs e) { Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); From fb3ba16a922a4347087624b2fc50ab91fd5719e9 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Mon, 9 May 2016 22:45:20 +0100 Subject: [PATCH 09/12] fix SingleInstance --- PreSolutionBuild/PreSolutionBuild.vcxproj | 87 ------------------- .../PreSolutionBuild.vcxproj.filters | 20 ----- PreSolutionBuild/readme.txt | 3 - Wox.sln | 28 ------ Wox/App.xaml.cs | 36 ++++---- Wox/Helper/ErrorReporting.cs | 3 +- Wox/Helper/SingleInstance.cs | 7 +- Wox/MainWindow.xaml.cs | 5 ++ Wox/PublicAPIInstance.cs | 7 +- Wox/SettingWindow.xaml.cs | 30 +++---- Wox/ViewModel/MainViewModel.cs | 19 +++- Wox/Wox.csproj | 3 +- 12 files changed, 56 insertions(+), 192 deletions(-) delete mode 100644 PreSolutionBuild/PreSolutionBuild.vcxproj delete mode 100644 PreSolutionBuild/PreSolutionBuild.vcxproj.filters delete mode 100644 PreSolutionBuild/readme.txt diff --git a/PreSolutionBuild/PreSolutionBuild.vcxproj b/PreSolutionBuild/PreSolutionBuild.vcxproj deleted file mode 100644 index f32f53970..000000000 --- a/PreSolutionBuild/PreSolutionBuild.vcxproj +++ /dev/null @@ -1,87 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {88731DA8-C020-476E-B79A-3ADEF65ACA9F} - MakeFileProj - 8.1 - - - - Makefile - true - v140 - - - Makefile - false - v140 - - - Makefile - true - v140 - - - Makefile - false - v140 - - - - - - - - - - - - - - - - - - - - - WIN32;_DEBUG;$(NMakePreprocessorDefinitions) - taskkill /f /fi "IMAGENAME eq Wox.exe" - - - WIN32;NDEBUG;$(NMakePreprocessorDefinitions) - taskkill /f /fi "IMAGENAME eq Wox.exe" - - - taskkill /f /fi "IMAGENAME eq Wox.exe" - - - taskkill /f /fi "IMAGENAME eq Wox.exe" - - - - - - - - - - \ No newline at end of file diff --git a/PreSolutionBuild/PreSolutionBuild.vcxproj.filters b/PreSolutionBuild/PreSolutionBuild.vcxproj.filters deleted file mode 100644 index 5ae9b65a1..000000000 --- a/PreSolutionBuild/PreSolutionBuild.vcxproj.filters +++ /dev/null @@ -1,20 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - \ No newline at end of file diff --git a/PreSolutionBuild/readme.txt b/PreSolutionBuild/readme.txt deleted file mode 100644 index c5ae5cc9d..000000000 --- a/PreSolutionBuild/readme.txt +++ /dev/null @@ -1,3 +0,0 @@ -This is project is just a workaround for pre solution level build event -See http://stackoverflow.com/a/2295583/2833083 -todo: we currently can only force close Wox, there should be a better way \ No newline at end of file diff --git a/Wox.sln b/Wox.sln index c16ef430e..3f8b41b45 100644 --- a/Wox.sln +++ b/Wox.sln @@ -6,13 +6,9 @@ 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} - {88731DA8-C020-476E-B79A-3ADEF65ACA9F} = {88731DA8-C020-476E-B79A-3ADEF65ACA9F} EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin", "Wox.Plugin\Wox.Plugin.csproj", "{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}" - ProjectSection(ProjectDependencies) = postProject - {88731DA8-C020-476E-B79A-3ADEF65ACA9F} = {88731DA8-C020-476E-B79A-3ADEF65ACA9F} - EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}" EndProject @@ -25,7 +21,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox", "Wox\Wox.csproj", "{D {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} - {88731DA8-C020-476E-B79A-3ADEF65ACA9F} = {88731DA8-C020-476E-B79A-3ADEF65ACA9F} {F35190AA-4758-4D9E-A193-E3BDF6AD3567} = {F35190AA-4758-4D9E-A193-E3BDF6AD3567} {FDED22C8-B637-42E8-824A-63B5B6E05A3A} = {FDED22C8-B637-42E8-824A-63B5B6E05A3A} {A3DCCBCA-ACC1-421D-B16E-210896234C26} = {A3DCCBCA-ACC1-421D-B16E-210896234C26} @@ -34,16 +29,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox", "Wox\Wox.csproj", "{D EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Infrastructure", "Wox.Infrastructure\Wox.Infrastructure.csproj", "{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}" - ProjectSection(ProjectDependencies) = postProject - {88731DA8-C020-476E-B79A-3ADEF65ACA9F} = {88731DA8-C020-476E-B79A-3ADEF65ACA9F} - EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.PluginManagement", "Plugins\Wox.Plugin.PluginManagement\Wox.Plugin.PluginManagement.csproj", "{049490F0-ECD2-4148-9B39-2135EC346EBE}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Core", "Wox.Core\Wox.Core.csproj", "{B749F0DB-8E75-47DB-9E5E-265D16D0C0D2}" - ProjectSection(ProjectDependencies) = postProject - {88731DA8-C020-476E-B79A-3ADEF65ACA9F} = {88731DA8-C020-476E-B79A-3ADEF65ACA9F} - EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Program", "Plugins\Wox.Plugin.Program\Wox.Plugin.Program.csproj", "{FDB3555B-58EF-4AE6-B5F1-904719637AB4}" EndProject @@ -66,9 +55,6 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Color", "Plugins\Wox.Plugin.Color\Wox.Plugin.Color.csproj", "{F35190AA-4758-4D9E-A193-E3BDF6AD3567}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.CrashReporter", "Wox.CrashReporter\Wox.CrashReporter.csproj", "{2FEB2298-7653-4009-B1EA-FFFB1A768BCC}" - ProjectSection(ProjectDependencies) = postProject - {88731DA8-C020-476E-B79A-3ADEF65ACA9F} = {88731DA8-C020-476E-B79A-3ADEF65ACA9F} - EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Everything", "Plugins\Wox.Plugin.Everything\Wox.Plugin.Everything.csproj", "{230AE83F-E92E-4E69-8355-426B305DA9C0}" EndProject @@ -83,8 +69,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution SolutionAssemblyInfo.cs = SolutionAssemblyInfo.cs EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PreSolutionBuild", "PreSolutionBuild\PreSolutionBuild.vcxproj", "{88731DA8-C020-476E-B79A-3ADEF65ACA9F}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorldCSharp", "Plugins\HelloWorldCSharp\HelloWorldCSharp.csproj", "{03FFA443-5F50-48D5-8869-F3DF316803AA}" EndProject Global @@ -314,18 +298,6 @@ Global {230AE83F-E92E-4E69-8355-426B305DA9C0}.Release|x64.Build.0 = Release|Any CPU {230AE83F-E92E-4E69-8355-426B305DA9C0}.Release|x86.ActiveCfg = Release|Any CPU {230AE83F-E92E-4E69-8355-426B305DA9C0}.Release|x86.Build.0 = Release|Any CPU - {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Debug|Any CPU.Build.0 = Debug|Win32 - {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Debug|x64.ActiveCfg = Debug|x64 - {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Debug|x64.Build.0 = Debug|x64 - {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Debug|x86.ActiveCfg = Debug|Win32 - {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Debug|x86.Build.0 = Debug|Win32 - {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|Any CPU.ActiveCfg = Release|x64 - {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|Any CPU.Build.0 = Release|x64 - {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|x64.ActiveCfg = Release|x64 - {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|x64.Build.0 = Release|x64 - {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|x86.ActiveCfg = Release|Win32 - {88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|x86.Build.0 = Release|Win32 {03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|Any CPU.Build.0 = Debug|Any CPU {03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|x64.ActiveCfg = Debug|Any CPU diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index c4eac247f..2021227c8 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -10,11 +10,10 @@ using Stopwatch = Wox.Infrastructure.Stopwatch; namespace Wox { - public partial class App : ISingleInstanceApp, IDisposable + public partial class App : IDisposable, ISingleInstanceApp { - private const string Unique = "Wox_Unique_Application_Mutex"; - public static MainWindow Window { get; private set; } public static PublicAPIInstance API { get; private set; } + private const string Unique = "Wox_Unique_Application_Mutex"; private static bool _disposed; [STAThread] @@ -44,10 +43,14 @@ namespace Wox API = new PublicAPIInstance(mainVM, mainVM._settings); PluginManager.InitializePlugins(API, pluginsSettings); - Window = new MainWindow(mainVM._settings, mainVM); var _notifyIconManager = new NotifyIconManager(API); + var window = new MainWindow(mainVM._settings, mainVM); RegisterExitEvents(); + + Current.MainWindow = window; + Current.MainWindow.Title = Infrastructure.Wox.Name; + window.Show(); }); } @@ -76,30 +79,21 @@ namespace Wox AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandle; } - public void OnActivate() - { - API.ShowApp(); - } - - private static void Save() - { - var vm = (MainViewModel)Window.DataContext; - vm.Save(); - PluginManager.Save(); - ImageLoader.Save(); - _disposed = true; - } - - public void Dispose() { // if sessionending is called, exit proverbially be called when log off / shutdown // but if sessionending is not called, exit won't be called when log off / shutdown if (!_disposed) { - Save(); - SingleInstance.Cleanup(); + var vm = (MainViewModel)Current.MainWindow.DataContext; + vm.Save(); + _disposed = true; } } + + public void OnSecondAppStarted() + { + API.ShowApp(); + } } } \ No newline at end of file diff --git a/Wox/Helper/ErrorReporting.cs b/Wox/Helper/ErrorReporting.cs index 560a35cf2..1bc9fb1ff 100644 --- a/Wox/Helper/ErrorReporting.cs +++ b/Wox/Helper/ErrorReporting.cs @@ -1,4 +1,5 @@ using System; +using System.Windows; using System.Windows.Threading; using Wox.Infrastructure.Exception; using Wox.Infrastructure.Logger; @@ -16,7 +17,7 @@ namespace Wox.Helper public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e) { //handle non-ui thread exceptions - App.Window.Dispatcher.Invoke(() => + Application.Current.MainWindow.Dispatcher.Invoke(() => { Report((Exception)e.ExceptionObject); if (!(e.ExceptionObject is WoxException)) diff --git a/Wox/Helper/SingleInstance.cs b/Wox/Helper/SingleInstance.cs index b26f59d7d..cdfb6c46f 100644 --- a/Wox/Helper/SingleInstance.cs +++ b/Wox/Helper/SingleInstance.cs @@ -186,7 +186,7 @@ namespace Wox.Helper public interface ISingleInstanceApp { - void OnActivate(); + void OnSecondAppStarted(); } /// @@ -416,7 +416,7 @@ namespace Wox.Helper return; } - ((TApplication)Application.Current).OnActivate(); + ((TApplication)Application.Current).OnSecondAppStarted(); } #endregion @@ -437,8 +437,7 @@ namespace Wox.Helper if (Application.Current != null) { // Do an asynchronous call to ActivateFirstInstance function - Application.Current.Dispatcher.BeginInvoke( - DispatcherPriority.Normal, new DispatcherOperationCallback(ActivateFirstInstanceCallback)); + Application.Current.Dispatcher.Invoke(ActivateFirstInstance); } } diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 4d94ef8d9..95b185d85 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -10,6 +10,7 @@ using Wox.Core.Resource; using Wox.Core.UserSettings; using Wox.Helper; using Wox.Infrastructure.Hotkey; +using Wox.Infrastructure.Logger; using Wox.ViewModel; using DataFormats = System.Windows.DataFormats; using DragEventArgs = System.Windows.DragEventArgs; @@ -42,8 +43,12 @@ namespace Wox { _settings.WindowLeft = Left; _settings.WindowTop = Top; + var vm = (MainViewModel) DataContext; + vm.Save(); } + + private void OnLoaded(object sender, RoutedEventArgs _) { InitProgressbarAnimation(); diff --git a/Wox/PublicAPIInstance.cs b/Wox/PublicAPIInstance.cs index c4626cba8..448a0dbba 100644 --- a/Wox/PublicAPIInstance.cs +++ b/Wox/PublicAPIInstance.cs @@ -63,16 +63,17 @@ namespace Wox public void CloseApp() { //notifyIcon.Visible = false; - Application.Current.Shutdown(); + Application.Current.MainWindow.Close(); } public void RestarApp() { HideWox(); - // we must force dispose application + // we must manually save // UpdateManager.RestartApp() will call Environment.Exit(0) // which will cause ungraceful exit - ((IDisposable) Application.Current).Dispose(); + var vm = (MainViewModel) Application.Current.MainWindow.DataContext; + vm.Save(); UpdateManager.RestartApp(); } diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index 95070080c..70a060470 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -7,7 +7,6 @@ using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Data; -using System.Windows.Forms; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; @@ -24,18 +23,11 @@ using Wox.Infrastructure.Hotkey; using Wox.Infrastructure.Image; using Wox.Plugin; using Wox.ViewModel; -using Application = System.Windows.Forms.Application; -using CheckBox = System.Windows.Controls.CheckBox; -using Control = System.Windows.Controls.Control; -using Cursors = System.Windows.Input.Cursors; -using HorizontalAlignment = System.Windows.HorizontalAlignment; -using KeyEventArgs = System.Windows.Input.KeyEventArgs; -using MessageBox = System.Windows.MessageBox; using Stopwatch = Wox.Infrastructure.Stopwatch; namespace Wox { - public partial class SettingWindow : Window + public partial class SettingWindow { public readonly IPublicAPI _api; bool settingsLoaded; @@ -227,7 +219,7 @@ namespace Wox RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) { - key.SetValue("Wox", "\"" + Application.ExecutablePath + "\" --hidestart"); + key.SetValue("Wox", "\"" + Infrastructure.Wox.ProgramPath + "\" --hidestart"); } } @@ -253,7 +245,7 @@ namespace Wox private void SelectPythonDirectoryOnClick(object sender, RoutedEventArgs e) { - var dlg = new FolderBrowserDialog + var dlg = new System.Windows.Forms.FolderBrowserDialog { SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) }; @@ -289,7 +281,7 @@ namespace Wox { SetHotkey(ctlHotkey.CurrentHotkey, delegate { - if (!App.Window.IsVisible) + if (!System.Windows.Application.Current.MainWindow.IsVisible) { _api.ShowApp(); } @@ -433,48 +425,48 @@ namespace Wox Title = "Wox is an effective launcher for windows", SubTitle = "Wox provide bundles of features let you access infomations quickly.", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) + PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) }, new Result { Title = "Search applications", SubTitle = "Search applications, files (via everything plugin) and browser bookmarks", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) + PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) }, new Result { Title = "Search web contents with shortcuts", SubTitle = "e.g. search google with g keyword or youtube keyword)", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) + PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) }, new Result { Title = "clipboard history ", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) + PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) }, new Result { Title = "Themes support", SubTitle = "get more themes from http://www.getwox.com/theme", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) + PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) }, new Result { Title = "Plugins support", SubTitle = "get more plugins from http://www.getwox.com/plugin", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) + PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) }, new Result { Title = "Wox is an open-source software", SubTitle = "Wox benefits from the open-source community a lot", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) + PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) } }); diff --git a/Wox/ViewModel/MainViewModel.cs b/Wox/ViewModel/MainViewModel.cs index 4a7978c6a..1f90bd8a3 100644 --- a/Wox/ViewModel/MainViewModel.cs +++ b/Wox/ViewModel/MainViewModel.cs @@ -11,6 +11,7 @@ using Wox.Core.UserSettings; using Wox.Helper; using Wox.Infrastructure; using Wox.Infrastructure.Hotkey; +using Wox.Infrastructure.Image; using Wox.Infrastructure.Storage; using Wox.Plugin; using Wox.Storage; @@ -47,6 +48,7 @@ namespace Wox.ViewModel private CancellationTokenSource _updateSource; private CancellationToken _updateToken; + private bool _saved; #endregion @@ -54,6 +56,7 @@ namespace Wox.ViewModel public MainViewModel() { + _saved = false; _queryTextBeforeLoadContextMenu = ""; _queryText = ""; _lastQuery = new Query(); @@ -592,10 +595,18 @@ namespace Wox.ViewModel public void Save() { - _settingsStorage.Save(); - _queryHistoryStorage.Save(); - _userSelectedRecordStorage.Save(); - _topMostRecordStorage.Save(); + if (!_saved) + { + _settingsStorage.Save(); + _queryHistoryStorage.Save(); + _userSelectedRecordStorage.Save(); + _topMostRecordStorage.Save(); + + PluginManager.Save(); + ImageLoader.Save(); + + _saved = true; + } } /// diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 9c7fe0001..8be8294cd 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -432,8 +432,7 @@ - - + taskkill /f /fi "IMAGENAME eq Wox.exe