-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CrashDialogForm.cs
95 lines (81 loc) · 2.99 KB
/
CrashDialogForm.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
using Microsoft.Win32;
using System;
using System.IO;
using System.Windows.Forms;
using BugSplatDotNetStandard;
using System.Diagnostics;
using System.Collections.Generic;
namespace BugSplatCrashHandler
{
public partial class CrashDialogForm : Form
{
BugSplat bugsplat;
BugSplatPostOptions options;
FileInfo crashReportFile;
RegistryKey userCredsKey;
public CrashDialogForm(BugSplat bugsplat, FileInfo crashReportFile, BugSplatPostOptions options)
{
this.bugsplat = bugsplat;
this.crashReportFile = crashReportFile;
this.options = options;
InitializeComponent();
InitializeOptions();
}
private void InitializeOptions()
{
// User entered credentials saved here
userCredsKey = Registry.CurrentUser.CreateSubKey(Program.USER_CREDS_REGISTRY_KEY_PATH);
// Update dialog text
usernameTextBox.Text = options.User;
emailTextBox.Text = options.Email;
userDescriptionTextBox.Text = options.Description;
}
private void userDescriptionTextBox_TextChanged(object sender, EventArgs e)
{
options.Description = userDescriptionTextBox.Text;
}
private void sendErrorReportButton_Click(object sender, EventArgs e)
{
sendErrorReportButton.Enabled = false;
if (File.Exists(crashReportFile?.FullName))
{
var poster = new CrashPoster(bugsplat);
poster.PostCrashAndDisplaySupportResponseIfAvailable(crashReportFile, options);
}
Application.Exit();
}
private void cancelButton_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void emailTextBox_TextChanged(object sender, EventArgs e)
{
var email = emailTextBox.Text;
options.Email = email;
userCredsKey?.SetValue(Program.USER_EMAIL_REGISTRY_KEY, email);
}
private void usernameTextBox_TextChanged(object sender, EventArgs e)
{
var username = usernameTextBox.Text;
options.User = username;
userCredsKey?.SetValue(Program.USER_NAME_REGISTRY_KEY, username);
}
private void viewReportDetailsButton_Click(object sender, EventArgs e)
{
var files = new List<FileInfo>();
files.Add(crashReportFile);
files.AddRange(options.Attachments);
new ReportDetailsForm(files).ShowDialog();
}
private void poweredByBugSplatLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
using (Process browser = new Process())
{
browser.StartInfo.FileName = "https://www.bugsplat.com";
browser.StartInfo.Arguments = null;
browser.StartInfo.UseShellExecute = true;
browser.Start();
}
}
}
}