<ResourceDictionary xmlns="https://github.com/avaloniaui"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:animations="clr-namespace:PixiEditor.AvaloniaUI.Views.Animations"
                    xmlns:visuals="clr-namespace:PixiEditor.AvaloniaUI.Views.Visuals"
                    xmlns:ui="clr-namespace:PixiEditor.Extensions.UI;assembly=PixiEditor.Extensions"
                    xmlns:converters="clr-namespace:PixiEditor.AvaloniaUI.Helpers.Converters">
    <ControlTheme TargetType="animations:KeyFrame" x:Key="{x:Type animations:KeyFrame}">
        <Setter Property="ClipToBounds" Value="False"/>
        <Setter Property="Template">
            <ControlTemplate>
                <Grid>
                    <Border CornerRadius="{DynamicResource ControlCornerRadius}" Name="MainBorder"
                            Background="{DynamicResource ThemeBackgroundBrush1}" Height="20"
                            BorderBrush="{DynamicResource ThemeBorderMidBrush}" BorderThickness="1">
                        <Grid>
                            <Panel HorizontalAlignment="Right" Name="PART_ResizePanelRight" Width="5" Cursor="SizeWestEast" Background="Transparent" ZIndex="1"/>
                            <Panel Margin="-35, 0, 0, 0" HorizontalAlignment="Left" Name="PART_ResizePanelLeft" Width="5" Cursor="SizeWestEast" Background="Transparent" ZIndex="1"/>
                        </Grid>
                    </Border>
                    
                    <Border CornerRadius="{DynamicResource ControlCornerRadius}" Width="60" Height="60" Margin="-30, 0, 0, 0"
                            BorderThickness="1" VerticalAlignment="Center" IsHitTestVisible="True" Name="PreviewBorder"
                            HorizontalAlignment="Left" BorderBrush="{DynamicResource ThemeBorderMidBrush}"
                            RenderOptions.BitmapInterpolationMode="None">
                        <Border.Background>
                            <ImageBrush Source="/Images/CheckerTile.png" TileMode="Tile">
                                <ImageBrush.Transform>
                                    <ScaleTransform ScaleX="0.4" ScaleY="0.4" />
                                </ImageBrush.Transform>
                            </ImageBrush>
                        </Border.Background>
                        <visuals:SurfaceControl
                            Surface="{Binding Item.PreviewSurface, RelativeSource={RelativeSource TemplatedParent}}"
                            Stretch="Uniform" Width="60" Height="60">
                            <ui:RenderOptionsBindable.BitmapInterpolationMode>
                                <MultiBinding Converter="{converters:WidthToBitmapScalingModeConverter}">
                                    <Binding Path="Item.PreviewSurface.Size.X"
                                             RelativeSource="{RelativeSource TemplatedParent}" />
                                    <Binding RelativeSource="{RelativeSource Mode=Self}" Path="Bounds.Width" />
                                </MultiBinding>
                            </ui:RenderOptionsBindable.BitmapInterpolationMode>
                        </visuals:SurfaceControl>
                    </Border>
                </Grid>
            </ControlTemplate>
        </Setter>
        
        <Style Selector="^:selected /template/ Border#MainBorder">
            <Setter Property="BorderBrush" Value="{DynamicResource ThemeAccent2Color}" />
        </Style>
        
        <Style Selector="^:selected /template/ Border#PreviewBorder">
            <Setter Property="BorderBrush" Value="{DynamicResource ThemeAccent2Color}" />
        </Style>
        
        <Style Selector="^:disabled">
            <Setter Property="Opacity" Value="0.5" />
        </Style>
    </ControlTheme>

</ResourceDictionary>