<Page xmlns:local="clr-namespace:ForzaUI;assembly="
      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_BucketListBlueprintShareOptions"
      mc:Ignorable="d"
      DataContext="{Binding RelativeSource={RelativeSource Self}}"
      Style="{StaticResource A_Style_Page_Generic}"
      x:Name="Page">

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

    <Page.Resources>
        <local:MappingConverter x:Key="A_Converter_LockStateToBoolean" Default="False" CheckEnumKey="LockState">
            <local:MappingConverterEntry Key="{x:Static local:LockState.Locked}" Value="True"/>
            <local:MappingConverterEntry Key="{x:Static local:LockState.Unlocked}" Value="False"/>
        </local:MappingConverter>

        <local:FZMaterialPresetRoundtangle x:Key="H_Roundtangle_Outer_1pxDesaturated"
                                           BasedOn="{StaticResource H_Roundtangle_Outer_1px}"
                                           Saturation="0"/>

        <MappingConverter x:Key="A_LangStrToTextBlockDescriptionMargin" Default="0,5,0,0">
            <MappingConverterEntry Key="CZ" Value="0,6,0,0"/>
            <MappingConverterEntry Key="DEV" Value="0"/>
            <MappingConverterEntry Key="EN" Value="0"/>
            <MappingConverterEntry Key="GB" Value="0"/>
        </MappingConverter>

        <!-- This margin offsets the margin from A_LangStrToTextBlockDescriptionMargin so that the initial Y position of the text inside the box is consistent across languages -->
        <MappingConverter x:Key="A_LangStrToAutoScrollDescriptionMargin" Default="23,18,23,23">
            <MappingConverterEntry Key="CZ" Value="23,17,23,23"/>
            <MappingConverterEntry Key="DEV" Value="23"/>
            <MappingConverterEntry Key="EN" Value="23"/>
            <MappingConverterEntry Key="GB" Value="23"/>
        </MappingConverter>

        <Style x:Key="A_Style_ListBoxItem_DescriptionPanel_Text" 
               TargetType="{x:Type local:FZTextBlock}"
               BasedOn="{StaticResource H_Style_Text_Description_Body_16px_Scrolling}">
            <Setter Property="CapHeight" Value="14"/>
            <Setter Property="TextAlignment" Value="Left"/>
            <Setter Property="ClipToBounds" Value="True"/>
            <Setter Property="VerticalAlignment" Value="Stretch"/>
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="TextWrapping" Value="WrapWithOverflow"/>
            <Setter Property="Margin" Value="{Binding LangStr, Source={StaticResource PART_UISceneContext}, Converter={StaticResource A_LangStrToTextBlockDescriptionMargin}}"/>
            <Setter Property="AutoScroll" Value="{StaticResource H_AutoScrollSettings_Descriptions}"/>
        </Style>

        <!-- Custom Flyer implementation: Needed to bypass A_ControlTemplate_Control_BucketListFlyer_Internal Selector.IsSelected creating a duplicated boarder-->
        <ControlTemplate x:Key="A_ControlTemplate_Control_ShareOptions_BucketListFlyer" TargetType="Control">
            <Grid >
                <Grid x:Name="FrontFace">
                    <local:FZMaterial Margin="-5" Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll3px}"
                                    Color="{Binding Path=(Selector.IsSelected), RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem},Converter={StaticResource A_MappingConverter_SelectedBorderColor}}"/>
                    <ContentControl Style="{StaticResource A_Style_Control_BucketListFlyer_Front}" />
                </Grid>
            </Grid>
        </ControlTemplate>

        <!-- Custom ListBoxItem and ListBox to enforce correct spacing of buttons-->
        <Style x:Key="A_Style_ListBoxItem_ShareOptions_Button"
               TargetType="ListBoxItem"
               BasedOn="{StaticResource A_Style_ListBoxItem_Creation_Button}">
            <Setter Property="Width" Value="512" />
            <Setter Property="Height" Value="50" />
        </Style>
    </Page.Resources>

    <Grid>
        <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />

        <!-- Bars -->
        <local: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}"
                            local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_Select}"
                            local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"/>
        </ContentControl>

        <Grid x:Name="PART_LayoutRoot">
            <Border Style="{StaticResource A_Style_Border_ScenePadding_Opus}"
                    Padding="150,0,153,0">
                <Grid>
                    <StackPanel HorizontalAlignment="Left"
                                VerticalAlignment="Center"
                                Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}" >
                        <ContentControl Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                        Content="{local:Loc ScreenTitles.IDS_BucketListBlueprintShareOptions}"
                                        HorizontalAlignment="Left"/>
                        <StackPanel Orientation="Horizontal">
                            <Decorator x:Name="PART_MenuContent"
                                       Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                                <DockPanel>
                                    <CommonListBox Style="{StaticResource A_Style_Carousel_Creation_ButtonList}"
                                                   ItemContainerStyle="{StaticResource A_Style_ListBoxItem_ShareOptions_Button}"
                                                   ItemsSource="{Binding Items, RelativeSource={RelativeSource AncestorType=Page}}"
                                                   SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                                                   DockPanel.Dock="Top"
                                                   Panel.ZIndex="1"/>

                                    <Grid DockPanel.Dock="Bottom" Width="{StaticResource A_Double_CreationButton_ListItem_Width}">
                                        <local:FZMaterial Preset="{StaticResource H_GlassRoundtangle_1px}" Color="{StaticResource H_Color_Glass_Purple_20pc}" />
                                        <Decorator Margin="{Binding LangStr, Source={StaticResource PART_UISceneContext}, Converter={StaticResource  A_LangStrToAutoScrollDescriptionMargin}}">
                                            <FZTextBlock Style="{StaticResource A_Style_ListBoxItem_DescriptionPanel_Text}"
                                                         Text="{Binding SelectedItem.Description}" />
                                        </Decorator>
                                    </Grid>
                                </DockPanel>
                            </Decorator>

                            <Grid Margin="4,0,0,0"  Panel.ZIndex="-1">
                                <Viewbox Margin="5,5,5,5" Stretch="Uniform" StretchDirection="DownOnly">
                                    <Control Template="{StaticResource A_ControlTemplate_Control_ShareOptions_BucketListFlyer}" 
                                             DataContext="{Binding BucketListSetup}"
                                             FontSize="{StaticResource A_Double_FlyerRotation_FrontFaceShowing}"/>
                                </Viewbox>
                            </Grid>
                        </StackPanel>
                    </StackPanel>
                </Grid>
            </Border>
        </Grid>
    </Grid>
</Page>
