Merge branch 'master' into dev

This commit is contained in:
bao-qian
2017-04-07 11:55:56 +01:00
27 changed files with 326 additions and 266 deletions

View File

@@ -29,8 +29,6 @@ namespace Wox
[STAThread]
public static void Main()
{
RegisterAppDomainExceptions();
if (SingleInstance<App>.InitializeAsFirstInstance(Unique))
{
using (var application = new App())
@@ -46,6 +44,8 @@ namespace Wox
Stopwatch.Normal("|App.OnStartup|Startup cost", () =>
{
Log.Info("|App.OnStartup|Begin Wox startup ----------------------------------------------------");
Log.Info($"|App.OnStartup|Runtime info:{ErrorReporting.RuntimeInfo()}");
RegisterAppDomainExceptions();
RegisterDispatcherUnhandledException();
ImageLoader.Initialize();
@@ -59,6 +59,7 @@ namespace Wox
var window = new MainWindow(_settings, _mainVM);
API = new PublicAPIInstance(_settingsVM, _mainVM);
PluginManager.InitializePlugins(API);
Log.Info($"|App.OnStartup|Dependencies Info:{ErrorReporting.DependenciesInfo()}");
Current.MainWindow = window;
Current.MainWindow.Title = Constant.Wox;
@@ -140,8 +141,10 @@ namespace Wox
private static void RegisterAppDomainExceptions()
{
AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandle;
AppDomain.CurrentDomain.FirstChanceException +=
(s, e) => { Log.Exception("|App.RegisterAppDomainExceptions|First Chance Exception:", e.Exception); };
AppDomain.CurrentDomain.FirstChanceException += (_, e) =>
{
Log.Exception("|App.RegisterAppDomainExceptions|First Chance Exception:", e.Exception);
};
}
public void Dispose()

View File

@@ -1,26 +0,0 @@
using System;
namespace Wox
{
public class CrashReporter
{
private Exception exception;
public CrashReporter(Exception e)
{
exception = e;
}
public void Show()
{
if (exception == null) return;
if (exception.InnerException != null)
{
exception = exception.InnerException;
}
ReportWindow reportWindow = new ReportWindow(exception);
reportWindow.Show();
}
}
}

View File

@@ -1,35 +1,49 @@
using System;
using System.Windows;
using System.Windows.Threading;
using NLog;
using Wox.Infrastructure;
using Wox.Infrastructure.Exception;
namespace Wox.Helper
{
public static class ErrorReporting
{
public static void Report(Exception e)
private static void Report(Exception e)
{
var logger = LogManager.GetLogger("UnHandledException");
logger.Fatal(ExceptionFormatter.FormatExcpetion(e));
new CrashReporter(e).Show();
var reportWindow = new ReportWindow(e);
reportWindow.Show();
}
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
{
//handle non-ui thread exceptions
Application.Current.MainWindow.Dispatcher.Invoke(() =>
{
Report((Exception)e.ExceptionObject);
});
Report((Exception)e.ExceptionObject);
}
public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
//handle ui thread exceptions
Report(e.Exception);
//prevent crash
//prevent application exist, so the user can copy prompted error info
e.Handled = true;
}
public static string RuntimeInfo()
{
var info = $"\nWox version: {Constant.Version}" +
$"\nOS Version: {Environment.OSVersion.VersionString}" +
$"\nIntPtr Length: {IntPtr.Size}" +
$"\nx64: {Environment.Is64BitOperatingSystem}";
return info;
}
public static string DependenciesInfo()
{
var info = $"\nPython Path: {Constant.PythonPath}" +
$"\nEverything SDK Path: {Constant.EverythingSDKPath}";
return info;
}
}
}

View File

@@ -84,7 +84,12 @@
<system:String x:Key="version">Version</system:String>
<system:String x:Key="about_activate_times">You have activated Wox {0} times</system:String>
<system:String x:Key="checkUpdates">Check for Updates</system:String>
<system:String x:Key="newVersionTips">New version {0} is available, please restart Wox</system:String>
<system:String x:Key="newVersionTips">New version {0} is available, please restart Wox.</system:String>
<system:String x:Key="checkUpdatesFailed">Check updates failed, please check your connection and proxy settings to api.github.com.</system:String>
<system:String x:Key="downloadUpdatesFailed">
Download updates failed, please check your connection and proxy settings to github-cloud.s3.amazonaws.com,
or go to https://github.com/Wox-launcher/Wox/releases to download updates manually.
</system:String>
<system:String x:Key="releaseNotes">Release Notes:</system:String>
<!--Action Keyword Setting Dialog-->

View File

@@ -84,7 +84,7 @@
<system:String x:Key="version">版本</system:String>
<system:String x:Key="about_activate_times">你已经激活了Wox {0} 次</system:String>
<system:String x:Key="checkUpdates">检查更新</system:String>
<system:String x:Key="newVersionTips">发现新版本 {0} , 请重启 wox</system:String>
<system:String x:Key="newVersionTips">发现新版本 {0} , 请重启 wox</system:String>
<system:String x:Key="releaseNotes">更新说明:</system:String>
<!--Action Keyword 设置对话框-->

View File

@@ -80,7 +80,7 @@
<system:String x:Key="version">版本</system:String>
<system:String x:Key="about_activate_times">您已經啟動了 Wox {0} 次</system:String>
<system:String x:Key="checkUpdates">檢查更新</system:String>
<system:String x:Key="newVersionTips">發現有新版本 {0} , 請重新啟動 Wox</system:String>
<system:String x:Key="newVersionTips">發現有新版本 {0} 請重新啟動 Wox</system:String>
<system:String x:Key="releaseNotes">更新說明:</system:String>
<!--Action Keyword 設定對話框-->

View File

@@ -6,6 +6,7 @@ using System.Text;
using System.Linq;
using System.Windows;
using System.Windows.Documents;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.Logger;
@@ -26,18 +27,14 @@ namespace Wox
var directory = new DirectoryInfo(path);
var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First();
var paragraph = Hyperlink("Please open new issue in: " , Constant.Issue);
var paragraph = Hyperlink("Please open new issue in: ", Constant.Issue);
paragraph.Inlines.Add($"1. upload log file: {log.FullName}\n");
paragraph.Inlines.Add($"2. copy below exception message");
ErrorTextbox.Document.Blocks.Add(paragraph);
StringBuilder content = new StringBuilder();
content.AppendLine($"Wox version: {Constant.Version}");
content.AppendLine($"OS Version: {Environment.OSVersion.VersionString}");
content.AppendLine($"IntPtr Length: {IntPtr.Size}");
content.AppendLine($"x64: {Environment.Is64BitOperatingSystem}");
content.AppendLine($"Python Path: {Constant.PythonPath}");
content.AppendLine($"Everything SDK Path: {Constant.EverythingSDKPath}");
content.AppendLine(ErrorReporting.RuntimeInfo());
content.AppendLine(ErrorReporting.DependenciesInfo());
content.AppendLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}");
content.AppendLine("Exception:");
content.AppendLine(exception.Source);
@@ -54,7 +51,7 @@ namespace Wox
var paragraph = new Paragraph();
paragraph.Margin = new Thickness(0);
var link = new Hyperlink {IsEnabled = true};
var link = new Hyperlink { IsEnabled = true };
link.Inlines.Add(url);
link.NavigateUri = new Uri(url);
link.RequestNavigate += (s, e) => Process.Start(e.Uri.ToString());

View File

@@ -384,8 +384,6 @@
<Button Grid.Row="4" Grid.Column="0"
Content="{DynamicResource checkUpdates}" Click="OnCheckUpdates"
HorizontalAlignment="Left" Margin="10 10 10 10" />
<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding NewVersionTips}"
HorizontalAlignment="Left" Visibility="{Binding NewVersionTipsVisibility}" />
</Grid>
</TabItem>
</TabControl>

View File

@@ -272,7 +272,7 @@ namespace Wox
return;
}
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Infrastructure.Constant.Github);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Infrastructure.Constant.Repository);
if (string.IsNullOrEmpty(_settings.Proxy.UserName) || string.IsNullOrEmpty(_settings.Proxy.Password))
{
request.Proxy = new WebProxy(_settings.Proxy.Server, _settings.Proxy.Port);
@@ -306,17 +306,7 @@ namespace Wox
private async void OnCheckUpdates(object sender, RoutedEventArgs e)
{
var version = await Updater.NewVersion();
if (!string.IsNullOrEmpty(version))
{
var newVersion = Updater.NumericVersion(version);
var oldVersion = Updater.NumericVersion(Infrastructure.Constant.Version);
if (newVersion > oldVersion)
{
Updater.UpdateApp();
_viewModel.NewVersionTips = version;
}
}
await Updater.UpdateApp();
}
private void OnRequestNavigate(object sender, RequestNavigateEventArgs e)

View File

@@ -6,6 +6,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Wox.Core;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Helper;
@@ -205,7 +206,7 @@ namespace Wox.ViewModel
},
new Result
{
Title = $"Open Source: {Constant.Github}",
Title = $"Open Source: {Constant.Repository}",
SubTitle = "Please star it!"
}
};
@@ -315,22 +316,10 @@ namespace Wox.ViewModel
#region about
public static string Github => Constant.Github;
public static string Github => Constant.Repository;
public static string ReleaseNotes => @"https://github.com/Wox-launcher/Wox/releases/latest";
public static string Version => Constant.Version;
public string ActivatedTimes => string.Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);
private string _newVersionTips;
public string NewVersionTips
{
get { return _newVersionTips; }
set
{
_newVersionTips = string.Format(_translater.GetTranslation("newVersionTips"), value);
NewVersionTipsVisibility = Visibility.Visible;
}
}
public Visibility NewVersionTipsVisibility { get; set; }
#endregion
}
}

View File

@@ -158,7 +158,6 @@
<Compile Include="..\SolutionAssemblyInfo.cs">
<Link>Properties\SolutionAssemblyInfo.cs</Link>
</Compile>
<Compile Include="CrashReporter.cs" />
<Compile Include="Helper\SingletonWindowOpener.cs" />
<Compile Include="PublicAPIInstance.cs" />
<Compile Include="ReportWindow.xaml.cs" />
@@ -433,33 +432,7 @@
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
xcopy /Y /E $(ProjectDir)Themes\* $(TargetDir)Themes\
xcopy /Y /E $(ProjectDir)Images\* $(TargetDir)Images\
xcopy /Y /D /E $(SolutionDir)Plugins\HelloWorldPython\* $(TargetDir)Plugins\HelloWorldPython\*
xcopy /Y /E $(SolutionDir)JsonRPC\* $(TargetDir)JsonRPC\
cd $(SolutionDir)packages\squirrel*\tools
copy /Y Squirrel.exe $(TargetDir)..\Update.exe
cd $(SolutionDir)
if $(ConfigurationName) == Release (
cd "$(TargetDir)Plugins" &amp; del /s /q NLog.dll
cd "$(TargetDir)Plugins" &amp; del /s /q NLog.config
cd "$(TargetDir)Plugins" &amp; del /s /q Wox.Plugin.pdb
cd "$(TargetDir)Plugins" &amp; del /s /q Wox.Plugin.dll
cd "$(TargetDir)Plugins" &amp; del /s /q Wox.Core.dll
cd "$(TargetDir)Plugins" &amp; del /s /q Wox.Core.pdb
cd "$(TargetDir)Plugins" &amp; del /s /q ICSharpCode.SharpZipLib.dll
cd "$(TargetDir)Plugins" &amp; del /s /q NAppUpdate.Framework.dll
cd "$(TargetDir)Plugins" &amp; del /s /q Wox.Infrastructure.dll
cd "$(TargetDir)Plugins" &amp; del /s /q Wox.Infrastructure.pdb
cd "$(TargetDir)Plugins" &amp; del /s /q Newtonsoft.Json.dll
cd "$(TargetDir)Plugins" &amp; del /s /q JetBrains.Annotations.dll
cd "$(TargetDir)Plugins" &amp; del /s /q Pinyin4Net.dll
cd "$(TargetDir)" &amp; del /s /q *.xml
)
</PostBuildEvent>
<PostBuildEvent>powershell.exe -NoProfile -File $(SolutionDir)Scripts\post_build.ps1 $(ConfigurationName) $(SolutionDir)</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent>taskkill /f /fi "IMAGENAME eq Wox.exe"</PreBuildEvent>