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

    <DropShadowEffect x:Key="A_DropShadowEffect_HelpBar"
                      Color="{StaticResource A_Color_DropShadow}"
                      BlurRadius="0"
                      ShadowDepth="2" />

    <local:MappingConverter x:Key="A_Converter_DLC2ButtonBarBackgroundColor"
                            Default="{StaticResource A_Color_ButtonBar_Background}">
        <local:MappingConverterEntry Key="{x:Static local:SceneEntryEnum.BrickChallenges}" Value="{StaticResource A_Color_ButtonBar_Dark_Background}" />
        <local:MappingConverterEntry Key="{x:Static local:SceneEntryEnum.MapScene}" Value="{StaticResource A_Color_ButtonBar_Dark_Background}" />
    </local:MappingConverter>

    <Style x:Key="A_Style_ControllerButton_Background"
           TargetType="local:FZMaterial"
           BasedOn="{StaticResource A_Style_FZMaterial_FlatPanel_Base}">
        <Setter Property="Color" Value="{StaticResource A_Color_ButtonBar_Background}" />
        <Setter Property="Height" Value="34" />
        <Style.Triggers>
            <DataTrigger Binding="{Binding ActiveTrack, RelativeSource={RelativeSource AncestorType=Page}}" Value="{x:Static local:XAMLTrack.ExpansionTwo}">
                <Setter Property="Color" Value="{Binding SceneEnum, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_Converter_DLC2ButtonBarBackgroundColor}}" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="A_Style_ControllerButtonControl_ControllerInputIcon"
           TargetType="local:FZMaterial"
           BasedOn="{StaticResource A_Style_FZMaterial_FlatPanel_Base}">
        <Setter Property="Color" Value="{Binding Color, RelativeSource={RelativeSource TemplatedParent}}" />
        <Setter Property="GreedyMeasure" Value="True" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="StretchDirection" Value="Both" />
        <Setter Property="Stretch" Value="Uniform" />
        <Setter Property="ImageSource" Value="{Binding ButtonForegroundIcon, RelativeSource={RelativeSource AncestorType=local:ControllerButtonControl}}" />
        <Style.Triggers>
            <DataTrigger Binding="{Binding Desaturate, RelativeSource={RelativeSource AncestorType=local:ControllerButtonControl}}" Value="True">
                <Setter Property="Preset" Value="{StaticResource A_FZMaterialPreset_AlphaOnly}"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="A_Style_ControllerButtonControl_KeyboardInputIcon"
           TargetType="local:FZMaterial"
           BasedOn="{StaticResource A_Style_ControllerButtonControl_ControllerInputIcon}">
        <Setter Property="Width" Value="12" />
        <Setter Property="Height" Value="12" />
    </Style>

    <Style x:Key="A_Style_FZTextBlock_ButtonBarDescription"
           BasedOn="{StaticResource A_Style_FZTextBlock_HorizonD}"
           TargetType="{x:Type local:FZTextBlock}">
        <Setter Property="FontSize" Value="20" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="Color" Value="{Binding Color, RelativeSource={RelativeSource TemplatedParent}}" />
        <Setter Property="Effect" Value="{StaticResource A_DropShadowEffect_HelpBar}" />
        <Setter Property="Text" Value="{Binding Description, RelativeSource={RelativeSource TemplatedParent}}" />
        <Setter Property="Visibility" Value="{Binding Description, Converter={StaticResource A_StringVisConverter}, RelativeSource={RelativeSource AncestorType=ControllerButtonControl}}" />
    </Style>

    <ControlTemplate x:Key="A_ControlTemplate_ControllerButtonControl_Controller"
                     TargetType="{x:Type local:ControllerButtonControl}">
        <Viewbox>
            <StackPanel Orientation="Horizontal"
                        x:Name="BtnContainer">
                <Grid Height="25" MaxWidth="25">
                    <local:FZMaterial Style="{StaticResource A_Style_ControllerButtonControl_ControllerInputIcon}" 
                                      ImageSource="{Binding ButtonBackgroundIcon, RelativeSource={RelativeSource AncestorType=local:ControllerButtonControl}}"
                                      Visibility="{Binding HideBackground, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden_Inverse}, RelativeSource={RelativeSource AncestorType=local:ControllerButtonControl}}"
                                      Margin="1"/>
                    <local:FZMaterial Style="{StaticResource A_Style_ControllerButtonControl_ControllerInputIcon}"
                                      Margin="1,1,-1,-1"
                                      Preset="{StaticResource A_FZMaterialPreset_AlphaOnly}"
                                      Color="{StaticResource A_Color_DropShadow}"
                                      Visibility="{Binding HideShadow, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden_Inverse}, RelativeSource={RelativeSource AncestorType=local:ControllerButtonControl}}" />
                    <local:FZMaterial Style="{StaticResource A_Style_ControllerButtonControl_ControllerInputIcon}" />
                    <local:FZTextBlock Text="{Binding RawControllerForegroundText, RelativeSource={RelativeSource AncestorType=local:ControllerButtonControl}}"
                                       Style="{StaticResource A_Style_FZTextBlock_HorizonA}"
                                       Color="{Binding Color, RelativeSource={RelativeSource TemplatedParent}}"
                                       CapHeight="10"
                                       Visibility="{Binding RawControllerForegroundText, RelativeSource={RelativeSource AncestorType=local:ControllerButtonControl}, Converter={StaticResource A_StringVisConverter}}"
                                       VerticalAlignment="Center"
                                       HorizontalAlignment="Center"
                                       TextAlignment="Center"
                                       MaxWidth="19" />
                </Grid>
                <local:FZTextBlock Margin="6,0,30,0"
                                   Style="{StaticResource A_Style_FZTextBlock_ButtonBarDescription}"
                                   MaxWidth="250"
                                   Stretch="Uniform"
                                   StretchDirection="DownOnly" />
            </StackPanel>
        </Viewbox>
    </ControlTemplate>

    <ControlTemplate x:Key="A_ControlTemplate_ControllerButtonControl_KeyboardSingle"
                     TargetType="{x:Type local:ControllerButtonControl}">
        <Viewbox x:Name="Contents">
            <Grid x:Name="Container" Margin="0,0,10,0">
                <local:FZMaterial x:Name="Background"
                                  Style="{StaticResource A_Style_ControllerButton_Background}"
                                  Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll}"
                                  Visibility="{Binding HideBackground, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden_Inverse}, RelativeSource={RelativeSource AncestorType=local:ControllerButtonControl}}"/>
                <DockPanel Margin="4,4,4,4"
                           IsHitTestVisible="False"
                           Height="26">
                    <Grid DockPanel.Dock="Left"
                          MinWidth="24">
                        <local:FZMaterial x:Name="OutlineShadow"
                                          Preset="{StaticResource A_FZMaterialPresetRoundtangleStroke_FlatPanel_Thin_Inner_All}"
                                          Color="{StaticResource A_Color_DropShadow}"
                                          Margin="1,1,-1,-1" />
                        <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetRoundtangleStroke_FlatPanel_Thin_Inner_All}"
                                          Color="{Binding Color, RelativeSource={RelativeSource TemplatedParent}}">
                            <Grid Margin="5,5">
                                <local:FZTextBlock x:Name="KeyText"
                                                   Text="{Binding KeyboardKeyText, RelativeSource={RelativeSource AncestorType=local:ControllerButtonControl}}"
                                                   Visibility="{Binding KeyboardKeyText, RelativeSource={RelativeSource AncestorType=local:ControllerButtonControl}, Converter={StaticResource A_StringVisConverter}}"
                                                   Style="{StaticResource A_Style_FZTextBlock_HorizonC}"
                                                   Effect="{StaticResource A_DropShadowEffect_HelpBar}"
                                                   Color="{Binding Color, RelativeSource={RelativeSource TemplatedParent}}"
                                                   FontSize="17"
                                                   HorizontalAlignment="Center"
                                                   VerticalAlignment="Center" />
                                <Grid Visibility="{Binding KeyboardKeyText, RelativeSource={RelativeSource AncestorType=local:ControllerButtonControl}, Converter={StaticResource A_StringVisConverter_Inverse}}">
                                    <local:FZMaterial x:Name="KeyIconShadow"
                                                      Style="{StaticResource A_Style_ControllerButtonControl_KeyboardInputIcon}"
                                                      Color="{StaticResource A_Color_DropShadow}"
                                                      Margin="2,2,0,0"/>
                                    <local:FZMaterial x:Name="KeyIcon"
                                                      Style="{StaticResource A_Style_ControllerButtonControl_KeyboardInputIcon}" />
                                </Grid>
                            </Grid>
                        </local:FZMaterial>
                    </Grid>
                    <local:FZTextBlock x:Name="DescriptionText"
                                       Style="{StaticResource A_Style_FZTextBlock_ButtonBarDescription}"
                                       HorizontalAlignment="Center"
                                       Margin="9,0,8,0" />
                </DockPanel>
            </Grid>
        </Viewbox>
        <ControlTemplate.Triggers>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
                               Value="True" />
                    <Condition Binding="{Binding AllowMouseClick, RelativeSource={RelativeSource Self}}"
                               Value="True" />
                </MultiDataTrigger.Conditions>
                <Setter TargetName="Background"
                        Property="Preset"
                        Value="{StaticResource A_FZMaterialPresetRoundtangle_GradientHighlight_OuterAll}" />
                <Setter TargetName="Background"
                        Property="Color"
                        Value="#FFFFFFFF" />
            </MultiDataTrigger>
            <DataTrigger Binding="{Binding Description, RelativeSource={RelativeSource Self}}"
                         Value="">
                <Setter TargetName="Container"
                        Property="Margin"
                        Value="0" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Description, RelativeSource={RelativeSource Self}}"
                         Value="{x:Null}">
                <Setter TargetName="Container"
                        Property="Margin"
                        Value="0" />
            </DataTrigger>
            <DataTrigger Binding="{Binding HideShadow, RelativeSource={RelativeSource Self}}"
                         Value="True">
                <Setter TargetName="OutlineShadow"
                        Property="Visibility"
                        Value="Hidden"/>
                <Setter TargetName="KeyIconShadow"
                        Property="Visibility"
                        Value="Hidden"/>
                <Setter TargetName="KeyText"
                        Property="Effect"
                        Value="{x:Null}"/>
            </DataTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="A_Style_ControllerButtonControl_Default"
           TargetType="{x:Type local:ControllerButtonControl}">
        <Setter Property="Focusable"
                Value="False" />
        <Setter Property="Reusable"
                Value="False" />
        <Setter Property="Height"
                Value="25" />
        <Setter Property="Color"
                Value="{StaticResource A_Color_ButtonBar_Foreground}" />
        <Setter Property="Template"
                Value="{StaticResource A_ControlTemplate_ControllerButtonControl_Controller}" />
        <Setter Property="Visibility"
                Value="{Binding Description, RelativeSource={RelativeSource Self}, Converter={StaticResource A_StringVisConverter}}" />
        <Setter Property="local:MultiStringFormatter.Format" Value="{local:Loc Main.IDS_ScreenReader_Format_ButtonControl_NameAndDescription}"/>
        <Setter Property="local:MultiStringFormatter.Param0" Value="{Binding ScreenReaderName, RelativeSource={RelativeSource Self}}"/>
        <Setter Property="local:MultiStringFormatter.Param1" Value="{Binding Description, RelativeSource={RelativeSource Self}}"/>
        <Style.Triggers>
            <DataTrigger Binding="{Binding IsControllerActiveInput, RelativeSource={RelativeSource AncestorType=Page}}"
                         Value="False">
                <Setter Property="Template"
                        Value="{StaticResource A_ControlTemplate_ControllerButtonControl_KeyboardSingle}" />
                <Setter Property="Height"
                        Value="34" />
                <Setter Property="MinWidth"
                        Value="34" />
            </DataTrigger>
            <DataTrigger Binding="{Binding IsValid, RelativeSource={RelativeSource Self}}" Value="False">
                <Setter Property="Opacity"
                        Value="0"/>
                <Setter Property="Width"
                        Value="0"/>
                <Setter Property="Height"
                        Value="0"/>
                <Setter Property="MinWidth"
                        Value="0"/>
                <Setter Property="MinHeight"
                        Value="0"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding ScreenReaderName, RelativeSource={RelativeSource Self}, Converter={StaticResource A_StringVisConverter}}" Value="{x:Static Visibility.Collapsed}">
                <Setter Property="local:MultiStringFormatter.Format" Value="{local:Loc Main.IDS_ScreenReader_Format_ButtonControl_DescriptionOnly}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Description, RelativeSource={RelativeSource Self}, Converter={StaticResource A_StringVisConverter}}" Value="{x:Static Visibility.Collapsed}">
                <Setter Property="local:MultiStringFormatter.Format" Value="{local:Loc Main.IDS_ScreenReader_Format_ButtonControl_NameOnly}"/>
            </DataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding IsValid, RelativeSource={RelativeSource Self}}" Value="True"/>
                    <Condition Binding="{Binding Visibility, RelativeSource={RelativeSource Self}}" Value="{x:Static Visibility.Visible}"/>
                </MultiDataTrigger.Conditions>
                <Setter Property="local:ControllerButtonPanel.ScreenReaderText" Value="{Binding (local:MultiStringFormatter.Output), RelativeSource={RelativeSource Self}}"/>
            </MultiDataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="A_Style_ControllerButtonControl_Default_ShowAlways"
           TargetType="{x:Type local:ControllerButtonControl}"
           BasedOn="{StaticResource A_Style_ControllerButtonControl_Default}">
        <Setter Property="Visibility"
                Value="Visible" />
    </Style>

    <Style x:Key="A_Style_ControllerButtonControl_ActivationButton"
           BasedOn="{StaticResource A_Style_ControllerButtonControl_Default_ShowAlways}"
           TargetType="local:ControllerButtonControl">
        <Setter Property="InputOverride"
                Value="{local:Input Command=INPUTCMD_ACTIVATE, Context=INPUTCONTEXT_RACING}" />
        <Setter Property="AllowMouseClick"
                Value="False" />
        <Setter Property="HideShadow"
                Value="True" />
    </Style>

    <Style x:Key="A_Style_ControllerButtonControl_OnlineActivationButton"
           BasedOn="{StaticResource A_Style_ControllerButtonControl_Default_ShowAlways}"
           TargetType="local:ControllerButtonControl">
        <Setter Property="InputOverride"
                Value="{local:Input Command=INPUTCMD_ONLINE_ACTIVATE, Context=INPUTCONTEXT_RACING}" />
        <Setter Property="AllowMouseClick"
                Value="False" />
        <Setter Property="HideShadow"
                Value="True" />
    </Style>

    <Style TargetType="{x:Type local:ControllerButtonControl}"
           BasedOn="{StaticResource A_Style_ControllerButtonControl_Default}">
    </Style>

    <Style x:Key="A_Style_ControllerButtonPanel_Default_NoScreenReader" TargetType="local:ControllerButtonPanel">
        <Setter Property="Canvas.Bottom" Value="0" />
        <Setter Property="Canvas.Left" Value="0" />
        <Setter Property="Layout" Value="RightToLeft" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="Margin" Value="0,0,0,0" />
        <Setter Property="Background" Value="{x:Null}" />
    </Style>

    <Style x:Key="A_Style_ControllerButtonPanel_Default" BasedOn="{StaticResource A_Style_ControllerButtonPanel_Default_NoScreenReader}" TargetType="local:ControllerButtonPanel">
        <Setter Property="local:ScreenReader.Line" Value="{Binding ChildScreenReaderTexts, RelativeSource={RelativeSource Self}}" />
        <Setter Property="local:ScreenReader.Event" Value="OnChange" />
        <Setter Property="local:ScreenReader.LineType" Value="ButtonBar" />
    </Style>

    <Style TargetType="{x:Type local:ControllerButtonPanel}"
           BasedOn="{StaticResource A_Style_ControllerButtonPanel_Default}" >
    </Style>

</ResourceDictionary>