Dispenser/DispenserUI/Views/Controls/ConsoleLog.axaml

29 lines
1.6 KiB
Plaintext
Raw Normal View History

2024-08-16 07:20:09 +00:00
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converter="clr-namespace:DispenserUI.ViewModels.Converter"
xmlns:components="clr-namespace:DispenserUI.ViewModels.Components"
x:DataType="components:ConsoleLogVM"
Background="#36394A"
Padding="20"
x:Class="DispenserUI.Views.Controls.ConsoleLog">
<UserControl.Resources>
<converter:LogColorConverter x:Key="LogColorConverter" />
</UserControl.Resources>
<ScrollViewer x:Name="ConsoleViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<ItemsRepeater ItemsSource="{Binding Logs}">
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Left" Margin="0,0,0,2">
<SelectableTextBlock Text="{Binding Timestamp}"
Foreground="{Binding Level,Converter={StaticResource LogColorConverter}}" />
<SelectableTextBlock Margin="10,0,0,0" Text="{Binding Message}"
TextWrapping="Wrap"
MaxWidth="1300"
Foreground="{Binding Level,Converter={StaticResource LogColorConverter}}" />
</StackPanel>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</ScrollViewer>
</UserControl>