<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:ForzaUI;assembly="
                    xmlns:System="clr-namespace:System;assembly=mscorlib">

    <local:FZBooleanToVisibilityConverter x:Key="A_Converter_BoolToVis" InvertResult="false" />
    <local:FZBooleanToVisibilityConverter x:Key="A_Converter_BoolToVis_Inverted" InvertResult="true" />

    <ControlTemplate x:Key="A_ControlTemplate_Arrow_Down"
                     TargetType="Control">
        <local:FZMaterial x:Name="FZMaterial_Arrow"
                          Data="{StaticResource A_Geometry_SpinnerArrow}"
                          Width="15"
                          Height="9"
                          Color="{DynamicResource A_Color_Spinner_ArrowUnselected}"
                          Focusable="False" />
        <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource AncestorType=local:SpinnerControl}}"
                         Value="True" >
                <Setter TargetName="FZMaterial_Arrow"
                        Property="Color"
                        Value="{DynamicResource A_Color_Spinner_ArrowSelected}" />
            </DataTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="A_Style_Arrow_Left" TargetType="Control">
        <Setter Property="Margin" Value="0,0,10,0" />
        <Setter Property="Template" Value="{StaticResource A_ControlTemplate_Arrow_Down}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="RenderTransformOrigin"
                Value="0.5, 0.5" />
        <Setter Property="RenderTransform">
            <Setter.Value>
                <RotateTransform Angle="90" />
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="A_Style_Arrow_Right"
           TargetType="Control" BasedOn="{StaticResource A_Style_Arrow_Left}">
        <Setter Property="Margin" Value="10,0,0,0" />
        <Setter Property="RenderTransform">
            <Setter.Value>
                <RotateTransform Angle="270" />
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="A_Style_Arrow_Up" TargetType="Control">
        <Setter Property="Margin" Value="0,0,0,10" />
        <Setter Property="Template" Value="{StaticResource A_ControlTemplate_Arrow_Down}" />
        <Setter Property="RenderTransformOrigin"
                Value="0.5, 0.5" />
        <Setter Property="RenderTransform">
            <Setter.Value>
                <RotateTransform Angle="180" />
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="A_Style_Arrow_Down"
           TargetType="Control">
        <Setter Property="Margin" Value="0,10,0,0" />
        <Setter Property="Template" Value="{StaticResource A_ControlTemplate_Arrow_Down}" />
    </Style>

    <local:FZMaterialPresetRoundtangle x:Key="A_FZMaterialPresetRoundtangle_SpinnerMouseOverButtonBackground"
                                       CornerRadius="5"/>

    <local:FZMaterialPresetRoundtangle x:Key="A_FZMaterialPresetRoundtangle_SpinnerMouseOverButtonForeground"
                                       CornerRadius="3"/>

    <Style x:Key="A_Style_FZMaterial_SpinnerButtonBorder" TargetType="local:FZMaterial">
        <Setter Property="Color"
                Value="{DynamicResource A_Color_Spinner_ArrowUnselected}" />
        <Setter Property="GreedyMeasure"
                Value="True" />
        <Setter Property="Preset"
                Value="{StaticResource A_FZMaterialPresetRoundtangleStroke_Sliders_ArrowButtons_PC}" />
        <Setter Property="Visibility"
                Value="{Binding IsControllerActiveInput, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_Converter_BoolToVis_Inverted}}" />
        <Style.Triggers>
            <DataTrigger Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource AncestorType=ListBoxItem}}"
                         Value="True">
                <Setter Property="Color"
                        Value="{DynamicResource A_Color_Spinner_ArrowSelected}" />
            </DataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding IsControllerActiveInput, RelativeSource={RelativeSource AncestorType=Page}}"
                               Value="False"/>
                    <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=local:FZButton}}"
                               Value="False"/>
                    <Condition Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource AncestorType=ListBoxItem}}"
                               Value="True"/>
                </MultiDataTrigger.Conditions>
                <Setter Property="Color"
                        Value="{DynamicResource A_Color_Spinner_ArrowPCBoxUnselected}" />
            </MultiDataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="A_Style_Button_SpinnerArrowButton" TargetType="local:FZButton">
        <Setter Property="Width"
                Value="38" />
        <Setter Property="Height"
                Value="38" />
        <Setter Property="MinWidth"
                Value="1" />
        <Setter Property="MinHeight"
                Value="1" />
        <Setter Property="VerticalAlignment"
                Value="Center" />
        <Setter Property="HorizontalAlignment"
                Value="Center" />
        <Setter Property="IsSfxEnabled"
                Value="False" />
        <Setter Property="Focusable"
                Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:FZButton}">
                    <Grid>
                        <local:FZMaterial x:Name="ButtonBackground"
                                          Style="{DynamicResource A_Style_FZMaterial_SpinnerButtonBorder}" />
                        <ContentPresenter HorizontalAlignment="Center"
                                          VerticalAlignment="Center"
                                          IsHitTestVisible="False"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Thickness x:Key="A_Margin_SpinnerTrailingMargin">0,0,-15,0</Thickness>

    <Style x:Key="A_Style_SpinnerControl_Default_Internal" TargetType="local:SpinnerControl">
        <Style.Resources>
            <GridLength x:Key="A_GridLength_SpinnerWidth">375</GridLength>
        </Style.Resources>
        <Setter Property="local:ScreenReader.SelectedNumber"
                Value="{Binding (ItemsControl.AlternationIndex), RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Converter={StaticResource A_IndexToNumberConverter}, FallbackValue=0}" />
        <Setter Property="local:ScreenReader.SelectedCount"
                Value="{Binding Items.Count, RelativeSource={RelativeSource AncestorType={x:Type Selector}}, FallbackValue=0}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:SpinnerControl">
                    <Grid VerticalAlignment="Center"
                          Margin="{DynamicResource A_Thickness_SpinnerMargin_Dynamic}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="LeftArrowStateGroup">
                                <VisualState x:Name="PrevDisabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                       Storyboard.TargetName="LeftArrow">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="{x:Static Visibility.Hidden}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="PrevEnabled" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="RightArrowStateGroup">
                                <VisualState x:Name="NextDisabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                       Storyboard.TargetName="RightArrow">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="{x:Static Visibility.Hidden}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="NextEnabled" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="{DynamicResource A_GridLength_SpinnerWidth}" />
                        </Grid.ColumnDefinitions>

                        <Grid Grid.Column="0">
                            <local:FZTextBlock x:Name="FZTextBlock_SpinnerLabelText"
                                               Text="{Binding Label, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource A_StringToUpper}}"
                                               Style="{DynamicResource A_Style_FZTextBlock_SpinnerTitle_Dynamic}"
                                               HorizontalAlignment="Left"
                                               local:ScreenReader.Event="OnChange"
                                               local:ScreenReader.ControlType="Spinner"
                                               local:ScreenReader.LineType="SelectedItem"
                                               local:ScreenReader.SelectedNumber="{Binding (local:ScreenReader.SelectedNumber), RelativeSource={RelativeSource AncestorType={x:Type local:SpinnerControl}}}"
                                               local:ScreenReader.SelectedCount="{Binding (local:ScreenReader.SelectedCount), RelativeSource={RelativeSource AncestorType={x:Type local:SpinnerControl}}}"/>
                        </Grid>

                        <Grid x:Name="SpinnerContainer"
                              Grid.Column="1"
                              Margin="{StaticResource A_Margin_SpinnerTrailingMargin}">
                            <DockPanel>
                                <Grid x:Name="LeftArrowContainer"
                                      DockPanel.Dock="Left">
                                    <local:FZButton x:Name="LeftArrow"
                                                    Command="{TemplateBinding PrevSelectCommand}"
                                                    Style="{StaticResource A_Style_Button_SpinnerArrowButton}"
                                                    Margin="3,0,0,0">
                                        <ContentControl Style="{StaticResource A_Style_Arrow_Left}"
                                                        HorizontalAlignment="Left"
                                                        Margin="-2,0,0,0" />
                                    </local:FZButton>
                                </Grid>

                                <Grid x:Name="RightArrowContainer"
                                      DockPanel.Dock="Right">
                                    <local:FZButton x:Name="RightArrow"
                                                    Command="{TemplateBinding NextSelectCommand}"
                                                    Style="{StaticResource A_Style_Button_SpinnerArrowButton}"
                                                    Margin="0,0,2,0">
                                        <ContentControl Style="{StaticResource A_Style_Arrow_Right}"
                                                        HorizontalAlignment="Right"
                                                        Margin="0,0,-2,0" />
                                    </local:FZButton>
                                </Grid>

                                <local:FZTextBlock x:Name="FZTextBlock_SpinnerItemText"
                                                   Text="{Binding SelectedItem, RelativeSource={RelativeSource TemplatedParent}}"
                                                   Style="{DynamicResource A_Style_FZTextBlock_SpinnerItem_Dynamic}"
                                                   TextTrimming="{DynamicResource A_TextTrimming_SpinnerItemTextTrimming_Dynamic}"
                                                   local:ScreenReader.Event="OnChange"
                                                   local:ScreenReader.LineType="SelectedValue"
                                                   local:ScreenReader.SelectedNumber="{Binding SelectedIndex, RelativeSource={RelativeSource AncestorType={x:Type local:SpinnerControl}}, Converter={StaticResource A_IndexToNumberConverter}, FallbackValue=0}"
                                                   local:ScreenReader.SelectedCount="{Binding ItemsSource.Count, RelativeSource={RelativeSource AncestorType={x:Type local:SpinnerControl}}, FallbackValue=0}" />
                            </DockPanel>
                        </Grid>
                    </Grid>


                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Color" TargetName="FZTextBlock_SpinnerLabelText" Value="{StaticResource A_Color_TextMenu_Text_Locked}"/>
                            <Setter Property="Color" TargetName="FZTextBlock_SpinnerItemText" Value="{StaticResource A_Color_TextMenu_Text_Locked}"/>
                            <Setter Property="Visibility" TargetName="LeftArrowContainer" Value="Hidden"/>
                            <Setter Property="Visibility" TargetName="RightArrowContainer" Value="Hidden"/>
                        </Trigger>
                        <Trigger Property="Tag" Value="Locked">
                            <Setter Property="Visibility" TargetName="SpinnerContainer" Value="Hidden"/>
                            <Setter Property="Color" TargetName="FZTextBlock_SpinnerLabelText" Value="{StaticResource A_Color_TextMenu_Text_Locked}"/>
                        </Trigger>
                        <Trigger Property="IsKeyboardFocusWithin" Value="True">
                            <Setter Property="Color" TargetName="FZTextBlock_SpinnerLabelText" Value="{StaticResource A_Color_TextMenu_Text_Highlighted}"/>
                            <Setter Property="Color" TargetName="FZTextBlock_SpinnerItemText" Value="{StaticResource A_Color_TextMenu_Text_Highlighted}"/>
                            <Setter Property="local:ScreenReader.Line" TargetName="FZTextBlock_SpinnerLabelText" Value="{Binding Label, RelativeSource={RelativeSource TemplatedParent}}" />
                            <Setter Property="local:ScreenReader.Line" TargetName="FZTextBlock_SpinnerItemText" Value="{Binding Text, RelativeSource={RelativeSource Self}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="A_Style_SpinnerControl_Default"
           BasedOn="{StaticResource A_Style_SpinnerControl_Default_Internal}"
           TargetType="local:SpinnerControl">
        <Style.Resources>
            <Style x:Key="A_Style_FZTextBlock_SpinnerTitle_Dynamic"
                   TargetType="local:FZTextBlock"
                   BasedOn="{StaticResource A_Style_FZTextBlock_SpinnerTitle}"/>
            <Style x:Key="A_Style_FZTextBlock_SpinnerItem_Dynamic"
                   TargetType="local:FZTextBlock"
                   BasedOn="{StaticResource A_Style_FZTextBlock_SpinnerItem}" />
            <TextTrimming x:Key="A_TextTrimming_SpinnerItemTextTrimming_Dynamic">None</TextTrimming>
        </Style.Resources>
    </Style>

    <Style x:Key="A_Style_SpinnerControl_DefaultEllipsis"
           BasedOn="{StaticResource A_Style_SpinnerControl_Default}"
           TargetType="local:SpinnerControl">
        <Style.Resources>
            <TextTrimming x:Key="A_TextTrimming_SpinnerItemTextTrimming_Dynamic">CharacterEllipsis</TextTrimming>
        </Style.Resources>
    </Style>

    <Style x:Key="A_Style_SpinnerControl_Default_AltStyle"
           BasedOn="{StaticResource A_Style_SpinnerControl_Default_Internal}"
           TargetType="local:SpinnerControl">
        <Style.Resources>
            <Style x:Key="A_Style_FZTextBlock_SpinnerTitle_Dynamic"
                   TargetType="local:FZTextBlock"
                   BasedOn="{StaticResource A_Style_FZTextBlock_SpinnerTitle}">
                <Setter Property="FontFamily" Value="Horizon_C" />
            </Style>
            <Style x:Key="A_Style_FZTextBlock_SpinnerItem_Dynamic"
                   TargetType="local:FZTextBlock"
                   BasedOn="{StaticResource A_Style_FZTextBlock_SpinnerItem}">
                <Setter Property="FontFamily" Value="Horizon_C" />
            </Style>
            <TextTrimming x:Key="A_TextTrimming_SpinnerItemTextTrimming_Dynamic">None</TextTrimming>
        </Style.Resources>
    </Style>

    <Style x:Key="A_Style_SpinnerControl_Default_InItemsList"
           BasedOn="{StaticResource A_Style_SpinnerControl_Default}"
           TargetType="local:SpinnerControl">
        <Style.Resources>
            <Thickness x:Key="A_Thickness_SpinnerMargin_Dynamic">18,0</Thickness>
        </Style.Resources>
        <Setter Property="Height"
                Value="{StaticResource A_Double_TextMenu_Height_Default}" />
    </Style>

    <Style x:Key="A_Style_SpinnerControl_Default_InItemsList_Ellipsis"
           BasedOn="{StaticResource A_Style_SpinnerControl_Default_InItemsList}"
           TargetType="local:SpinnerControl">
        <Style.Resources>
            <TextTrimming x:Key="A_TextTrimming_SpinnerItemTextTrimming_Dynamic">CharacterEllipsis</TextTrimming>
        </Style.Resources>
    </Style>

    <Style x:Key="A_Style_SpinnerControl_Default_InItemsList_AltStyle"
           BasedOn="{StaticResource A_Style_SpinnerControl_Default_AltStyle}"
           TargetType="local:SpinnerControl">
        <Style.Resources>
            <Thickness x:Key="A_Thickness_SpinnerMargin_Dynamic">18,0</Thickness>
        </Style.Resources>
        <Setter Property="Height"
                Value="{StaticResource A_Double_TextMenu_Height_Default}" />
    </Style>
</ResourceDictionary>