<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:noesis="clr-namespace:NoesisGUIExtensions" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
  
  <ControlTemplate x:Key="Checkbox_Template" TargetType="CheckBox">

    <Grid x:Name="Master">
      <Grid x:Name="Sizer_Grid" Margin="16,16,16,16" Width="400">
        <Grid.Height>
          <Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}">
            <Binding.Converter>
              <noesis:MathConverter Expression="{}{0}/1.5"/>
            </Binding.Converter>
          </Binding>
        </Grid.Height>
        <Grid x:Name="Glow_Grid" Margin="0,0,0,-0.333">
          <Grid.Effect>
            <DropShadowEffect Color="{Binding Path=Foreground.Color, RelativeSource={RelativeSource TemplatedParent}}" Direction="0" ShadowDepth="0" BlurRadius="24" Opacity="0.5"/>
          </Grid.Effect>
          <Grid x:Name="Background_Grid">
            <Border x:Name="Image_Locked_Border" BorderThickness="1" CornerRadius="8,8,0,0">
              <Border.Background>
                <ImageBrush ImageSource="Assets/Bitmap_Image_Lock.png" Stretch="UniformToFill"/>
              </Border.Background>
            </Border>
            <Border x:Name="Image_Ready_Border" BorderThickness="1" CornerRadius="8,8,0,0">
              <Border.Background>
                <ImageBrush ImageSource="Assets/Bitmap_Image_Ready.png" Stretch="UniformToFill"/>
              </Border.Background>
            </Border>
            <Border x:Name="ImageTint_Border" CornerRadius="8,8,0,0" Background="{Binding Path=Foreground, RelativeSource={RelativeSource TemplatedParent}}" Opacity="0.2" BorderThickness="1,1,1,1"/>
          </Grid>
          <Border x:Name="Notch_Border" BorderBrush="{Binding Path=Foreground, RelativeSource={RelativeSource TemplatedParent}}" BorderThickness="0,0,0,16" CornerRadius="8,8,0,0">
            <Grid x:Name="ButtonContent">
              <Grid x:Name="TextBacker_Grid">
                <Grid.Background>
                  <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                    <GradientStop Color="#00000000"/>
                    <GradientStop Color="#FF000000" Offset="1"/>
                  </LinearGradientBrush>
                </Grid.Background>
              </Grid>
              <TextBlock TextWrapping="Wrap" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource TemplatedParent}}" FontFamily="Old English Text MT" FontSize="50" VerticalAlignment="Bottom" Margin="16,0,16,8">
                <TextBlock.Text>
                  <Binding Path="Content" RelativeSource="{RelativeSource TemplatedParent}">
                    <Binding.Converter>
                      <noesis:CaseConverter Format="LowerCase"/>
                    </Binding.Converter>
                  </Binding>
                </TextBlock.Text>
                <TextBlock.Effect>
                  <DropShadowEffect Color="{Binding Path=Foreground.Color, RelativeSource={RelativeSource TemplatedParent}}" Direction="0" ShadowDepth="0" BlurRadius="16"/>
                </TextBlock.Effect>
              </TextBlock>
              <noesis:Star Fill="{Binding Path=Foreground, RelativeSource={RelativeSource TemplatedParent}}" Width="28" Height="16" VerticalAlignment="Top" HorizontalAlignment="Right" Count="3" Ratio="0.5" RenderTransformOrigin="0.5,0.5">
                <noesis:Star.Effect>
                  <DropShadowEffect Direction="0" Opacity="0.5" BlurRadius="24" Color="{Binding Path=Foreground.Color, RelativeSource={RelativeSource TemplatedParent}}" ShadowDepth="0"/>
                </noesis:Star.Effect>
                <noesis:Star.LayoutTransform>
                  <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform Angle="45"/>
                    <TranslateTransform/>
                  </TransformGroup>
                </noesis:Star.LayoutTransform>
                <noesis:Star.RenderTransform>
                  <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform/>
                  </TransformGroup>
                </noesis:Star.RenderTransform>
              </noesis:Star>
            </Grid>
          </Border>
          <Border x:Name="OuterStroke_Border" BorderThickness="2,2,2,2" BorderBrush="{Binding Path=Foreground, RelativeSource={RelativeSource TemplatedParent}}" CornerRadius="8,8,0,0"/>
        </Grid>
      </Grid>
    </Grid>

    <ControlTemplate.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Value="True" Property="IsThreeState"/>
        </MultiTrigger.Conditions>
        <Setter TargetName="Image_Locked_Border" Property="Visibility" Value="Visible"/>
        <Setter TargetName="Image_Ready_Border" Property="Visibility" Value="Collapsed"/>
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Value="False" Property="IsThreeState"/>
        </MultiTrigger.Conditions>
        <Setter TargetName="Image_Locked_Border" Property="Visibility" Value="Collapsed"/>
        <Setter TargetName="Image_Ready_Border" Property="Visibility" Value="Visible"/>
      </MultiTrigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="CheckBox_Style_DERIVATIVE" TargetType="CheckBox">
    <Setter Property="Background">
      <Setter.Value>
        <SolidColorBrush Color="#70a503"/>
      </Setter.Value>
    </Setter>
    <Setter Property="Foreground">
      <Setter.Value>
        <SolidColorBrush Color="#FFEBAB00"/>
      </Setter.Value>
    </Setter>
    <Setter Property="BorderBrush">
      <Setter.Value>
        <SolidColorBrush Color="#ebab00"/>
      </Setter.Value>
    </Setter>
    <Setter Property="BorderThickness" Value="16,0,0,0"/>
    <Setter Property="Cursor" Value="Hand"/>
    <Setter Property="Template" Value="{DynamicResource }"/>
    <Style.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" Value="True"/>
        </MultiTrigger.Conditions>
        <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
        <Setter Property="RenderTransform">
          <Setter.Value>
            <TransformGroup>
              <ScaleTransform ScaleY="1.05" ScaleX="1.05"/>
              <SkewTransform/>
              <RotateTransform/>
              <TranslateTransform/>
            </TransformGroup>
          </Setter.Value>
        </Setter>
      </MultiTrigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="CheckBox_Style_BASE" TargetType="CheckBox" BasedOn="{StaticResource {x:Type CheckBox}}">
    <Setter Property="BorderThickness" Value="16,0,0,0"/>
    <Setter Property="Cursor" Value="Hand"/>
    <Setter Property="Template" Value="{DynamicResource Checkbox_Template}"/>
    <Setter Property="Background">
      <Setter.Value>
        <SolidColorBrush Color="#FF000000"/>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" Value="True"/>
        </MultiTrigger.Conditions>
        <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
        <Setter Property="RenderTransform">
          <Setter.Value>
            <TransformGroup>
              <ScaleTransform ScaleY="1.05" ScaleX="1.05"/>
              <SkewTransform/>
              <RotateTransform/>
              <TranslateTransform/>
            </TransformGroup>
          </Setter.Value>
        </Setter>
      </MultiTrigger>
    </Style.Triggers>
  </Style>
</ResourceDictionary>