mirror of
https://github.com/4sval/FModel.git
synced 2026-09-19 06:54:28 -05:00
Additional exception info in a dropdown
This commit is contained in:
Submodule CUE4Parse updated: 9a5f8b9f38...b046ebb430
@@ -502,4 +502,29 @@ public class LogEntryViewModel(LogEvent log)
|
||||
_ => log.Exception?.Message ?? log.RenderMessage()
|
||||
};
|
||||
public Exception? Exception { get; } = log.Exception;
|
||||
public IReadOnlyList<ExceptionDetailsViewModel> ExceptionDetails { get; } =
|
||||
log.Exception is { } exception ? [new ExceptionDetailsViewModel(exception)] : [];
|
||||
}
|
||||
|
||||
public class ExceptionDetailsViewModel
|
||||
{
|
||||
public string Header { get; }
|
||||
public string Details { get; }
|
||||
|
||||
public ExceptionDetailsViewModel(Exception exception)
|
||||
{
|
||||
var text = exception.ToString().ReplaceLineEndings("\n");
|
||||
var newline = text.IndexOf('\n');
|
||||
|
||||
if (newline < 0)
|
||||
{
|
||||
Header = text;
|
||||
Details = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
Header = text[..newline];
|
||||
Details = text[(newline + 1)..];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,8 +131,25 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ExceptionTreeViewItemStyle"
|
||||
TargetType="TreeViewItem">
|
||||
<Setter Property="HorizontalContentAlignment"
|
||||
Value="Stretch" />
|
||||
<Setter Property="Focusable"
|
||||
Value="False" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TreeViewItem">
|
||||
<ContentPresenter ContentSource="Header"
|
||||
HorizontalAlignment="Stretch"
|
||||
Margin="0,2,8,6" />
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<DataTemplate x:Key="LogEntryTemplate" DataType="{x:Type vm:LogEntryViewModel}">
|
||||
<Grid Margin="0 1" ToolTip="{Binding Exception}">
|
||||
<Grid Margin="0 1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@@ -389,7 +406,8 @@
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
VirtualizingPanel.ScrollUnit="Item"
|
||||
ScrollViewer.CanContentScroll="True">
|
||||
ScrollViewer.CanContentScroll="True"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="TreeViewItem" BasedOn="{StaticResource StretchTreeViewItemStyle}">
|
||||
<Style.Triggers>
|
||||
@@ -414,9 +432,44 @@
|
||||
HorizontalAlignment="Stretch" />
|
||||
|
||||
<HierarchicalDataTemplate.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type vm:LogEntryViewModel}">
|
||||
<ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource LogEntryTemplate}" />
|
||||
</DataTemplate>
|
||||
<HierarchicalDataTemplate DataType="{x:Type vm:LogEntryViewModel}"
|
||||
ItemsSource="{Binding ExceptionDetails}"
|
||||
ItemContainerStyle="{StaticResource ExceptionTreeViewItemStyle}">
|
||||
<ContentPresenter Content="{Binding}"
|
||||
ContentTemplate="{StaticResource LogEntryTemplate}"
|
||||
HorizontalAlignment="Stretch" />
|
||||
<HierarchicalDataTemplate.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type vm:ExceptionDetailsViewModel}">
|
||||
<Border Padding="8"
|
||||
CornerRadius="3"
|
||||
BorderThickness="2,0,0,0"
|
||||
BorderBrush="#EF5350"
|
||||
Background="{DynamicResource {x:Static adonisUi:Brushes.Layer1BackgroundBrush}}">
|
||||
<RichTextBox IsReadOnly="True"
|
||||
IsDocumentEnabled="False"
|
||||
MaxHeight="220"
|
||||
FontFamily="Consolas"
|
||||
FontSize="10"
|
||||
BorderThickness="0"
|
||||
Padding="0"
|
||||
Background="Transparent"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
HorizontalScrollBarVisibility="Disabled">
|
||||
<FlowDocument PagePadding="0">
|
||||
<Paragraph Margin="0">
|
||||
<Run Text="{Binding Header, Mode=OneWay}"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="#EF5350" />
|
||||
<LineBreak />
|
||||
<Run Text="{Binding Details, Mode=OneWay}"
|
||||
Foreground="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" />
|
||||
</Paragraph>
|
||||
</FlowDocument>
|
||||
</RichTextBox>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</HierarchicalDataTemplate.ItemTemplate>
|
||||
</HierarchicalDataTemplate>
|
||||
</HierarchicalDataTemplate.ItemTemplate>
|
||||
</HierarchicalDataTemplate>
|
||||
</HierarchicalDataTemplate.ItemTemplate>
|
||||
|
||||
Reference in New Issue
Block a user