<Styles xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:converters="using:Avalonia.Controls.Converters"
        xmlns:pc="using:Avalonia.Controls.Primitives.Converters"
        x:CompileBindings="True">

  <Styles.Resources>
    <pc:AccentColorConverter x:Key="AccentColor" />
    <converters:ToBrushConverter x:Key="ToBrush" />
    <converters:CornerRadiusFilterConverter x:Key="RightCornerRadiusFilterConverter" Filter="TopRight, BottomRight"/>
    <converters:CornerRadiusFilterConverter x:Key="LeftCornerRadiusFilterConverter" Filter="TopLeft, BottomLeft"/>
  </Styles.Resources>

  <Style Selector="ColorPreviewer">
    <Setter Property="Height" Value="70" />
    <Setter Property="CornerRadius" Value="0" />
    <Setter Property="Template">
      <ControlTemplate>
        <Grid ColumnDefinitions="Auto,*,Auto">
          <!-- Left accent colors -->
          <Grid Grid.Column="0"
                Height="40"
                Width="80"
                ColumnDefinitions="*,*"
                Margin="0,0,-10,0"
                VerticalAlignment="Center"
                IsVisible="{TemplateBinding ShowAccentColors}">
            <Border Grid.Column="0"
                    Grid.ColumnSpan="2"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"
                    Background="{StaticResource CheckeredBackgroundBrush}" />
            <Border x:Name="AccentDec2Border"
                    Grid.Column="0"
                    CornerRadius="{TemplateBinding CornerRadius, Converter={StaticResource LeftCornerRadiusFilterConverter}}"
                    Tag="-2"
                    Background="{TemplateBinding HsvColor, Converter={StaticResource AccentColor}, ConverterParameter='-2'}" />
            <Border x:Name="AccentDec1Border"
                    Grid.Column="1"
                    Tag="-1"
                    Background="{TemplateBinding HsvColor, Converter={StaticResource AccentColor}, ConverterParameter='-1'}" />
          </Grid>
          <!-- Right accent colors -->
          <Grid Grid.Column="2"
                Height="40"
                Width="80"
                ColumnDefinitions="*,*"
                Margin="-10,0,0,0"
                VerticalAlignment="Center"
                IsVisible="{TemplateBinding ShowAccentColors}">
            <Border Grid.Column="0"
                    Grid.ColumnSpan="2"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"
                    Background="{StaticResource CheckeredBackgroundBrush}" />
            <Border x:Name="AccentInc1Border"
                    Grid.Column="0"
                    Tag="1"
                    Background="{TemplateBinding HsvColor, Converter={StaticResource AccentColor}, ConverterParameter='1'}" />
            <Border x:Name="AccentInc2Border"
                    Grid.Column="1"
                    CornerRadius="{TemplateBinding CornerRadius, Converter={StaticResource RightCornerRadiusFilterConverter}}"
                    Tag="2"
                    Background="{TemplateBinding HsvColor, Converter={StaticResource AccentColor}, ConverterParameter='2'}" />
          </Grid>
          <!-- Must be last for drop shadow Z-index -->
          <Border Grid.Column="1"
                  BoxShadow="0 0 10 2 #BF000000"
                  CornerRadius="{TemplateBinding CornerRadius}"
                  Margin="10">
            <Panel>
              <Border Background="{StaticResource CheckeredBackgroundBrush}"
                      CornerRadius="{TemplateBinding CornerRadius}" />
              <Border x:Name="PreviewBorder"
                      CornerRadius="{TemplateBinding CornerRadius}"
                      Background="{TemplateBinding HsvColor, Converter={StaticResource ToBrush}}"
                      HorizontalAlignment="Stretch"
                      VerticalAlignment="Stretch" />
            </Panel>
          </Border>
        </Grid>
      </ControlTemplate>
    </Setter>
  </Style>

</Styles>
