diff --git a/Deploy/NAppUpdate/FeedBuilder.config b/Deploy/NAppUpdate/FeedBuilder.config
new file mode 100644
index 0000000000..f06954dd29
--- /dev/null
+++ b/Deploy/NAppUpdate/FeedBuilder.config
@@ -0,0 +1,18 @@
+
+
+
+ True
+ False
+ True
+ True
+ <?xml version="1.0" encoding="utf-16"?>
+<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
+ True
+ True
+ E:\github\Wox\Output\Debug
+ True
+ False
+ E:\github\Wox\Output\Update\Update.xml
+
+ http://127.0.0.1:8888
+
diff --git a/Deploy/NAppUpdate/FeedBuilder.exe b/Deploy/NAppUpdate/FeedBuilder.exe
new file mode 100644
index 0000000000..fae2128316
Binary files /dev/null and b/Deploy/NAppUpdate/FeedBuilder.exe differ
diff --git a/Deploy/NAppUpdate/FeedBuilder.exe.config b/Deploy/NAppUpdate/FeedBuilder.exe.config
new file mode 100644
index 0000000000..ae58790841
--- /dev/null
+++ b/Deploy/NAppUpdate/FeedBuilder.exe.config
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+
+
+ False
+
+
+ True
+
+
+ False
+
+
+ True
+
+
+ True
+
+
+
+
+
+ True
+
+
+
+
+ *.pdb
+ *.config
+
+
+
+
+ True
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Deploy/NAppUpdate/NAppUpdate.Framework.dll b/Deploy/NAppUpdate/NAppUpdate.Framework.dll
new file mode 100644
index 0000000000..60fac8ffc9
Binary files /dev/null and b/Deploy/NAppUpdate/NAppUpdate.Framework.dll differ
diff --git a/Deploy/NAppUpdate/build.bat b/Deploy/NAppUpdate/build.bat
new file mode 100644
index 0000000000..4cf7775756
--- /dev/null
+++ b/Deploy/NAppUpdate/build.bat
@@ -0,0 +1 @@
+FeedBuilder.exe "FeedBuilder.config" -Build
diff --git a/Deploy/NAppUpdate/gui.bat b/Deploy/NAppUpdate/gui.bat
new file mode 100644
index 0000000000..6c8eaf13e7
--- /dev/null
+++ b/Deploy/NAppUpdate/gui.bat
@@ -0,0 +1 @@
+FeedBuilder.exe "FeedBuilder.config" -ShowGUI
diff --git a/References/NAppUpdate.Framework.dll b/References/NAppUpdate.Framework.dll
new file mode 100644
index 0000000000..398d46b810
Binary files /dev/null and b/References/NAppUpdate.Framework.dll differ
diff --git a/Wox.Core/Updater/UpdaterManager.cs b/Wox.Core/Updater/UpdaterManager.cs
index 12daa7f8f3..431246b173 100644
--- a/Wox.Core/Updater/UpdaterManager.cs
+++ b/Wox.Core/Updater/UpdaterManager.cs
@@ -1,4 +1,11 @@
-using Squirrel;
+
+using System;
+using System.IO;
+using System.Windows.Forms;
+using System.Windows.Threading;
+using NAppUpdate.Framework;
+using NAppUpdate.Framework.Common;
+using NAppUpdate.Framework.Sources;
namespace Wox.Core.Updater
{
@@ -18,14 +25,82 @@ namespace Wox.Core.Updater
}
}
- private UpdaterManager() { }
+ private UpdaterManager()
+ {
+ UpdateManager.Instance.UpdateSource = GetUpdateSource();
+ }
public void CheckUpdate()
{
- using (var mgr = new UpdateManager("https://path/to/my/update/folder", "nuget-package-id", FrameworkVersion.Net45))
+ // Get a local pointer to the UpdateManager instance
+ UpdateManager updManager = UpdateManager.Instance;
+
+ updManager.BeginCheckForUpdates(asyncResult =>
{
- mgr.UpdateApp();
+ if (asyncResult.IsCompleted)
+ {
+ // still need to check for caught exceptions if any and rethrow
+ ((UpdateProcessAsyncResult)asyncResult).EndInvoke();
+
+ // No updates were found, or an error has occured. We might want to check that...
+ if (updManager.UpdatesAvailable == 0)
+ {
+ MessageBox.Show("All is up to date!");
+ return;
+ }
+ }
+
+ updManager.BeginPrepareUpdates(result =>
+ {
+ ((UpdateProcessAsyncResult)result).EndInvoke();
+
+ // ApplyUpdates is a synchronous method by design. Make sure to save all user work before calling
+ // it as it might restart your application
+ // get out of the way so the console window isn't obstructed
+ try
+ {
+ updManager.ApplyUpdates(true,false,true);
+ }
+ catch
+ {
+ // this.WindowState = WindowState.Normal;
+ MessageBox.Show(
+ "An error occurred while trying to install software updates");
+ }
+
+ updManager.CleanUp();
+ }, null);
+ }, null);
+ }
+
+ public void Reinstall()
+ {
+ UpdateManager.Instance.ReinstateIfRestarted();
+ }
+
+ private void OnPrepareUpdatesCompleted(bool obj)
+ {
+ UpdateManager updManager = UpdateManager.Instance;
+
+ DialogResult dr = MessageBox.Show(
+ "Updates are ready to install. Do you wish to install them now?",
+ "Software updates ready",
+ MessageBoxButtons.YesNo);
+
+ if (dr == DialogResult.Yes)
+ {
+ // This is a synchronous method by design, make sure to save all user work before calling
+ // it as it might restart your application
+ updManager.ApplyUpdates(true,true,true);
}
}
+
+ private IUpdateSource GetUpdateSource()
+ {
+ // Normally this would be a web based source.
+ // But for the demo app, we prepare an in-memory source.
+ var source = new NAppUpdate.Framework.Sources.SimpleWebSource("http://127.0.0.1:8888/Update.xml");
+ return source;
+ }
}
}
diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj
index 87cbaa4e5b..b9b40bb80a 100644
--- a/Wox.Core/Wox.Core.csproj
+++ b/Wox.Core/Wox.Core.csproj
@@ -39,6 +39,10 @@
False
..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll
+
+ False
+ ..\References\NAppUpdate.Framework.dll
+
False
..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll
@@ -65,6 +69,7 @@
+
diff --git a/Wox.UAC/App.xaml b/Wox.UAC/App.xaml
deleted file mode 100644
index 8404afa418..0000000000
--- a/Wox.UAC/App.xaml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
diff --git a/Wox.UAC/App.xaml.cs b/Wox.UAC/App.xaml.cs
deleted file mode 100644
index 0080eae232..0000000000
--- a/Wox.UAC/App.xaml.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Data;
-using System.Linq;
-using System.Windows;
-
-namespace Wox.UAC
-{
- ///
- /// App.xaml 的交互逻辑
- ///
- public partial class App : Application
- {
- }
-}
diff --git a/Wox.UAC/FileTypeAssociateInstaller.cs b/Wox.UAC/FileTypeAssociateInstaller.cs
deleted file mode 100644
index 8cea1d4682..0000000000
--- a/Wox.UAC/FileTypeAssociateInstaller.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Windows;
-using ICSharpCode.SharpZipLib.Zip;
-using Microsoft.Win32;
-using Newtonsoft.Json;
-using Wox.Plugin;
-
-namespace Wox.UAC
-{
- public class FileTypeAssociateInstaller
- {
- [DllImport("shell32.dll")]
- private static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
-
- ///
- /// associate filetype with specified program
- ///
- ///
- ///
- ///
- ///
- private static void SaveReg(string filePath, string fileType, string iconPath, bool overrides)
- {
- RegistryKey classRootKey = Registry.ClassesRoot.OpenSubKey("", true);
- RegistryKey woxKey = classRootKey.OpenSubKey(fileType, true);
- if (woxKey != null)
- {
- if (!overrides)
- {
- return;
- }
- classRootKey.DeleteSubKeyTree(fileType);
- }
- classRootKey.CreateSubKey(fileType);
- woxKey = classRootKey.OpenSubKey(fileType, true);
- woxKey.SetValue("", "wox.wox");
- woxKey.SetValue("Content Type", "application/wox");
-
- RegistryKey iconKey = woxKey.CreateSubKey("DefaultIcon");
- iconKey.SetValue("", iconPath);
-
- woxKey.CreateSubKey("shell");
- RegistryKey shellKey = woxKey.OpenSubKey("shell", true);
- shellKey.SetValue("", "Open");
- RegistryKey openKey = shellKey.CreateSubKey("open");
- openKey.SetValue("", "Open with wox");
-
- openKey = shellKey.OpenSubKey("open", true);
- openKey.CreateSubKey("command");
- RegistryKey commandKey = openKey.OpenSubKey("command", true);
- string pathString = "\"" + filePath + "\" \"installPlugin\" \"%1\"";
- commandKey.SetValue("", pathString);
-
- //refresh cache
- SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
- }
-
- public void RegisterInstaller()
- {
- string filePath = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Wox.exe");
- string iconPath = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "app.ico");
-
- SaveReg(filePath, ".wox", iconPath, true);
- }
-
- }
-}
diff --git a/Wox.UAC/MainWindow.xaml b/Wox.UAC/MainWindow.xaml
deleted file mode 100644
index 48db273c9f..0000000000
--- a/Wox.UAC/MainWindow.xaml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
diff --git a/Wox.UAC/MainWindow.xaml.cs b/Wox.UAC/MainWindow.xaml.cs
deleted file mode 100644
index bcf8e9780a..0000000000
--- a/Wox.UAC/MainWindow.xaml.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.Reflection;
-using System.Windows;
-
-namespace Wox.UAC
-{
- public partial class MainWindow : Window
- {
- FileTypeAssociateInstaller installer = new FileTypeAssociateInstaller();
-
- public MainWindow()
- {
- InitializeComponent();
- string[] param = Environment.GetCommandLineArgs();
- if (param.Length > 1)
- {
- switch (param[1])
- {
- case "AssociatePluginInstaller":
- installer.RegisterInstaller();
- break;
- }
- }
- Application.Current.Shutdown(0);
- }
- }
-}
diff --git a/Wox.UAC/Properties/AssemblyInfo.cs b/Wox.UAC/Properties/AssemblyInfo.cs
deleted file mode 100644
index 581039384f..0000000000
--- a/Wox.UAC/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System.Reflection;
-using System.Resources;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Windows;
-
-// 有关程序集的常规信息通过以下
-// 特性集控制。更改这些特性值可修改
-// 与程序集关联的信息。
-[assembly: AssemblyTitle("Wox.UAC")]
-[assembly: AssemblyDescription("https://github.com/qianlifeng/Wox")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Wox.UAC")]
-[assembly: AssemblyCopyright("The MIT License (MIT)")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 将 ComVisible 设置为 false 使此程序集中的类型
-// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
-// 则将该类型上的 ComVisible 特性设置为 true。
-[assembly: ComVisible(false)]
-
-//若要开始生成可本地化的应用程序,请在
-// 中的 .csproj 文件中
-//设置 CultureYouAreCodingWith。 例如,如果您在源文件中
-//使用的是美国英语,请将 设置为 en-US。 然后取消
-//对以下 NeutralResourceLanguage 特性的注释。 更新
-//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
-
-//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
-
-
-[assembly: ThemeInfo(
- ResourceDictionaryLocation.None, //主题特定资源词典所处位置
- //(在页面或应用程序资源词典中
- // 未找到某个资源的情况下使用)
- ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
- //(在页面、应用程序或任何主题特定资源词典中
- // 未找到某个资源的情况下使用)
-)]
-
-
-// 程序集的版本信息由下面四个值组成:
-//
-// 主版本
-// 次版本
-// 生成号
-// 修订号
-//
-// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
-// 方法是按如下所示使用“*”:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Wox.UAC/Properties/Resources.Designer.cs b/Wox.UAC/Properties/Resources.Designer.cs
deleted file mode 100644
index ae9d71cd4f..0000000000
--- a/Wox.UAC/Properties/Resources.Designer.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 此代码由工具生成。
-// 运行时版本: 4.0.30319.18408
-//
-// 对此文件的更改可能会导致不正确的行为,并且如果
-// 重新生成代码,这些更改将丢失。
-//
-//------------------------------------------------------------------------------
-
-namespace Wox.UAC.Properties
-{
-
-
- ///
- /// 一个强类型的资源类,用于查找本地化的字符串等。
- ///
- // 此类是由 StronglyTypedResourceBuilder
- // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
- // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
- // (以 /str 作为命令选项),或重新生成 VS 项目。
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources()
- {
- }
-
- ///
- /// 返回此类使用的、缓存的 ResourceManager 实例。
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ((resourceMan == null))
- {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Wox.UAC.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// 为所有资源查找重写当前线程的 CurrentUICulture 属性,
- /// 方法是使用此强类型资源类。
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
- return resourceCulture;
- }
- set
- {
- resourceCulture = value;
- }
- }
- }
-}
diff --git a/Wox.UAC/Properties/Resources.resx b/Wox.UAC/Properties/Resources.resx
deleted file mode 100644
index af7dbebbac..0000000000
--- a/Wox.UAC/Properties/Resources.resx
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/Wox.UAC/Properties/Settings.Designer.cs b/Wox.UAC/Properties/Settings.Designer.cs
deleted file mode 100644
index 6dbc8f74b1..0000000000
--- a/Wox.UAC/Properties/Settings.Designer.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.18408
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace Wox.UAC.Properties
-{
-
-
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
- {
-
- private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
- public static Settings Default
- {
- get
- {
- return defaultInstance;
- }
- }
- }
-}
diff --git a/Wox.UAC/Properties/Settings.settings b/Wox.UAC/Properties/Settings.settings
deleted file mode 100644
index 033d7a5e9e..0000000000
--- a/Wox.UAC/Properties/Settings.settings
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Wox.UAC/Wox.UAC.csproj b/Wox.UAC/Wox.UAC.csproj
deleted file mode 100644
index a69735aec0..0000000000
--- a/Wox.UAC/Wox.UAC.csproj
+++ /dev/null
@@ -1,143 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {C9BC17A0-C2BC-4185-AC1F-32E3352C1233}
- WinExe
- Properties
- Wox.UAC
- Wox.UAC
- v3.5
- 512
- {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 4
- ..\
- true
-
-
- AnyCPU
- true
- full
- false
- ..\Output\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- ..\Output\Release\
- TRACE
- prompt
- 4
-
-
- app.ico
-
-
- app.manifest
-
-
-
- False
- ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll
-
-
- ..\packages\log4net.2.0.3\lib\net35-full\log4net.dll
-
-
- ..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- App.xaml
- Code
-
-
- MainWindow.xaml
- Code
-
-
-
-
-
- Code
-
-
- True
- True
- Resources.resx
-
-
- True
- Settings.settings
- True
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
-
-
-
- {4fd29318-a8ab-4d8f-aa47-60bc241b8da3}
- Wox.Infrastructure
-
-
- {8451ecdd-2ea4-4966-bb0a-7bbc40138e80}
- Wox.Plugin
-
-
-
-
-
-
-
-
-
-
-
-
-
- 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
-
-
-
-
-
\ No newline at end of file
diff --git a/Wox.UAC/app.ico b/Wox.UAC/app.ico
deleted file mode 100644
index 8e914ac566..0000000000
Binary files a/Wox.UAC/app.ico and /dev/null differ
diff --git a/Wox.UAC/app.manifest b/Wox.UAC/app.manifest
deleted file mode 100644
index 4d02a83439..0000000000
--- a/Wox.UAC/app.manifest
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Wox.UAC/packages.config b/Wox.UAC/packages.config
deleted file mode 100644
index ca19dcd7d4..0000000000
--- a/Wox.UAC/packages.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs
index e80c981372..901c7765b6 100644
--- a/Wox/MainWindow.xaml.cs
+++ b/Wox/MainWindow.xaml.cs
@@ -17,6 +17,7 @@ using NHotkey.Wpf;
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;
@@ -264,6 +265,7 @@ namespace Wox
HwndSource.FromHwnd(new WindowInteropHelper(this).Handle).CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);
WindowIntelopHelper.DisableControlBox(this);
+ UpdaterManager.Instance.CheckUpdate();
}
public void SetHotkey(string hotkeyStr, EventHandler action)
diff --git a/src/NAppUpdate.Framework/Updater/updater.exe b/src/NAppUpdate.Framework/Updater/updater.exe
new file mode 100644
index 0000000000..9451958fc4
--- /dev/null
+++ b/src/NAppUpdate.Framework/Updater/updater.exe
@@ -0,0 +1 @@
+This is a dummy file