Ionite
2 years ago
committed by
GitHub
5 changed files with 170 additions and 0 deletions
@ -0,0 +1,112 @@ |
|||||||
|
<ui:FluentWindow |
||||||
|
Background="{DynamicResource ApplicationBackgroundBrush}" |
||||||
|
ExtendsContentIntoTitleBar="True" |
||||||
|
Foreground="{DynamicResource TextFillColorPrimaryBrush}" |
||||||
|
Height="500" |
||||||
|
Loaded="ExceptionWindow_OnLoaded" |
||||||
|
ResizeMode="NoResize" |
||||||
|
Title="Unexpected Application Error" |
||||||
|
Width="800" |
||||||
|
WindowStartupLocation="CenterOwner" |
||||||
|
mc:Ignorable="d" |
||||||
|
x:Class="StabilityMatrix.ExceptionWindow" |
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||||
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors" |
||||||
|
xmlns:local="clr-namespace:StabilityMatrix" |
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||||
|
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" |
||||||
|
xmlns:viewModels="clr-namespace:StabilityMatrix.ViewModels" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||||
|
|
||||||
|
<Window.DataContext> |
||||||
|
<viewModels:ExceptionWindowViewModel /> |
||||||
|
</Window.DataContext> |
||||||
|
|
||||||
|
<Window.Resources> |
||||||
|
<Style TargetType="TextBlock" x:Key="Label"> |
||||||
|
<Setter Property="FontWeight" Value="Bold" /> |
||||||
|
<Setter Property="Margin" Value="0,8,0,4" /> |
||||||
|
</Style> |
||||||
|
<Style TargetType="TextBlock" x:Key="Content"> |
||||||
|
<Setter Property="Margin" Value="0,4,0,8" /> |
||||||
|
</Style> |
||||||
|
</Window.Resources> |
||||||
|
|
||||||
|
<Grid> |
||||||
|
<Grid.RowDefinitions> |
||||||
|
<RowDefinition Height="auto" /> |
||||||
|
<RowDefinition Height="*" /> |
||||||
|
<RowDefinition Height="auto" /> |
||||||
|
</Grid.RowDefinitions> |
||||||
|
|
||||||
|
<ui:TitleBar Background="DarkOrange"> |
||||||
|
<ui:TitleBar.Header> |
||||||
|
<TextBlock Margin="16,8" Text="Unexpected error" /> |
||||||
|
</ui:TitleBar.Header> |
||||||
|
</ui:TitleBar> |
||||||
|
|
||||||
|
<Grid Grid.Row="1"> |
||||||
|
<Grid.RowDefinitions> |
||||||
|
<RowDefinition Height="auto" /> |
||||||
|
<RowDefinition Height="*" /> |
||||||
|
<RowDefinition Height="auto" /> |
||||||
|
</Grid.RowDefinitions> |
||||||
|
<!-- Info --> |
||||||
|
<TextBlock |
||||||
|
FontSize="14" |
||||||
|
Grid.Row="0" |
||||||
|
Margin="16" |
||||||
|
Text="An unexpected error occured." |
||||||
|
TextWrapping="Wrap" |
||||||
|
VerticalAlignment="Top" /> |
||||||
|
|
||||||
|
<!-- Exception details --> |
||||||
|
<Border Grid.Row="1" VerticalAlignment="Stretch"> |
||||||
|
<Expander |
||||||
|
Header="Exception Details" |
||||||
|
IsExpanded="True" |
||||||
|
Margin="16,8,16,8" |
||||||
|
VerticalAlignment="Top"> |
||||||
|
|
||||||
|
<ScrollViewer |
||||||
|
CanContentScroll="True" |
||||||
|
HorizontalScrollBarVisibility="Auto" |
||||||
|
VerticalScrollBarVisibility="Auto"> |
||||||
|
<StackPanel> |
||||||
|
<!-- Exception Message --> |
||||||
|
<TextBlock Style="{StaticResource Label}" Text="Exception message" /> |
||||||
|
<TextBlock |
||||||
|
Grid.Column="1" |
||||||
|
Text="{Binding Exception.Message, Mode=OneWay, TargetNullValue=-}" |
||||||
|
TextWrapping="Wrap" /> |
||||||
|
<!-- Exception Type --> |
||||||
|
<TextBlock Style="{StaticResource Label}" Text="Exception type" /> |
||||||
|
<TextBlock Style="{StaticResource Content}" Text="{Binding ExceptionType, Mode=OneWay, TargetNullValue=-}" /> |
||||||
|
<!-- Callstack --> |
||||||
|
<TextBlock Style="{StaticResource Label}" Text="Callstack" /> |
||||||
|
<TextBlock Style="{StaticResource Content}" Text="{Binding Exception.StackTrace, Mode=OneWay, TargetNullValue=-}" /> |
||||||
|
<!-- Inner exception --> |
||||||
|
<TextBlock Style="{StaticResource Label}" Text="Inner exception" /> |
||||||
|
<TextBlock Style="{StaticResource Content}" Text="{Binding Exception.InnerException, Mode=OneWay, TargetNullValue=-}" /> |
||||||
|
</StackPanel> |
||||||
|
</ScrollViewer> |
||||||
|
</Expander> |
||||||
|
</Border> |
||||||
|
<!-- Close Button --> |
||||||
|
<Button |
||||||
|
Content="Exit Application" |
||||||
|
Grid.Row="2" |
||||||
|
HorizontalAlignment="Right" |
||||||
|
Margin="16" |
||||||
|
Padding="8"> |
||||||
|
<i:Interaction.Triggers> |
||||||
|
<i:EventTrigger EventName="Click"> |
||||||
|
<i:CallMethodAction MethodName="Close" TargetObject="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" /> |
||||||
|
</i:EventTrigger> |
||||||
|
</i:Interaction.Triggers> |
||||||
|
</Button> |
||||||
|
</Grid> |
||||||
|
</Grid> |
||||||
|
|
||||||
|
</ui:FluentWindow> |
@ -0,0 +1,17 @@ |
|||||||
|
using System.Windows; |
||||||
|
using Wpf.Ui.Controls.Window; |
||||||
|
|
||||||
|
namespace StabilityMatrix; |
||||||
|
|
||||||
|
public partial class ExceptionWindow : FluentWindow |
||||||
|
{ |
||||||
|
public ExceptionWindow() |
||||||
|
{ |
||||||
|
InitializeComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
private void ExceptionWindow_OnLoaded(object sender, RoutedEventArgs e) |
||||||
|
{ |
||||||
|
System.Media.SystemSounds.Hand.Play(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
using System; |
||||||
|
using System.Windows; |
||||||
|
using CommunityToolkit.Mvvm.Input; |
||||||
|
|
||||||
|
namespace StabilityMatrix.ViewModels; |
||||||
|
|
||||||
|
public class ExceptionWindowViewModel |
||||||
|
{ |
||||||
|
public Exception Exception { get; set; } |
||||||
|
|
||||||
|
public string ExceptionType => Exception.GetType().Name; |
||||||
|
} |
Loading…
Reference in new issue