<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:helper="clr-namespace:Platform.Controls.ControlsHelper"
                    xmlns:dhcc="http://www.dhcc.com.cn"
                    xmlns:wpfspark="clr-namespace:Platform.Controls.BaseContainer">
    <LinearGradientBrush x:Key="ToggleSwitch_Background" StartPoint="0.499999,2.19231" EndPoint="0.499999,-1.19231">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Offset="0.325581" Color="#FFD6F0FD" />
                <GradientStop Offset="0.502326" Color="#FF90CBF3" />
                <GradientStop Offset="0.506977" Color="#FFC7EAFF" />
                <GradientStop Offset="0.683721" Color="#FFF0F5F8" />
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="CheckedStateBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#FF81230E" />
        <GradientStop Offset="0.365" Color="#FFF15910" />
        <GradientStop Offset="1" Color="#FFF5A782" />
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="UncheckedStateBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#FFD6F0FD" />
        <GradientStop Offset="0.365" Color="#FFF0F5F8" />
        <GradientStop Offset="1" Color="#FFC7EAFF" />
    </LinearGradientBrush>

    <!-- ToggleSwitch Template -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly=wpfspark:ToggleSwitch, ResourceId=ToggleSwitchTemplate}"
                     TargetType="{x:Type wpfspark:ToggleSwitch}">
        <ControlTemplate.Resources>
            <Storyboard x:Key="BeginGlow">
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                               Storyboard.TargetName="Glow"
                                               Storyboard.TargetProperty="(UIElement.Opacity)">
                    <SplineDoubleKeyFrame KeyTime="00:00:00.4000000"
                                          Value="1" />
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="EndGlow">
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                               Storyboard.TargetName="Glow"
                                               Storyboard.TargetProperty="(UIElement.Opacity)">
                    <SplineDoubleKeyFrame KeyTime="00:00:00.4000000"
                                          Value="0" />
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </ControlTemplate.Resources>

        <!-- Outermost border of the ToggleSwitch -->
        <wpfspark:ClipBorder Width="{TemplateBinding Width}"
                             Height="{TemplateBinding Height}"
                             BorderBrush="{TemplateBinding BorderBrush}"
                             Background="{TemplateBinding Background}"
                             CornerRadius="{Binding Path=CornerRadius, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}"
                             BorderThickness="{TemplateBinding BorderThickness}">
            <Grid Name="PART_RootGrid">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.4*"></ColumnDefinition>
                    <ColumnDefinition Width="0.2*"></ColumnDefinition>
                    <ColumnDefinition Width="0.4*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <!--<i:Interaction.Behaviors>
                    <ei:FluidMoveBehavior AppliesTo="Children"
                                          Duration="0:0:0.2">
                        <ei:FluidMoveBehavior.EaseX>
                            <QuarticEase  EasingMode="EaseIn" />
                        </ei:FluidMoveBehavior.EaseX>
                    </ei:FluidMoveBehavior>
                </i:Interaction.Behaviors>-->
                <!-- PART_Content -->
                <Border Name="PART_ContentBorder"
                        Grid.Column="0"
                        CornerRadius="0"
                        Background="Transparent"
                        BorderThickness="0">
                    <Grid Name="PART_ContentGrid">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.375*"></ColumnDefinition>
                            <ColumnDefinition Width="0.1*"></ColumnDefinition>
                            <ColumnDefinition Width="0.05*"></ColumnDefinition>
                            <ColumnDefinition Width="0.1*"></ColumnDefinition>
                            <ColumnDefinition Width="0.375*"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <!-- Checked State -->
                        <!-- Background displayed when the ToggleSwitch is in the Checked State -->
                        <Border x:Name="PART_CheckedBorder"
                                Grid.Column="0"
                                Grid.ColumnSpan="2"
                                BorderThickness="0"
                                Margin="0"
                                CornerRadius="0"
                                Background="{Binding Path=CheckedBackground, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}">
                        </Border>
                        <!-- Text which is displayed when the ToggleSwitch is in the Checked State -->
                        <TextBlock x:Name="PART_CheckedContent"
                                   Grid.Column="0"
                                   Text="{Binding Path=CheckedText, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   FontFamily="{TemplateBinding FontFamily}"
                                   FontWeight="{TemplateBinding FontWeight}"
                                   FontSize="{TemplateBinding FontSize}"
                                   Foreground="{Binding Path=CheckedForeground, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}">
                            <TextBlock.Effect>
                                <DropShadowEffect BlurRadius="4"
                                                  ShadowDepth="1"
                                                  Color="Black"
                                                  Opacity="0.7"
                                                  Direction="-88"></DropShadowEffect>
                            </TextBlock.Effect>
                        </TextBlock>

                        <!-- Unchecked State -->
                        <!-- Background displayed when the ToggleSwitch is in the Unchecked State -->
                        <Border x:Name="PART_UncheckedBorder"
                                Grid.Column="3"
                                Grid.ColumnSpan="2"
                                BorderThickness="0"
                                Margin="0"
                                CornerRadius="0"
                                Background="{Binding Path=UncheckedBackground, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}">
                        </Border>
                        <!-- Text which is displayed when the ToggleSwitch is in the Unchecked State -->
                        <TextBlock x:Name="PART_UncheckedContent"
                                   Grid.Column="4"
                                   Text="{Binding Path=UncheckedText, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   FontFamily="{TemplateBinding FontFamily}"
                                   FontWeight="{TemplateBinding FontWeight}"
                                   FontSize="{TemplateBinding FontSize}"
                                   Foreground="{Binding Path=UncheckedForeground, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}">
                            <TextBlock.Effect>
                                <DropShadowEffect BlurRadius="4"
                                                  ShadowDepth="1"
                                                  Color="Black"
                                                  Opacity="0.7"
                                                  Direction="-88"></DropShadowEffect>
                            </TextBlock.Effect>
                        </TextBlock>

                        <!-- ToggleSwitch Thumb -->
                        <wpfspark:ClipBorder x:Name="PART_Thumb"
                                             Grid.Column="1"
                                             Grid.ColumnSpan="3"
                                             Margin="0"
                                             BorderBrush="{Binding Path=ThumbBorderBrush, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}"
                                             BorderThickness="{Binding Path=ThumbBorderThickness, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}"
                                             CornerRadius="{Binding Path=ThumbCornerRadius, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}"
                                             Background="{Binding Path=ThumbBackground, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="0.507*" />
                                    <RowDefinition Height="0.493*" />
                                </Grid.RowDefinitions>
                                <Border x:Name="Glow"
                                        Opacity="0"
                                        HorizontalAlignment="Stretch"
                                        Width="Auto"
                                        Grid.RowSpan="2"
                                        CornerRadius="{Binding Path=ThumbCornerRadius, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}">
                                    <Border.Background>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform ScaleX="1.702"
                                                                    ScaleY="2.743" />
                                                    <SkewTransform AngleX="0"
                                                                   AngleY="0" />
                                                    <RotateTransform Angle="0" />
                                                    <TranslateTransform X="-0.368"
                                                                        Y="-0.152" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="{Binding Path=ThumbGlowColor, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}"
                                                          Offset="0.1" />
                                            <GradientStop Color="#44222222"
                                                          Offset="0.8" />
                                        </RadialGradientBrush>
                                    </Border.Background>
                                </Border>
                                <Border x:Name="Shine"
                                        HorizontalAlignment="Stretch"
                                        Margin="0,0,0,0"
                                        Width="Auto"
                                        CornerRadius="{Binding Path=ThumbShineCornerRadius, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}">
                                    <Border.Background>
                                        <LinearGradientBrush EndPoint="0.494,0.889"
                                                             StartPoint="0.494,0.028">
                                            <GradientStop Color="#99FFFFFF"
                                                          Offset="0" />
                                            <GradientStop Color="#33FFFFFF"
                                                          Offset="1" />
                                        </LinearGradientBrush>
                                    </Border.Background>
                                </Border>
                                <Border x:Name="DisabledBorder"
                                        Grid.Column="0"
                                        Grid.ColumnSpan="5"
                                        BorderThickness="0"
                                        Margin="0"
                                        CornerRadius="0"
                                        Background="White"
                                        Opacity="0.5"
                                        Visibility="Hidden">
                                </Border>
                            </Grid>
                        </wpfspark:ClipBorder>
                    </Grid>
                </Border>
            </Grid>
        </wpfspark:ClipBorder>

        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="ToggleButton.IsChecked"
                               Value="true"></Condition>
                    <Condition Property="IsCheckedLeft"
                               Value="true"></Condition>
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Grid.Column"
                            TargetName="PART_ContentBorder"
                            Value="{Binding Path=TargetColumnInternal, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}" />
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="ToggleButton.IsChecked"
                               Value="false"></Condition>
                    <Condition Property="IsCheckedLeft"
                               Value="false"></Condition>
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Grid.Column"
                            TargetName="PART_ContentBorder"
                            Value="{Binding Path=TargetColumnInternal, RelativeSource={RelativeSource AncestorType={x:Type wpfspark:ToggleSwitch}}}" />
                </MultiTrigger.Setters>
            </MultiTrigger>

            <Trigger Property="IsEnabled"
                     Value="false">
                <Setter Property="Opacity"
                        Value="0.3" />
                <Setter TargetName="PART_UncheckedContent"
                        Property="Foreground"
                        Value="LightGray"></Setter>
                <Setter TargetName="PART_CheckedContent"
                        Property="Foreground"
                        Value="LightGray"></Setter>
                <Setter TargetName="DisabledBorder"
                        Property="Visibility"
                        Value="Visible"></Setter>
            </Trigger>
            <Trigger Property="ToggleButton.IsPressed"
                     Value="True">
                <Setter Property="Opacity"
                        TargetName="Shine"
                        Value="0.6" />
            </Trigger>
            <Trigger Property="ToggleButton.IsMouseOver"
                     Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard Storyboard="{StaticResource BeginGlow}" />
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard Storyboard="{StaticResource EndGlow}" />
                </Trigger.ExitActions>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type wpfspark:ToggleSwitch}">
        <Setter Property="dhcc:FocusManager.FocusHandled" Value="{x:Static helper:ToggleSwitchHelper.ToggleSwitchFocusHandled}" />
        <Setter Property="dhcc:FocusManager.IsInternalKeyboardControlling" Value="True" />
        <Setter Property="dhcc:FocusManagerExt.IsFocusAdorner" Value="True" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Width" Value="75" />
        <Setter Property="Height" Value="23" />
        <Setter Property="Background" Value="Black" />
        <Setter Property="BorderBrush" Value="#FF389BCC" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="CheckedForeground" Value="Black" />
        <Setter Property="CheckedBackground" Value="{StaticResource CheckedStateBrush}" />
        <Setter Property="CheckedText" Value="No" />
        <Setter Property="CornerRadius" Value="7" />
        <Setter Property="FontFamily" Value="Tahoma" />
        <Setter Property="FontSize" Value="15" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="ThumbBackground" Value="{StaticResource ToggleSwitch_Background}" />
        <Setter Property="ThumbBorderThickness" Value="1" />
        <Setter Property="ThumbCornerRadius" Value="4" />
        <Setter Property="ThumbGlowColor" Value="Gray" />
        <Setter Property="ThumbShineCornerRadius" Value="6,6,5,5" />
        <Setter Property="UncheckedBackground" Value="{StaticResource UncheckedStateBrush}" />
        <Setter Property="UncheckedForeground" Value="Black" />
        <Setter Property="UncheckedText" Value="Yes" />
        <Setter Property="Template"
                Value="{StaticResource {ComponentResourceKey TypeInTargetAssembly=wpfspark:ToggleSwitch, ResourceId=ToggleSwitchTemplate}}" />
    </Style>

</ResourceDictionary>