<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns:animation="clr-namespace:Telerik.Windows.Controls.Animation;assembly=Telerik.Windows.Controls"
    xmlns:sys="clr-namespace:System;assembly=mscorlib">
	
	<LinearGradientBrush x:Key="ProgressBarBorder" EndPoint="0.04,0.5" StartPoint="0.972,0.5">
		<GradientStop Color="#FF707070" Offset="0"/>
		<GradientStop Color="#FF707070" Offset="1"/>
		<GradientStop Color="#FFA3A3A3" Offset="0.5"/>
		<GradientStop Color="#FF707070" Offset="0.993"/>
	</LinearGradientBrush>
	<SolidColorBrush x:Key="ProgressBarBackground_Nomral" Color="#8C878787" />
	<RadialGradientBrush x:Key="ProgressBarBackground_Indeterminate" Center="0.5,-0.23" GradientOrigin="0.8,0.25" RadiusX="0.68" RadiusY="0.68">
		<GradientStop Color="#BFFFFFFF" Offset="0" />
		<GradientStop Color="#00FFFFFF" Offset="1" />
		<GradientStop Color="#21FFFFFF" Offset="0.65"/>
	</RadialGradientBrush>
	<SolidColorBrush x:Key="ProgressBarBackground_Loaded" Color="#FF789FC3" />
	
	<SolidColorBrush x:Key="BusyIndicatorBusyOverlayBrush" Color="#7F080808" />
	<SolidColorBrush x:Key="BusyIndicatorBorder" Color="Transparent" />
	<SolidColorBrush x:Key="BusyIndicatorBackground" Color="Transparent" />
	<SolidColorBrush x:Key="BusyIndicatorForeground" Color="#FFDDDDDD" />
	
    <Style x:Key="BusyIndicatorProgressBarStyle" TargetType="telerik:RadProgressBar">
        <Setter Property="IsIndeterminate" Value="True" />
        <Setter Property="Maximum" Value="100" />
        <Setter Property="Orientation" Value="Horizontal" />
        <Setter Property="IsTabStop" Value="False" />
        
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerik:RadProgressBar">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Determinate"/>
                                <VisualState x:Name="Indeterminate">
                                    <Storyboard RepeatBehavior="Forever">
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="IndeterminateDonut" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                            	<DiscreteObjectKeyFrame.Value>
                                            		<Visibility>Visible</Visibility>                                	
												</DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ProgressIndicator" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                            	<DiscreteObjectKeyFrame.Value>
                                            		<Visibility>Collapsed</Visibility>                                	
												</DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="IndeterminateDonut" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:01" Value="360"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        
                        <Path x:Name="IndeterminateBackgroundDonut" RenderTransformOrigin="0.5 0.5" Stroke="{StaticResource ProgressBarBorder}" Fill="{StaticResource ProgressBarBackground_Nomral}" Height="44" Width="44">
                            <Path.Data>
                                <GeometryGroup FillRule="EvenOdd">
                                    <EllipseGeometry Center="22 22" RadiusX="20.5" RadiusY="20.5" />
                                    <EllipseGeometry Center="22 22" RadiusX="14.5" RadiusY="14.5" />
                                </GeometryGroup>
                            </Path.Data>
                        </Path>
                        <Path x:Name="IndeterminateDonut" Visibility="Collapsed" Fill="{StaticResource ProgressBarBackground_Indeterminate}" RenderTransformOrigin="0.5 0.5" Height="44" Width="44">
                            <Path.RenderTransform>
                                <TransformGroup>
                                    <RotateTransform/>
                                </TransformGroup>
                            </Path.RenderTransform>
                            <Path.Data>
                                <GeometryGroup FillRule="EvenOdd">
                                    <EllipseGeometry Center="22 22" RadiusX="20" RadiusY="20" />
                                    <EllipseGeometry Center="22 22" RadiusX="14" RadiusY="14" />
                                </GeometryGroup>
                            </Path.Data>
                        </Path>
						<telerik:Arc x:Name="ProgressIndicator" Width="42" Height="42" Diameter="42" HorizontalAlignment="Center" VerticalAlignment="Center" Progress="{TemplateBinding Value}" MinimumProgress="{TemplateBinding Minimum}" MaximumProgress="{TemplateBinding Maximum}" ArcThickness="7" Fill="{StaticResource ProgressBarBackground_Loaded}" StartAngle="-89.999" EndAngle="269.999" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Foreground" Value="{StaticResource ProgressBarBackground_Loaded}"/>
    </Style>
	
	<ControlTemplate x:Key="RadBusyIndicatorControlTemplate" TargetType="telerik:RadBusyIndicator">
		<Grid Background="{TemplateBinding Background}">
			<VisualStateManager.VisualStateGroups>
            	<VisualStateGroup x:Name="VisibilityStates">
					<VisualState x:Name="Hidden">
						<Storyboard>
							<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="IndicatorVisual" Storyboard.TargetProperty="(UIElement.Visibility)">
								<DiscreteObjectKeyFrame KeyTime="00:00:00">
									<DiscreteObjectKeyFrame.Value>
										<Visibility>Collapsed</Visibility>
									</DiscreteObjectKeyFrame.Value>
								</DiscreteObjectKeyFrame>
							</ObjectAnimationUsingKeyFrames>
							<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="Overlay" Storyboard.TargetProperty="(UIElement.Visibility)">
								<DiscreteObjectKeyFrame KeyTime="00:00:00">
									<DiscreteObjectKeyFrame.Value>
										<Visibility>Collapsed</Visibility>
										</DiscreteObjectKeyFrame.Value>
								</DiscreteObjectKeyFrame>
							</ObjectAnimationUsingKeyFrames>
						</Storyboard>
					</VisualState>
					<VisualState x:Name="Visible">
						<Storyboard>
							<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="IndicatorVisual" Storyboard.TargetProperty="(UIElement.Visibility)">
								<DiscreteObjectKeyFrame KeyTime="00:00:00">
									<DiscreteObjectKeyFrame.Value>
										<Visibility>Visible</Visibility>
									</DiscreteObjectKeyFrame.Value>
								</DiscreteObjectKeyFrame>
							</ObjectAnimationUsingKeyFrames>
							<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="Overlay" Storyboard.TargetProperty="(UIElement.Visibility)">
								<DiscreteObjectKeyFrame KeyTime="00:00:00">
									<DiscreteObjectKeyFrame.Value>
										<Visibility>Visible</Visibility>
									</DiscreteObjectKeyFrame.Value>
								</DiscreteObjectKeyFrame>
							</ObjectAnimationUsingKeyFrames>
						</Storyboard>
					</VisualState>
				</VisualStateGroup>
				<VisualStateGroup x:Name="BusyStatusStates">
					<VisualState x:Name="Idle">
						<Storyboard>
							<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="Content" Storyboard.TargetProperty="(Control.IsEnabled)">
								<DiscreteObjectKeyFrame KeyTime="00:00:00">
									<DiscreteObjectKeyFrame.Value>
										<sys:Boolean>True</sys:Boolean>
									</DiscreteObjectKeyFrame.Value>
								</DiscreteObjectKeyFrame>
							</ObjectAnimationUsingKeyFrames>
						</Storyboard>
					</VisualState>
					<VisualState x:Name="Busy">
						<Storyboard>
							<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="Content" Storyboard.TargetProperty="(Control.IsEnabled)">
								<DiscreteObjectKeyFrame KeyTime="00:00:00">
									<DiscreteObjectKeyFrame.Value>
										<sys:Boolean>False</sys:Boolean>
									</DiscreteObjectKeyFrame.Value>
								</DiscreteObjectKeyFrame>
							</ObjectAnimationUsingKeyFrames>
						</Storyboard>
					</VisualState>
				</VisualStateGroup>
			</VisualStateManager.VisualStateGroups>
			
			<ContentControl x:Name="Content"
					IsEnabled="False"
					Content="{TemplateBinding Content}"
					ContentTemplate="{TemplateBinding ContentTemplate}"
					HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
					VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />

			<Grid x:Name="Indicator">
				<Rectangle x:Name="Overlay" Style="{TemplateBinding OverlayStyle}" />
				<Border x:Name="IndicatorVisual" MinWidth="180" CornerRadius="2" HorizontalAlignment="Center" VerticalAlignment="Center" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
					<StackPanel>
						<telerik:RadProgressBar x:Name="ProgressBar" Margin="10 10 10 5" IsIndeterminate="{TemplateBinding IsIndeterminate}" Value="{TemplateBinding ProgressValue}" Style="{TemplateBinding ProgressBarStyle}" />
						<ContentPresenter Margin="10 5 10 10" HorizontalAlignment="Center" Content="{TemplateBinding BusyContent}" ContentTemplate="{TemplateBinding BusyContentTemplate}" />
					</StackPanel>
				</Border>
			</Grid>
		</Grid>        
	</ControlTemplate>
	
	<Style x:Key="OverlayStyle" TargetType="Rectangle">
		<Setter Property="Fill" Value="{StaticResource BusyIndicatorBusyOverlayBrush}"/>
	</Style>

    <Style TargetType="telerik:RadBusyIndicator">

        <Setter Property="BusyContent" Value="Loading..."/>
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="DisplayAfter" Value="00:00:00.1" />
		
		<Setter Property="Foreground" Value="{StaticResource BusyIndicatorForeground}" />
        <Setter Property="BorderBrush" Value="{StaticResource BusyIndicatorBorder}" />
        <Setter Property="Background" Value="{StaticResource BusyIndicatorBackground}" />
        <Setter Property="BorderThickness" Value="1" />
        
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />

        <Setter Property="ProgressBarStyle" Value="{StaticResource BusyIndicatorProgressBarStyle}" />
        
		<Setter Property="OverlayStyle" Value="{StaticResource OverlayStyle}" />
			
        <Setter Property="animation:AnimationManager.AnimationSelector">
            <Setter.Value>
                <animation:AnimationSelector>
                    <animation:FadeAnimation AnimationName="Hide" Direction="Out" TargetElementName="Indicator" />
                    <animation:FadeAnimation AnimationName="Show" Direction="In" TargetElementName="Indicator" />
                </animation:AnimationSelector>
            </Setter.Value>
        </Setter>
        
        <Setter Property="Template" Value="{StaticResource RadBusyIndicatorControlTemplate}" />
    </Style>
    

</ResourceDictionary>

