<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"
      x:Class="ForzaUI.A_CampaignSetupRoot"
      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"/>

        <Style x:Key="A_Style_FZMaterial_RouteSelectContainer"
               TargetType="{x:Type local:FZMaterial}">
            <Setter Property="Preset" Value="{StaticResource H_Roundtangle_Outer_1px}"/>
            <Setter Property="CaptureSubgraph" Value="True"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding (local:TileMenuNavigationManager.LockState), ElementName=PART_Button_CustomRouteSelect, Converter={StaticResource A_Converter_LockStateToBoolean}}" Value="True">
                    <Setter Property="Preset" Value="{StaticResource H_Roundtangle_Outer_1pxDesaturated}"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <MappingConverter x:Key="A_LangStrToComingSoonTextWrapping" Default="Wrap">
            <MappingConverterEntry Key="HU" Value="NoWrap"/>
        </MappingConverter>

        <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="Wrap"/>
            <Setter Property="Margin" Value="{Binding LangStr, Source={StaticResource PART_UISceneContext}, Converter={StaticResource A_LangStrToTextBlockDescriptionMargin}}"/>
            <Setter Property="AutoScroll" Value="{StaticResource H_AutoScrollSettings_Descriptions}"/>
        </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>
        <local:NetworkCountdownControl Style="{StaticResource A_Style_NetworkCountdownControl_EventSetup}" />

        <Grid x:Name="PART_LayoutRoot">
            <Border Style="{StaticResource A_Style_Border_ScenePadding_Opus}"
                    Padding="161,0,153,0">
                <Grid>
                    <StackPanel VerticalAlignment="Bottom"
                                Margin="0,0,0,180"
                                Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}" >
                        <ContentControl Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                        Content="{local:Loc ScreenTitles.IDS_CampaignSetupRoot}"
                                        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}"
                                                   ItemsSource="{Binding Items, RelativeSource={RelativeSource AncestorType=Page}}"
                                                   SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                                                   DockPanel.Dock="Top" />
                                    <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>
                            <Decorator Width="8"/>
                            <Viewbox Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}" 
                                     Width="480" Height="708">
                                <Control x:Name="PART_Flyer"
                                         DataContext="{Binding CampaignSetup}"
                                         Style="{StaticResource A_Style_Control_CampaignFlyer}"/>
                            </Viewbox>
                            <Decorator Width="8"/>
                            <DockPanel Height="708"
                                       Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                                <ContentControl DockPanel.Dock="Top" Style="{StaticResource A_Style_ContentControl_Header}" 
                                                Content="{Loc EventBlueprint.IDS_RoutePreview}"
                                                Width="364"/>
                                <Grid DockPanel.Dock="Top"
                                      Height="356">
                                    <local:MapViewControllerWindowed x:Name="CampaignSetupRootMapMapView"
                                                                     DataContext="{Binding RouteMap, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Page}}}"
                                                                     Style="{StaticResource A_Style_MapViewController_UIMap}" />
                                    <local:FZMaterial Preset="{StaticResource H_Roundtangle_Outer_1px}" Color="#ff0A0E1A"/>
                                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_RouteSelectContainer}">
                                        <local:MapCustomRenderElement MapId="default" Style="{StaticResource A_Style_MapCustomRenderElement_UIMap}"
                                                                        DataContext="{Binding RouteMap, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Page}}}"
                                                                        ClipToBounds="True"
                                                                        MapView="{Binding ElementName=CampaignSetupRootMapMapView}"
                                                                        x:Name="mapCustomRenderElement" />
                                    </local:FZMaterial>
                                </Grid>
                                <ContentControl DockPanel.Dock="Top" Style="{StaticResource A_Style_ContentControl_Header}" 
                                                Content="{Loc EventBlueprint.IDS_Description}"
                                                Width="364"
                                                Margin="0,4,0,0"/>
                                <Decorator>
                                    <Grid Width="364">
                                        <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 CampaignSetup.Description}" />
                                        </Decorator>
                                    </Grid>
                                </Decorator>
                            </DockPanel>
                        </StackPanel>
                    </StackPanel>
                </Grid>
            </Border>
        </Grid>
    </Grid>
</Page>