<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
                    xmlns:Converters="clr-namespace:Vulnerator.View.Converter"
                    xmlns:IconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
                    xmlns:local="clr-namespace:Vulnerator.View.Styles"
                    xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
                    xmlns:vh="clr-namespace:Vulnerator.View.ViewHelper"
                    xmlns:vm="clr-namespace:Vulnerator.ViewModel">

    <Style x:Key="GreyBorderedDataGridStyle"
           BasedOn="{StaticResource MetroDataGrid}"
           TargetType="{x:Type DataGrid}">
        <Setter Property="AlternatingRowBackground" Value="{DynamicResource GrayBrush10}" />
        <Setter Property="AutoGenerateColumns" Value="False" />
        <Setter Property="BorderBrush" Value="{DynamicResource TextBoxBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="CanUserAddRows" Value="False" />
        <Setter Property="Controls:ControlsHelper.CornerRadius" Value="3" />
        <Setter Property="Controls:ControlsHelper.FocusBorderBrush" Value="{DynamicResource TextBoxFocusBorderBrush}" />
        <Setter Property="HorizontalScrollBarVisibility" Value="Disabled" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGrid}">
                    <Border Padding="{TemplateBinding Padding}"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="3"
                            SnapsToDevicePixels="True">
                        <ScrollViewer x:Name="DG_ScrollViewer"
                                      Focusable="False">
                            <ScrollViewer.Template>
                                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Button Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
                                                Command="{x:Static DataGrid.SelectAllCommand}"
                                                Focusable="False"
                                                Style="{DynamicResource {ComponentResourceKey ResourceId=MetroDataGridSelectAllButtonStyle,
                                                                                              TypeInTargetAssembly={x:Type DataGrid}}}"
                                                Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.All}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
                                        <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter"
                                                                        Grid.Row="0"
                                                                        Grid.Column="1"
                                                                        Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
                                        <Grid Grid.Row="1"
                                              Grid.ColumnSpan="2">
                                            <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
                                                                    Grid.ColumnSpan="2"
                                                                    CanContentScroll="{TemplateBinding CanContentScroll}" />
                                        </Grid>
                                        <ScrollBar x:Name="PART_VerticalScrollBar"
                                                   Grid.Row="1"
                                                   Grid.Column="2"
                                                   Maximum="{TemplateBinding ScrollableHeight}"
                                                   Orientation="Vertical"
                                                   ViewportSize="{TemplateBinding ViewportHeight}"
                                                   Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                                   Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
                                        <Grid Grid.Row="2"
                                              Grid.Column="1">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="{Binding NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
                                                <ColumnDefinition Width="*" />
                                            </Grid.ColumnDefinitions>
                                            <ScrollBar x:Name="PART_HorizontalScrollBar"
                                                       Grid.Column="1"
                                                       Maximum="{TemplateBinding ScrollableWidth}"
                                                       Orientation="Horizontal"
                                                       ViewportSize="{TemplateBinding ViewportWidth}"
                                                       Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                                       Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
                                        </Grid>
                                    </Grid>
                                </ControlTemplate>
                            </ScrollViewer.Template>
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="CustomColumnHeaderGripper"
           TargetType="{x:Type Thumb}">
        <Setter Property="Background" Value="{DynamicResource GrayBrush5}" />
        <Setter Property="Cursor" Value="SizeWE" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Margin="{TemplateBinding Padding}"
                            Background="Transparent"
                            BorderBrush="{TemplateBinding Background}"
                            BorderThickness="0,0,1,0"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Width" Value="8" />
    </Style>

    <Style x:Key="CustomHeaderBaseStyle"
           BasedOn="{StaticResource MetroDataGridColumnHeader}"
           TargetType="{x:Type DataGridColumnHeader}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Border x:Name="BackgroundBorder"
                                Grid.ColumnSpan="2"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}" />

                        <Controls:ContentControlEx x:Name="HeaderContent"
                                                   Margin="{TemplateBinding BorderThickness}"
                                                   Padding="{TemplateBinding Padding}"
                                                   HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                   VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                   Content="{TemplateBinding Content}"
                                                   ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                                   ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                   ContentTemplate="{TemplateBinding ContentTemplate}"
                                                   ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                   RecognizesAccessKey="True"
                                                   SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />

                        <Thumb x:Name="PART_LeftHeaderGripper"
                               HorizontalAlignment="Left"
                               Background="Transparent"
                               Style="{StaticResource CustomColumnHeaderGripper}" />



                        <IconPacks:PackIconFontAwesomeLight x:Name="SortArrow"
                                                            Grid.Column="1"
                                                            Width="8"
                                                            Height="10"
                                                            Margin="0,0,8,2"
                                                            VerticalAlignment="Center"
                                                            Foreground="{TemplateBinding Foreground}"
                                                            Visibility="Collapsed" />

                        <Thumb x:Name="PART_RightHeaderGripper"
                               Grid.Column="1"
                               HorizontalAlignment="Right"
                               Style="{StaticResource CustomColumnHeaderGripper}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="SortDirection" Value="Ascending">
                            <Setter TargetName="SortArrow" Property="Kind" Value="LongArrowAltUp" />
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <Trigger Property="SortDirection" Value="Descending">
                            <Setter TargetName="SortArrow" Property="Kind" Value="LongArrowAltDown" />
                            <Setter TargetName="SortArrow" Property="Margin" Value="0,0,8,0" />
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <Trigger Property="DisplayIndex" Value="0">
                            <Setter TargetName="PART_LeftHeaderGripper" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="CustomCenterAlignedDataGridHeaderStyle"
           BasedOn="{StaticResource CustomHeaderBaseStyle}"
           TargetType="{x:Type DataGridColumnHeader}">
        <Setter Property="Controls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="TextBlock.TextTrimming" Value="CharacterEllipsis" />
    </Style>

    <Style x:Key="CustomLeftAlignedDataGridHeaderStyle"
           BasedOn="{StaticResource CustomHeaderBaseStyle}"
           TargetType="{x:Type DataGridColumnHeader}">
        <Setter Property="Controls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="TextBlock.TextTrimming" Value="CharacterEllipsis" />
    </Style>

</ResourceDictionary>