forked from NickeManarin/ScreenToGif
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExceptionDialog.xaml.cs
98 lines (75 loc) · 2.78 KB
/
ExceptionDialog.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Documents;
using Translator.Util;
namespace Translator;
public partial class ExceptionDialog : Window
{
#region Properties
public bool BugWithHotFix4055002 { get; set; }
public Exception Exception { get; set; }
#endregion
public ExceptionDialog(Exception exception)
{
InitializeComponent();
Exception = exception;
}
#region Eventos
private void Window_Loaded(object sender, RoutedEventArgs e)
{
if (Exception == null)
DetailsButton.IsEnabled = false;
}
private void DetailsButton_Click(object sender, RoutedEventArgs e)
{
var errorViewer = new ExceptionViewer(Exception);
errorViewer.ShowDialog();
}
private void OkButton_Click(object sender, RoutedEventArgs e)
{
Close();
}
#endregion
#region Métodos
private void PrepareOk(string title, string instruction, string observation)
{
TypeTextBlock.Text = instruction;
DetailsTextBlock.Inlines.Add(new Run("\t" + observation));
Title = title ?? "ScreenToGif - Error";
if (BugWithHotFix4055002)
{
DetailsTextBlock.Inlines.Add(new LineBreak());
DetailsTextBlock.Inlines.Add(new LineBreak());
DetailsTextBlock.Inlines.Add(new Run("\tThis was likely caused by a bug with an update for .Net Framework 4.7.1 (KB4055002, released in January 2018). This bug happens on machines with Windows 7 SP1 or Windows Server 2008 R2."));
DetailsTextBlock.Inlines.Add(new LineBreak());
DetailsTextBlock.Inlines.Add(new LineBreak());
DetailsTextBlock.Inlines.Add(new Run("\t"));
var hyper = new Hyperlink(new Run("Click here to open a page with some details on how to fix this issue.") {ToolTip = "https://github.com/dotnet/announcements/issues/53" });
hyper.Click += HyperOnClick;
DetailsTextBlock.Inlines.Add(hyper);
}
OkButton.Focus();
}
private void HyperOnClick(object sender, RoutedEventArgs routedEventArgs)
{
try
{
Process.Start("https://github.com/dotnet/announcements/issues/53");
}
catch (Exception e)
{
LogWriter.Log(e, "Impossible to open link");
}
}
#endregion
#region Static Methods
public static bool Ok(Exception exception, string title, string instruction, string observation = "", bool bugWith4055002 = false)
{
var dialog = new ExceptionDialog(exception) { BugWithHotFix4055002 = bugWith4055002 };
dialog.PrepareOk(title, instruction, observation);
var result = dialog.ShowDialog();
return result.HasValue && result.Value;
}
#endregion
}