<UserControl x:Class="PerformanceMonitorDashboard.Controls.DefaultTraceContent"
             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"
             xmlns:local="clr-namespace:PerformanceMonitorDashboard.Controls"
             Loaded="OnLoaded">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <local:TimeRangeSlicerControl x:Name="DefaultTraceSlicer" Grid.Row="0"/>

        <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="10" Background="{DynamicResource BackgroundLightBrush}">
            <TextBlock Text="Event Filter:" VerticalAlignment="Center" Margin="5,0" FontWeight="Bold"/>
            <ComboBox x:Name="DefaultTraceEventsFilterCombo" Width="200" Margin="2,0" SelectionChanged="DefaultTraceEventsFilter_Changed">
                <ComboBoxItem Content="All Events" Tag="" IsSelected="True"/>
                <ComboBoxItem Content="Auto Grow/Shrink" Tag="%Auto %"/>
                <ComboBoxItem Content="Audit Events" Tag="Audit%"/>
                <ComboBoxItem Content="Config Changes" Tag="%Configuration Change%"/>
                <ComboBoxItem Content="ErrorLog" Tag="%ErrorLog%"/>
                <ComboBoxItem Content="Memory Changes" Tag="%Memory Change%"/>
                <ComboBoxItem Content="Object:Altered" Tag="%Object:Altered%"/>
                <ComboBoxItem Content="Object:Created" Tag="%Object:Created%"/>
                <ComboBoxItem Content="Object:Deleted" Tag="%Object:Deleted%"/>
            </ComboBox>
            <Separator Margin="10,0" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}"/>
            <Button Content="Refresh" Click="DefaultTraceEvents_Refresh_Click" Margin="5,0" Padding="10,4" Style="{DynamicResource SuccessButton}"/>
        </StackPanel>

        <Grid Grid.Row="2">
            <DataGrid x:Name="DefaultTraceEventsDataGrid" AutoGenerateColumns="False" IsReadOnly="True"
                      GridLinesVisibility="Horizontal" CanUserResizeColumns="True" ContextMenu="{DynamicResource DataGridContextMenu}"
                      ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding EventTime, Converter={StaticResource ServerTimeConverter}}" Width="150">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="EventTime" Click="DefaultTraceFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Event Time" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding EventName}" Width="150">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="EventName" Click="DefaultTraceFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Event Name" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding DatabaseName}" Width="120">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="DatabaseName" Click="DefaultTraceFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Database" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding ObjectName}" Width="150">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="ObjectName" Click="DefaultTraceFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Object Name" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding LoginName}" Width="120">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="LoginName" Click="DefaultTraceFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Login" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding HostName}" Width="120">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="HostName" Click="DefaultTraceFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Host" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding ApplicationName}" Width="150">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="ApplicationName" Click="DefaultTraceFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Application" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding DurationMs, StringFormat='{}{0:N1}'}" Width="90">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="DurationMs" Click="DefaultTraceFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Duration (ms)" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding GrowthMb, StringFormat='{}{0:N2}'}" Width="90">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="GrowthMb" Click="DefaultTraceFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Growth (MB)" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding TextData}" Width="300">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="TextData" Click="DefaultTraceFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Text Data" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding Severity}" Width="60">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="Severity" Click="DefaultTraceFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Severity" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding Spid}" Width="60">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="Spid" Click="DefaultTraceFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="SPID" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>
            <TextBlock x:Name="DefaultTraceEventsNoDataMessage" Style="{DynamicResource NoDataMessage}"/>
        </Grid>
    </Grid>
</UserControl>
