<Page xmlns:local="clr-namespace:ForzaUI"
      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"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      x:Class="ForzaUI.A_PostRaceRivalsChallengeChoicePanel"
      mc:Ignorable="d"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

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

    <Page.Resources>
        <ResourceDictionary>

            <Style x:Key="A_Style_Control_WhooshTextBlock"
                   TargetType="Control"
                   BasedOn="{StaticResource A_Style_FrameworkElement_PostRace_TotalLabelBlock}">
                <Setter Property="HorizontalContentAlignment"
                        Value="Left" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <local:FZTextBlock Style="{DynamicResource A_Style_FZTextBlock_WhooshText}"
                                               HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="local:ZPanel.Transform">
                    <Setter.Value>
                        <Transform3DGroup>
                            <RotateTransform3D />
                            <TranslateTransform3D OffsetZ="0" />
                        </Transform3DGroup>
                    </Setter.Value>
                </Setter>
            </Style>

            <local:FZMaterialPresetRoundtangle x:Key="A_FZMaterialPresetRoundtangle_PostRace_Gamerpic" />

            <ImageBrush x:Key="A_Brush_GamerpicOpacity"
                        ImageSource="/ForzaUI;component/Textures/Data_Bound/PostRace/Gamerpic_Mask.png" />

            <Size x:Key="A_Size_PostRace_GamerPicSizeParams">424,424</Size>

            <local:OffsetKeyTime x:Key="A_KeyTime_Begin"
                                 KeyTime="0:0:0"/>
            
            <local:OffsetKeyTime x:Key="A_KeyTime_Rival_In_Begin"
                                 KeyTime="{StaticResource A_KeyTime_Begin}"/>
            <local:OffsetKeyTime x:Key="A_KeyTime_Rival_In_End"
                                 KeyTime="{StaticResource A_KeyTime_Rival_In_Begin}"
                                 Offset="{StaticResource A_TimeSpan_WhooshDuration}"/>
            

            <local:UIStoryboard x:Key="A_Storyboard_AnimateInitial">
                <local:UIStoryboard.TriggerAnimation>
                    <local:BeginUIStoryboard local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_Begin}"
                                             Storyboard.TargetName="NewRivalBlock"
                                             Storyboard="{StaticResource A_Storyboard_PostRace_WhooshInFromLeft}" />
                    <local:StartAudioTrigger local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_Begin}"
                                             EventName="/Master/UI/PostRace/HZ2_SFX_HUD_PostRace_XPRewardsTitleOn_01" />
                </local:UIStoryboard.TriggerAnimation>
            </local:UIStoryboard>
            
            <local:UIStoryboard x:Key="A_Storyboard_AnimateWithRivalInfo">
                <local:UIStoryboard.TriggerAnimation>
                    <local:BeginUIStoryboard local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_Rival_In_Begin}"
                                             Storyboard.TargetName="GamerPicBlock"
                                             Storyboard="{StaticResource A_Storyboard_PostRace_WhooshInFromLeft}" />
                    <local:BeginUIStoryboard local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_Rival_In_Begin}"
                                             Storyboard.TargetName="NameBlock"
                                             Storyboard="{StaticResource A_Storyboard_PostRace_WhooshInFromLeft}" />
                    <local:StartAudioTrigger local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_Rival_In_Begin}"
                                             EventName="/Master/UI/PostRace/HZ2_SFX_HUD_PostRace_XPRewardsTitleOn_01" />
                    <local:BeginUIStoryboard local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_Rival_In_Begin}"
                                             Storyboard.TargetName="Numbers"
                                             Storyboard="{StaticResource A_Storyboard_PostRace_WhooshInFromRight}" />
                </local:UIStoryboard.TriggerAnimation>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TitleText"
                                               Storyboard.TargetProperty="(UIElement.Visibility)">
                    <DiscreteObjectKeyFrame KeyTime="{StaticResource A_KeyTime_Rival_In_End}"
                                            Value="{x:Static Visibility.Visible}" />
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Downloading"
                                               Storyboard.TargetProperty="(UIElement.Visibility)">
                    <DiscreteObjectKeyFrame KeyTime="{StaticResource A_KeyTime_Rival_In_End}"
                                            Value="{x:Static Visibility.Collapsed}" />
                </ObjectAnimationUsingKeyFrames>
            </local:UIStoryboard>

        </ResourceDictionary>
    </Page.Resources>
    <Grid>
        <Grid Width="1920"
              Height="540"
              ClipToBounds="True">
            <Grid x:Name="NewStyleBits">

                <local:FZMaterial>
                  <local:FZMaterial.Preset>
                    <local:FZMaterialPresetRoundtangle
                        GradientColorA="{StaticResource A_Color_InfluenceThread_BackgroundGradientA_rivals}"
                        GradientColorB="{StaticResource A_Color_InfluenceThread_BackgroundGradientB_rivals}"
                        GradientAngle="90" />
                  </local:FZMaterial.Preset>
                </local:FZMaterial>
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PostRace_Hatching}" />

                <Decorator Margin="0,0,0,0">
                    <Grid Height="540"
                          Width="1500"
                          HorizontalAlignment="Left"
                          ClipToBounds="True"
                          Style="{StaticResource A_Style_FrameworkElement_PostRace_SmallAnimatedBlock}"
                          x:Name="GamerPicBlock">
                        <Grid HorizontalAlignment="Left"
                              Margin="80,0,0,0">
                            <local:FZMaterial OpacityMask="{StaticResource A_Brush_GamerpicOpacity}"
                                              Width="878"
                                              Height="540"
                                              HorizontalAlignment="Left">
                                <Grid HorizontalAlignment="Left">
                                    <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetRoundtangle_PostRace_Gamerpic}"
                                                      ClipToBounds="True"
                                                      VerticalAlignment="Center"
                                                      HorizontalAlignment="Center"
                                                      GreedyMeasure="True"
                                                      x:Name="Gamerpic"
                                                      ImageSource="{Binding UserProfile, Converter={StaticResource A_GamerPicConverter}, ConverterParameter={StaticResource A_Size_PostRace_GamerPicSizeParams}}"
                                                      Stretch="UniformToFill" />
                                    <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/PostRace/Gamerpic_Vignette.png" />

                                </Grid>
                            </local:FZMaterial>

                        </Grid>
                    </Grid>
                </Decorator>

                <Decorator Width="1100"
                           HorizontalAlignment="Right">
                    <StackPanel VerticalAlignment="Center"
                                HorizontalAlignment="Center"
                                local:ZPanel.TransformOrigin="0.5,0.5">
                        <local:ZPanel.Transform>
                            <local:ZRotation Angle="-6" />
                        </local:ZPanel.Transform>
                        <StackPanel HorizontalAlignment="Left">
                            <Decorator RenderTransformOrigin="0.5,0.5"
                                       RenderTransform="{StaticResource A_Transform_Italic}">
                                <Grid Style="{StaticResource A_Style_FrameworkElement_PostRace_TotalLabelBlock}"
                                      x:Name="NewRivalBlock"
                                      HorizontalAlignment="Left">
                                    <local:FZTextBlock x:Name="Downloading"
                                                       Style="{StaticResource A_Style_FZTextBlock_HorizonB}"
                                                       Color="#fff"
                                                       CapHeight="50"
                                                       Text="{local:Loc InGame.IDS_Rival_DownloadingRival}" />
                                    <local:FZTextBlock x:Name="TitleText"
                                                       Style="{StaticResource A_Style_FZTextBlock_HorizonB}"
                                                       Color="#fff"
                                                       CapHeight="50"
                                                       Text="{Binding WantToRaceMessage}"
                                                       Visibility="Collapsed" />
                                </Grid>
                            </Decorator>

                            <Decorator Height="15" />

                            <Decorator RenderTransformOrigin="0.5,0.5"
                                       RenderTransform="{StaticResource A_Transform_Italic}">
                                <Control Style="{StaticResource A_Style_Control_WhooshTextBlock}"
                                         x:Name="NameBlock"
                                         HorizontalAlignment="Left">
                                    <Control.Resources>
                                        <Style x:Key="A_Style_FZTextBlock_WhooshText"
                                               TargetType="local:FZTextBlock"
                                               BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}">
                                            <Setter Property="Color"
                                                    Value="#fff" />
                                            <Setter Property="CapHeight"
                                                    Value="82" />
                                            <Setter Property="Text"
                                                    Value="{Binding UserProfile.FormattedGamertag}" />
                                        </Style>

                                    </Control.Resources>
                                </Control>
                            </Decorator>
                        </StackPanel>

                        <Decorator Height="40" />
                        <StackPanel x:Name="Numbers"
                                    HorizontalAlignment="Right"
                                    Style="{StaticResource A_Style_FrameworkElement_PostRace_TotalLabelBlock}">
                            <StackPanel Orientation="Horizontal"
                                        HorizontalAlignment="Right"
                                        RenderTransformOrigin="0.5,0.5"
                                        RenderTransform="{StaticResource A_Transform_Italic}">
                                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_HorizonA}"
                                                   Color="#fff"
                                                   CapHeight="50"
                                                   Text="{Binding TargetTime}" />
                                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_HorizonB}"
                                                   Visibility="{Binding TargetSplit, Converter={StaticResource A_StringVisConverter}}"
                                                   Color="#fff"
                                                   CapHeight="50"
                                                   Margin="48,0,0,0"
                                                   Text="{Binding TargetSplit}" />
                                <Decorator Width="6" />
                            </StackPanel>

                            <Decorator Height="19" />

                            <StackPanel Orientation="Horizontal"
                                        HorizontalAlignment="Right"
                                        Visibility="Collapsed">
                                <local:FZMaterial CaptureSubgraph="True"
                                                  RenderTransformOrigin="0.5,0.5"
                                                  RenderTransform="{StaticResource A_Transform_Italic}">
                                    <StackPanel Orientation="Horizontal"
                                                ClipToBounds="True">
                                        <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll}">
                                            <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_HorizonA}"
                                                               CapHeight="37"
                                                               Margin="14"
                                                               Preset="{StaticResource A_FZMaterialPreset_Cutout}"
                                                               Text="{local:Loc InGame.IDS_Reward}" />
                                        </local:FZMaterial>

                                        <Decorator Width="13" />

                                        <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll}">
                                            <StackPanel Orientation="Horizontal"
                                                        VerticalAlignment="Center"
                                                        Margin="18,0,26,0">
                                                <local:FZMaterial Width="42"
                                                                  Height="42"
                                                                  Preset="{StaticResource A_FZMaterialPreset_Cutout}"
                                                                  ImageSource="/ForzaUI;component/Textures/Anthem/Icons/CRIcon/CR_64_FilledCircle.png" />
                                                <Decorator Width="8" />
                                                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_HorizonA}"
                                                                   VerticalAlignment="Top"
                                                                   CapHeight="37"
                                                                   Preset="{StaticResource A_FZMaterialPreset_Cutout}"
                                                                   Text="{Binding CreditsRewardValue}" />
                                            </StackPanel>
                                        </local:FZMaterial>
                                    </StackPanel>
                                </local:FZMaterial>
                                <Decorator Width="35" />
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                </Decorator>
                
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PostRacePanel_Vignette}"
                                  IsHitTestVisible="False"/>
                
                <local:FZMaterial Color="#000000"
                              Opacity="0.3"
                              Height="27"
                              VerticalAlignment="Bottom" />
                <local:FZMaterial Color="#000000"
                              Opacity="0.3"
                              Height="27"
                              VerticalAlignment="Top" />
            </Grid>
        </Grid>
    </Grid>

    <Page.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <local:BeginUIStoryboard Storyboard="{StaticResource A_Storyboard_AnimateInitial}"
                                     Storyboard.TargetName="{x:Null}" />
        </EventTrigger>
    </Page.Triggers>
    <local:EventFire.FzTriggers>
        <local:BeginUIStoryboard local:EventFireTrigger.Event="RivalDataDownloaded"
                                 Storyboard="{StaticResource A_Storyboard_AnimateWithRivalInfo}" />
    </local:EventFire.FzTriggers>
    <Page.Style>
        <Style TargetType="FrameworkElement">
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsRivalAvailable}"
                                   Value="True" />
                        <Condition Binding="{Binding Downloaded, ElementName=Gamerpic}"
                                   Value="True" />
                    </MultiDataTrigger.Conditions>

                    <MultiDataTrigger.EnterActions>
                        <local:RaiseFzEvent EventName="RivalDataDownloaded" />
                    </MultiDataTrigger.EnterActions>
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>
    </Page.Style>

</Page>
