Files
Artemis/src/Artemis.UI.Shared/Screens/Dialogs/ExceptionDialogViewModel.cs
T
SpoinkyNL 35944e064d Device visualizer - Added support for rotation and scale
Profile editor - Fixed keyframe context menu actions
2020-06-22 17:43:04 +02:00

50 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using Artemis.UI.Shared.Services.Dialog;
using ICSharpCode.AvalonEdit.Document;
namespace Artemis.UI.Shared.Screens.Dialogs
{
public class ExceptionDialogViewModel : DialogViewModelBase
{
private List<DialogException> _exceptions;
public ExceptionDialogViewModel(string message, Exception exception)
{
Header = message;
Exceptions = new List<DialogException>();
var currentException = exception;
while (currentException != null)
{
Exceptions.Add(new DialogException(currentException));
currentException = currentException.InnerException;
}
}
public string Header { get; }
public List<DialogException> Exceptions
{
get => _exceptions;
set => SetAndNotify(ref _exceptions, value);
}
public void Close()
{
Session.Close();
}
}
public class DialogException
{
public DialogException(Exception exception)
{
Exception = exception;
Document = new TextDocument(new StringTextSource($"{exception.Message}\r\n\r\n{exception.StackTrace}"));
}
public Exception Exception { get; }
public IDocument Document { get; set; }
}
}