~ruther/NosTale-PacketLogger

ref: 676e5bb566fd796d9d023b1ccbdc751d8e0bb5c2 NosTale-PacketLogger/src/PacketLogger/Views/Log/PacketLogView.axaml -rw-r--r-- 5.5 KiB
676e5bb5 — Rutherther feat: add possibility to save and load settings to json 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<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.Log.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"
             xmlns:log="clr-namespace:PacketLogger.ViewModels.Log"
             x:Name="UserControl">
    <UserControl.Resources>
        <converters:PacketSourceConverter x:Key="packetSourceConverter" />
    </UserControl.Resources>
    <Design.DataContext>
        <log:PacketLogViewModel />
    </Design.DataContext>
    <SplitView OpenPaneLength="300" IsPaneOpen="{Binding PaneOpen, Mode = TwoWay}" DisplayMode="CompactInline"
               PanePlacement="Right">
        <SplitView.Pane>
            <Grid Width="280" HorizontalAlignment="Left"
                  ColumnDefinitions="*" RowDefinitions="Auto,*,Auto" Margin="10">
                <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Stretch">
                    <Button Grid.Row="0" 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" FontSize="30" Text="Filter"
                               Margin="5,0,0,0" />

                    <ComboBox Width="160" Margin="10,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Stretch"
                              Items="{Binding Profiles.SelectableProfiles}" SelectedItem="{Binding FilterChoose.CurrentProfile, Mode = TwoWay}">
                        <ComboBox.DataTemplates>
                            <DataTemplate>
                                <TextBlock Text="{Binding Name}" />
                            </DataTemplate>
                        </ComboBox.DataTemplates>
                    </ComboBox>
                </StackPanel>

                <ContentControl Grid.Row="1" Content="{Binding FilterChoose}" />

                <Grid Grid.Row="2" 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"
                 SelectionMode="Multiple"
                 SelectedItem="{Binding SelectedPacket, Mode=TwoWay}"
                 VerticalAlignment="Stretch"
                 SelectionChanged="PacketsLog_OnSelectionChanged">
            <ListBox.Styles>
                <Style Selector="ListBoxItem">
                    <Setter Property="Padding" Value="1" />
                </Style>
                <Style Selector="TextBlock">
                    <Setter Property="FontSize" Value="12" />
                </Style>
            </ListBox.Styles>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Height="16" Margin="0" Orientation="Horizontal">
                        <TextBlock Width="60" Text="{Binding Date, StringFormat = {}{0:HH:mm:ss}}" />
                        <TextBlock Width="40"
                                   Text="{Binding Source, Converter = {StaticResource packetSourceConverter}}">
                        </TextBlock>
                        <Border 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>
Do not follow this link