Add upgrade dialog

This commit is contained in:
qianlifeng 2015-02-01 22:46:56 +08:00
parent 691cf1ce72
commit 5ef72b81ae
14 changed files with 507 additions and 266 deletions

View File

@ -7,5 +7,10 @@
public string download_link1 { get; set; }
public string download_link2 { get; set; }
public string description { get; set; }
public override string ToString()
{
return version;
}
}
}

View File

@ -1,11 +1,15 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Windows.Forms;
using System.Windows.Threading;
using NAppUpdate.Framework;
using NAppUpdate.Framework.Common;
using NAppUpdate.Framework.Sources;
using NAppUpdate.Framework.Tasks;
using Newtonsoft.Json;
using Wox.Core.i18n;
using Wox.Core.UserSettings;
@ -18,9 +22,15 @@ namespace Wox.Core.Updater
{
private static UpdaterManager instance;
private const string VersionCheckURL = "https://api.getwox.com/release/latest/";
private const string UpdateFeedURL = "http://upgrade.getwox.com/update.xml";
//private const string UpdateFeedURL = "http://upgrade.getwox.com/update.xml";
private const string UpdateFeedURL = "http://127.0.0.1:8888/update.xml";
private static SemanticVersion currentVersion;
public event EventHandler PrepareUpdateReady;
public event EventHandler UpdateError;
public Release NewRelease { get; set; }
public static UpdaterManager Instance
{
get
@ -57,6 +67,19 @@ namespace Wox.Core.Updater
return new SemanticVersion(release.version) > CurrentVersion;
}
public List<string> GetAvailableUpdateFiles()
{
List<string> files = new List<string>();
foreach (var task in UpdateManager.Instance.Tasks)
{
if (task is FileUpdateTask)
{
files.Add(((FileUpdateTask)task).LocalPath);
}
}
return files;
}
public void CheckUpdate()
{
string json = HttpRequest.Get(VersionCheckURL, HttpProxy.Instance);
@ -64,14 +87,15 @@ namespace Wox.Core.Updater
{
try
{
Release newRelease = JsonConvert.DeserializeObject<Release>(json);
if (IsNewerThanCurrent(newRelease))
NewRelease = JsonConvert.DeserializeObject<Release>(json);
if (IsNewerThanCurrent(NewRelease) && !UserSettingStorage.Instance.DontPromptUpdateMsg)
{
StartUpdate();
}
}
catch
catch (System.Exception e)
{
Log.Error(e);
}
}
}
@ -105,45 +129,52 @@ namespace Wox.Core.Updater
updManager.BeginPrepareUpdates(result =>
{
((UpdateProcessAsyncResult)result).EndInvoke();
string updateReady = InternationalizationManager.Instance.GetTranslation("update_wox_update_ready");
string updateInstall = InternationalizationManager.Instance.GetTranslation("update_wox_update_install");
updateInstall = string.Format(updateInstall, updManager.UpdatesAvailable);
DialogResult dr = MessageBox.Show(updateInstall, updateReady, MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
// 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, UserSettingStorage.Instance.EnableUpdateLog, false);
}
catch (System.Exception e)
{
string updateError =
InternationalizationManager.Instance.GetTranslation("update_wox_update_error");
Log.Error(e);
MessageBox.Show(updateError);
}
updManager.CleanUp();
}
else
{
updManager.CleanUp();
}
OnPrepareUpdateReady();
}, null);
}, null);
}
public void CleanUp()
{
UpdateManager.Instance.CleanUp();
}
public void ApplyUpdates()
{
// 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
{
UpdateManager.Instance.ApplyUpdates(true, UserSettingStorage.Instance.EnableUpdateLog, false);
}
catch (System.Exception e)
{
string updateError = InternationalizationManager.Instance.GetTranslation("update_wox_update_error");
Log.Error(e);
MessageBox.Show(updateError);
OnUpdateError();
}
UpdateManager.Instance.CleanUp();
}
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 SimpleWebSource(UpdateFeedURL);
var source = new WoxUpdateSource(UpdateFeedURL, HttpRequest.GetWebProxy(HttpProxy.Instance));
return source;
}
protected virtual void OnPrepareUpdateReady()
{
var handler = PrepareUpdateReady;
if (handler != null) handler(this, EventArgs.Empty);
}
protected virtual void OnUpdateError()
{
var handler = UpdateError;
if (handler != null) handler(this, EventArgs.Empty);
}
}
}

View File

@ -0,0 +1,68 @@
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;
namespace Wox.Core.Updater
{
internal class WoxUpdateSource : IUpdateSource
{
public IWebProxy Proxy { get; set; }
public string FeedUrl { get; set; }
public WoxUpdateSource(string feedUrl,IWebProxy proxy)
{
this.FeedUrl = feedUrl;
this.Proxy = proxy;
}
private void TryResolvingHost()
{
Uri uri = new Uri(this.FeedUrl);
try
{
Dns.GetHostEntry(uri.Host);
}
catch (System.Exception ex)
{
throw new WebException(string.Format("Failed to resolve {0}. Check your connectivity.", (object)uri.Host), WebExceptionStatus.ConnectFailure);
}
}
public string GetUpdatesFeed()
{
this.TryResolvingHost();
string str = string.Empty;
WebRequest webRequest = WebRequest.Create(this.FeedUrl);
webRequest.Method = "GET";
webRequest.Proxy = this.Proxy;
using (WebResponse response = webRequest.GetResponse())
{
Stream responseStream = response.GetResponseStream();
if (responseStream != null)
{
using (StreamReader streamReader = new StreamReader(responseStream, true))
str = streamReader.ReadToEnd();
}
}
return str;
}
public bool GetData(string url, string baseUrl, Action<UpdateProgressInfo> onProgress, ref string tempLocation)
{
if (!string.IsNullOrEmpty(baseUrl) && !baseUrl.EndsWith("/"))
baseUrl += "/";
FileDownloader fileDownloader = !Uri.IsWellFormedUriString(url, UriKind.Absolute) ? (!Uri.IsWellFormedUriString(baseUrl, UriKind.Absolute) ? (string.IsNullOrEmpty(baseUrl) ? new FileDownloader(url) : new FileDownloader(new Uri(new Uri(baseUrl), url))) : new FileDownloader(new Uri(new Uri(baseUrl, UriKind.Absolute), url))) : new FileDownloader(url);
fileDownloader.Proxy = this.Proxy;
if (string.IsNullOrEmpty(tempLocation) || !Directory.Exists(Path.GetDirectoryName(tempLocation)))
tempLocation = Path.GetTempFileName();
return fileDownloader.DownloadToFile(tempLocation, onProgress);
}
}
}

View File

@ -71,6 +71,7 @@
<Compile Include="Exception\WoxPluginException.cs" />
<Compile Include="Updater\Release.cs" />
<Compile Include="Updater\UpdaterManager.cs" />
<Compile Include="Updater\WoxUpdateSource.cs" />
<Compile Include="UserSettings\HttpProxy.cs" />
<Compile Include="i18n\AvailableLanguages.cs" />
<Compile Include="i18n\IInternationalization.cs" />

View File

@ -14,6 +14,24 @@ namespace Wox.Infrastructure.Http
return Get(url, encoding, proxy);
}
public static WebProxy GetWebProxy(IHttpProxy proxy)
{
if (proxy != null && proxy.Enabled && !string.IsNullOrEmpty(proxy.Server))
{
if (string.IsNullOrEmpty(proxy.UserName) || string.IsNullOrEmpty(proxy.Password))
{
return new WebProxy(proxy.Server, proxy.Port);
}
return new WebProxy(proxy.Server, proxy.Port)
{
Credentials = new NetworkCredential(proxy.UserName, proxy.Password)
};
}
return null;
}
private static string Get(string url, string encoding, IHttpProxy proxy)
{
if (string.IsNullOrEmpty(url)) return string.Empty;
@ -21,20 +39,7 @@ namespace Wox.Infrastructure.Http
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = "GET";
request.Timeout = 10 * 1000;
if (proxy != null && proxy.Enabled && !string.IsNullOrEmpty(proxy.Server))
{
if (string.IsNullOrEmpty(proxy.UserName) || string.IsNullOrEmpty(proxy.Password))
{
request.Proxy = new WebProxy(proxy.Server, proxy.Port);
}
else
{
request.Proxy = new WebProxy(proxy.Server, proxy.Port)
{
Credentials = new NetworkCredential(proxy.UserName, proxy.Password)
};
}
}
request.Proxy = GetWebProxy(proxy);
try
{

BIN
Wox/Images/update.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -103,8 +103,14 @@
<system:String x:Key="reportWindow_wox_got_an_error">Wox got an error</system:String>
<!--update-->
<system:String x:Key="update_wox_update_ready">Wox updates available</system:String>
<system:String x:Key="update_wox_update_install">Wox updates are ready to install. {0} files will be added and replaced, this operation may restart Wox. Do you wish to install them now?</system:String>
<system:String x:Key="update_wox_update_new_version_available">Wox new version V{0} is available</system:String>
<system:String x:Key="update_wox_update_error">An error occurred while trying to install software updates</system:String>
<system:String x:Key="update_wox_update">Update</system:String>
<system:String x:Key="update_wox_update_cancel">Cancel</system:String>
<system:String x:Key="update_wox_update_restart_wox_tip">This upgrade will restart Wox</system:String>
<system:String x:Key="update_wox_update_upadte_files">Following files will be updated</system:String>
<system:String x:Key="update_wox_update_files">Update files</system:String>
<system:String x:Key="update_wox_update_upadte_description">Update description</system:String>
</ResourceDictionary>

View File

@ -1,108 +1,114 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--主窗体-->
<system:String x:Key="registerHotkeyFailed">注册热键:{0} 失败</system:String>
<system:String x:Key="couldnotStartCmd">启动命令 {0} 失败</system:String>
<system:String x:Key="invalidWoxPluginFileFormat">不是合法的Wox插件格式</system:String>
<!--设置,通用-->
<system:String x:Key="woxsettings">Wox设置</system:String>
<system:String x:Key="general">通用</system:String>
<system:String x:Key="startWoxOnSystemStartup">开机启动</system:String>
<system:String x:Key="hideWoxWhenLoseFocus">失去焦点时自动隐藏Wox</system:String>
<system:String x:Key="dontPromptUpdateMsg">不显示新版本提示</system:String>
<system:String x:Key="language">语言</system:String>
<!--设置,插件-->
<system:String x:Key="plugin">插件</system:String>
<system:String x:Key="browserMorePlugins">浏览更多插件</system:String>
<system:String x:Key="disable">禁用</system:String>
<system:String x:Key="actionKeyword">触发关键字</system:String>
<system:String x:Key="pluginDirectory">插件目录</system:String>
<system:String x:Key="author">作者</system:String>
<!--设置,主题-->
<system:String x:Key="theme">主题</system:String>
<system:String x:Key="browserMoreThemes">浏览更多主题</system:String>
<system:String x:Key="helloWox">你好Wox</system:String>
<system:String x:Key="queryBoxFont">查询框字体</system:String>
<system:String x:Key="resultItemFont">结果项字体</system:String>
<system:String x:Key="windowMode">窗口模式</system:String>
<system:String x:Key="opacity">透明度</system:String>
<!--设置,热键-->
<system:String x:Key="hotkey">热键</system:String>
<system:String x:Key="woxHotkey">Wox激活热键</system:String>
<system:String x:Key="customQueryHotkey">自定义查询热键</system:String>
<system:String x:Key="delete">删除</system:String>
<system:String x:Key="edit">编辑</system:String>
<system:String x:Key="add">增加</system:String>
<system:String x:Key="pleaseSelectAnItem">请选择一项</system:String>
<system:String x:Key="deleteCustomHotkeyWarning">你确定要删除插件 {0} 的热键吗?</system:String>
<!--设置,代理-->
<system:String x:Key="proxy">代理</system:String>
<system:String x:Key="enableProxy">启用代理</system:String>
<system:String x:Key="server">服务器</system:String>
<system:String x:Key="port">端口</system:String>
<system:String x:Key="userName">用户名</system:String>
<system:String x:Key="password">密码</system:String>
<system:String x:Key="testProxy">测试代理</system:String>
<system:String x:Key="save">保存</system:String>
<system:String x:Key="serverCantBeEmpty">服务器不能为空</system:String>
<system:String x:Key="portCantBeEmpty">端口不能为空</system:String>
<system:String x:Key="invalidPortFormat">非法的端口格式</system:String>
<system:String x:Key="saveProxySuccessfully">保存代理设置成功</system:String>
<system:String x:Key="proxyIsCorrect">代理设置正确</system:String>
<system:String x:Key="proxyConnectFailed">代理连接失败</system:String>
<!--设置,版本-->
<system:String x:Key="about">关于</system:String>
<system:String x:Key="website">网站</system:String>
<system:String x:Key="version">版本</system:String>
<system:String x:Key="about_activate_times">你已经激活了Wox {0} 次</system:String>
<!--Action Keyword 设置对话框-->
<system:String x:Key="oldActionKeyword">旧触发关键字</system:String>
<system:String x:Key="newActionKeyword">新触发关键字</system:String>
<system:String x:Key="cancel">取消</system:String>
<system:String x:Key="done">确定</system:String>
<system:String x:Key="cannotFindSpecifiedPlugin">找不到指定的插件</system:String>
<system:String x:Key="newActionKeywordCannotBeEmpty">新触发关键字不能为空</system:String>
<system:String x:Key="newActionKeywordHasBeenAssigned">新触发关键字已经被指派给其他插件了,请重新选择一个关键字</system:String>
<system:String x:Key="succeed">成功</system:String>
<system:String x:Key="actionkeyword_tips">如果你不想设置触发关键字,可以使用*代替</system:String>
<!--Custom Query Hotkey 对话框-->
<system:String x:Key="preview">预览</system:String>
<system:String x:Key="hotkeyIsNotUnavailable">热键不可用,请选择一个新的热键</system:String>
<system:String x:Key="invalidPluginHotkey">插件热键不合法</system:String>
<system:String x:Key="update">更新</system:String>
<!--Hotkey 控件-->
<system:String x:Key="hotkeyUnavailable">热键不可用</system:String>
<!--崩溃报告窗体-->
<system:String x:Key="reportWindow_version">版本</system:String>
<system:String x:Key="reportWindow_time">时间</system:String>
<system:String x:Key="reportWindow_reproduce">请告诉我们如何重现此问题,以便我们进行修复</system:String>
<system:String x:Key="reportWindow_send_report">发送报告</system:String>
<system:String x:Key="reportWindow_cancel">取消</system:String>
<system:String x:Key="reportWindow_general">基本信息</system:String>
<system:String x:Key="reportWindow_exceptions">异常信息</system:String>
<system:String x:Key="reportWindow_exception_type">异常类型</system:String>
<system:String x:Key="reportWindow_source">异常源</system:String>
<system:String x:Key="reportWindow_stack_trace">堆栈信息</system:String>
<system:String x:Key="reportWindow_sending">发送中</system:String>
<system:String x:Key="reportWindow_report_succeed">发送成功</system:String>
<system:String x:Key="reportWindow_report_failed">发送失败</system:String>
<system:String x:Key="reportWindow_wox_got_an_error">Wox出错啦</system:String>
<!--更新-->
<system:String x:Key="update_wox_update_ready">Wox更新</system:String>
<system:String x:Key="update_wox_update_install">Wox更新啦{0}个文件会被添加和替换并且在此过程中可能会重启Wox。你确定需要更新吗</system:String>
<system:String x:Key="update_wox_update_error">更新Wox出错</system:String>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--主窗体-->
<system:String x:Key="registerHotkeyFailed">注册热键:{0} 失败</system:String>
<system:String x:Key="couldnotStartCmd">启动命令 {0} 失败</system:String>
<system:String x:Key="invalidWoxPluginFileFormat">不是合法的Wox插件格式</system:String>
<!--设置,通用-->
<system:String x:Key="woxsettings">Wox设置</system:String>
<system:String x:Key="general">通用</system:String>
<system:String x:Key="startWoxOnSystemStartup">开机启动</system:String>
<system:String x:Key="hideWoxWhenLoseFocus">失去焦点时自动隐藏Wox</system:String>
<system:String x:Key="dontPromptUpdateMsg">不显示新版本提示</system:String>
<system:String x:Key="language">语言</system:String>
<!--设置,插件-->
<system:String x:Key="plugin">插件</system:String>
<system:String x:Key="browserMorePlugins">浏览更多插件</system:String>
<system:String x:Key="disable">禁用</system:String>
<system:String x:Key="actionKeyword">触发关键字</system:String>
<system:String x:Key="pluginDirectory">插件目录</system:String>
<system:String x:Key="author">作者</system:String>
<!--设置,主题-->
<system:String x:Key="theme">主题</system:String>
<system:String x:Key="browserMoreThemes">浏览更多主题</system:String>
<system:String x:Key="helloWox">你好Wox</system:String>
<system:String x:Key="queryBoxFont">查询框字体</system:String>
<system:String x:Key="resultItemFont">结果项字体</system:String>
<system:String x:Key="windowMode">窗口模式</system:String>
<system:String x:Key="opacity">透明度</system:String>
<!--设置,热键-->
<system:String x:Key="hotkey">热键</system:String>
<system:String x:Key="woxHotkey">Wox激活热键</system:String>
<system:String x:Key="customQueryHotkey">自定义查询热键</system:String>
<system:String x:Key="delete">删除</system:String>
<system:String x:Key="edit">编辑</system:String>
<system:String x:Key="add">增加</system:String>
<system:String x:Key="pleaseSelectAnItem">请选择一项</system:String>
<system:String x:Key="deleteCustomHotkeyWarning">你确定要删除插件 {0} 的热键吗?</system:String>
<!--设置,代理-->
<system:String x:Key="proxy">代理</system:String>
<system:String x:Key="enableProxy">启用代理</system:String>
<system:String x:Key="server">服务器</system:String>
<system:String x:Key="port">端口</system:String>
<system:String x:Key="userName">用户名</system:String>
<system:String x:Key="password">密码</system:String>
<system:String x:Key="testProxy">测试代理</system:String>
<system:String x:Key="save">保存</system:String>
<system:String x:Key="serverCantBeEmpty">服务器不能为空</system:String>
<system:String x:Key="portCantBeEmpty">端口不能为空</system:String>
<system:String x:Key="invalidPortFormat">非法的端口格式</system:String>
<system:String x:Key="saveProxySuccessfully">保存代理设置成功</system:String>
<system:String x:Key="proxyIsCorrect">代理设置正确</system:String>
<system:String x:Key="proxyConnectFailed">代理连接失败</system:String>
<!--设置,版本-->
<system:String x:Key="about">关于</system:String>
<system:String x:Key="website">网站</system:String>
<system:String x:Key="version">版本</system:String>
<system:String x:Key="about_activate_times">你已经激活了Wox {0} 次</system:String>
<!--Action Keyword 设置对话框-->
<system:String x:Key="oldActionKeyword">旧触发关键字</system:String>
<system:String x:Key="newActionKeyword">新触发关键字</system:String>
<system:String x:Key="cancel">取消</system:String>
<system:String x:Key="done">确定</system:String>
<system:String x:Key="cannotFindSpecifiedPlugin">找不到指定的插件</system:String>
<system:String x:Key="newActionKeywordCannotBeEmpty">新触发关键字不能为空</system:String>
<system:String x:Key="newActionKeywordHasBeenAssigned">新触发关键字已经被指派给其他插件了,请重新选择一个关键字</system:String>
<system:String x:Key="succeed">成功</system:String>
<system:String x:Key="actionkeyword_tips">如果你不想设置触发关键字,可以使用*代替</system:String>
<!--Custom Query Hotkey 对话框-->
<system:String x:Key="preview">预览</system:String>
<system:String x:Key="hotkeyIsNotUnavailable">热键不可用,请选择一个新的热键</system:String>
<system:String x:Key="invalidPluginHotkey">插件热键不合法</system:String>
<system:String x:Key="update">更新</system:String>
<!--Hotkey 控件-->
<system:String x:Key="hotkeyUnavailable">热键不可用</system:String>
<!--崩溃报告窗体-->
<system:String x:Key="reportWindow_version">版本</system:String>
<system:String x:Key="reportWindow_time">时间</system:String>
<system:String x:Key="reportWindow_reproduce">请告诉我们如何重现此问题,以便我们进行修复</system:String>
<system:String x:Key="reportWindow_send_report">发送报告</system:String>
<system:String x:Key="reportWindow_cancel">取消</system:String>
<system:String x:Key="reportWindow_general">基本信息</system:String>
<system:String x:Key="reportWindow_exceptions">异常信息</system:String>
<system:String x:Key="reportWindow_exception_type">异常类型</system:String>
<system:String x:Key="reportWindow_source">异常源</system:String>
<system:String x:Key="reportWindow_stack_trace">堆栈信息</system:String>
<system:String x:Key="reportWindow_sending">发送中</system:String>
<system:String x:Key="reportWindow_report_succeed">发送成功</system:String>
<system:String x:Key="reportWindow_report_failed">发送失败</system:String>
<system:String x:Key="reportWindow_wox_got_an_error">Wox出错啦</system:String>
<!--更新-->
<system:String x:Key="update_wox_update_new_version_available">发现Wox新版本 V{0}</system:String>
<system:String x:Key="update_wox_update_error">更新Wox出错</system:String>
<system:String x:Key="update_wox_update">更新</system:String>
<system:String x:Key="update_wox_update_cancel">取消</system:String>
<system:String x:Key="update_wox_update_restart_wox_tip">此更新需要重启Wox</system:String>
<system:String x:Key="update_wox_update_upadte_files">下列文件会被更新</system:String>
<system:String x:Key="update_wox_update_files">更新文件</system:String>
<system:String x:Key="update_wox_update_upadte_description">更新日志</system:String>
</ResourceDictionary>

View File

@ -1,108 +1,113 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--主窗體-->
<system:String x:Key="registerHotkeyFailed">註冊熱鍵:{0} 失敗</system:String>
<system:String x:Key="couldnotStartCmd">啟動命令 {0} 失敗</system:String>
<system:String x:Key="invalidWoxPluginFileFormat">不是合法的Wox插件格式</system:String>
<!--設置,通用-->
<system:String x:Key="woxsettings">Wox設置</system:String>
<system:String x:Key="general">通用</system:String>
<system:String x:Key="startWoxOnSystemStartup">開機啟動</system:String>
<system:String x:Key="hideWoxWhenLoseFocus">失去焦點時自動隱藏Wox</system:String>
<system:String x:Key="dontPromptUpdateMsg">不顯示新版本提示</system:String>
<system:String x:Key="language">語言</system:String>
<!--設置,插件-->
<system:String x:Key="plugin">插件</system:String>
<system:String x:Key="browserMorePlugins">瀏覽更多插件</system:String>
<system:String x:Key="disable">禁用</system:String>
<system:String x:Key="actionKeyword">觸發關鍵字</system:String>
<system:String x:Key="pluginDirectory">插件目錄</system:String>
<system:String x:Key="author">作者</system:String>
<!--設置,主題-->
<system:String x:Key="theme">主題</system:String>
<system:String x:Key="browserMoreThemes">瀏覽更多主題</system:String>
<system:String x:Key="helloWox">你好Wox</system:String>
<system:String x:Key="queryBoxFont">查詢框字體</system:String>
<system:String x:Key="resultItemFont">結果項字體</system:String>
<system:String x:Key="windowMode">窗口模式</system:String>
<system:String x:Key="opacity">透明度</system:String>
<!--設置,熱鍵-->
<system:String x:Key="hotkey">熱鍵</system:String>
<system:String x:Key="woxHotkey">Wox激活熱鍵</system:String>
<system:String x:Key="customQueryHotkey">自定義查詢熱鍵</system:String>
<system:String x:Key="delete">刪除</system:String>
<system:String x:Key="edit">編輯</system:String>
<system:String x:Key="add">增加</system:String>
<system:String x:Key="pleaseSelectAnItem">請選擇一項</system:String>
<system:String x:Key="deleteCustomHotkeyWarning">你確定要刪除插件 {0} 的熱鍵嗎?</system:String>
<!--設置,代理-->
<system:String x:Key="proxy">代理</system:String>
<system:String x:Key="enableProxy">啟用代理</system:String>
<system:String x:Key="server">服務器</system:String>
<system:String x:Key="port">端口</system:String>
<system:String x:Key="userName">用戶名</system:String>
<system:String x:Key="password">密碼</system:String>
<system:String x:Key="testProxy">測試代理</system:String>
<system:String x:Key="save">保存</system:String>
<system:String x:Key="serverCantBeEmpty">服務器不能為空</system:String>
<system:String x:Key="portCantBeEmpty">端口不能為空</system:String>
<system:String x:Key="invalidPortFormat">非法的端口格式</system:String>
<system:String x:Key="saveProxySuccessfully">保存代理設置成功</system:String>
<system:String x:Key="proxyIsCorrect">代理設置正確</system:String>
<system:String x:Key="proxyConnectFailed">代理連接失敗</system:String>
<!--設置,版本-->
<system:String x:Key="about">關於</system:String>
<system:String x:Key="website">網站</system:String>
<system:String x:Key="version">版本</system:String>
<system:String x:Key="about_activate_times">你已經激活了Wox {0} 次</system:String>
<!--Action Keyword 設置對話框-->
<system:String x:Key="oldActionKeyword">舊觸發關鍵字</system:String>
<system:String x:Key="newActionKeyword">新觸發關鍵字</system:String>
<system:String x:Key="cancel">取消</system:String>
<system:String x:Key="done">確定</system:String>
<system:String x:Key="cannotFindSpecifiedPlugin">找不到指定的插件</system:String>
<system:String x:Key="newActionKeywordCannotBeEmpty">新觸發關鍵字不能為空</system:String>
<system:String x:Key="newActionKeywordHasBeenAssigned">新觸發關鍵字已經被指派給其他插件了,請重新選擇一個關鍵字</system:String>
<system:String x:Key="succeed">成功</system:String>
<system:String x:Key="actionkeyword_tips">如果你不想設置觸發關鍵字,可以使用*代替</system:String>
<!--Custom Query Hotkey 對話框-->
<system:String x:Key="preview">預覽</system:String>
<system:String x:Key="hotkeyIsNotUnavailable">熱鍵不可用,請選擇一個新的熱鍵</system:String>
<system:String x:Key="invalidPluginHotkey">插件熱鍵不合法</system:String>
<system:String x:Key="update">更新</system:String>
<!--Hotkey 控件-->
<system:String x:Key="hotkeyUnavailable">熱鍵不可用</system:String>
<!--崩潰報告窗體-->
<system:String x:Key="reportWindow_version">版本</system:String>
<system:String x:Key="reportWindow_time">時間</system:String>
<system:String x:Key="reportWindow_reproduce">請告訴我們如何重現此問題,以便我們進行修復</system:String>
<system:String x:Key="reportWindow_send_report">發送報告</system:String>
<system:String x:Key="reportWindow_cancel">取消</system:String>
<system:String x:Key="reportWindow_general">基本信息</system:String>
<system:String x:Key="reportWindow_exceptions">異常信息</system:String>
<system:String x:Key="reportWindow_exception_type">異常類型</system:String>
<system:String x:Key="reportWindow_source">異常源</system:String>
<system:String x:Key="reportWindow_stack_trace">堆棧信息</system:String>
<system:String x:Key="reportWindow_sending">發送中</system:String>
<system:String x:Key="reportWindow_report_succeed">發送成功</system:String>
<system:String x:Key="reportWindow_report_failed">發送失敗</system:String>
<system:String x:Key="reportWindow_wox_got_an_error">Wox出錯啦</system:String>
<!--更新-->
<system:String x:Key="update_wox_update_ready">Wox更新</system:String>
<system:String x:Key="update_wox_update_install">Wox更新啦{0}個文件會被添加和替換並且在此過程中可能會重啟Wox。你確定需要更新嗎</system:String>
<system:String x:Key="update_wox_update_error">更新Wox出錯</system:String>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--主窗體-->
<system:String x:Key="registerHotkeyFailed">註冊熱鍵:{0} 失敗</system:String>
<system:String x:Key="couldnotStartCmd">啟動命令 {0} 失敗</system:String>
<system:String x:Key="invalidWoxPluginFileFormat">不是合法的Wox插件格式</system:String>
<!--設置,通用-->
<system:String x:Key="woxsettings">Wox設置</system:String>
<system:String x:Key="general">通用</system:String>
<system:String x:Key="startWoxOnSystemStartup">開機啟動</system:String>
<system:String x:Key="hideWoxWhenLoseFocus">失去焦點時自動隱藏Wox</system:String>
<system:String x:Key="dontPromptUpdateMsg">不顯示新版本提示</system:String>
<system:String x:Key="language">語言</system:String>
<!--設置,插件-->
<system:String x:Key="plugin">插件</system:String>
<system:String x:Key="browserMorePlugins">瀏覽更多插件</system:String>
<system:String x:Key="disable">禁用</system:String>
<system:String x:Key="actionKeyword">觸發關鍵字</system:String>
<system:String x:Key="pluginDirectory">插件目錄</system:String>
<system:String x:Key="author">作者</system:String>
<!--設置,主題-->
<system:String x:Key="theme">主題</system:String>
<system:String x:Key="browserMoreThemes">瀏覽更多主題</system:String>
<system:String x:Key="helloWox">你好Wox</system:String>
<system:String x:Key="queryBoxFont">查詢框字體</system:String>
<system:String x:Key="resultItemFont">結果項字體</system:String>
<system:String x:Key="windowMode">窗口模式</system:String>
<system:String x:Key="opacity">透明度</system:String>
<!--設置,熱鍵-->
<system:String x:Key="hotkey">熱鍵</system:String>
<system:String x:Key="woxHotkey">Wox激活熱鍵</system:String>
<system:String x:Key="customQueryHotkey">自定義查詢熱鍵</system:String>
<system:String x:Key="delete">刪除</system:String>
<system:String x:Key="edit">編輯</system:String>
<system:String x:Key="add">增加</system:String>
<system:String x:Key="pleaseSelectAnItem">請選擇一項</system:String>
<system:String x:Key="deleteCustomHotkeyWarning">你確定要刪除插件 {0} 的熱鍵嗎?</system:String>
<!--設置,代理-->
<system:String x:Key="proxy">代理</system:String>
<system:String x:Key="enableProxy">啟用代理</system:String>
<system:String x:Key="server">服務器</system:String>
<system:String x:Key="port">端口</system:String>
<system:String x:Key="userName">用戶名</system:String>
<system:String x:Key="password">密碼</system:String>
<system:String x:Key="testProxy">測試代理</system:String>
<system:String x:Key="save">保存</system:String>
<system:String x:Key="serverCantBeEmpty">服務器不能為空</system:String>
<system:String x:Key="portCantBeEmpty">端口不能為空</system:String>
<system:String x:Key="invalidPortFormat">非法的端口格式</system:String>
<system:String x:Key="saveProxySuccessfully">保存代理設置成功</system:String>
<system:String x:Key="proxyIsCorrect">代理設置正確</system:String>
<system:String x:Key="proxyConnectFailed">代理連接失敗</system:String>
<!--設置,版本-->
<system:String x:Key="about">關於</system:String>
<system:String x:Key="website">網站</system:String>
<system:String x:Key="version">版本</system:String>
<system:String x:Key="about_activate_times">你已經激活了Wox {0} 次</system:String>
<!--Action Keyword 設置對話框-->
<system:String x:Key="oldActionKeyword">舊觸發關鍵字</system:String>
<system:String x:Key="newActionKeyword">新觸發關鍵字</system:String>
<system:String x:Key="cancel">取消</system:String>
<system:String x:Key="done">確定</system:String>
<system:String x:Key="cannotFindSpecifiedPlugin">找不到指定的插件</system:String>
<system:String x:Key="newActionKeywordCannotBeEmpty">新觸發關鍵字不能為空</system:String>
<system:String x:Key="newActionKeywordHasBeenAssigned">新觸發關鍵字已經被指派給其他插件了,請重新選擇一個關鍵字</system:String>
<system:String x:Key="succeed">成功</system:String>
<system:String x:Key="actionkeyword_tips">如果你不想設置觸發關鍵字,可以使用*代替</system:String>
<!--Custom Query Hotkey 對話框-->
<system:String x:Key="preview">預覽</system:String>
<system:String x:Key="hotkeyIsNotUnavailable">熱鍵不可用,請選擇一個新的熱鍵</system:String>
<system:String x:Key="invalidPluginHotkey">插件熱鍵不合法</system:String>
<system:String x:Key="update">更新</system:String>
<!--Hotkey 控件-->
<system:String x:Key="hotkeyUnavailable">熱鍵不可用</system:String>
<!--崩潰報告窗體-->
<system:String x:Key="reportWindow_version">版本</system:String>
<system:String x:Key="reportWindow_time">時間</system:String>
<system:String x:Key="reportWindow_reproduce">請告訴我們如何重現此問題,以便我們進行修復</system:String>
<system:String x:Key="reportWindow_send_report">發送報告</system:String>
<system:String x:Key="reportWindow_cancel">取消</system:String>
<system:String x:Key="reportWindow_general">基本信息</system:String>
<system:String x:Key="reportWindow_exceptions">異常信息</system:String>
<system:String x:Key="reportWindow_exception_type">異常類型</system:String>
<system:String x:Key="reportWindow_source">異常源</system:String>
<system:String x:Key="reportWindow_stack_trace">堆棧信息</system:String>
<system:String x:Key="reportWindow_sending">發送中</system:String>
<system:String x:Key="reportWindow_report_succeed">發送成功</system:String>
<system:String x:Key="reportWindow_report_failed">發送失敗</system:String>
<system:String x:Key="reportWindow_wox_got_an_error">Wox出錯啦</system:String>
<!--更新-->
<system:String x:Key="update_wox_update_new_version_available">發現Wox新版本 V{0}</system:String>
<system:String x:Key="update_wox_update_error">更新Wox出錯</system:String>
<system:String x:Key="update_wox_update">更新</system:String>
<system:String x:Key="update_wox_update_cancel">取消</system:String>
<system:String x:Key="update_wox_update_restart_wox_tip">此更新需要重啟Wox</system:String>
<system:String x:Key="update_wox_update_upadte_files">下列文件會被更新</system:String>
<system:String x:Key="update_wox_update_files">更新文件</system:String>
<system:String x:Key="update_wox_update_upadte_description">更新日誌</system:String>
</ResourceDictionary>

View File

@ -238,9 +238,30 @@ namespace Wox
InitProgressbarAnimation();
WindowIntelopHelper.DisableControlBox(this);
CheckUpdate();
}
private void CheckUpdate()
{
UpdaterManager.Instance.PrepareUpdateReady+=OnPrepareUpdateReady;
UpdaterManager.Instance.UpdateError += OnUpdateError;
UpdaterManager.Instance.CheckUpdate();
}
void OnUpdateError(object sender, EventArgs e)
{
string updateError = InternationalizationManager.Instance.GetTranslation("update_wox_update_error");
MessageBox.Show(updateError);
}
private void OnPrepareUpdateReady(object sender, EventArgs e)
{
Dispatcher.Invoke(new Action(() =>
{
new WoxUpdate().ShowDialog();
}));
}
public void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action)
{
var hotkey = new HotkeyModel(hotkeyStr);

View File

@ -66,6 +66,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="MarkdownSharp">
<HintPath>..\packages\MarkdownSharp.1.13.0.0\lib\35\MarkdownSharp.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
@ -113,6 +116,9 @@
<Compile Include="Converters\StringNullOrEmptyToVisibilityConverter.cs" />
<Compile Include="ImageLoader\ImageCacheStroage.cs" />
<Compile Include="Storage\UserSelectedRecordStorage.cs" />
<Compile Include="WoxUpdate.xaml.cs">
<DependentUpon>WoxUpdate.xaml</DependentUpon>
</Compile>
<Page Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -170,6 +176,9 @@
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Resource Include="Images\update.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Content Include="Languages\en.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -230,6 +239,10 @@
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Page Include="WoxUpdate.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">

45
Wox/WoxUpdate.xaml Normal file
View File

@ -0,0 +1,45 @@
<Window x:Class="Wox.WoxUpdate"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Icon="Images/app.png"
Topmost="True"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
Title="{DynamicResource update_wox_update}" Height="400" Width="600">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="80"></RowDefinition>
<RowDefinition ></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<Image Source="Images/update.png" Width="64"></Image>
<TextBlock x:Name="tbNewVersionAvailable" Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" FontSize="20" Text="{DynamicResource update_wox_update_new_version_available}"></TextBlock>
<TabControl Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2">
<TabItem Header="{DynamicResource update_wox_update_upadte_description}">
<WebBrowser x:Name="wbDetails" Grid.Row="1"></WebBrowser>
</TabItem>
<TabItem Header="{DynamicResource update_wox_update_files}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Padding="8" Text="{DynamicResource update_wox_update_upadte_files}"></TextBlock>
<ListBox x:Name="lbUpdatedFiles" Grid.Row="1">
</ListBox>
</Grid>
</TabItem>
</TabControl>
<StackPanel Grid.Column="1" Grid.Row="4" HorizontalAlignment="Right" Orientation="Horizontal">
<TextBlock Foreground="Gray" TextAlignment="Center" Margin="0 0 10 0" VerticalAlignment="Center" Text="{DynamicResource update_wox_update_restart_wox_tip}"></TextBlock>
<Button x:Name="btnUpdate" Padding="8 3" Margin="8" Click="btnUpdate_Click" Content="{DynamicResource update_wox_update}">
</Button>
<Button x:Name="btnCancel" Padding="8 3" Margin="8" Click="btnCancel_Click" Content="{DynamicResource update_wox_update_cancel}">
</Button>
</StackPanel>
</Grid>
</Window>

34
Wox/WoxUpdate.xaml.cs Normal file
View File

@ -0,0 +1,34 @@
using System.Windows;
using MarkdownSharp;
using Wox.Core.i18n;
using Wox.Core.Updater;
namespace Wox
{
public partial class WoxUpdate : Window
{
public WoxUpdate()
{
InitializeComponent();
string newVersionAvailable = string.Format(
InternationalizationManager.Instance.GetTranslation("update_wox_update_new_version_available"),
UpdaterManager.Instance.NewRelease);
tbNewVersionAvailable.Text = newVersionAvailable;
Markdown markdown = new Markdown();
wbDetails.NavigateToString(markdown.Transform(UpdaterManager.Instance.NewRelease.description));
lbUpdatedFiles.ItemsSource = UpdaterManager.Instance.GetAvailableUpdateFiles();
}
private void btnUpdate_Click(object sender, RoutedEventArgs e)
{
UpdaterManager.Instance.ApplyUpdates();
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
UpdaterManager.Instance.CleanUp();
Close();
}
}
}

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="InputSimulator" version="1.0.4.0" targetFramework="net35" />
<package id="MarkdownSharp" version="1.13.0.0" targetFramework="net35" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net35" />
<package id="NHotkey" version="1.2.1" targetFramework="net35" />
<package id="NHotkey.Wpf" version="1.2.1" targetFramework="net35" />