diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-12 12:53:46 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-12 12:53:46 +0200 |
| commit | 8231c057a4073e7397dbb1d953c43a76d8187e72 (patch) | |
| tree | 1c40c8497aac2f10f919ab732af0c357493ca320 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows | |
| parent | 2bef1ef7fb1d5cd57e2af3f47a648e512cfcd4f2 (diff) | |
| download | Tango-8231c057a4073e7397dbb1d953c43a76d8187e72.tar.gz Tango-8231c057a4073e7397dbb1d953c43a76d8187e72.zip | |
Implemented global exception trapping on machine studio.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows')
3 files changed, 124 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionResolutions.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionResolutions.cs new file mode 100644 index 000000000..2e7327559 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionResolutions.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.UI.Windows +{ + public enum ExceptionResolutions + { + Shutdown, + Restart, + Ignore + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml new file mode 100644 index 000000000..c08a08842 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml @@ -0,0 +1,61 @@ +<Window x:Class="Tango.MachineStudio.UI.Windows.ExceptionWindow" + 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:local="clr-namespace:Tango.MachineStudio.UI.Windows" + mc:Ignorable="d" + WindowStyle="None" ResizeMode="NoResize" Topmost="True" AllowsTransparency="True" WindowStartupLocation="CenterScreen" d:DesignHeight="300" d:DesignWidth="300" Width="610" Height="410" Background="Transparent" d:DataContext="{d:DesignInstance Type=local:ExceptionWindow, IsDesignTimeCreatable=False}"> + <Grid> + <Border BorderThickness="1" BorderBrush="DodgerBlue" Background="White" Margin="10" CornerRadius="10"> + <Border.Effect> + <DropShadowEffect ShadowDepth="0" BlurRadius="10" /> + </Border.Effect> + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="80"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <Grid> + <StackPanel Orientation="Horizontal" Margin="10"> + <Image Source="/Images/exception.png" RenderOptions.BitmapScalingMode="Fant"></Image> + <TextBlock Text="Machine Studio Error" VerticalAlignment="Center" Margin="10 0 0 0" FontSize="20"></TextBlock> + </StackPanel> + </Grid> + + <Grid Grid.Row="1" Margin="10 0 10 10"> + <Grid.RowDefinitions> + <RowDefinition Height="1*"/> + <RowDefinition Height="50"/> + </Grid.RowDefinitions> + + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="30"/> + <RowDefinition Height="223*"/> + </Grid.RowDefinitions> + + <Grid> + <TextBlock TextWrapping="Wrap" VerticalAlignment="Center" Margin="0 0 0 0"> + <Run>Machine Studio encountered an unexpected error. It is recommended to restart the application in order to resolve the issue.</Run> + </TextBlock> + </Grid> + + <Grid Grid.Row="1" Margin="0 10 0 0"> + <TextBox Style="{x:Null}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" BorderBrush="#515151" IsReadOnly="True" AcceptsReturn="True" Foreground="#FF5C5C" Padding="2" TextWrapping="Wrap" Text="{Binding Exception}"></TextBox> + </Grid> + </Grid> + + <Grid Grid.Row="1"> + <Button HorizontalAlignment="Left" Width="140" Command="{Binding ResolveCommand}" CommandParameter="{x:Static local:ExceptionResolutions.Ignore}">Ignore</Button> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> + <Button Margin="5 0 0 0" Width="140" Command="{Binding ResolveCommand}" CommandParameter="{x:Static local:ExceptionResolutions.Shutdown}">Shutdown</Button> + <Button Margin="5 0 0 0" Width="140" Command="{Binding ResolveCommand}" CommandParameter="{x:Static local:ExceptionResolutions.Restart}">Restart</Button> + </StackPanel> + </Grid> + </Grid> + </Grid> + </Border> + </Grid> +</Window> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml.cs new file mode 100644 index 000000000..0f74fee17 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml.cs @@ -0,0 +1,48 @@ +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.Shapes; +using Tango.Core.Commands; +using Tango.MachineStudio.UI.ViewModels; + +namespace Tango.MachineStudio.UI.Windows +{ + /// <summary> + /// Interaction logic for ExceptionWindow.xaml + /// </summary> + public partial class ExceptionWindow : Window + { + public ExceptionResolutions Resolution { get; set; } + + public String Exception { get; set; } + + public RelayCommand<ExceptionResolutions> ResolveCommand { get; set; } + + public ExceptionWindow() + { + InitializeComponent(); + DataContext = this; + } + + public ExceptionWindow(Exception ex) : this() + { + Exception = ex.FlattenException(); + ResolveCommand = new RelayCommand<ExceptionResolutions>(Resolve); + } + + private void Resolve(ExceptionResolutions resolution) + { + Resolution = resolution; + Close(); + } + } +} |
