<ResourceDictionary
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:CompileBindings="True">
    <Design.PreviewWith>
        <CaptionButtons />
    </Design.PreviewWith>

    <ControlTheme x:Key="CaptionButton" TargetType="Button">
        <Setter Property="Foreground" Value="{DynamicResource CaptionButtonForeground}" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="CornerRadius" Value="{StaticResource CaptionButtonCornerRadius}" />
        <Setter Property="Padding" Value="{StaticResource CaptionButtonPadding}" />
        <Setter Property="Width" Value="{StaticResource CaptionButtonWidth}" />
        <Setter Property="Height" Value="{StaticResource CaptionButtonHeight}" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="Template">
            <ControlTemplate TargetType="Button">
                <ContentPresenter
                    Name="PART_ContentPresenter"
                    Padding="{TemplateBinding Padding}"
                    Foreground="{TemplateBinding Foreground}"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    Content="{TemplateBinding Content}"
                    ContentTemplate="{TemplateBinding ContentTemplate}"
                    CornerRadius="{TemplateBinding CornerRadius}" />
            </ControlTemplate>
        </Setter>

        <Style Selector="^:pointerover">
            <Setter Property="Background" Value="{DynamicResource CaptionButtonPointeroverBackground}" />
        </Style>

        <Style Selector="^:pressed">
            <Setter Property="Background" Value="{DynamicResource CaptionButtonPressedBackground}" />
        </Style>
    </ControlTheme>

    <ControlTheme x:Key="{x:Type CaptionButtons}" TargetType="CaptionButtons">
        <Setter Property="Foreground" Value="{DynamicResource CaptionButtonForeground}" />
        <Setter Property="Template">
            <ControlTemplate TargetType="CaptionButtons">
                <StackPanel Orientation="Horizontal">
                    <Button Name="PART_FullScreenButton" Theme="{StaticResource CaptionButton}">
                        <PathIcon
                            Name="PART_FullScreenButtonIcon"
                            Theme="{StaticResource InnerPathIcon}"
                            Data="{StaticResource WindowExpandGlyph}"
                            Foreground="{Binding $parent[Button].Foreground}" />
                    </Button>
                    <Button Name="PART_MinimizeButton" Theme="{StaticResource CaptionButton}">
                        <PathIcon
                            Name="PART_MinimizeButtonIcon"
                            Theme="{StaticResource InnerPathIcon}"
                            Data="{StaticResource WindowMinimizeGlyph}"
                            Foreground="{Binding $parent[Button].Foreground}" />
                    </Button>
                    <Button Name="PART_RestoreButton" Theme="{StaticResource CaptionButton}">
                        <PathIcon
                            Name="PART_RestoreButtonIcon"
                            Theme="{StaticResource InnerPathIcon}"
                            Data="{StaticResource WindowMaximizeGlyph}"
                            Foreground="{Binding $parent[Button].Foreground}" />
                    </Button>
                    <Button Name="PART_CloseButton" Theme="{StaticResource CaptionButton}">
                        <PathIcon
                            Name="PART_CloseButtonIcon"
                            Theme="{StaticResource InnerPathIcon}"
                            Data="{StaticResource WindowCloseIconGlyph}"
                            Foreground="{Binding $parent[Button].Foreground}" />
                    </Button>
                </StackPanel>
            </ControlTemplate>
        </Setter>

        <Style Selector="^ /template/ Button#PART_CloseButton:pointerover">
            <Setter Property="Foreground" Value="{DynamicResource CaptionButtonCloseForeground}" />
            <Setter Property="Background" Value="{DynamicResource CaptionButtonClosePointeroverBackground}" />
        </Style>
        <Style Selector="^ /template/ Button#PART_CloseButton:pressed">
            <Setter Property="Foreground" Value="{DynamicResource CaptionButtonCloseForeground}" />
            <Setter Property="Background" Value="{DynamicResource CaptionButtonClosePressedBackground}" />
        </Style>

        <Style Selector="^:maximized /template/ PathIcon#PART_RestoreButtonIcon">
            <Setter Property="Data" Value="{StaticResource WindowRestoreGlyph}" />
        </Style>
        <Style Selector="^:fullscreen /template/ PathIcon#PART_FullScreenButtonIcon">
            <Setter Property="Data" Value="{StaticResource WindowCollapseGlyph}" />
        </Style>
        <Style Selector="^:fullscreen /template/ Button#PART_RestoreButton">
            <Setter Property="IsVisible" Value="False" />
        </Style>
        <Style Selector="^:fullscreen /template/ Button#PART_MinimizeButton">
            <Setter Property="IsVisible" Value="False" />
        </Style>
    </ControlTheme>
</ResourceDictionary>