59 lines
2.7 KiB
XML
59 lines
2.7 KiB
XML
<UserControl x:Class="Torch.Server.Views.LogViewerControl"
|
|
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:local="clr-namespace:Torch.Server.Views"
|
|
xmlns:viewModels="clr-namespace:Torch.Server.ViewModels"
|
|
mc:Ignorable="d"
|
|
d:DesignHeight="300" d:DesignWidth="300">
|
|
<UserControl.DataContext>
|
|
<viewModels:LogViewerViewModel />
|
|
</UserControl.DataContext>
|
|
<UserControl.Resources>
|
|
<Style TargetType="ItemsControl" x:Key="LogViewerStyle">
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate>
|
|
<ScrollViewer CanContentScroll="True" ScrollChanged="ScrollViewer_OnScrollChanged"
|
|
Loaded="ScrollViewer_OnLoaded" Unloaded="ScrollViewer_OnUnloaded">
|
|
<ItemsPresenter />
|
|
</ScrollViewer>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
|
|
<Setter Property="ItemsPanel">
|
|
<Setter.Value>
|
|
<ItemsPanelTemplate>
|
|
<VirtualizingStackPanel IsItemsHost="True" />
|
|
</ItemsPanelTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
|
|
<DataTemplate DataType="{x:Type viewModels:LogEntry}">
|
|
<Grid IsSharedSizeScope="True">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition SharedSizeGroup="Date" Width="Auto" />
|
|
<ColumnDefinition />
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<TextBlock Text="{Binding Timestamp, StringFormat=HH:mm:ss.fff}" Grid.Column="0"
|
|
FontWeight="Bold" FontFamily="Consolas" Foreground="{Binding Color}" Margin="5,0,5,0" />
|
|
|
|
<TextBox Grid.Column="1"
|
|
Text="{Binding Message, Mode=OneWay}"
|
|
TextWrapping="Wrap"
|
|
FontFamily="Consolas"
|
|
Background="Transparent"
|
|
BorderThickness="0"
|
|
IsReadOnly="True"
|
|
Foreground="{Binding Color}" />
|
|
</Grid>
|
|
</DataTemplate>
|
|
</UserControl.Resources>
|
|
<Grid Background="#0c0c0c">
|
|
<ItemsControl ItemsSource="{Binding LogEntries}" Style="{StaticResource LogViewerStyle}" />
|
|
</Grid>
|
|
</UserControl> |