-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup button for bug reporting (#862)
Overhaul bug exception window Closes #784
- Loading branch information
1 parent
a656d4b
commit 9d8e024
Showing
8 changed files
with
218 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<UserControl x:Class="Daybreak.Controls.Glyphs.BugGlyph" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:Daybreak.Controls.Glyphs" | ||
x:Name="_this" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<Viewbox> | ||
<Path Fill="{Binding ElementName=_this, Path=Foreground, Mode=OneWay}" | ||
Data="m1.188,47.173a2,2 0 0 0 -1.188,1.827l0,8l4,0l0,-6.7l6.992,-3.108a17.968,17.968 0 0 0 32.016,0l6.992,3.108l0,6.7l4,0l0,-8a2,2 0 0 0 -1.188,-1.827l-8.39,-3.729a17.858,17.858 0 0 0 0.511,-3.115l7.879,-3.5a2,2 0 0 0 1.188,-1.829l0,-8l-4,0l0,6.7l-5,2.223l0,-10.623l7.812,-3.472a2,2 0 0 0 1.188,-1.828l0,-8l-4,0l0,6.7l-5.325,2.367a6.006,6.006 0 0 0 -5.675,-4.067l-2,0l0,-4a7.941,7.941 0 0 0 -0.99,-3.847l3.239,-2.591a2,2 0 0 0 0.751,-1.562l0,-5l-4,0l0,4.039l-2.747,2.2a7.939,7.939 0 0 0 -4.253,-1.239l-4,0a7.939,7.939 0 0 0 -4.253,1.237l-2.747,-2.198l0,-4.039l-4,0l0,5a2,2 0 0 0 0.751,1.562l3.239,2.591a7.941,7.941 0 0 0 -0.99,3.847l0,4l-2,0a6.006,6.006 0 0 0 -5.675,4.067l-5.325,-2.367l0,-6.7l-4,0l0,8a2,2 0 0 0 1.188,1.827l7.812,3.473l0,10.623l-5,-2.223l0,-6.7l-4,0l0,8a2,2 0 0 0 1.188,1.827l7.879,3.5a17.858,17.858 0 0 0 0.511,3.115l-8.39,3.731zm11.812,-8.173l0,-10l12,0l0,23.84a14.009,14.009 0 0 1 -12,-13.84zm16,13.84l0,-23.84l12,0l0,10a14.009,14.009 0 0 1 -12,13.84zm-8,-39.84a4,4 0 0 1 4,-4l4,0a4,4 0 0 1 4,4l0,4l-12,0l0,-4zm-6,8l24,0a2,2 0 0 1 2,2l0,2l-28,0l0,-2a2,2 0 0 1 2,-2z"/> | ||
</Viewbox> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
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; | ||
|
||
namespace Daybreak.Controls.Glyphs; | ||
/// <summary> | ||
/// Interaction logic for BugGlyph.xaml | ||
/// </summary> | ||
public partial class BugGlyph : UserControl | ||
{ | ||
public BugGlyph() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<Window x:Class="Daybreak.Launch.ExceptionDialog" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:controls="clr-namespace:Daybreak.Controls" | ||
xmlns:buttons="clr-namespace:Daybreak.Controls.Buttons" | ||
xmlns:local="clr-namespace:Daybreak.Launch" | ||
x:Name="_this" | ||
Title="Unhandled exception encountered!" | ||
mc:Ignorable="d" | ||
Height="450" Width="800"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="*"/> | ||
<RowDefinition Height="auto"/> | ||
</Grid.RowDefinitions> | ||
<TextBox Text="{Binding ElementName=_this, Path=ExceptionMessage, Mode=OneWay}" | ||
IsReadOnly="True"/> | ||
<StackPanel Grid.Row="1" | ||
Orientation="Horizontal" | ||
HorizontalAlignment="Center"> | ||
<buttons:HighlightButton | ||
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}" | ||
Background="{StaticResource MahApps.Brushes.ThemeBackground}" | ||
BorderBrush="{StaticResource MahApps.Brushes.ThemeForeground}" | ||
HighlightColor="{StaticResource MahApps.Brushes.Accent}" | ||
BorderThickness="1" | ||
Title="Ok" | ||
Width="80" | ||
Height="30" | ||
FontSize="16" | ||
Margin="0, 0, 50, 0" | ||
HorizontalContentAlignment="Center" | ||
VerticalContentAlignment="Center" | ||
Clicked="OkButton_Clicked"> | ||
</buttons:HighlightButton> | ||
<buttons:HighlightButton | ||
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}" | ||
Background="{StaticResource MahApps.Brushes.ThemeBackground}" | ||
BorderBrush="{StaticResource MahApps.Brushes.ThemeForeground}" | ||
HighlightColor="{StaticResource MahApps.Brushes.Accent}" | ||
BorderThickness="1" | ||
Title="Report" | ||
Width="80" | ||
Height="30" | ||
FontSize="16" | ||
Margin="50, 0, 0, 0" | ||
HorizontalContentAlignment="Center" | ||
VerticalContentAlignment="Center" | ||
Clicked="ReportButton_Clicked"> | ||
</buttons:HighlightButton> | ||
</StackPanel> | ||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Web; | ||
using System.Windows; | ||
using System.Windows.Extensions; | ||
|
||
namespace Daybreak.Launch; | ||
/// <summary> | ||
/// Interaction logic for ExceptionDialog.xaml | ||
/// </summary> | ||
public partial class ExceptionDialog : Window | ||
{ | ||
private const string TitlePlaceholder = "[TITLE]"; | ||
private const string BodyPlaceholder = "[BODY]"; | ||
private const string IssueUrl = $"https://github.com/gwdevhub/Daybreak/issues/new?title={TitlePlaceholder}&body={BodyPlaceholder}&labels=bug"; | ||
|
||
private string exceptionName; | ||
|
||
[GenerateDependencyProperty] | ||
private string exceptionMessage = string.Empty; | ||
|
||
public ExceptionDialog(Exception exception) | ||
{ | ||
this.InitializeComponent(); | ||
this.exceptionName = exception.GetType().Name; | ||
this.ExceptionMessage = exception.ToString(); | ||
} | ||
|
||
public ExceptionDialog(string exceptionName, string exceptionMessage) | ||
{ | ||
this.InitializeComponent(); | ||
this.exceptionName = exceptionName; | ||
this.ExceptionMessage = exceptionMessage; | ||
} | ||
|
||
private void OkButton_Clicked(object sender, EventArgs e) | ||
{ | ||
this.Close(); | ||
} | ||
|
||
private void ReportButton_Clicked(object sender, EventArgs e) | ||
{ | ||
var title = $"[User Report] {this.exceptionName}"; | ||
var body = this.ExceptionMessage; | ||
|
||
var url = IssueUrl | ||
.Replace(TitlePlaceholder, HttpUtility.UrlEncode(title)) | ||
.Replace(BodyPlaceholder, HttpUtility.UrlEncode(body)); | ||
|
||
Process.Start(new ProcessStartInfo | ||
{ | ||
FileName = url, | ||
UseShellExecute = true | ||
}); | ||
|
||
this.Close(); | ||
} | ||
|
||
public static void ShowException(Exception exception) | ||
{ | ||
var exceptionDialog = new ExceptionDialog(exception); | ||
exceptionDialog.ShowDialog(); | ||
return; | ||
} | ||
|
||
public static void ShowException(string exceptionName, string exceptionMessage) | ||
{ | ||
var exceptionDialog = new ExceptionDialog(exceptionName, exceptionMessage); | ||
exceptionDialog.ShowDialog(); | ||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
using System.Windows; | ||
using Daybreak.Launch; | ||
using System.Windows; | ||
|
||
namespace Daybreak.Models.Notifications.Handling; | ||
|
||
public sealed class MessageBoxHandler : INotificationHandler | ||
{ | ||
public void OpenNotification(Notification notification) | ||
{ | ||
MessageBox.Show(notification.Description, notification.Title); | ||
ExceptionDialog.ShowException(notification.Title, notification.Description); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters