<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:converters="clr-namespace:MahApps.Metro.Converters;assembly=MahApps.Metro"
                    xmlns:local="clr-namespace:Vulnerator.View.Styles"
                    xmlns:vh="clr-namespace:Vulnerator.View.ViewHelper">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Themes/ToggleSwitch.xaml" />
    </ResourceDictionary.MergedDictionaries>

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

    <!--  obsolete  -->
    <Style x:Key="MetroToggleSwitchButton"
           BasedOn="{StaticResource MahApps.Metro.Styles.ToggleSwitchButton}"
           TargetType="{x:Type Controls:ToggleSwitchButton}" />

    <!--  obsolete  -->
    <Style x:Key="MetroToggleSwitch"
           BasedOn="{StaticResource MahApps.Metro.Styles.ToggleSwitch}"
           TargetType="{x:Type Controls:ToggleSwitch}">
        <Setter Property="HeaderTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock HorizontalAlignment="Left"
                               VerticalAlignment="Top"
                               Opacity="0.65"
                               Text="{Binding Mode=OneWay}"
                               TextWrapping="Wrap" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--  Win10 style  -->
    <converters:ThicknessToDoubleConverter x:Key="ThicknessToDouble"
                                           TakeThicknessSide="Left" />

    <Style x:Key="MahApps.Metro.Styles.ToggleSwitchButton.Win10"
           BasedOn="{StaticResource MahApps.Metro.Styles.ToggleSwitchButton}"
           TargetType="{x:Type Controls:ToggleSwitchButton}">
        <Setter Property="BorderBrush" Value="{DynamicResource ControlBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Height" Value="18" />
        <Setter Property="IsChecked" Value="{Binding Path=(vh:DependencyProperties.PrimaryValue), RelativeSource={RelativeSource Self}, Mode=TwoWay, FallbackValue=False}" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="OffSwitchBrush" Value="{DynamicResource ControlBorderBrush}" />
        <Setter Property="OnSwitchBrush" Value="{DynamicResource AccentColorBrush}" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:ToggleSwitchButton}">
                    <Grid>
                        <Grid x:Name="PART_SwitchTrack"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                              UseLayoutRounding="False">
                            <Rectangle x:Name="PART_SwitchBrushOuterBorder"
                                       Width="{TemplateBinding Width}"
                                       Height="{TemplateBinding Height}"
                                       Fill="{TemplateBinding OffSwitchBrush}"
                                       RadiusX="3"
                                       RadiusY="3"
                                       Stroke="{TemplateBinding BorderBrush}"
                                       StrokeThickness="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={StaticResource ThicknessToDouble}}" />
                            <Rectangle x:Name="PART_SwitchBrushBorder"
                                       Width="{TemplateBinding Width}"
                                       Height="{TemplateBinding Height}"
                                       Fill="{TemplateBinding OnSwitchBrush}"
                                       Opacity="0"
                                       RadiusX="3"
                                       RadiusY="3"
                                       StrokeThickness="0" />
                            <Grid x:Name="PART_ThumbIndicator"
                                  Width="{TemplateBinding Height}"
                                  Height="{TemplateBinding Height}"
                                  HorizontalAlignment="Left"
                                  VerticalAlignment="Center">
                                <Grid.RenderTransform>
                                    <TranslateTransform x:Name="PART_ThumbTranslate" />
                                </Grid.RenderTransform>
                                <Rectangle x:Name="PART_ThumbIndicatorInner"
                                           Width="12"
                                           Height="12"
                                           Fill="{TemplateBinding ThumbIndicatorBrush}"
                                           RadiusX="3"
                                           RadiusY="3" />
                            </Grid>
                        </Grid>
                        <Thumb x:Name="PART_DraggingThumb">
                            <Thumb.Template>
                                <ControlTemplate>
                                    <Rectangle Fill="Transparent" />
                                </ControlTemplate>
                            </Thumb.Template>
                        </Thumb>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Disabled" />
                                <VisualState x:Name="MouseOver" />
                                <VisualState x:Name="Pressed" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <!--  Checked  -->
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="PART_SwitchBrushBorder" Property="Opacity" Value="1" />
                            <Setter TargetName="PART_SwitchBrushOuterBorder" Property="Opacity" Value="1" />
                            <Setter TargetName="PART_ThumbIndicatorInner" Property="Fill" Value="{DynamicResource AccentColorBrush}" />
                        </Trigger>
                        <!--  MouseOver  -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsChecked" Value="False" />
                                <Condition Property="IsEnabled" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_SwitchBrushOuterBorder" Property="Stroke" Value="{DynamicResource MahApps.Metro.Brushes.ToggleSwitchButton.OffMouseOverBorderBrush.Win10}" />
                            <Setter TargetName="PART_ThumbIndicatorInner" Property="Fill" Value="{DynamicResource MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorMouseOverBrush.Win10}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsChecked" Value="True" />
                                <Condition Property="IsEnabled" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_SwitchBrushOuterBorder" Property="Stroke" Value="{DynamicResource MahApps.Metro.Brushes.ToggleSwitchButton.OffMouseOverBorderBrush.Win10}" />
                        </MultiTrigger>
                        <!--  Pressed  -->
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="PART_SwitchBrushBorder" Property="Fill" Value="{DynamicResource MahApps.Metro.Brushes.ToggleSwitchButton.PressedBrush.Win10}" />
                            <Setter TargetName="PART_SwitchBrushBorder" Property="Opacity" Value="1" />
                            <Setter TargetName="PART_SwitchBrushOuterBorder" Property="Opacity" Value="0" />
                            <Setter TargetName="PART_ThumbIndicatorInner" Property="Fill" Value="{DynamicResource MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorPressedBrush.Win10}" />
                        </Trigger>
                        <!--  Disabled  -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsEnabled" Value="False" />
                                <Condition Property="IsChecked" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_SwitchBrushBorder" Property="Fill" Value="{DynamicResource MahApps.Metro.Brushes.ToggleSwitchButton.OnSwitchDisabledBrush.Win10}" />
                            <Setter TargetName="PART_SwitchBrushBorder" Property="Opacity" Value="1" />
                            <Setter TargetName="PART_SwitchBrushOuterBorder" Property="Opacity" Value="0" />
                            <Setter TargetName="PART_ThumbIndicatorInner" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ThumbIndicatorDisabledBrush}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsEnabled" Value="False" />
                                <Condition Property="IsChecked" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_SwitchBrushOuterBorder" Property="Stroke" Value="{DynamicResource MahApps.Metro.Brushes.ToggleSwitchButton.OffDisabledBorderBrush.Win10}" />
                            <Setter TargetName="PART_ThumbIndicatorInner" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ThumbIndicatorDisabledBrush}" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ThumbIndicatorBrush" Value="{DynamicResource ControlBorderBrush}" />
        <Setter Property="ThumbIndicatorDisabledBrush" Value="{DynamicResource MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorDisabledBrush.Win10}" />
        <Setter Property="ThumbIndicatorWidth" Value="12" />
        <Setter Property="Width" Value="44" />
        <Setter Property="vh:DependencyProperties.PrimaryValue" Value="{Binding Path=(vh:DependencyProperties.PrimaryValue), RelativeSource={RelativeSource Self}, FallbackValue=False}" />
        <Setter Property="vh:DependencyProperties.SecondaryValue" Value="{Binding Path=(vh:DependencyProperties.PrimaryValue), RelativeSource={RelativeSource Self}, FallbackValue=False}" />
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=(vh:DependencyProperties.AlternateValueTrigger), RelativeSource={RelativeSource Self}, Converter={StaticResource IsNullConverter}}"
                         Value="False">
                <Setter Property="IsChecked" Value="{Binding Path=(vh:DependencyProperties.SecondaryValue), RelativeSource={RelativeSource Self}, Mode=TwoWay, Converter={StaticResource NullToBooleanConverter}}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=(vh:DependencyProperties.AlternateValueTrigger), RelativeSource={RelativeSource Self}, Converter={StaticResource IsNullConverter}}"
                         Value="True">
                <Setter Property="IsChecked" Value="{Binding Path=(vh:DependencyProperties.PrimaryValue), RelativeSource={RelativeSource Self}, Mode=TwoWay, Converter={StaticResource NullToBooleanConverter}}" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="CustomWin10ToggleSwitchStyle"
           BasedOn="{StaticResource MahApps.Metro.Styles.ToggleSwitch}"
           TargetType="{x:Type Controls:ToggleSwitch}">
        <Setter Property="ContentDirection" Value="RightToLeft" />
        <Setter Property="Controls:ControlsHelper.HeaderFontSize" Value="{DynamicResource ToggleSwitchHeaderFontSize.Win10}" />
        <Setter Property="FontFamily" Value="{DynamicResource ToggleSwitchFontFamily.Win10}" />
        <Setter Property="FontSize" Value="{DynamicResource ToggleSwitchFontSize.Win10}" />
        <Setter Property="HeaderFontFamily" Value="{DynamicResource ToggleSwitchHeaderFontFamily.Win10}" />
        <Setter Property="OffSwitchBrush" Value="{DynamicResource MahApps.Metro.Brushes.ToggleSwitchButton.OffSwitchBrush.Win10}" />
        <Setter Property="OnSwitchBrush" Value="{DynamicResource MahApps.Metro.Brushes.ToggleSwitchButton.OffSwitchBrush.Win10}" />
        <Setter Property="ThumbIndicatorBrush" Value="{DynamicResource ControlBorderBrush}" />
        <Setter Property="ThumbIndicatorDisabledBrush" Value="{DynamicResource MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorDisabledBrush.Win10}" />
        <Setter Property="ThumbIndicatorWidth" Value="12" />
        <Setter Property="ToggleSwitchButtonStyle" Value="{StaticResource MahApps.Metro.Styles.ToggleSwitchButton.Win10}" />
        <!--  for v1.5.0 or later  -->
        <!--        <Setter Property="ContentPadding" Value="0 0 10 0" />-->
        <!--        <Style.Triggers>-->
        <!--            <Trigger Property="ContentDirection" Value="RightToLeft">-->
        <!--                <Setter Property="ContentPadding" Value="10 0 0 0" />-->
        <!--            </Trigger>-->
        <!--        </Style.Triggers>-->
    </Style>

</ResourceDictionary>