chr
2026-04-05 fe750b791d5b517cc4e9bc8e99a9a75139a0cfba
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
<UserControl x:Class="OpenTapEditor.LogControl"
             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:OpenTapEditor.UI"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <CollectionViewSource x:Key="LogFilter" Source="{Binding Datasouruce}" Filter="CollectionViewSource_Filter">
            
        </CollectionViewSource>
    </UserControl.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
            <CheckBox VerticalAlignment="Center" VerticalContentAlignment="Center" IsChecked="{Binding ShowError,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Content="错误"/>
            <CheckBox VerticalAlignment="Center" VerticalContentAlignment="Center" IsChecked="{Binding ShowWarn,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Content="警告"/>
            <CheckBox VerticalAlignment="Center" VerticalContentAlignment="Center" IsChecked="{Binding ShowInfo,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Content="信息"/>
            <CheckBox VerticalAlignment="Center" VerticalContentAlignment="Center" IsChecked="{Binding ShowDebug,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Content="调试"/>
            <Button VerticalAlignment="Center" VerticalContentAlignment="Center" Click="Button_Click">清空</Button>
        </StackPanel>
        <ListView x:Name="log" Grid.Row="1" ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                  VirtualizingPanel.ScrollUnit="Pixel" 
                  ItemsSource="{Binding ViewSource.View}">
            <ListView.Resources>
                <Style TargetType="TextBlock">
                    <Setter Property="TextWrapping" Value="Wrap"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Type}" Value="10">
                            <Setter Property="Foreground" Value="Red"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Type}" Value="20">
                            <Setter Property="Foreground" Value="OrangeRed"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Type}" Value="40">
                            <Setter Property="Foreground" Value="Gray"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </ListView.Resources>
            <!--<ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="Foreground" Value="Red"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <Texy BorderThickness="0" IsReadOnly="True"
                                         TextWrapping="Wrap" Text="{Binding Mode=OneWay}"/>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Type,RelativeSource={RelativeSource Self}}" Value="10">
                            <Setter Property="Foreground" Value="Red"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Type,RelativeSource={RelativeSource Self}}" Value="20">
                            <Setter Property="Foreground" Value="OrangeRed"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Type,RelativeSource={RelativeSource Self}}" Value="40">
                            <Setter Property="Foreground" Value="Gray"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </ListView.ItemContainerStyle>-->
        </ListView>
    </Grid>
</UserControl>