UI - Moved exception viewer to its own seperate window

Conditions - Started adding list conditions
This commit is contained in:
Robert committed 2020-08-11 17:27:11 +02:00
1 parent 930a7b4ef7
commit 6803bc5a37
36 files changed
+930 -471

No files matched your search

@@ -40,7 +40,7 @@
</Border>
<!-- Input -->
<TextBox x:Name="Input"
<TextBox x:Name="DraggableFloatInputTextBox"
Width="60"
Height="21"
Padding="0 0 -2 0"
@@ -140,7 +140,7 @@ namespace Artemis.UI.Shared.Controls
DisplayDragHandle();
else if (e.Key == Key.Escape)
{
Input.Text = _startValue.ToString();
DraggableFloatInputTextBox.Text = _startValue.ToString();
DisplayDragHandle();
}
}
@@ -148,14 +148,14 @@ namespace Artemis.UI.Shared.Controls
private void DisplayInput()
{
DragHandle.Visibility = Visibility.Collapsed;
Input.Visibility = Visibility.Visible;
Input.Focus();
Input.SelectAll();
DraggableFloatInputTextBox.Visibility = Visibility.Visible;
DraggableFloatInputTextBox.Focus();
DraggableFloatInputTextBox.SelectAll();
}
private void DisplayDragHandle()
{
Input.Visibility = Visibility.Collapsed;
DraggableFloatInputTextBox.Visibility = Visibility.Collapsed;
DragHandle.Visibility = Visibility.Visible;
}
@@ -1,50 +0,0 @@
<UserControl x:Class="Artemis.UI.Shared.Screens.Dialogs.ExceptionDialogView"
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:s="https://github.com/canton7/Stylet"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:dialogs="clr-namespace:Artemis.UI.Shared.Screens.Dialogs"
xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
mc:Ignorable="d"
d:DesignHeight="163.274" d:DesignWidth="254.425"
d:DataContext="{d:DesignInstance dialogs:ExceptionDialogViewModel}">
<StackPanel Orientation="Vertical" HorizontalAlignment="Right" Margin="16">
<TextBlock Style="{StaticResource MaterialDesignHeadline6TextBlock}" Text="{Binding Header}"
TextWrapping="Wrap" />
<Separator Margin="0 15" />
<ScrollViewer MaxHeight="500" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<ItemsControl ItemsSource="{Binding Exceptions}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}"
Text="Stack trace"
TextWrapping="Wrap"
FontWeight="Bold"
MaxWidth="1000"/>
<avalonedit:TextEditor SyntaxHighlighting="C#"
FontFamily="pack://application:,,,/Resources/Fonts/#Roboto Mono"
FontSize="10pt"
IsReadOnly="True"
Document="{Binding Document}"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto"
MaxWidth="1000"
Margin="0 10 10 0"
Padding="10" />
<Separator Margin="0 15" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</ScrollViewer>
<Button Style="{StaticResource MaterialDesignFlatButton}" IsDefault="True" Margin="0 8 0 0"
Command="{s:Action Close}" Content="Close" HorizontalAlignment="Right" />
</StackPanel>
</UserControl>
@@ -0,0 +1,59 @@
<controls:MaterialWindow x:Class="Artemis.UI.Shared.Screens.Exceptions.ExceptionView"
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:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:exceptions="clr-namespace:Artemis.UI.Shared.Screens.Exceptions"
xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
mc:Ignorable="d"
Title="Unhandled exception"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
UseLayoutRounding="True"
Width="800"
Height="800"
d:DesignHeight="800"
d:DesignWidth="800"
d:DataContext="{d:DesignInstance exceptions:ExceptionViewModel}">
<DockPanel>
<controls:AppBar Type="Dense" Title="{Binding Header}" DockPanel.Dock="Top" Margin="-18 0 0 0" ShowShadow="False">
<controls:AppBar.AppIcon>
<materialDesign:PackIcon Kind="ErrorOutline" Width="20" Height="28" />
</controls:AppBar.AppIcon>
</controls:AppBar>
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Margin="16">
<StackPanel>
<ItemsControl ItemsSource="{Binding Exceptions}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}"
Text="Stack trace"
TextWrapping="Wrap"
FontWeight="Bold"
MaxWidth="1000" />
<avalonedit:TextEditor SyntaxHighlighting="C#"
FontFamily="pack://application:,,,/Resources/Fonts/#Roboto Mono"
FontSize="10pt"
IsReadOnly="True"
Document="{Binding Document}"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto"
Margin="0 10 10 0"
MaxHeight="500"
Padding="10" />
<Separator Margin="0 15" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</ScrollViewer>
</DockPanel>
</controls:MaterialWindow>
@@ -2,14 +2,15 @@
using System.Collections.Generic;
using Artemis.UI.Shared.Services.Dialog;
using ICSharpCode.AvalonEdit.Document;
using Stylet;
namespace Artemis.UI.Shared.Screens.Dialogs
namespace Artemis.UI.Shared.Screens.Exceptions
{
public class ExceptionDialogViewModel : DialogViewModelBase
public class ExceptionViewModel : Screen
{
private List<DialogException> _exceptions;
public ExceptionDialogViewModel(string message, Exception exception)
public ExceptionViewModel(string message, Exception exception)
{
Header = message;
Exceptions = new List<DialogException>();
@@ -29,11 +30,6 @@ namespace Artemis.UI.Shared.Screens.Dialogs
get => _exceptions;
set => SetAndNotify(ref _exceptions, value);
}
public void Close()
{
Session.Close();
}
}
public class DialogException
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Artemis.UI.Shared.Screens.Dialogs;
using Artemis.UI.Shared.Screens.Exceptions;
using Artemis.UI.Shared.Services.Interfaces;
using MaterialDesignThemes.Wpf;
using Ninject;
@@ -15,15 +16,15 @@ namespace Artemis.UI.Shared.Services.Dialog
{
private readonly IKernel _kernel;
private readonly IViewManager _viewManager;
private readonly IWindowManager _windowManager;
public DialogService(IKernel kernel, IViewManager viewManager)
public DialogService(IKernel kernel, IViewManager viewManager, IWindowManager windowManager)
{
_kernel = kernel;
_viewManager = viewManager;
_windowManager = windowManager;
}
public bool IsExceptionDialogOpen { get; private set; }
public async Task<bool> ShowConfirmDialog(string header, string text, string confirmText = "Confirm", string cancelText = "Cancel")
{
var arguments = new IParameter[]
@@ -90,30 +91,9 @@ namespace Artemis.UI.Shared.Services.Dialog
return await ShowDialog(identifier, _kernel.Get<T>(parameters));
}
public async Task ShowExceptionDialog(string message, Exception exception)
public void ShowExceptionDialog(string message, Exception exception)
{
if (IsExceptionDialogOpen)
return;
IsExceptionDialogOpen = true;
var arguments = new IParameter[]
{
new ConstructorArgument("message", message),
new ConstructorArgument("exception", exception)
};
await Execute.OnUIThreadAsync(async () =>
{
try
{
DialogHost.CloseDialogCommand.Execute(new object(), null);
await ShowDialog<ExceptionDialogViewModel>(arguments);
}
finally
{
IsExceptionDialogOpen = false;
}
});
_windowManager.ShowDialog(new ExceptionViewModel(message, exception));
}
private async Task<object> ShowDialog(string identifier, DialogViewModelBase viewModel)
@@ -99,10 +99,7 @@ namespace Artemis.UI.Shared.Services.Interfaces
/// Shows a dialog displaying the provided message and exception. Does not handle, log or throw the exception.
/// </summary>
/// <param name="message">The message to display in the dialog title</param>
/// <param name="exception">The exception to display. The exception message and stacktrace will be shown.</param>
/// <returns>A task resolving when the dialog is closed</returns>
Task ShowExceptionDialog(string message, Exception exception);
bool IsExceptionDialogOpen { get; }
void ShowExceptionDialog(string message, Exception exception);
}
}