<UserControl x:Class="PerformanceMonitorDashboard.Controls.ConfigChangesContent"
             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"
             mc:Ignorable="d"
             d:DesignHeight="450" d:DesignWidth="800"
             Loaded="OnLoaded">
    <UserControl.Resources>
        <ContextMenu x:Key="DataGridContextMenu">
            <MenuItem Header="Copy Cell" Click="CopyCell_Click"/>
            <MenuItem Header="Copy Row" Click="CopyRow_Click"/>
            <MenuItem Header="Copy All Rows" Click="CopyAllRows_Click"/>
            <Separator/>
            <MenuItem Header="Export to CSV..." Click="ExportToCsv_Click"/>
        </ContextMenu>
    </UserControl.Resources>
    <TabControl ItemContainerStyle="{DynamicResource SubTabItemStyle}">
        <!-- Server Configuration Changes Sub-Tab -->
        <TabItem Header="Server Config Changes">
            <Grid>
            <DataGrid x:Name="ServerConfigChangesDataGrid" AutoGenerateColumns="False" IsReadOnly="True"
                      RowHeight="28" GridLinesVisibility="Horizontal" CanUserResizeColumns="True"
                      ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"
                      ContextMenu="{StaticResource DataGridContextMenu}">
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding ChangeTime, Converter={StaticResource ServerTimeConverter}}" Width="150">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="ChangeTime" Click="ServerConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Change Time" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding ConfigurationName}" Width="200">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="ConfigurationName" Click="ServerConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Configuration" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding OldValueConfigured}" Width="110">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="OldValueConfigured" Click="ServerConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Old Configured" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding NewValueConfigured}" Width="110">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="NewValueConfigured" Click="ServerConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="New Configured" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding OldValueInUse}" Width="100">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="OldValueInUse" Click="ServerConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Old In Use" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding NewValueInUse}" Width="100">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="NewValueInUse" Click="ServerConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="New In Use" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridCheckBoxColumn Binding="{Binding RequiresRestart}" Width="80">
                        <DataGridCheckBoxColumn.Header>
                            <StackPanel>
                                <TextBlock Text="Restart?" FontWeight="Bold" Margin="0,0,0,2"/>
                                <ComboBox x:Name="ServerConfigChangesRestartFilterCombo" Width="70" Height="22" FontSize="11"
                                          SelectionChanged="ServerConfigChangesBoolFilter_Changed" Tag="RequiresRestart">
                                    <ComboBoxItem Content="All" IsSelected="True"/>
                                    <ComboBoxItem Content="True"/>
                                    <ComboBoxItem Content="False"/>
                                </ComboBox>
                            </StackPanel>
                        </DataGridCheckBoxColumn.Header>
                    </DataGridCheckBoxColumn>
                    <DataGridCheckBoxColumn Binding="{Binding IsDynamic}" Width="70">
                        <DataGridCheckBoxColumn.Header>
                            <StackPanel>
                                <TextBlock Text="Dynamic" FontWeight="Bold" Margin="0,0,0,2"/>
                                <ComboBox x:Name="ServerConfigChangesDynamicFilterCombo" Width="60" Height="22" FontSize="11"
                                          SelectionChanged="ServerConfigChangesBoolFilter_Changed" Tag="IsDynamic">
                                    <ComboBoxItem Content="All" IsSelected="True"/>
                                    <ComboBoxItem Content="True"/>
                                    <ComboBoxItem Content="False"/>
                                </ComboBox>
                            </StackPanel>
                        </DataGridCheckBoxColumn.Header>
                    </DataGridCheckBoxColumn>
                    <DataGridCheckBoxColumn Binding="{Binding IsAdvanced}" Width="70">
                        <DataGridCheckBoxColumn.Header>
                            <StackPanel>
                                <TextBlock Text="Advanced" FontWeight="Bold" Margin="0,0,0,2"/>
                                <ComboBox x:Name="ServerConfigChangesAdvancedFilterCombo" Width="60" Height="22" FontSize="11"
                                          SelectionChanged="ServerConfigChangesBoolFilter_Changed" Tag="IsAdvanced">
                                    <ComboBoxItem Content="All" IsSelected="True"/>
                                    <ComboBoxItem Content="True"/>
                                    <ComboBoxItem Content="False"/>
                                </ComboBox>
                            </StackPanel>
                        </DataGridCheckBoxColumn.Header>
                    </DataGridCheckBoxColumn>
                    <DataGridTextColumn Binding="{Binding ChangeDescription}" Width="250">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="ChangeDescription" Click="ServerConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Change Description" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding Description}" Width="*">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="Description" Click="ServerConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Setting Description" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>
            <TextBlock x:Name="ServerConfigChangesNoDataMessage" Style="{DynamicResource NoDataMessage}"/>
            </Grid>
        </TabItem>

        <!-- Database Configuration Changes Sub-Tab -->
        <TabItem Header="Database Config Changes">
            <Grid>
            <DataGrid x:Name="DatabaseConfigChangesDataGrid" AutoGenerateColumns="False" IsReadOnly="True"
                      RowHeight="28" GridLinesVisibility="Horizontal" CanUserResizeColumns="True"
                      ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"
                      ContextMenu="{StaticResource DataGridContextMenu}">
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding ChangeTime, Converter={StaticResource ServerTimeConverter}}" Width="150">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="ChangeTime" Click="DbConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Change Time" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding DatabaseName}" Width="150">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="DatabaseName" Click="DbConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Database" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding SettingType}" Width="120">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="SettingType" Click="DbConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Setting Type" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding SettingName}" Width="200">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="SettingName" Click="DbConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Setting Name" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding OldValue}" Width="150">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="OldValue" Click="DbConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Old Value" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding NewValue}" Width="150">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="NewValue" Click="DbConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="New Value" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding ChangeDescription}" Width="*">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="ChangeDescription" Click="DbConfigChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Change Description" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>
            <TextBlock x:Name="DatabaseConfigChangesNoDataMessage" Style="{DynamicResource NoDataMessage}"/>
            </Grid>
        </TabItem>

        <!-- Trace Flag Changes Sub-Tab -->
        <TabItem Header="Trace Flag Changes">
            <Grid>
            <DataGrid x:Name="TraceFlagChangesDataGrid" AutoGenerateColumns="False" IsReadOnly="True"
                      RowHeight="28" GridLinesVisibility="Horizontal" CanUserResizeColumns="True"
                      ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"
                      ContextMenu="{StaticResource DataGridContextMenu}">
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding ChangeTime, Converter={StaticResource ServerTimeConverter}}" Width="150">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="ChangeTime" Click="TraceFlagChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Change Time" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding TraceFlag}" ElementStyle="{StaticResource NumericCell}" Width="90">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="TraceFlag" Click="TraceFlagChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Trace Flag" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding PreviousStatus}" Width="100">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="PreviousStatus" Click="TraceFlagChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Previous Status" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding NewStatus}" Width="100">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="NewStatus" Click="TraceFlagChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="New Status" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding Scope}" Width="80">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="Scope" Click="TraceFlagChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Scope" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridCheckBoxColumn Binding="{Binding IsGlobal}" Width="80">
                        <DataGridCheckBoxColumn.Header>
                            <StackPanel>
                                <TextBlock Text="Global" FontWeight="Bold" Margin="0,0,0,2"/>
                                <ComboBox x:Name="TraceFlagChangesGlobalFilterCombo" Width="70" Height="22" FontSize="11"
                                          SelectionChanged="TraceFlagChangesBoolFilter_Changed" Tag="IsGlobal">
                                    <ComboBoxItem Content="All" IsSelected="True"/>
                                    <ComboBoxItem Content="True"/>
                                    <ComboBoxItem Content="False"/>
                                </ComboBox>
                            </StackPanel>
                        </DataGridCheckBoxColumn.Header>
                    </DataGridCheckBoxColumn>
                    <DataGridCheckBoxColumn Binding="{Binding IsSession}" Width="80">
                        <DataGridCheckBoxColumn.Header>
                            <StackPanel>
                                <TextBlock Text="Session" FontWeight="Bold" Margin="0,0,0,2"/>
                                <ComboBox x:Name="TraceFlagChangesSessionFilterCombo" Width="70" Height="22" FontSize="11"
                                          SelectionChanged="TraceFlagChangesBoolFilter_Changed" Tag="IsSession">
                                    <ComboBoxItem Content="All" IsSelected="True"/>
                                    <ComboBoxItem Content="True"/>
                                    <ComboBoxItem Content="False"/>
                                </ComboBox>
                            </StackPanel>
                        </DataGridCheckBoxColumn.Header>
                    </DataGridCheckBoxColumn>
                    <DataGridTextColumn Binding="{Binding ChangeDescription}" Width="*">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="ChangeDescription" Click="TraceFlagChangesFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Change Description" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>
            <TextBlock x:Name="TraceFlagChangesNoDataMessage" Style="{DynamicResource NoDataMessage}"/>
            </Grid>
        </TabItem>
    </TabControl>
</UserControl>
