<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:ForzaUI"
    x:Class="ForzaUI.Scenes.Anthem.A_BadgeSelect"
    Style="{StaticResource A_Style_Page_Generic}"
    DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <UIPageTransitionManager.TransitionManager>
        <UIPageTransitionManager
            Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}" />
    </UIPageTransitionManager.TransitionManager>
    <Page.Resources>
        <ResourceDictionary>
            <Style x:Key="A_Style_AutoScroll_FZTextBox_BadgeDescription"
                TargetType="FZTextBlock">
                <Setter Property="Text" Value="{Binding Description}"/>
                <Setter Property="TextWrapping" Value="Wrap" />
                <Setter Property="MaxWidth" Value="264" />
                <Setter Property="MaxHeight" Value="150" />
                <Setter Property="MinHeight" Value="25" />
                <Setter Property="Stretch" Value="None" />
                <Setter Property="VerticalAlignment" Value="Stretch" />
                <Setter Property="HorizontalAlignment" Value="Stretch"/>
                <Setter Property="TextAlignment" Value="Center" />
                <Setter Property="CapHeight" Value="14" />
                <Setter Property="LineAdjust" Value="-0.25" />
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_White}" />
                <Setter Property="AutoScroll" Value="{StaticResource H_AutoScrollSettings_Descriptions}" />
                <Setter Property="AutoScroll.AllowScrolling" Value="True" />
                <Setter Property="FontFamily" Value="Horizon_B" />
            </Style>
            <Style x:Key="A_Style_ContentControl_NewBadge"
                TargetType="ContentControl"
                BasedOn="{StaticResource A_Style_MarketplaceBlammo}">
                <Style.Resources>
                    <Style x:Key="A_Style_FZTextBlock_CarSelectCarouseItem_StatusText" TargetType="{x:Type FZTextBlock}"
                           BasedOn="{StaticResource H_Style_Text_StateBox_Text}">
                        <Setter Property="FontFamily" Value="Horizon_A"/>
                    </Style>
                </Style.Resources>
                <Setter
                    Property="Visibility"
                    Value="Collapsed" />
                <Style.Triggers>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition
                                Binding="{Binding State}"
                                Value="{x:Static local:BadgeItemState.Unlocked}" />
                            <Condition
                                Binding="{Binding IsNew}"
                                Value="True" />
                        </MultiDataTrigger.Conditions>
                        <Setter
                            Property="Visibility"
                            Value="Visible" />
                    </MultiDataTrigger>
                </Style.Triggers>
            </Style>

            <local:MappingConverter x:Key="A_Converter_BadgeStateToBadgeColor" Default="{StaticResource H_Color_Primary_White}">
                <local:MappingConverterEntry Key="{x:Static local:BadgeItemState.Locked}" Value="#40FFFFFF"/>
            </local:MappingConverter>

            <local:MappingConverter x:Key="A_Converter_BadgeStateToAdornmentVisibility" Default="{x:Static Visibility.Visible}">
                <local:MappingConverterEntry Key="{x:Static local:BadgeItemState.Unlocked}" Value="{x:Static Visibility.Collapsed}"/>
            </local:MappingConverter>

            <Style x:Key="A_Style_FZMaterial_BadgeStateIcon" TargetType="FZMaterial">
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_White}"/>
                <Setter Property="Visibility" Value="{Binding State, Converter={StaticResource A_Converter_BadgeStateToAdornmentVisibility}}"/>
                <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/Icons/Locked_Icon.png"/>
                <Setter Property="Width" Value="19.5"/>
                <Setter Property="Height" Value="24"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding State}" Value="{x:Static local:BadgeItemState.Active}">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/Icons/Equipped_Icon.png"/>
                        <Setter Property="Width" Value="26"/>
                        <Setter Property="Height" Value="26"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            <DataTemplate x:Key="H_Template_BadgeItem">
                <Grid Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Width}"
                      Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Height}">
                    <FZMaterial Width="102"
                                Height="85"
                                HorizontalAlignment="Center"
                                VerticalAlignment ="Center"
                                Color="{Binding State, Converter={StaticResource A_Converter_BadgeStateToBadgeColor}}"
                                ImageSource="{Binding Texture}"
                                Visibility="{Binding Downloaded, RelativeSource={RelativeSource Self}, Converter={FZBooleanToVisibilityConverter UseHidden=True}}"/>

                    <FZMaterial Style="{StaticResource A_Style_FZMaterial_BadgeStateIcon}"
                                HorizontalAlignment="Right"
                                VerticalAlignment ="Bottom"
                                Margin="0,0,10,10"/>
                    <ContentControl
                                Style="{StaticResource A_Style_ContentControl_NewBadge}"
                                Margin="10,10,0,0"
                                Tag="{x:Static local:MarketplaceBlammoType.New}"
                                x:Name="New_Box"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Top"/>
                </Grid>   
            </DataTemplate>

            <Style TargetType="ContentControl"
                   x:Key="H_Style_ContentControl_Carousel_BadgeContainerStyle"
                   BasedOn="{StaticResource H_Style_ContentControl_Carousel_ContainerStyle}">
                <Setter Property="Margin" Value="0,0,4,4"/>
            </Style>

            <Style TargetType="WrapListBox"
               x:Key="H_Style_BadgeCarousel"
               BasedOn="{StaticResource {Type WrapListBox}}">
                <Setter Property="OverrideAcrossNavigation"
                        Value="True" />
                <Setter Property="Template"
                        Value="{StaticResource H_ControlTemplate_Carousel_Default}" />
                <Setter Property="ItemContainerStyle"
                        Value="{StaticResource H_Style_ContentControl_Carousel_BadgeContainerStyle}" />
                <Setter Property="ItemTemplate"
                        Value="{StaticResource H_Template_BadgeItem}" />
                <Setter Property="DynamicData.Data">
                    <Setter.Value>
                        <DynamicDataSource>
                            <DynamicDataItem Name="ItemBackgroundStyle"
                                             DataType="Style">
                                <DynamicDataItem.Value>
                                    <Style TargetType="{Type FZMaterial}">
                                        <Setter Property="Preset" Value="{GlassRoundtangle BlurAmount=Low, CornerRadius=8}"/>
                                        <Setter Property="Color" Value="{StaticResource H_Color_Glass_Purple_40pc}"/>
                                    </Style>
                                </DynamicDataItem.Value>
                            </DynamicDataItem>
                        </DynamicDataSource>
                    </Setter.Value>
                </Setter>
                <Setter Property="ScrollOrientation"
                        Value="Vertical" />
                <Setter Property="Height"
                        Value="656" />
                <Setter Property="Width"
                        Value="1312" />
                <Setter Property="ItemWidth"
                        Value="164" />
                <Setter Property="ItemHeight"
                        Value="164" />
                <Setter Property="SelectionLimitTop"
                    Value="0" />
                <Setter Property="SelectionLimitBottom"
                    Value="164" />
                <Setter Property="EmptyItemStyle"
                        Value="{StaticResource H_Style_Control_Carousel_EmptyItemStyle}" />
            </Style>

            <Style TargetType="local:FZTextBlock"
               x:Key="A_Style_FZTextBlock_BadgeChallengeProgress"
               BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}">
                <Setter Property="CapHeight" Value="28" />
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_White}" />
                <Setter Property="Visibility" Value="Collapsed" />
                <Style.Triggers>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding Progress, Converter={StaticResource A_StringVisConverter}}" Value="{x:Static Visibility.Visible}"/>
                            <Condition Binding="{Binding ShowProgress, Converter={StaticResource A_Converter_BoolToVis}}" Value="{x:Static Visibility.Visible}"/>
                        </MultiDataTrigger.Conditions>
                        <Setter Property="Visibility" Value="Visible"/>
                    </MultiDataTrigger>
                </Style.Triggers>
            </Style>

            <Style TargetType="{x:Type local:FZRun}" x:Key="A_Style_FZRun_BadgeChallengeProgress_HIGHLIGHT">
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_Green}"/>
            </Style>

            <MappingConverter x:Key="A_MappingConverter_BadgeCallengeProgress" >
                <MappingConverterEntry Key="{NoCase HIGHLIGHT}" Value="{StaticResource A_Style_FZRun_BadgeChallengeProgress_HIGHLIGHT}"/>
            </MappingConverter>

            <AutoScrollSettings x:Key="A_AutoScrollSettings_BadgeTitle"
                    ScrollSeparation="50"
                    InitialPause="0:0:0.5"
                    Speed="40"
                    ScrollOrientation="Horizontal"
                    ApplyClip="True"/>
                    
            <Style x:Key="A_Style_ContentControl_BadgeName" TargetType="ContentControl" BasedOn="{StaticResource A_Style_ContentControl_Header}">
                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ContentControl">
                            <ContentControl Style="{StaticResource A_Style_ContentControl_Header_Custom}"
                                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                            MinWidth="{TemplateBinding MinWidth}">
                                <FZTextBlock Style="{StaticResource H_Style_Text_DescriptionTitle}"
                                             Margin="10,2,0,0"
                                             Text="{TemplateBinding Content}"
                                             AutoScroll="{StaticResource A_AutoScrollSettings_BadgeTitle}"
                                             AutoScroll.AllowScrolling="True"/>
                            </ContentControl>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </Page.Resources>
    <Grid>
        <Control
            Style="{StaticResource A_Style_Control_ScreenBackground}" />
        <PlayerBarControl
            x:Name="TopBar"
            Style="{StaticResource A_Style_PlayerBarControl}"/>
        <ContentControl
            x:Name="BottomBar"
            Style="{StaticResource A_Style_ButtonBar}">
            <ContentControl
                x:Name="PART_DefaultHelpPanel"
                Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
        </ContentControl>
        <Border
            Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}"
            Padding="160,163,160,0"
            SnapsToDevicePixels="True"
            UseLayoutRounding="True">
            <StackPanel Orientation="Vertical" Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                <Decorator
                    VerticalAlignment="Top">
                    <ContentControl
                        Content="{Loc ScreenTitles.IDS_Badges}"
                        Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                        HorizontalAlignment="Left"
                        MinWidth="284"
                        x:Name="Screen_Title" />
                </Decorator>
                <Decorator
                    Focusable="False"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Top">
                    <FZTabButtonsSelector
                        ItemsSource="{Binding BadgeCategories}"
                        SelectedIndex="0"
                        Style="{StaticResource H_Style_TabBar}"
                        x:Name="PART_Categories"
                        Margin="0,0,0,10" />
                </Decorator>
                <StackPanel Orientation="Horizontal">
                    <Grid Width="284"
                        Height="652"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        DataContext="{Binding SelectedItem}">
                        <StackPanel>
                            <ContentControl Content="{Binding Title}" Style="{StaticResource A_Style_ContentControl_BadgeName}" />
                            <FZMaterial Preset="{GlassRoundtangle BlurAmount=Low, CornerRadius={StaticResource H_CornerRadius_All_2px}}"
                                        Color="{StaticResource H_Color_Glass_Purple_40pc}"
                                        Height="540"
                                        Margin="0,4,0,0">
                                <StackPanel Height="232"
                                            VerticalAlignment="Top"
                                            Margin="4,210,4,0"
                                            MaxWidth="284">
                                    <FZTextBlock CapHeight="18"
                                                 Color="{StaticResource H_Color_Primary_White}"
                                                 HorizontalAlignment="Center"
                                                 Margin="22,40,22,26">
                                        <FZTextBlock.Style>
                                            <Style TargetType="FZTextBlock"
                                                   BasedOn="{StaticResource A_Style_FZTextBlock_HorizonC}">
                                                <Setter Property="Text" Value="{Loc Campaign.IDS_Badges_Objective}"/>
                                            </Style>
                                        </FZTextBlock.Style>
                                    </FZTextBlock>
                                    <FZTextBlock Style="{StaticResource A_Style_AutoScroll_FZTextBox_BadgeDescription}" />
                                    <StackPanel Orientation="Vertical"
                                                MaxWidth="284"
                                                Margin="0,4,0,0">
                                        <StackPanel Orientation="Vertical">
                                            <FZMaterial Color="#55ffffff"
                                                        Margin="0,12,0,8"
                                                        Height="2"
                                                        Width="220"
                                                        HorizontalAlignment="Center"
                                                        VerticalAlignment="Center"/>
                                            <FZTextBlock Text="{Binding Progress}"
                                                         MaxWidth="264"
                                                         HorizontalAlignment="Center"
                                                         MarkupConverter="{StaticResource A_MappingConverter_BadgeCallengeProgress}"
                                                         Margin="0,12,0,0"
                                                         Style="{StaticResource A_Style_FZTextBlock_BadgeChallengeProgress}"/>
                                        </StackPanel>
                                    </StackPanel>
                                </StackPanel>
                            </FZMaterial>
                        </StackPanel>
                        <FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/Badges/Circle_Badge_Frame.png"
                                    Width="200"
                                    Height="200"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Top"
                                    Margin="0,87,0,0">
                            <FZMaterial HorizontalAlignment="Center"
                                        VerticalAlignment="Center"
                                        Width="102"
                                        Height="85"
                                        ImageSource="{Binding Texture}"
                                        Visibility="{Binding Downloaded, RelativeSource={RelativeSource Self}, Converter={FZBooleanToVisibilityConverter UseHidden=True}}"/>
                        </FZMaterial>
                        <Control VerticalAlignment="Bottom">
                            <Control.Template>
                                <ControlTemplate>
                                    <Grid VerticalAlignment="Bottom"
                                          HorizontalAlignment="Center"
                                          Height="210"
                                          Width="284">
                                        <FZMaterial Width="284"
                                                    Height="124"
                                                    Margin="0,0,0,54"
                                                    VerticalAlignment="Bottom"
                                                    ImageSource="/ForzaUI;component/Textures/Data_Bound/Badges/Badge_Pattern.png"/>
                                        <Grid Height="50"
                                                VerticalAlignment="Bottom">
                                            <FZMaterial Preset="{Roundtangle CornerRadius={StaticResource H_CornerRadius_All_2px}}"
                                                        Color="{StaticResource H_Color_Primary_Black}">
                                            </FZMaterial>
                                            <DockPanel Margin="12,4,10,4">
                                                <StackPanel DockPanel.Dock="Right"
                                                            Orientation="Horizontal"
                                                            VerticalAlignment="Center"
                                                            HorizontalAlignment="Right">
                                                    <FZTextBlock CapHeight="18"
                                                                    Text="{Binding Value, Converter={NumUnitConverter FractionDigits=0}}"
                                                                    VerticalAlignment="Center"
                                                                    HorizontalAlignment="Left"
                                                                    FontFamily="Horizon_C"
                                                                    Color="{StaticResource H_Color_Primary_White}"/>
                                                    <FZMaterial Style ="{StaticResource A_Style_FZMaterial_BadgeStateIcon}"
                                                                HorizontalAlignment="Right"
                                                                VerticalAlignment ="Center"/>
                                                </StackPanel>
                                                <StackPanel DockPanel.Dock="Left"
                                                            Orientation="Horizontal"
                                                            VerticalAlignment="Center"
                                                            HorizontalAlignment="Left">
                                                    <FZTextBlock VerticalAlignment="Center"
                                                                    HorizontalAlignment="Left"
                                                                    MaxWidth="150"
                                                                    CapHeight="18"
                                                                    FontFamily="Horizon_C"
                                                                    Color="{StaticResource H_Color_Primary_White}">
                                                        <FZTextBlock.Style>
                                                            <Style TargetType="FZTextBlock">
                                                                <Style.Triggers>
                                                                    <DataTrigger Binding="{Binding State}" Value="{x:Static local:BadgeItemState.Locked}">
                                                                        <Setter Property="Text" Value="{Loc Campaign.IDS_Badges_Locked}" />
                                                                    </DataTrigger>
                                                                    <DataTrigger Binding="{Binding State}" Value="{x:Static local:BadgeItemState.Unlocked}">
                                                                        <Setter Property="Text" Value="{Binding UnlockTimeStamp}" />
                                                                    </DataTrigger>
                                                                    <DataTrigger Binding="{Binding State}" Value="{x:Static local:BadgeItemState.Active}">
                                                                        <Setter Property="Text" Value="{Loc Campaign.IDS_Badges_Equipped}" />
                                                                    </DataTrigger>
                                                                </Style.Triggers>
                                                            </Style>
                                                        </FZTextBlock.Style>
                                                    </FZTextBlock>
                                                </StackPanel>
                                            </DockPanel>
                                        </Grid>
                                    </Grid>
                                </ControlTemplate>
                            </Control.Template>
                        </Control>
                    </Grid>
                    <Decorator Width="9"
                               HorizontalAlignment="Right" />
                    <local:WrapListBox Style="{StaticResource H_Style_BadgeCarousel}"
                                        ItemsSource="{Binding SelectedItem.Items, ElementName=PART_Categories}"
                                        FocusOnPageFocusGained.SelectorSelectedItem="True"
                                        SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                                        Focusable="False"
                                        x:Name="PART_Menu" />
                    <ScrollBar Style="{StaticResource A_Style_ScrollBar_Default}"
                            Height="auto"
                            Orientation="Vertical"
                            Minimum="{Binding ScrollWindowMin, ElementName=PART_Menu}"
                            Maximum="{Binding ScrollWindowMax, ElementName=PART_Menu}"
                            Value="{Binding ScrollWindowValue, ElementName=PART_Menu, Mode=TwoWay}"
                            ViewportSize="{Binding ScrollWindowSize, ElementName=PART_Menu}"
                            Margin="4,0,0,4" />
                </StackPanel>
            </StackPanel>
        </Border>
    </Grid>
</Page>