<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:hc="clr-namespace:HandyControl.Controls"
                    xmlns:shapes="clr-namespace:HandyControl.Expression.Shapes"
                    xmlns:system="clr-namespace:System;assembly=mscorlib">

    <LinearGradientBrush x:Key="ProgressBarIndicatorAnimatedFill" StartPoint="0,0" EndPoint="1,0">
        <GradientStop Color="#00FFFFFF" Offset="0"/>
        <GradientStop Color="#60FFFFFF" Offset="0.4"/>
        <GradientStop Color="#60FFFFFF" Offset="0.6"/>
        <GradientStop Color="#00FFFFFF" Offset="1"/>
    </LinearGradientBrush>

    <Style x:Key="ProgressBarBaseStyle" TargetType="ProgressBar">
        <Setter Property="hc:VisualElement.Text">
            <Setter.Value>
                <MultiBinding Converter="{StaticResource Number2PercentageConverter}" StringFormat="{}{0:F0} %">
                    <Binding Path="Value" RelativeSource="{RelativeSource Self}"/>
                    <Binding Path="Maximum" RelativeSource="{RelativeSource Self}"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Setter Property="Height" Value="20"/>
        <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
        <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ProgressBar">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="IsIndeterminate" RepeatBehavior="Forever">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="Animation">
                                <EasingDoubleKeyFrame KeyTime="0" Value="0.25"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.25"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:2" Value="0.25"/>
                            </DoubleAnimationUsingKeyFrames>
                            <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="Animation">
                                <EasingPointKeyFrame KeyTime="0" Value="-0.5,0.5"/>
                                <EasingPointKeyFrame KeyTime="0:0:1" Value="0.5,0.5"/>
                                <EasingPointKeyFrame KeyTime="0:0:2" Value="1.5,0.5"/>
                            </PointAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Border x:Name="TemplateRoot" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                        <hc:SimplePanel>
                            <Rectangle x:Name="PART_Track"/>
                            <TextBlock Visibility="{Binding Visibility,ElementName=PART_GlowRect}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{TemplateBinding Foreground}" Text="{Binding Path=(hc:VisualElement.Text),RelativeSource={RelativeSource TemplatedParent}}"/>
                            <Border Style="{StaticResource BorderClip}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" x:Name="PART_Indicator" HorizontalAlignment="Left">
                                <hc:SimplePanel>
                                    <Border x:Name="Indicator" Background="{TemplateBinding Foreground}">
                                        <Border Width="{Binding ActualWidth,ElementName=TemplateRoot}">
                                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource TextIconBrush}" Text="{Binding Path=(hc:VisualElement.Text),RelativeSource={RelativeSource TemplatedParent}}"/>
                                        </Border>
                                    </Border>
                                    <Rectangle x:Name="PART_GlowRect" Fill="{StaticResource ProgressBarIndicatorAnimatedFill}" HorizontalAlignment="Left" Margin="-100,0,0,0" Width="100"/>
                                    <Rectangle x:Name="Animation" Visibility="Collapsed" Fill="{TemplateBinding Foreground}" RenderTransformOrigin="0.5,0.5">
                                        <Rectangle.RenderTransform>
                                            <TransformGroup>
                                                <ScaleTransform/>
                                            </TransformGroup>
                                        </Rectangle.RenderTransform>
                                    </Rectangle>
                                </hc:SimplePanel>
                            </Border>
                        </hc:SimplePanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Orientation" Value="Vertical">
                            <Setter Property="Height" Value="{x:Static system:Double.NaN}"/>
                            <Setter Property="LayoutTransform" TargetName="TemplateRoot">
                                <Setter.Value>
                                    <RotateTransform Angle="-90"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsIndeterminate" Value="true">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource IsIndeterminate}"/>
                            </Trigger.EnterActions>
                            <Setter Property="Visibility" TargetName="Indicator" Value="Collapsed"/>
                            <Setter Property="Visibility" TargetName="PART_GlowRect" Value="Collapsed"/>
                            <Setter Property="Visibility" TargetName="Animation" Value="Visible"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ProgressBarStripeBaseStyle" TargetType="ProgressBar">
        <Setter Property="Height" Value="20"/>
        <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
        <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ProgressBar">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="OnLoaded">
                            <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetProperty="(Border.Background).(Brush.Transform).(TransformGroup.Children)[1].(TranslateTransform.X)" Storyboard.TargetName="Indicator">
                                <LinearDoubleKeyFrame KeyTime="0" Value="0"/>
                                <LinearDoubleKeyFrame KeyTime="0:0:.25" Value="21"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <hc:SimplePanel x:Name="TemplateRoot" SnapsToDevicePixels="true">
                        <Border CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
                        <Rectangle x:Name="PART_Track"/>
                        <Decorator x:Name="PART_Indicator" HorizontalAlignment="Left">
                            <Border x:Name="Indicator" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Foreground}"/>
                        </Decorator>
                    </hc:SimplePanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Orientation" Value="Vertical">
                            <Setter Property="Height" Value="{x:Static system:Double.NaN}"/>
                            <Setter Property="LayoutTransform" TargetName="TemplateRoot">
                                <Setter.Value>
                                    <RotateTransform Angle="-90"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <EventTrigger RoutedEvent="FrameworkElement.Loaded" SourceName="Indicator">
                            <BeginStoryboard Storyboard="{StaticResource OnLoaded}"/>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="CircleProgressBarIndeterminateTemplate" TargetType="hc:CircleProgressBar">
        <ControlTemplate.Resources>
            <Storyboard x:Key="IsIndeterminate" RepeatBehavior="Forever">
                <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)" Storyboard.TargetName="TemplateRoot">
                    <LinearDoubleKeyFrame KeyTime="0:0:1.568" Value="360"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)" Storyboard.TargetName="arc">
                    <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                    <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:0.666" Value="135"/>
                    <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:1.333" Value="270"/>
                    <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:1.999" Value="405"/>
                    <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:2.666" Value="540"/>
                    <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:3.333" Value="675"/>
                    <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:3.999" Value="810"/>
                    <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:4.666" Value="945"/>
                    <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:5.332" Value="1080"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetProperty="(shapes:Arc.StartAngle)" Storyboard.TargetName="arc">
                    <SplineDoubleKeyFrame KeyTime="0" Value="-5"/>
                    <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:0.666" Value="-130"/>
                    <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:1.333" Value="-5"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetProperty="(shapes:Arc.EndAngle)" Storyboard.TargetName="arc">
                    <SplineDoubleKeyFrame KeyTime="0" Value="5"/>
                    <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:0.666" Value="130"/>
                    <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:1.333" Value="5"/>
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </ControlTemplate.Resources>
        <hc:SimplePanel x:Name="TemplateRoot" RenderTransformOrigin="0.5,0.5">
            <hc:SimplePanel.RenderTransform>
                <TransformGroup>
                    <RotateTransform/>
                </TransformGroup>
            </hc:SimplePanel.RenderTransform>
            <shapes:Arc ArcThickness="{TemplateBinding ArcThickness}" Stretch="None" EndAngle="360" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}" Stroke="{TemplateBinding BorderBrush}" Fill="{TemplateBinding Background}" StrokeThickness="0"/>
            <shapes:Arc RenderTransformOrigin="0.5,0.5" StartAngle="-5" EndAngle="5" ArcThickness="{TemplateBinding ArcThickness}" Stretch="None" Width="{TemplateBinding ActualWidth}" StrokeThickness="0" Height="{TemplateBinding ActualHeight}" x:Name="arc" Fill="{TemplateBinding Foreground}">
                <shapes:Arc.RenderTransform>
                    <TransformGroup>
                        <RotateTransform/>
                    </TransformGroup>
                </shapes:Arc.RenderTransform>
            </shapes:Arc>
        </hc:SimplePanel>
        <ControlTemplate.Triggers>
            <Trigger Property="IsIndeterminate" Value="true">
                <Trigger.EnterActions>
                    <BeginStoryboard Storyboard="{StaticResource IsIndeterminate}"/>
                </Trigger.EnterActions>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="CircleProgressBarTemplate" TargetType="hc:CircleProgressBar">
        <hc:SimplePanel x:Name="TemplateRoot">
            <shapes:Arc ArcThickness="{TemplateBinding ArcThickness}" Stretch="None" EndAngle="360" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}" Stroke="{TemplateBinding BorderBrush}" Fill="{TemplateBinding Background}" StrokeThickness="0"/>
            <shapes:Arc ArcThickness="{TemplateBinding ArcThickness}" Stretch="None" Width="{TemplateBinding ActualWidth}" StrokeThickness="0" Height="{TemplateBinding ActualHeight}" x:Name="PART_Indicator" Fill="{TemplateBinding Foreground}"/>
            <TextBlock Visibility="{Binding ShowText,RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource Boolean2VisibilityConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Text}"/>
        </hc:SimplePanel>
    </ControlTemplate>

    <Style x:Key="ProgressBarCircleBaseStyle" TargetType="hc:CircleProgressBar">
        <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
        <Setter Property="Height" Value="100"/>
        <Setter Property="Width" Value="100"/>
        <Setter Property="ArcThickness" Value="4"/>
        <Setter Property="Text" Value="{Binding Value,RelativeSource={RelativeSource Self},StringFormat={}{0:F0} %}"/>
        <Setter Property="Template" Value="{StaticResource CircleProgressBarTemplate}"/>
        <Style.Triggers>
            <Trigger Property="IsIndeterminate" Value="True">
                <Setter Property="Template" Value="{StaticResource CircleProgressBarIndeterminateTemplate}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="ProgressBarWaveBaseStyle" TargetType="hc:WaveProgressBar">
        <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
        <Setter Property="Width" Value="100"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
        <Setter Property="Text" Value="{Binding Value,RelativeSource={RelativeSource Self},StringFormat={}{0:F0} %}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="hc:WaveProgressBar">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="StoryboardOnLoaded" RepeatBehavior="Forever">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)" Storyboard.TargetName="PART_Wave">
                                <EasingDoubleKeyFrame KeyTime="0:0:2" Value="-400"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <StackPanel>
                        <Border Style="{StaticResource BorderCircular}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
                            <Viewbox>
                                <Border x:Name="PART_Clip" Style="{StaticResource BorderCircularClip}" CornerRadius="100" Width="200" Height="200">
                                    <Path x:Name="PART_Wave" Stroke="{TemplateBinding WaveStroke}" StrokeThickness="{TemplateBinding WaveThickness}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="600" Height="250" Fill="{TemplateBinding WaveFill}" Stretch="Fill" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" Margin="0,0,-400,-20">
                                        <Path.Data>
                                            <PathGeometry>
                                                <PathFigure StartPoint="0,1">
                                                    <PolyBezierSegment Points="0.5,1 0.5,0 1,0"/>
                                                    <PolyBezierSegment Points="1.5,0 1.5,1 2,1"/>
                                                    <PolyBezierSegment Points="2.5,1 2.5,0 3,0"/>
                                                    <PolyLineSegment Points="3,0 3,10, 0,10 0,1"/>
                                                </PathFigure>
                                            </PathGeometry>
                                        </Path.Data>
                                    </Path>
                                </Border>
                            </Viewbox>
                        </Border>
                        <TextBlock Margin="0,10,0,0" Visibility="{Binding ShowText,RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource Boolean2VisibilityConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Text}"/>
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <EventTrigger RoutedEvent="FrameworkElement.Loaded" SourceName="PART_Wave">
                            <BeginStoryboard Name="BeginStoryboardWave" Storyboard="{StaticResource StoryboardOnLoaded}"/>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="FrameworkElement.Unloaded" SourceName="PART_Wave">
                            <StopStoryboard BeginStoryboardName="BeginStoryboardWave"/>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
