<Page xmlns:local="clr-namespace:ForzaUI"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      x:Class="ForzaUI.Scenes.Anthem.A_AssistOptions"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      FlowDirection="LeftToRight"
      DataContext="{Binding DataSource, RelativeSource={RelativeSource Self}}"
      >

    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}"/>
    </local:UIPageTransitionManager.TransitionManager>

    <Page.Resources>
        <ResourceDictionary>
            <local:NumUnitConverter x:Key="A_Assist_NumUnitConverter_TotalRaceBonus" FractionDigits="0" ShowUnit="True" PositiveSign="True"/>
            <local:LinearTransformConverter x:Key="A_LinearTransformConverter_BonusTransform" Scale="0.8005"/> <!-- Max Bonus is 1.25, *0.8 = 1, slightly above to avoid single pixel gap-->

            <Style x:Key="A_Style_FZTextBlock_TotalRaceBonusBody" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}" >
                <Setter Property="Color" Value="{StaticResource A_Color_SubHeader_Text}"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="CapHeight" Value="14" />
            </Style>

            <Style x:Key="A_Style_Assist_TotalRaceBonus_Circle" TargetType="{x:Type Control}" BasedOn="{StaticResource A_Style_Control_Circle}">
                <Setter Property="Tag" Value="{StaticResource A_Color_TileSelected_Background}"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="Width" Value="132"/>
                <Setter Property="Height" Value="132"/>
            </Style>

            <QuarticEase x:Key="A_EasingFunction_AssistOptions_Infographic_Animation"
                         EasingMode="EaseOut" />

            <local:UIStoryboard x:Key="A_Storyboard_AssistOptions_BlendValueInputChanged">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="{x:Null}"
                                               FillBehavior="Stop"
                                               Storyboard.TargetProperty="(local:BlendValue.Blend)">
                    <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                            Value="0" />
                    <DiscreteDoubleKeyFrame KeyTime="0:0:0.0"
                                            Value="0" />
                    <EasingDoubleKeyFrame KeyTime="0:0:0.5"
                                          Value="1"
                                          EasingFunction="{StaticResource A_EasingFunction_AssistOptions_Infographic_Animation}">
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
            </local:UIStoryboard>
            <Style x:Key="A_Style_Control_DescriptionBlock"
                   TargetType="Control">
                <Setter Property="MaxHeight" Value="250" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsE3, RelativeSource={RelativeSource AncestorType=Page}}"
                                 Value="True">
                        <Setter Property="MaxHeight" Value="Auto" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </Page.Resources>

    <Grid>
        <!-- Background Blur -->
       <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />

        <Grid>
            <local:PlayerBarControl x:Name="TopBar" Style="{StaticResource A_Style_PlayerBarControl}" />
            <ContentControl x:Name="BottomBar" Style="{StaticResource A_Style_ButtonBar}">
                <ContentControl x:Name="DefaultHelpPanel"
                        local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_Accept}"
                        local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                        local:ControllerButtonPanel.YDescription="{local:Loc HelpButtons.IDS_ResetDefault}"
                        Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
            </ContentControl>
            <Border x:Name="LayoutRoot"
                    Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="OptionsStates">
                        <VisualState x:Name="OfflineState">
                            <Storyboard>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="E3State">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="DrivatarDifficulty">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="DifficultyPanel">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="DifficultyFooter">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="OnlineState">
                        </VisualState>
                        <VisualState x:Name="RivalsState">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="DrivatarDifficulty">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsEnabled)" Storyboard.TargetName="DrivatarDifficulty">
                                    <DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
                                </BooleanAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="OnlineCoopLeaderState">
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>

                <Grid>
                    <!--Main Tile Content -->
                    <Grid Style="{StaticResource A_Style_FrameworkElement_ScreenTilt}" Focusable="False" >
                        <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Margin="16,0,0,0" Orientation="Vertical">
                            <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                                <ContentControl Tag="{local:Loc ScreenTitles.IDS_MyProfile}"
                                                Content="{local:Loc ScreenTitles.IDS_Difficulty}"
                                                local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Options.png"
                                                Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}" HorizontalAlignment="Left" />
                            </Grid>
                            <DockPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}" >
                                <ContentControl DockPanel.Dock="Right"
                                                Template="{StaticResource A_ControlTemplate_SidePanel}"
                                                local:RoutedEventCommand.Action="{Binding ElementName=ToggleStatsRoutedEventCommand}"
                                                Tag="{local:Loc ScreenTitles.IDS_Description}"
                                                Width="341"
                                                Height="660"
                                                VerticalAlignment="Top">
                                    <DockPanel LastChildFill="False">
                                        <ContentControl Template="{StaticResource A_ControlTemplate_ContentControl_DescriptionPanel_DescriptionText}"
                                                        DataContext="{Binding SelectedItem, ElementName=OptionsList}"
                                                        Content="{Binding Tag}"
                                                        DockPanel.Dock="Top"
                                                        Style="{StaticResource A_Style_Control_DescriptionBlock}" />
                                        <local:FZMaterial x:Name="DifficultyFooter"
                                                          Style="{StaticResource A_Style_FZMaterial_FlatPanel_FooterPanel}"
                                                          DockPanel.Dock="Bottom"
                                                          Height="Auto">
                                            <StackPanel
                                                        HorizontalAlignment="Center"
                                                        Margin="21">
                                                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_TotalRaceBonusBody}"
                                                                   CapHeight="27"
                                                                   Color="{StaticResource A_Color_SubHeader_Text}"
                                                                   HorizontalAlignment="Center"
                                                                   local:BlendValue.InputChangedStoryboard="{StaticResource A_Storyboard_AssistOptions_BlendValueInputChanged}"
                                                                   local:BlendValue.Input="{Binding TotalBonus}"
                                                                   local:BlendValue.BlendFromPreviousOutput="True"
                                                                   local:BlendValue.ShouldSkipInitialInputChange="True"
                                                                   Text="{Binding Path=(local:BlendValue.Output), ConverterParameter=fracpercentage, Converter={StaticResource A_Assist_NumUnitConverter_TotalRaceBonus}, RelativeSource={RelativeSource Self}}"
                                                                   Margin="0,0,0,12" />
                                                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_TotalRaceBonusBody}"
                                                                   FontFamily="Horizon_D" CapHeight="16"
                                                                   Text="{local:Loc Assists.IDS_Title_Total_Race_Bonus}" />
                                            </StackPanel>
                                        </local:FZMaterial>
                                        <Grid x:Name="DifficultyPanel"
                                              DockPanel.Dock="Bottom"
                                              HorizontalAlignment="Center"
                                              Margin="0,-90,0,0">
                                            <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/UI_Symbols/CR_Difficulty_Infographic_BG.png"
                                                              Width="178"
                                                              Height="178" />
                                            <local:FZMaterial CaptureSubgraph="True"
                                                              Style="{StaticResource A_Style_FZMaterial_HighlightShadow}"
                                                              Preset="{StaticResource A_FZMaterialPresetStreak_DifficultyInfographicShadow}"
                                                              Width="341"
                                                              DockPanel.Dock="Bottom"
                                                              HorizontalAlignment="Center">
                                                <Grid Height="275"
                                                      Width="275">
                                                    <local:FZMaterial x:Name="InitialRing"
                                                                      Color="{StaticResource A_Color_Options_DifficultyBonus}"
                                                                      Tag="{Binding TotalBonus, NotifyOnTargetUpdated=True}"
                                                                      local:BlendValue.InputChangedStoryboard="{StaticResource A_Storyboard_AssistOptions_BlendValueInputChanged}"
                                                                      local:BlendValue.Input="{Binding TotalBonus, Converter={StaticResource A_LinearTransformConverter_BonusTransform}}"
                                                                      local:BlendValue.BlendFromPreviousOutput="True"
                                                                      local:BlendValue.ShouldSkipInitialInputChange="True">
                                                        <local:FZMaterial.Preset>
                                                            <local:FZMaterialPresetRadialBar x:Name="Preset"
                                                                                             TargetRatio="1.0"
                                                                                             ShadowIntensity="0"
                                                                                             TipGlowFade="0.0"
                                                                                             AngleAmount="0"
                                                                                             BarWidth="0.15"
                                                                                             BackgroundColor="#00FFFFFF"
                                                                                             Ratio="{Binding Path=(local:BlendValue.Output), RelativeSource={RelativeSource FindAncestor, AncestorType=local:FZMaterial}}">
                                                            </local:FZMaterialPresetRadialBar>
                                                        </local:FZMaterial.Preset>
                                                    </local:FZMaterial>
                                                </Grid>
                                            </local:FZMaterial>
                                            <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/UI_Symbols/CR_Difficulty_Infographic_CR_Icon.png"
                                                              Width="178"
                                                              Height="178" />
                                        </Grid>
                                    </DockPanel>
                                </ContentControl>
                                
                                <Grid local:UIPageTransitionManager.TransitionIndex="0" ZIndex="3" DockPanel.Dock="Left" Margin="0,0,5,0">
                                    <local:CommonListBox x:Name="EmptyOptionsList" Style="{StaticResource A_Style_ListBox_List_Default}"
                                                         ItemContainerStyle="{StaticResource A_Style_ListBoxItem_TextMenu_NotFocusable}" VerticalAlignment="Top"/>

                                    <local:CommonListBox x:Name="OptionsList"
                                                         Style="{StaticResource A_Style_ListBox_List_Default}"
                                                         ItemContainerStyle="{StaticResource A_Style_ListBoxItem_TextMenu_NotFocusable}"
                                                         Width="824" Height="Auto"
                                                         VerticalAlignment="Top"
                                                         Tag="NoScrollArrows">
                                        <local:SpinnerControl x:Name="DrivatarDifficulty" Label="{local:Loc Assists.IDS_DrivatarDifficulty}" ItemsSource="{Binding AIDiffOptions}" Style="{StaticResource A_Style_SpinnerControl_Default_InItemsList}" SelectedIndex="{Binding AIDiff}" Tag="{local:Loc Assists.IDS_Desc_AIDifficulty}"
                                                              Visibility="{Binding IsE3, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}"/>
                                        <local:SpinnerControl x:Name="MetaDifficulty" Label="{local:Loc Assists.IDS_MetaDifficulty}" ItemsSource="{Binding MetaDiffOptions}" Style="{StaticResource A_Style_SpinnerControl_Default_InItemsList_AltStyle}" SelectedIndex="{Binding MetaDiff}" Tag="{local:Loc Assists.IDS_Desc_MetaDifficulty}"/>
                                        <local:SpinnerControl x:Name="Braking" Label="{local:Loc Assists.IDS_Braking}" ItemsSource="{Binding BrakingOptions}" Style="{StaticResource A_Style_SpinnerControl_Default_InItemsList}" SelectedIndex="{Binding Braking}" Tag="{local:Loc Assists.IDS_Desc_Braking}"/>
                                        <local:SpinnerControl x:Name="Steering" Label="{local:Loc Assists.IDS_Steering}" ItemsSource="{Binding SteeringOptions}" Style="{StaticResource A_Style_SpinnerControl_Default_InItemsList}" SelectedIndex="{Binding Steering}" Tag="{local:Loc Assists.IDS_Desc_Steering}"/>
                                        <local:SpinnerControl x:Name="TractionControl" Label="{local:Loc Assists.IDS_TractionControl}" ItemsSource="{Binding TractionControlOptions}" Style="{StaticResource A_Style_SpinnerControl_Default_InItemsList}" SelectedIndex="{Binding TractionControl}" Tag="{local:Loc Assists.IDS_Desc_TractionControl}"/>
                                        <local:SpinnerControl x:Name="StabilityControl" Label="{local:Loc Assists.IDS_StabilityControl}" ItemsSource="{Binding StabilityControlOptions}" Style="{StaticResource A_Style_SpinnerControl_Default_InItemsList}" SelectedIndex="{Binding StabilityControl}" Tag="{local:Loc Assists.IDS_Desc_StabilityControl}"/>
                                        <local:SpinnerControl x:Name="Shifting" Label="{local:Loc Assists.IDS_Shifting}" ItemsSource="{Binding ShiftingOptions}" Style="{StaticResource A_Style_SpinnerControl_Default_InItemsList}" SelectedIndex="{Binding Shifting}" Tag="{local:Loc Assists.IDS_Desc_Shifting}"/>
                                        <local:SpinnerControl x:Name="DrivingLine" Label="{local:Loc Assists.IDS_DrivingLine}" ItemsSource="{Binding SuggestedLineOptions}" Style="{StaticResource A_Style_SpinnerControl_Default_InItemsList}" SelectedIndex="{Binding SuggestedLine}" Tag="{local:Loc Assists.IDS_Desc_SuggestedLine}"/>
                                        <local:SpinnerControl x:Name="DamageDifficulty" Label="{local:Loc Assists.IDS_DamageDifficulty}" ItemsSource="{Binding DamageFuelWearOptions}" Style="{StaticResource A_Style_SpinnerControl_Default_InItemsList}" SelectedIndex="{Binding DamageFuelWear}" Tag="{local:Loc Assists.IDS_Desc_DamageDifficulty}"/>
                                        <local:SpinnerControl x:Name="Rewind" Label="{local:Loc Assists.IDS_Rewind}" ItemsSource="{Binding RewindOptions}" Style="{StaticResource A_Style_SpinnerControl_Default_InItemsList}" SelectedIndex="{Binding Rewind}" Tag="{local:Loc Assists.IDS_Desc_Rewind}"/>
                                    </local:CommonListBox>
                                </Grid>
                            </DockPanel>
                        </StackPanel>
                    </Grid>
                </Grid>
            </Border>
        </Grid>
    </Grid>
</Page>
