<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:bpa="clr-namespace:BPA.UIControl">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/Resources/Default.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <!--  默认按钮  -->
    <Style x:Key="RubyerButtonBase" TargetType="{x:Type ButtonBase}">
        <Setter Property="Background" Value="{DynamicResource Primary}" />
        <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="10 5" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource AllControlCornerRadius}" />
        <Setter Property="bpa:ControlHelper.MaskOpacity" Value="0.6" />
        <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource MaskDark}" />
        <Setter Property="bpa:ButtonHelper.ShowShadow" Value="False" />
        <Setter Property="bpa:ButtonHelper.Loading" Value="False" />
        <Setter Property="bpa:ButtonHelper.LoadingContent" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <Border x:Name="border"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Grid>
                            <Border x:Name="effectBorder"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                    Effect="{DynamicResource RightBottomEffect}"
                                    Visibility="Collapsed" />

                            <bpa:ControlMask Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                             CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                             IsActive="{TemplateBinding IsPressed}"
                                             MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource Mode=TemplatedParent}}" />

                            <StackPanel Margin="{TemplateBinding Padding}"
                                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                        Orientation="Horizontal">
                                <bpa:Loading x:Name="loading"
                                             Margin="0 0 5 0"
                                             Background="Transparent"
                                             Diameter="16"
                                             FocusedBrush="{TemplateBinding Foreground}"
                                             StrokeThickness="2"
                                             Visibility="Collapsed" />

                                <ContentPresenter x:Name="contentPresenter"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                  Focusable="False"
                                                  RecognizesAccessKey="True"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </StackPanel>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="effectBorder"
                                                         Storyboard.TargetProperty="Effect.ShadowDepth"
                                                         To="0"
                                                         Duration="0:0:0.15">
                                            <DoubleAnimation.EasingFunction>
                                                <CubicEase EasingMode="EaseOut" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="effectBorder"
                                                         Storyboard.TargetProperty="Effect.ShadowDepth"
                                                         Duration="0:0:0.25">
                                            <DoubleAnimation.EasingFunction>
                                                <CubicEase EasingMode="EaseIn" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="border" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                        </Trigger>
                        <Trigger Property="bpa:ButtonHelper.ShowShadow" Value="True">
                            <Setter TargetName="effectBorder" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <Trigger Property="bpa:ButtonHelper.Shape" Value="Round">
                            <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}, Converter={StaticResource HalfOfDoubleConverter}}" />
                        </Trigger>
                        <Trigger Property="bpa:ButtonHelper.Shape" Value="Circle">
                            <Setter Property="Width" Value="{Binding Path=ActualHeight, RelativeSource={RelativeSource Self}}" />
                            <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}, Converter={StaticResource HalfOfDoubleConverter}}" />
                            <Setter Property="Padding" Value="5" />
                            <Setter Property="VerticalAlignment" Value="Center" />
                        </Trigger>
                        <Trigger Property="bpa:ButtonHelper.Loading" Value="True">
                            <Setter TargetName="loading" Property="Visibility" Value="Visible" />
                            <Setter TargetName="contentPresenter" Property="Content" Value="{Binding Path=(bpa:ButtonHelper.LoadingContent), RelativeSource={RelativeSource AncestorType=Button}}" />
                        </Trigger>
                        <Trigger Property="Content" Value="{x:Null}">
                            <Setter TargetName="loading" Property="Margin" Value="0" />
                        </Trigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding DependencyObjectType.SystemType, RelativeSource={RelativeSource Self}}" Value="{x:Type Button}" />
                                <Condition Binding="{Binding IsDefault, RelativeSource={RelativeSource Self}}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="effectBorder" Property="Visibility" Value="Visible" />
                            <Setter TargetName="effectBorder" Property="Effect" Value="{DynamicResource AllDirectionEffect3}" />
                        </MultiDataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="RubyerButton"
           BasedOn="{StaticResource RubyerButtonBase}"
           TargetType="{x:Type Button}" />

    <Style x:Key="LightButton"
           BasedOn="{StaticResource RubyerButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{DynamicResource Light}" />
        <Setter Property="Foreground" Value="{DynamicResource BlackForeground}" />
    </Style>

    <Style x:Key="DarkButton"
           BasedOn="{StaticResource RubyerButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{DynamicResource Dark}" />
        <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
    </Style>

    <Style x:Key="AccentButton"
           BasedOn="{StaticResource RubyerButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{DynamicResource Accent}" />
        <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
    </Style>

    <Style x:Key="SecondaryButton"
           BasedOn="{StaticResource RubyerButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{DynamicResource Secondary}" />
        <Setter Property="Foreground" Value="{DynamicResource SecondaryForeground}" />
    </Style>

    <Style x:Key="InfoButton"
           BasedOn="{StaticResource RubyerButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{DynamicResource Info}" />
        <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
    </Style>

    <Style x:Key="WarningButton"
           BasedOn="{StaticResource RubyerButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{DynamicResource Warning}" />
        <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
    </Style>

    <Style x:Key="SuccessButton"
           BasedOn="{StaticResource RubyerButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{DynamicResource Success}" />
        <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
    </Style>

    <Style x:Key="ErrorButton"
           BasedOn="{StaticResource RubyerButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{DynamicResource Error}" />
        <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
    </Style>

    <!--  文字按钮  -->
    <Style x:Key="TextButton"
           BasedOn="{StaticResource RubyerButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="{DynamicResource Primary}" />
        <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Mask}" />
        <Setter Property="bpa:ControlHelper.MaskOpacity" Value="0.5" />
        <Setter Property="BorderBrush" Value="{Binding Foreground, RelativeSource={RelativeSource Self}}" />
    </Style>

    <Style x:Key="TextLightButton"
           BasedOn="{StaticResource TextButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource Light}" />
    </Style>

    <Style x:Key="TextDarkButton"
           BasedOn="{StaticResource TextButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource Dark}" />
    </Style>

    <Style x:Key="TextAccentButton"
           BasedOn="{StaticResource TextButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource Accent}" />
    </Style>

    <Style x:Key="TextSuccessButton"
           BasedOn="{StaticResource TextButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource Success}" />
    </Style>

    <Style x:Key="TextInfoButton"
           BasedOn="{StaticResource TextButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource Info}" />
    </Style>

    <Style x:Key="TextWarningButton"
           BasedOn="{StaticResource TextButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource Warning}" />
    </Style>

    <Style x:Key="TextErrorButton"
           BasedOn="{StaticResource TextButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource Error}" />
    </Style>

    <!--  Outline 按钮  -->
    <Style x:Key="OutlineButton"
           BasedOn="{StaticResource TextButton}"
           TargetType="{x:Type Button}">
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
    </Style>

    <Style x:Key="OutlineLightButton"
           BasedOn="{StaticResource OutlineButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource Light}" />
    </Style>

    <Style x:Key="OutlineDarkButton"
           BasedOn="{StaticResource OutlineButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource Dark}" />
    </Style>

    <Style x:Key="OutlineAccentButton"
           BasedOn="{StaticResource OutlineButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource Accent}" />
    </Style>

    <Style x:Key="OutlineSuccessButton"
           BasedOn="{StaticResource OutlineButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource Success}" />
    </Style>

    <Style x:Key="OutlineInfoButton"
           BasedOn="{StaticResource OutlineButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource Info}" />
    </Style>

    <Style x:Key="OutlineWarningButton"
           BasedOn="{StaticResource OutlineButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource Warning}" />
    </Style>

    <Style x:Key="OutlineErrorButton"
           BasedOn="{StaticResource OutlineButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource Error}" />
    </Style>
</ResourceDictionary>