<!--================================================================================================
## CommonHelpers satellite library | Author: Sergei Y.Kitáev
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<ResourceDictionary
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:sys="clr-namespace:System;assembly=mscorlib"
   xmlns:userwin="clr-namespace:UserWin">

   <sys:Double x:Key="GradualBusyOverlayOpacity">0.2</sys:Double>
   <KeyTime x:Key="GradualBusyOverlayAppearanceInterval">00:00:01.0</KeyTime>
   <KeyTime x:Key="GradualBusyOverlayAppearanceDelay">00:00:00.1</KeyTime>

   <Style x:Key="GradualBusyOverlayRectangleAppearanceStyle" TargetType="{x:Type Rectangle}">
      <Setter Property="Fill" Value="{x:Static Brushes.Gray}" />
      <Style.Triggers>
         <Trigger Property="Visibility" Value="Visible">
            <Trigger.EnterActions>
               <BeginStoryboard>
                  <Storyboard>
                     <DoubleAnimationUsingKeyFrames
                        Storyboard.TargetProperty="Opacity">
                        <LinearDoubleKeyFrame
                           Value="0.0"
                           KeyTime="00:00:00.0" />
                        <LinearDoubleKeyFrame
                           Value="0.0"
                           KeyTime="{StaticResource GradualBusyOverlayAppearanceDelay}" />
                        <LinearDoubleKeyFrame
                           Value="{StaticResource GradualBusyOverlayOpacity}"
                           KeyTime="{StaticResource GradualBusyOverlayAppearanceInterval}" />
                     </DoubleAnimationUsingKeyFrames>
                  </Storyboard>
               </BeginStoryboard>
            </Trigger.EnterActions>
         </Trigger>
      </Style.Triggers>
   </Style>

   <DataTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type userwin:UXWinResources},
                        ResourceId=GradualBusyOverlayDataTemplate}">
      <Rectangle Style="{StaticResource GradualBusyOverlayRectangleAppearanceStyle}"
                 HorizontalAlignment="{x:Static userwin:UXBusyOverlayHelpers.HorizontalAlignment}">
         <Rectangle.Visibility>
            <Binding Path="IsBusy"
                     RelativeSource="{RelativeSource FindAncestor,AncestorType={x:Type Window}}">
               <Binding.Converter>
                  <userwin:UXBusyToOverlayVisibilityConverter />
               </Binding.Converter>
            </Binding>
         </Rectangle.Visibility>
      </Rectangle>
   </DataTemplate>

</ResourceDictionary>
