<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:MahApps.Metro.Converters;assembly=MahApps.Metro"
                    xmlns:IconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
                    xmlns:local="clr-namespace:Vulnerator.View.Styles"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    xmlns:vsm="clr-namespace:System.Windows;assembly=PresentationFramework">

    <Converters:ThicknessBindingConverter x:Key="ThicknessBindingConverter" />

    <Thickness x:Key="ExpanderHeaderThemePadding">2</Thickness>
    <sys:Double x:Key="ExpanderToggleButtonEllipseThemeSize">18</sys:Double>

    <Style x:Key="CustomExpanderHeaderRight"
           BasedOn="{StaticResource ExpanderBaseHeaderStyle}"
           TargetType="{x:Type ToggleButton}">
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Grid Margin="{TemplateBinding Padding}"
                              Background="Transparent"
                              SnapsToDevicePixels="False">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Grid Margin="1">
                                <IconPacks:PackIconFontAwesomeLight x:Name="Arrow"
                                                                    HorizontalAlignment="Center"
                                                                    VerticalAlignment="Center"
                                                                    Foreground="{TemplateBinding Foreground}"
                                                                    Kind="CaretCircleRight" />
                            </Grid>
                            <Controls:ContentControlEx Grid.Row="1"
                                                       Margin="0,4,0,0"
                                                       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}" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter TargetName="Arrow" Property="Flip" Value="Horizontal" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Arrow" Property="Foreground" Value="{DynamicResource GrayBrush2}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Arrow" Property="Foreground" Value="{DynamicResource LabelTextBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
    </Style>

    <Style x:Key="CustomExpanderHeaderUp"
           BasedOn="{StaticResource ExpanderBaseHeaderStyle}"
           TargetType="{x:Type ToggleButton}">
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Grid Margin="{TemplateBinding Padding}"
                              Background="Transparent"
                              SnapsToDevicePixels="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Controls:ContentControlEx Margin="0,4,0,0"
                                                       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}" />
                            <Grid Grid.Column="1"
                                  Margin="1">
                                <IconPacks:PackIconFontAwesomeLight x:Name="Arrow"
                                                                    HorizontalAlignment="Center"
                                                                    VerticalAlignment="Center"
                                                                    Foreground="{TemplateBinding Foreground}"
                                                                    Kind="CaretCircleUp" />
                            </Grid>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter TargetName="Arrow" Property="Flip" Value="Horizontal" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Arrow" Property="Foreground" Value="{DynamicResource GrayBrush2}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Arrow" Property="Foreground" Value="{DynamicResource LabelTextBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="VerticalContentAlignment" Value="Center" />
    </Style>

    <Style x:Key="CustomExpanderHeaderLeft"
           BasedOn="{StaticResource CustomExpanderHeaderRight}"
           TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Grid Margin="{TemplateBinding Padding}"
                              Background="Transparent"
                              SnapsToDevicePixels="False">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Grid Margin="1">
                                <IconPacks:PackIconFontAwesomeLight x:Name="Arrow"
                                                                    HorizontalAlignment="Center"
                                                                    VerticalAlignment="Center"
                                                                    Foreground="{TemplateBinding Foreground}"
                                                                    Kind="CaretCircleLeft" />
                            </Grid>
                            <Controls:ContentControlEx Grid.Row="1"
                                                       Margin="0,4,0,0"
                                                       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}" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter TargetName="Arrow" Property="Flip" Value="Horizontal" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Arrow" Property="Foreground" Value="{DynamicResource GrayBrush2}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Arrow" Property="Foreground" Value="{DynamicResource LabelTextBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="CustomExpanderHeaderDown"
           BasedOn="{StaticResource CustomExpanderHeaderUp}"
           TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Grid Margin="{TemplateBinding Padding}"
                              Background="Transparent"
                              SnapsToDevicePixels="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Controls:ContentControlEx Grid.Column="0"
                                                       Margin="0,4,0,0"
                                                       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}" />
                            <Grid Grid.Column="1"
                                  Margin="1">
                                <IconPacks:PackIconFontAwesomeLight x:Name="Arrow"
                                                                    HorizontalAlignment="Center"
                                                                    VerticalAlignment="Center"
                                                                    Foreground="{TemplateBinding Foreground}"
                                                                    Kind="CaretCircleDown" />
                            </Grid>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter TargetName="Arrow" Property="Flip" Value="Vertical" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Arrow" Property="Foreground" Value="{DynamicResource GrayBrush2}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Arrow" Property="Foreground" Value="{DynamicResource LabelTextBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="CustomExpander"
           TargetType="{x:Type Expander}">
        <Setter Property="Background" Value="{DynamicResource AccentColorBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource AccentColorBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Controls:ControlsHelper.ContentCharacterCasing" Value="Upper" />
        <Setter Property="Controls:ControlsHelper.HeaderFontSize" Value="{DynamicResource ContentFontSize}" />
        <Setter Property="Controls:ExpanderHelper.HeaderDownStyle" Value="{StaticResource CustomExpanderHeaderDown}" />
        <Setter Property="Controls:ExpanderHelper.HeaderLeftStyle" Value="{StaticResource CustomExpanderHeaderLeft}" />
        <Setter Property="Controls:ExpanderHelper.HeaderRightStyle" Value="{StaticResource CustomExpanderHeaderRight}" />
        <Setter Property="Controls:ExpanderHelper.HeaderUpStyle" Value="{StaticResource CustomExpanderHeaderUp}" />
        <Setter Property="Controls:GroupBoxHelper.HeaderForeground" Value="{x:Null}" />
        <Setter Property="Foreground" Value="{DynamicResource BlackBrush}" />
        <Setter Property="Padding" Value="4" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <Grid>
                        <Rectangle x:Name="DisabledVisualElement"
                                   Fill="{DynamicResource ControlsDisabledBrush}"
                                   IsHitTestVisible="false"
                                   Opacity="0"
                                   RadiusX="3"
                                   RadiusY="3" />
                        <DockPanel x:Name="ExpanderRoot">
                            <Border x:Name="HeaderSite"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    CornerRadius="3"
                                    DockPanel.Dock="Top"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                    UseLayoutRounding="True">
                                <ToggleButton x:Name="ToggleSite"
                                              Controls:ControlsHelper.ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                              Content="{TemplateBinding Header}"
                                              ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                                              ContentTemplate="{TemplateBinding HeaderTemplate}"
                                              ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                                              FontSize="{TemplateBinding Controls:ControlsHelper.HeaderFontSize}"
                                              FontStretch="{TemplateBinding Controls:ControlsHelper.HeaderFontStretch}"
                                              FontWeight="{TemplateBinding Controls:ControlsHelper.HeaderFontWeight}"
                                              IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                              Style="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ExpanderHelper.HeaderDownStyle)}"
                                              UseLayoutRounding="False">
                                    <ToggleButton.Foreground>
                                        <MultiBinding Converter="{x:Static Converters:BackgroundToForegroundConverter.Instance}">
                                            <Binding Mode="OneWay"
                                                     Path="Background"
                                                     RelativeSource="{RelativeSource TemplatedParent}" />
                                            <Binding Mode="OneWay"
                                                     Path="(Controls:GroupBoxHelper.HeaderForeground)"
                                                     RelativeSource="{RelativeSource TemplatedParent}" />
                                        </MultiBinding>
                                    </ToggleButton.Foreground>
                                </ToggleButton>
                            </Border>
                            <Border x:Name="ExpandSite"
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                    Background="Transparent"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={StaticResource ThicknessBindingConverter}, ConverterParameter={x:Static Converters:ThicknessSideType.Top}}"
                                    CornerRadius="3"
                                    DockPanel.Dock="Bottom"
                                    Focusable="false"
                                    Opacity="0"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                    UseLayoutRounding="True"
                                    Visibility="Collapsed">
                                <ContentPresenter Margin="{TemplateBinding Padding}"
                                                  Content="{TemplateBinding Content}"
                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                  Cursor="{TemplateBinding Cursor}"
                                                  UseLayoutRounding="False" />
                            </Border>
                        </DockPanel>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal" />
                                <vsm:VisualState x:Name="MouseOver" />
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledVisualElement"
                                                                       Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0"
                                                                  Value="0.7" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ExpanderRoot"
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="0"
                                                                  Value="0.3" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="true">
                            <Setter TargetName="ExpandSite" Property="CornerRadius" Value="0,0,3,3" />
                            <Setter TargetName="ExpandSite" Property="Visibility" Value="Visible" />
                            <Setter TargetName="HeaderSite" Property="CornerRadius" Value="3,3,0,0" />
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource MetroExpanderExpandStoryboard}" />
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource MetroExpanderCollapseStoryboard}" />
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Right">
                            <Setter TargetName="ExpandSite" Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={StaticResource ThicknessBindingConverter}, ConverterParameter={x:Static Converters:ThicknessSideType.Left}}" />
                            <Setter TargetName="ExpandSite" Property="DockPanel.Dock" Value="Right" />
                            <Setter TargetName="HeaderSite" Property="DockPanel.Dock" Value="Left" />
                            <Setter TargetName="ToggleSite" Property="Style" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ExpanderHelper.HeaderRightStyle)}" />
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Up">
                            <Setter TargetName="ExpandSite" Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={StaticResource ThicknessBindingConverter}, ConverterParameter={x:Static Converters:ThicknessSideType.Bottom}}" />
                            <Setter TargetName="ExpandSite" Property="DockPanel.Dock" Value="Top" />
                            <Setter TargetName="HeaderSite" Property="DockPanel.Dock" Value="Bottom" />
                            <Setter TargetName="ToggleSite" Property="Style" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ExpanderHelper.HeaderUpStyle)}" />
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Down">
                            <Setter TargetName="ExpandSite" Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={StaticResource ThicknessBindingConverter}, ConverterParameter={x:Static Converters:ThicknessSideType.Top}}" />
                            <Setter TargetName="ExpandSite" Property="DockPanel.Dock" Value="Bottom" />
                            <Setter TargetName="HeaderSite" Property="DockPanel.Dock" Value="Top" />
                            <Setter TargetName="ToggleSite" Property="Style" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ExpanderHelper.HeaderDownStyle)}" />
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Left">
                            <Setter TargetName="ExpandSite" Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={StaticResource ThicknessBindingConverter}, ConverterParameter={x:Static Converters:ThicknessSideType.Right}}" />
                            <Setter TargetName="ExpandSite" Property="DockPanel.Dock" Value="Left" />
                            <Setter TargetName="HeaderSite" Property="DockPanel.Dock" Value="Right" />
                            <Setter TargetName="ToggleSite" Property="Style" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ExpanderHelper.HeaderLeftStyle)}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>