<Window x:Class="ReAct_PME.VoirLogs"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        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:local="clr-namespace:ReAct_PME"
        mc:Ignorable="d"
        Title="Historique des logs" Height="800" Width="1200" Background="#FFF0F0F0">
    <Window.Resources>
        <!-- Style pour changer la couleur des en-têtes -->
        <Style x:Key="DefaultColumnHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
            <Setter Property="Background" Value="LightGray" />
            <Setter Property="Foreground" Value="Black" />
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
        </Style>
        <!-- Style pour la colonne cliquée -->
        <Style x:Key="ClickedColumnHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
            <Setter Property="Background" Value="LightBlue" />
            <Setter Property="Foreground" Value="Black" />
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,0,0,0">
            <Button 
                Content="Précédent" Width="80" Margin="5" 
                Style="{DynamicResource ButtonStyle}" 
                Click="BtnPrecedent_Click"
                />
            <TextBlock x:Name="PageInfoTextBlock" FontWeight="Bold" Text="{Binding DateRefStr}" VerticalAlignment="Center" Margin="10,0"/>
            <Button Content="Suivant" Width="80" Margin="5" 
                Style="{DynamicResource ButtonStyle}" 
                Click="BtnSuivant_Click"                
                />
        </StackPanel>

        <StackPanel Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Left" Margin="10,5">
            <CheckBox Content="Debug" IsChecked="{Binding ShowDebug}" Margin="5,0"/>
            <CheckBox Content="Info" IsChecked="{Binding ShowInfo}" Margin="5,0"/>
            <CheckBox Content="Warning" IsChecked="{Binding ShowWarning}" Margin="5,0"/>
            <CheckBox Content="Error" IsChecked="{Binding ShowError}" Margin="5,0"/>
        </StackPanel>

           <ListView x:Name="LogsListView" Grid.Row="1" VerticalAlignment="Top" Margin="5,5,5,5"
                  AlternationCount="2" ItemContainerStyle="{DynamicResource AlternatingListViewItemStyle}"
                      Style="{DynamicResource ListViewStyle}" 
                  IsSynchronizedWithCurrentItem="false"
                  ItemsSource="{Binding LogsView}" >
            <ListView.View>
                <GridView>
                    <!--
                    <GridViewColumn Header="Niveau" Width="100" DisplayMemberBinding="{Binding Part1}" />
                    <GridViewColumn Header="Horodatage" Width="150" DisplayMemberBinding="{Binding Part2}" />
                    <GridViewColumn Header="Message" Width="100" DisplayMemberBinding="{Binding Part3}"  />
                    -->
                    <GridViewColumn Width="100" local:GridViewSort.PropertyName="Niveau">
                        <GridViewColumnHeader Content="Niveau" Style="{DynamicResource DefaultColumnHeaderStyle}"/>
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Part1}" 
                                       TextTrimming="CharacterEllipsis" 
                                       VerticalAlignment="Center" 
                                       FontSize="10"
                                       Padding="0" ToolTip="{Binding Part1}" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>

                    <GridViewColumn Width="150" local:GridViewSort.PropertyName="Horodatage">
                        <GridViewColumnHeader Content="Horodatage" Style="{DynamicResource DefaultColumnHeaderStyle}"/>
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Part2}" 
                                       TextTrimming="CharacterEllipsis" 
                                       VerticalAlignment="Center" 
                                       FontSize="10"
                                       Padding="0" ToolTip="{Binding Part2}" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    
                    <GridViewColumn Width="900" local:GridViewSort.PropertyName="Message">
                        <GridViewColumnHeader Content="Message" Style="{DynamicResource DefaultColumnHeaderStyle}"/>
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Part3}" 
                                       TextTrimming="CharacterEllipsis" 
                                       VerticalAlignment="Center" 
                                       FontSize="10"
                                       Padding="0" ToolTip="{Binding Part3}" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>

        <Button Content="Fermer" Style="{DynamicResource ButtonStyle}" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,5,5,5" Width="65" Click="Button_Click"></Button>
    </Grid>
</Window>
