<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">

    <ControlTemplate x:Key="Template.CraftingBar.Radial" TargetType="{x:Type ProgressBar}">
        <Grid>
            <Ellipse
                x:Name="RadialProgressBar"
                noesis:Path.TrimEnd="{Binding Value, RelativeSource={RelativeSource TemplatedParent}}"
                noesis:Path.TrimStart="0"
                RenderTransformOrigin="0.5,0.5"
                Stroke="{DynamicResource Color.Fill.RadialProgressBar}"
                StrokeThickness="6">

                <Ellipse.RenderTransform>
                    <RotateTransform Angle="-90"/>
                </Ellipse.RenderTransform>
            </Ellipse>
        </Grid>
    </ControlTemplate>

    <!-- CRAFTING BAR ASSETS -->
    <ImageBrush x:Key="CraftingBar.Background" ImageSource="../Textures/Controls/CraftingBarBackground.png" TileMode="None" Stretch="None"/>
    <ImageBrush x:Key="CraftingBar.Fill" ImageSource="../Textures/Controls/CraftingBarFill.png" TileMode="None" Stretch="None"/>
    <ImageBrush x:Key="CraftingBar.Decor" ImageSource="../Textures/Controls/CraftingBarDecor.png" TileMode="None" Stretch="None"/>

    <!-- CRAFTING BAR TEMPLATE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <ControlTemplate x:Key="Template.CraftingBar" TargetType="{x:Type ProgressBar}">

        <!-- This is the parent Grid of the bar. It displays a runic decoration behind the actual progress bar -->
        <Grid
            x:Name="CraftingBar.Wrapper"
            Width="474"
            Height="88"
            Background="{StaticResource CraftingBar.Decor}">

            <!-- This grid defines the layout and size for the progress bar -->
            <Grid
                x:Name="CraftingBar.Layout"
                SnapsToDevicePixels="True"
                Width="444"
                Height="54"
                HorizontalAlignment="Center"
                VerticalAlignment="Center">

                <!-- BASE SECTION -->
                <!-- This part serves as the backer for the progress bar. It is very important to conserve the PART_Track name or it will break -->
                <Grid x:Name="PART_Track" HorizontalAlignment="Right">
                    <Viewbox Stretch="None">
                        <Path Fill="{StaticResource CraftingBar.Background}"
                            Data="M444,27L428,11H233L222,0 211,11H17L0,27 17,43H211L222,54 233,43H427L444,27z"/>
                    </Viewbox>
                </Grid>

                <!-- FILL SECTION -->
                <!-- This is the part that grows or shrinks based on the value. It is very important to conserve the PART_Indicator name or it will break -->
                <Grid x:Name="PART_Indicator" HorizontalAlignment="Left">
                    <Viewbox Stretch="None">
                        <Path Fill="{StaticResource CraftingBar.Fill}"
                            Data="M444,27L428,11H233L222,0 211,11H17L0,27 17,43H211L222,54 233,43H427L444,27z"/>
                    </Viewbox>
                </Grid>
            </Grid>

        </Grid>
    </ControlTemplate>

    <!-- CRAFTING BAR STYLE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <Style x:Key="Style.CraftingBar" TargetType="{x:Type ProgressBar}" BasedOn="{StaticResource {x:Type Control}}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Template" Value="{StaticResource Template.CraftingBar}"/>
    </Style>

    <!-- ANIMATION -->
    <!-- This animates the fill of the bar to shrink and grow with a smooth linear interpolation for the duration of the craft -->
	<Storyboard
        x:Key="Animation.CraftingBar"
		RepeatBehavior="{Binding RecipeDetails.ActiveCraft.RepeatBehavior}">

        <DoubleAnimation
                Storyboard.TargetName="CraftingBar"
                Storyboard.TargetProperty="Value"
                From="0"
                To="1"
                BeginTime="0:0:0"
                Duration="{Binding RecipeDetails.ActiveCraft.Duration}">
		</DoubleAnimation>
	</Storyboard>
</ResourceDictionary>
