<UserControl xmlns="https://github.com/avaloniaui"
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:vm="clr-namespace:PacketLogger.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="PacketLogger.Views.PacketLogView"
xmlns:i="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia"
xmlns:converters="clr-namespace:PacketLogger.Converters"
xmlns:views="clr-namespace:PacketLogger.Views"
xmlns:packets="clr-namespace:PacketLogger.Models.Packets"
xmlns:packetLogger="clr-namespace:PacketLogger"
x:Name="UserControl">
<UserControl.Resources>
<converters:PacketSourceConverter x:Key="packetSourceConverter" />
</UserControl.Resources>
<Design.DataContext>
<vm:PacketLogViewModel />
</Design.DataContext>
<SplitView IsPaneOpen="{Binding PaneOpen, Mode = TwoWay}" DisplayMode="CompactInline" PanePlacement="Right">
<SplitView.Pane>
<Grid ColumnDefinitions="*" RowDefinitions="*,80" Margin="10">
<Grid Grid.Row="0" RowDefinitions="45,*">
<Grid Grid.Row="0" Grid.Column="0" ColumnDefinitions="24, Auto, *">
<Button Margin="0,1,0,0" VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch" Width="22" Height="22"
Command="{Binding TogglePane}">
<Grid>
<i:Icon Value="mdi-menu-left" Height="22" Width="22" Margin="0,0,2,0"
IsVisible="{Binding !PaneOpen}" />
<i:Icon Value="mdi-menu-right" Height="22" Width="22" IsVisible="{Binding PaneOpen}" />
</Grid>
</Button>
<TextBlock VerticalAlignment="Center" Grid.Column="1" FontSize="30" Text="Filter"
Margin="5,0,0,0" />
<TabStrip Grid.Column="2" VerticalAlignment="Center">
<TabStripItem IsSelected="{Binding RecvFilterSelected, Mode = TwoWay}">Recv</TabStripItem>
<TabStripItem IsSelected="{Binding SendFilterSelected, Mode = TwoWay}">Send</TabStripItem>
</TabStrip>
</Grid>
<Panel Grid.Row="1" Margin="0,5,0,0">
<ContentControl IsVisible="{Binding RecvFilterSelected}" Content="{Binding RecvFilter}"></ContentControl>
<ContentControl IsVisible="{Binding SendFilterSelected}" Content="{Binding SendFilter}"></ContentControl>
</Panel>
</Grid>
<Grid Grid.Row="1" RowDefinitions="40,40" ColumnDefinitions="140,140">
<CheckBox Grid.Row="0" Grid.Column="0" Content="Log received" IsChecked="{Binding LogReceived}" />
<CheckBox Grid.Row="0" Grid.Column="1" Content="Log sent" IsChecked="{Binding LogSent}" />
<CheckBox Grid.Row="1" Grid.Column="0" Content="Scroll" IsChecked="{Binding Scroll}" />
<Button Grid.Row="1" Grid.Column="1" Content="Clear" HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center" Command="{Binding Clear}" />
</Grid>
</Grid>
</SplitView.Pane>
<ListBox Items="{Binding FilteredPackets}"
x:Name="PacketsLog"
SelectedItem="{Binding SelectedPacket, Mode=TwoWay}"
SelectionChanged="PacketsLog_OnSelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Width="80" Text="{Binding Date, StringFormat = {}{0:HH:mm:ss}}" />
<TextBlock Width="50"
Text="{Binding Source, Converter = {StaticResource packetSourceConverter}}">
</TextBlock>
<Border Margin="5,0,0,0" ToolTip.Tip="{Binding PacketString}">
<TextBlock VerticalAlignment="Center" Text="{Binding PacketString}"
TextTrimming="CharacterEllipsis">
</TextBlock>
</Border>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ContextMenu>
<ContextMenu Name="PacketMenu">
<MenuItem Header="Copy packets" Command="{Binding CopyPackets}"
CommandParameter="{Binding ElementName=PacketsLog, Path=SelectedItems}" IsEnabled="True">
</MenuItem>
</ContextMenu>
</ListBox.ContextMenu>
</ListBox>
</SplitView>
</UserControl>