-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTroubleshootingDialog.xaml.cs
More file actions
165 lines (144 loc) · 6.3 KB
/
Copy pathTroubleshootingDialog.xaml.cs
File metadata and controls
165 lines (144 loc) · 6.3 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// This file is part of BOINC.
// https://boinc.berkeley.edu
// Copyright (C) 2025 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Diagnostics;
using System.Text;
using System.Windows;
namespace boinc_buda_runner_wsl_installer
{
public partial class TroubleshootingDialog : Window
{
private TroubleshootingGuide.TroubleshootingAdvice _advice;
private string _errorContext;
public TroubleshootingDialog(TroubleshootingGuide.TroubleshootingAdvice advice, string errorContext = null)
{
InitializeComponent();
_advice = advice;
_errorContext = errorContext;
LoadAdvice();
}
private void LoadAdvice()
{
TitleTextBlock.Text = _advice.Title;
DescriptionTextBlock.Text = _advice.Description;
var stepsBuilder = new StringBuilder();
foreach (var step in _advice.Steps)
{
stepsBuilder.AppendLine(step);
}
StepsTextBlock.Text = stepsBuilder.ToString();
if (_advice.AdditionalResources.Count > 0)
{
var resourcesBuilder = new StringBuilder();
foreach (var resource in _advice.AdditionalResources)
{
resourcesBuilder.AppendLine($"• {resource}");
}
ResourcesTextBlock.Text = resourcesBuilder.ToString();
ResourcesExpander.Visibility = Visibility.Visible;
}
else
{
ResourcesExpander.Visibility = Visibility.Collapsed;
}
ReportIssueButton.Visibility = _advice.ShouldOfferIssueReport ? Visibility.Visible : Visibility.Collapsed;
}
private void CopyButton_Click(object sender, RoutedEventArgs e)
{
try
{
var fullText = TroubleshootingGuide.FormatAdviceAsMessage(_advice);
if (!string.IsNullOrEmpty(_errorContext))
{
fullText += "\n\nError Context:\n" + _errorContext;
}
Clipboard.SetText(fullText);
MessageBox.Show(
"Troubleshooting information has been copied to clipboard.",
"Copied",
MessageBoxButton.OK,
MessageBoxImage.Information);
}
catch (Exception ex)
{
MessageBox.Show(
$"Failed to copy to clipboard: {ex.Message}",
"Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
private void ReportIssueButton_Click(object sender, RoutedEventArgs e)
{
try
{
var issueTitle = Uri.EscapeDataString(_advice.Title);
var issueBody = new StringBuilder();
issueBody.AppendLine("## Problem Description");
issueBody.AppendLine(_advice.Description);
issueBody.AppendLine();
issueBody.AppendLine("## Steps Attempted");
issueBody.AppendLine("(Please describe what troubleshooting steps you've tried)");
issueBody.AppendLine();
if (!string.IsNullOrEmpty(_errorContext))
{
issueBody.AppendLine("## Error Context");
issueBody.AppendLine("```");
issueBody.AppendLine(_errorContext);
issueBody.AppendLine("```");
issueBody.AppendLine();
}
issueBody.AppendLine("## System Information");
issueBody.AppendLine($"- OS: {Environment.OSVersion}");
issueBody.AppendLine($"- 64-bit OS: {Environment.Is64BitOperatingSystem}");
issueBody.AppendLine($"- 64-bit Process: {Environment.Is64BitProcess}");
try
{
var version = FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).FileVersion;
issueBody.AppendLine($"- Installer Version: {version}");
}
catch { }
if (!string.IsNullOrEmpty(DebugLogger.LogFilePath))
{
issueBody.AppendLine();
issueBody.AppendLine("## Log File");
issueBody.AppendLine($"Log file path: `{DebugLogger.LogFilePath}`");
issueBody.AppendLine("(Please attach the log file to this issue)");
}
var url = $"https://github.com/BOINC/boinc-buda-runner-wsl-installer/issues/new?title={issueTitle}&body={Uri.EscapeDataString(issueBody.ToString())}";
Process.Start(url);
MessageBox.Show(
"Your web browser will open to report this issue on GitHub.\n\nPlease provide as much detail as possible and attach your log file if available.",
"Report Issue",
MessageBoxButton.OK,
MessageBoxImage.Information);
}
catch (Exception ex)
{
MessageBox.Show(
$"Failed to open browser: {ex.Message}\n\nPlease manually visit:\nhttps://github.com/BOINC/boinc-buda-runner-wsl-installer/issues/new",
"Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
Close();
}
}
}