PowerToys/Wox.CrashReporter/ReportWindow.xaml.cs

79 lines
2.3 KiB
C#
Raw Normal View History

2015-01-11 21:52:30 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
2015-01-16 23:42:12 +08:00
using System.Threading;
2015-01-11 21:52:30 +08:00
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Exceptionless;
2015-01-11 21:52:30 +08:00
using Wox.Core;
using Wox.Core.Exception;
2015-01-12 22:46:36 +08:00
using Wox.Core.i18n;
2015-01-11 21:52:30 +08:00
using Wox.Core.UI;
2015-01-27 21:51:29 +08:00
using Wox.Core.Updater;
2015-01-11 21:52:30 +08:00
using Wox.Core.UserSettings;
using Wox.Infrastructure.Http;
2015-02-03 18:32:16 +08:00
using Wox.Infrastructure.Logger;
2015-01-11 21:52:30 +08:00
namespace Wox.CrashReporter
{
2015-01-12 22:46:36 +08:00
internal partial class ReportWindow
2015-01-11 21:52:30 +08:00
{
private Exception exception;
public ReportWindow(Exception exception)
{
this.exception = exception;
InitializeComponent();
SetException(exception);
}
private void SetException(Exception exception)
{
tbSummary.AppendText(exception.Message);
2015-01-27 21:51:29 +08:00
tbVersion.Text = UpdaterManager.Instance.CurrentVersion.ToString();
2015-01-11 21:52:30 +08:00
tbDatetime.Text = DateTime.Now.ToString();
tbStackTrace.AppendText(exception.StackTrace);
tbSource.Text = exception.Source;
tbType.Text = exception.GetType().ToString();
}
private void btnSend_Click(object sender, RoutedEventArgs e)
{
2015-01-21 23:00:56 +08:00
string sendingMsg = InternationalizationManager.Instance.GetTranslation("reportWindow_sending");
2015-01-12 22:46:36 +08:00
tbSendReport.Content = sendingMsg;
2015-01-11 21:52:30 +08:00
btnSend.IsEnabled = false;
SendReport();
2015-01-16 23:42:12 +08:00
}
private void SendReport()
{
2015-02-10 23:48:09 +08:00
Hide();
ThreadPool.QueueUserWorkItem(o =>
{
string reproduceSteps = new TextRange(tbReproduceSteps.Document.ContentStart, tbReproduceSteps.Document.ContentEnd).Text;
exception.ToExceptionless()
.SetUserDescription(reproduceSteps)
.Submit();
ExceptionlessClient.Current.ProcessQueue();
Dispatcher.Invoke(new Action(() =>
{
Close();
}));
});
2015-01-11 21:52:30 +08:00
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
Close();
}
}
}