<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      x:Class="ForzaUI.Scenes.Anthem.A_PopupCarAction"
      xmlns:local="clr-namespace:ForzaUI;assembly="
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <UIPageTransitionManager.TransitionManager>
        <UIPageTransitionManager
            Preset="{StaticResource A_UIPageTransitionManagerPreset_Popup}" />
    </UIPageTransitionManager.TransitionManager>
    <Page.Resources>
        <ResourceDictionary>
            <Style
                x:Key="A_Style_FZTextBlock_MessageBox_Text"
                BasedOn="{StaticResource A_Style_FZTextBlock_PopupText}"
                TargetType="local:FZTextBlock">
                <Setter
                    Property="Width"
                    Value="Auto" />
                <Setter
                    Property="Margin"
                    Value="0,0,0,12" />
                <Style.Triggers>
                    <Trigger
                        Property="Text"
                        Value="{Null}">
                        <Setter
                            Property="Visibility"
                            Value="Collapsed" />
                    </Trigger>
                    <Trigger
                        Property="Text"
                        Value="">
                        <Setter
                            Property="Visibility"
                            Value="Collapsed" />
                    </Trigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_ContentControl_MessageBoxPopupContentBlock"
                   TargetType="ContentControl"
                   BasedOn="{StaticResource A_Style_ContentControl_PopupContentBlock}">
                <Style.Triggers>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding HasImage}" Value="False" />
                            <Condition Binding="{Binding HasMessage}" Value="False" />
                        </MultiDataTrigger.Conditions>
                        <MultiDataTrigger.Setters>
                            <Setter Property="Visibility" Value="Collapsed" />
                        </MultiDataTrigger.Setters>
                    </MultiDataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZMaterial_Image"
                   TargetType="FZMaterial">
                <Setter Property="Height" Value="240" />
                <Setter Property="Width" Value="240" />
                <Setter Property="Margin" Value="{Binding ImageMargin}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsCarThumbnail}" Value="True">
                        <Setter Property="Height" Value="300" />
                        <Setter Property="Width" Value="534" />
                        <Setter Property="Margin" Value="0,-40,0,0" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style
                x:Key="A_Style_ListBoxItem_TextMenu_Default_MessageBox"
                BasedOn="{StaticResource A_Style_ListBoxItem_TextMenu_Default}"
                TargetType="{Type ListBoxItem}">
                <Setter
                    Property="Template">
                    <Setter.Value>
                        <ControlTemplate
                            TargetType="ListBoxItem">
                            <ControlTemplate.Resources>
                                <ResourceDictionary>
                                    <Style
                                        x:Key="A_Style_RoutedEventCommand_MouseLeftButtonUp"
                                        TargetType="local:RoutedEventCommand">
                                        <Setter
                                            Property="Command"
                                            Value="{Binding ItemFuncCommand}" />
                                        <Style.Triggers>
                                            <DataTrigger
                                                Binding="{Binding ItemFuncCommand}"
                                                Value="{Null}">
                                                <Setter
                                                    Property="Command"
                                                    Value="{Binding SelectCommand, RelativeSource={RelativeSource AncestorType={Type Page}}}" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                    <Style
                                        x:Key="H_Style_Selected_Shadow_MessageBox"
                                        BasedOn="{StaticResource H_Style_Selected_Shadow}"
                                        TargetType="{Type FZMaterial}">
                                        <Setter Property="Color" Value="#66000000" />
                                    </Style>
                                </ResourceDictionary>
                            </ControlTemplate.Resources>
                            <Grid>
                                <FZMaterial x:Name="SelectedShadow"
                                            Style="{StaticResource H_Style_Selected_Shadow_MessageBox}" />
                                <Grid
                                    x:Name="Background"
                                    RenderTransformOrigin="0.5,0.5">
                                    <Grid.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform />
                                            <SkewTransform />
                                            <RotateTransform />
                                            <TranslateTransform />
                                        </TransformGroup>
                                    </Grid.RenderTransform>
                                    <RoutedEventCommand
                                        x:Name="MouseLeftButtonUpCommand"
                                        RoutedEvent="UIElement.MouseLeftButtonUp"
                                        Style="{StaticResource A_Style_RoutedEventCommand_MouseLeftButtonUp}" />
                                    <FZMaterial
                                        x:Name="BackgroundMaterial"
                                        RoutedEventCommand.Action="{Binding ElementName=MouseLeftButtonUpCommand}"
                                        Style="{StaticResource A_Style_FZMaterial_FlatPanel_Tile}"
                                        Preset="{StaticResource H_Roundtangle_Outer_2px}"
                                        Color="{StaticResource H_Color_Primary_White}" />
                                    <ContentPresenter
                                        Focusable="{Binding Focusable, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                                        x:Name="Presenter"
                                        PropertySetter.Value="{Binding IsKeyboardFocused, RelativeSource={RelativeSource Self}}"
                                        PropertySetter.Property="Content.(FocusSelf.WhenTrue)"/>
                                    <StrokeHighlightControl Style="{StaticResource H_Style_StrokeHighlight_Instant}"
                                                            ContentRadius="2"
    		                                                InnerThickness="4"
                                                            IsEnabled="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource TemplatedParent}}"/>
                                </Grid>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger
                                    Property="IsKeyboardFocused"
                                    Value="True">
                                    <Setter
                                        TargetName="Presenter"
                                        Property="FocusSelf.WhenTrue"
                                        Value="True" />
                                </Trigger>
                                <Trigger
                                    Property="Tag"
                                    Value="GroupHeader">
                                    <Setter
                                        Property="Visibility"
                                        TargetName="BackgroundMaterial"
                                        Value="Collapsed" />
                                </Trigger>
                                <Trigger
                                    Property="Tag"
                                    Value="Inactive">
                                    <Setter
                                        TargetName="BackgroundMaterial"
                                        Property="Preset"
                                        Value="{StaticResource H_GlassRoundtangle_1px}" />
                                    <Setter
                                        TargetName="BackgroundMaterial"
                                        Property="Color"
                                        Value="{StaticResource H_Color_Glass_Purple_20pc}" />
                                </Trigger>
                                <Trigger
                                    Property="IsEnabled"
                                    Value="False">
                                    <Setter
                                        TargetName="BackgroundMaterial"
                                        Property="Preset"
                                        Value="{StaticResource H_GlassRoundtangle_1px}" />
                                    <Setter
                                        TargetName="BackgroundMaterial"
                                        Property="Color"
                                        Value="{StaticResource H_Color_Glass_Purple_20pc}" />
                                </Trigger>
                                <Trigger
                                    Property="IsSelected"
                                    Value="True">
                                    <Trigger.EnterActions>
                                        <BeginStoryboard
                                            x:Name="ShowSelected_BeginStoryboard1"
                                            Storyboard="{StaticResource A_StoryBoard_TextMenu_Focus}" />
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard
                                            x:Name="ShowSelected_BeginStoryboard2"
                                            Storyboard="{StaticResource A_StoryBoard_TextMenu_Blur}" />
                                    </Trigger.ExitActions>
                                    <Setter
                                        Property="Color"
                                        TargetName="BackgroundMaterial"
                                        Value="{StaticResource H_Color_HighlightedItemBg}" />
                                    <Setter
                                        Property="Opacity"
                                        TargetName="SelectedShadow"
                                        Value="1"/>
                                </Trigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition
                                            Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource Self}}"
                                            Value="True" />
                                        <Condition
                                            Binding="{Binding (ItemContainerGenerator.ItemForItemContainer), RelativeSource={RelativeSource Self}, Converter={StaticResource A_Converter_IsNotNull}}"
                                            Value="True" />
                                    </MultiDataTrigger.Conditions>
                                    <Setter
                                        Property="IsSelected"
                                        Value="True" />
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition
                                            Binding="{Binding Focusable, RelativeSource={RelativeSource Self}}"
                                            Value="False" />
                                        <Condition
                                            Binding="{Binding Tag, RelativeSource={RelativeSource Self}}"
                                            Value="{Null}" />
                                    </MultiDataTrigger.Conditions>
                                    <Setter
                                        TargetName="BackgroundMaterial"
                                        Property="Visibility"
                                        Value="Collapsed" />
                                </MultiDataTrigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_AutoScroll_Message"
                BasedOn="{StaticResource H_Style_Text_Description_Body_16px_Scrolling}"
                TargetType="FZTextBlock">
                <Setter Property="MaxHeight" Value="500" />
                <Setter Property="AutoScroll.AllowScrolling" Value="True" />
                <Setter Property="AutoScroll" Value="{StaticResource H_AutoScrollSettings_Descriptions}" />
            </Style>

            <Style x:Key="A_Style_PopupCarAction_ListBoxItem"
                   BasedOn="{StaticResource A_Style_ListBoxItem_TextMenu_Default_MessageBox}"
                           TargetType="ListBoxItem">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsEnabled}" Value="False">
                        <Setter Property="Tag" Value="Inactive"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <DataTemplate x:Key="A_DataTemplate_ListItem_CarActionItem">
                <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                      MinHeight="50">
                    <local:FZMaterial x:Name="DropShadow" Opacity="0.6" Visibility="Hidden" Margin="-25,-15"
                          Style="{StaticResource A_Style_FZMaterial_ShadowBase_ForSubgraph}">
                    </local:FZMaterial>
                    <local:FZTextBlock x:Name="SlotText"
                               Text="{Binding Text}"
                               Style="{StaticResource A_Style_FZTextBlock_OptionText}"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center"
                               TextWrapping="Wrap"
                               FontFamily="Horizon_A"
                               TextAlignment="Center"
                               CapHeight="18"
                               Margin="19,0,0,0"
                               IsHitTestVisible="False"
                               local:ScreenReader.Event="OnChange"
                               local:ScreenReader.ControlType="Button"
                               local:ScreenReader.LineType="SelectedItem"
                               local:ScreenReader.SelectedNumber="{Binding (VirtualizingWrapPanel.ItemIndex), RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Converter={StaticResource A_IndexToNumberConverter}, FallbackValue=0}"
                               local:ScreenReader.SelectedCount="{Binding Items.Count, RelativeSource={RelativeSource AncestorType={x:Type Selector}}}"/>
                    <local:FZMaterial x:Name="PadLock" Width="39" Height="30" Visibility="Collapsed"
                          ImageSource="/ForzaUI;component/Textures/Anthem/Icons/TiledMenus/SlotMenu/Locked.png"
                          HorizontalAlignment="Right"
                          Opacity="0.6"
                          VerticalAlignment="Center"
                          Color="{StaticResource H_Color_Primary_White}"
                          local:ScreenReader.Event="OnChange"
                          local:ScreenReader.ControlType="None"
                          local:ScreenReader.LineType="SelectedValue"/>
                    <StrokeHighlightControl Style="{StaticResource A_Style_ContentControl_TileSelectionStroke}" Focusable="False"/>
                </Grid>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="True">
                        <Setter TargetName="SlotText" Property="local:ScreenReader.Line" Value="{Binding Text, ElementName=SlotText}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding IsEnabled}" Value="False">
                        <Setter TargetName="PadLock" Property="local:ScreenReader.Line" Value="{local:Loc Main.IDS_ItemLocked_ScreenReader}"/>
                        <Setter TargetName="PadLock" Property="Visibility" Value="Visible"/>
                        <Setter TargetName="SlotText" Property="Opacity" Value="0.6"/>
                        <Setter TargetName="SlotText" Property="Color" Value="{StaticResource A_Color_White}"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsKeyboardFocused}" Value="True">
                        <Setter TargetName="DropShadow" Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <Style TargetType="local:FZTextBlock"
                   x:Key="A_Style_FZTextBlock_CarActions_CarDetail">
                <Setter Property="HorizontalAlignment" Value="Center" />
                <Setter Property="LineAdjust" Value="-0.35" />
                <Setter Property="VerticalAlignment" Value="Top" />
                <Setter Property="StretchDirection" Value="DownOnly" />
                <Setter Property="CapHeight" Value="25" />
                <Setter Property="Color" Value="{StaticResource A_Color_AuctionHouse_PillDetailText}" />
                <Setter Property="TextAlignment" Value="Left" />
                <Setter Property="TextTrimming" Value="None" />
                <Setter Property="ClipToBounds" Value="False"/>
                <Setter Property="Stretch" Value="None"/>
                <Setter Property="AutoScroll" Value="{StaticResource A_AutoScrollSettings_CarName}"/>
                <Setter Property="AutoScroll.AllowScrolling" Value="True"/>
            </Style>

            <Style x:Key="A_Style_Control_CarActions_Owned"
               TargetType="{x:Type Control}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_InnerInnerAll}"
                                          Color="{StaticResource H_Color_Primary_Black}"
                                          Visibility="{Binding IsOwned, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                          HorizontalAlignment="Left"
                                          VerticalAlignment="Top">
                                <local:FZMaterial Color="{StaticResource A_Color_AuctionHouse_BidNow_Light}"
                                              Margin="2">
                                    <local:FZTextBlock CapHeight="18"
                                                   Margin="15,7"
                                                   Color="{StaticResource H_Color_Primary_Black}"
                                                   HorizontalAlignment="Center"
                                                   VerticalAlignment="Center"
                                                   Text="{local:Loc Upgrades_flow.IDS_Owned}"/>
                                </local:FZMaterial>
                            </local:FZMaterial>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>


        </ResourceDictionary>
    </Page.Resources>
    <Grid>
        <FZMaterialGlassCapture />
        <FZMaterial
            Style="{StaticResource A_Style_FZMaterial_Popup_Background}" />
        <FZMaterialGlassCapture />
        <ContentControl
            x:Name="BottomBar"
            Style="{StaticResource A_Style_ButtonBar}">
            <ControllerButtonPanel
                x:Name="PART_HelpPanel"
                Layout="RightToLeft"
                HorizontalAlignment="Left"
                VerticalAlignment="Bottom"
                Background="{Null}" />
        </ContentControl>
        <Grid
            Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
            <DockPanel
                x:Name="MainContent"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                Width="{StaticResource H_Width_PopUp}">
                <ContentControl DockPanel.Dock="Top"
                    Style="{StaticResource A_Style_ContentControl_PopupTitleBlock}"
                    Content="{Binding Title}" />
                <ContentControl  DockPanel.Dock="Top"
                    Style="{StaticResource A_Style_ContentControl_MessageBoxPopupContentBlock}"
                    Margin="0">
                    <StackPanel>
                        <!--Car Name, Year and Manufacturer-->
                        <local:FZTextBlock Color="{StaticResource A_Color_SubHeader_Text}"
                                           LineAdjust="-0.35"
                                           Style="{StaticResource A_Style_FZTextBlock_CarActions_CarDetail}"
                                           FontFamily="Horizon_A"
                                           Text="{Binding CarModel, Converter={StaticResource A_StringToUpper}}" 
                                           AutoScroll.AllowScrolling="True"
                                           TextTrimming="None"
                                           Margin="0,23,0,0"/>
                        <Decorator Height="11" />
                        <local:FZTextBlock Color="{StaticResource H_Color_Primary_White}"
                                      FontFamily="Horizon_B"
                                      CapHeight="23"
                                      Style="{StaticResource A_Style_FZTextBlock_CarActions_CarDetail}"
                                      VerticalAlignment="Center">
                            <local:FZRun Text="{Binding CarYear}"
                                    FontFamily="Horizon_B"/>
                            <local:FZRun Text=" " />
                            <local:FZRun Text="{Binding CarManufacturer, Converter={StaticResource A_StringToUpper}}"/>
                        </local:FZTextBlock>

                        <!--Car Image-->
                        <Grid>
                            <FZMaterial ImageSource="/ForzaUI;component/Textures/Anthem/DotPatternA.png"
                                        GetSizeFromTexture="True"
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Center"
                                        Visibility="{Binding IsCarThumbnail, Converter={StaticResource A_FZBooleanToVisibilityConverter}, FallbackValue=Collapsed}"/>
                            <FZMaterial x:Name="Image"
                                        Style="{StaticResource A_Style_FZMaterial_Image}"
                                        ImageSource="{Binding Image}" 
                                        Visibility="{Binding HasImage, Converter={StaticResource A_FZBooleanToVisibilityConverter}, FallbackValue=Collapsed}" />
                        </Grid>
                        <!--Rarity, PI and Class-->
                        <StackPanel HorizontalAlignment="Center"
                                    VerticalAlignment="Bottom"
                                    Orientation="Horizontal"
                                    Margin="20,0,20,20">
                            <Control Style="{StaticResource A_Style_Control_AuctionHouse_RarityPill}"/>

                            <Control Margin="10,0,0,0" Height="35"
                                     Width="95"
                                     Style="{StaticResource A_Style_Control_CarClassBadge_Small}"
                                     local:BindingProxy.A="{Binding CarPerformanceRating}"
                                     local:BindingProxy.B="{Binding CarClass}"/>

                            <Control Style="{StaticResource A_Style_Control_CarActions_Owned}"
                                     Margin="10,0,0,0"
                                     VerticalAlignment="Center"
                                     HorizontalAlignment="Right"/>
                        </StackPanel>
                        <Decorator Height="5" />
                    </StackPanel>
                </ContentControl>
                <CommonListBox x:Name="PART_Menu"
                               MaxHeight="676"
                               Style="{StaticResource A_Style_ListBox_TextMenu_Default}"
                               ItemContainerStyle="{StaticResource A_Style_PopupCarAction_ListBoxItem}"
                               ItemTemplate="{StaticResource A_DataTemplate_ListItem_CarActionItem}"
                               ItemsSource="{Binding Options}" />
            </DockPanel>
        </Grid>
    </Grid>
</Page>