<AuctionStartPopup x:Class="ForzaUI.Scenes.Anthem.A_AuctionSettings"
      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"
      mc:Ignorable="d"
      xmlns:local="clr-namespace:ForzaUI;assembly="
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

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

    <Page.Resources>
        <ResourceDictionary>
            <System:Double x:Key="A_Double_PanelWidth">816</System:Double>
        
            <DataTemplate DataType="{x:Type local:SettingItem}">
                <Grid>
                    <local:SpinnerControl x:Name="Spinner"
                                      Label="{Binding Name}"
                                      Style="{StaticResource A_Style_SpinnerControl_Default_InItemsList}"
                                      ItemsSource="{Binding Options}"
                                      WrapSelection="{Binding WrapSelection}"
                                      SelectedItem="{Binding SelectedValue, Mode=TwoWay}">
                    </local:SpinnerControl>
                </Grid>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding Enabled}" Value="False">
                        <Setter TargetName="Spinner" Property="Tag" Value="Locked" />
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <DataTemplate DataType="{x:Type local:StringSettingItem}">
                <Grid>
                    <local:SpinnerControl x:Name="Spinner"
                                      Label="{Binding Name}"
                                      Style="{StaticResource A_Style_SpinnerControl_Default_InItemsList}"
                                      ItemsSource="{Binding Options}"
                                      WrapSelection="{Binding WrapSelection}"
                                      SelectedItem="{Binding SelectedValue, Mode=TwoWay}">
                        <SpinnerControl.Resources>
                            <Style x:Key="A_Style_FZTextBlock_SpinnerTitle_Dynamic" TargetType="{x:Type FZTextBlock}"
                                BasedOn="{StaticResource A_Style_FZTextBlock_SpinnerTitle_Default}">
                                <Setter Property="ScreenReader.ControlType" Value="EditableTextSpinner"/>
                            </Style>
                        </SpinnerControl.Resources>
                    </local:SpinnerControl>
                </Grid>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding Enabled}" Value="False">
                        <Setter TargetName="Spinner" Property="Tag" Value="Locked" />
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <GridLength x:Key="A_GridLength_SpinnerWidth">375</GridLength>

            <DataTemplate DataType="{x:Type local:CommandButtonSettingItem}">
                <local:FZButton Command="{Binding Command}"
                                Template="{StaticResource A_ControlTemplate_Button_ToItemSelect_TextMenu}">
                    <Grid Margin="18,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="{StaticResource A_GridLength_SpinnerWidth}" />
                        </Grid.ColumnDefinitions>
                        <Decorator Grid.Column="0">
                            <local:FZTextBlock Text="{Binding Name}"
                                               Style="{StaticResource A_Style_FZTextBlock_TitleInListboxItem}"
                                               HorizontalAlignment="Left" />
                        </Decorator>
                        <Decorator Grid.Column="1"
                                   Margin="{StaticResource A_Margin_SpinnerTrailingMargin}">
                            <local:FZTextBlock Text="{Binding SelectedItem.Text}"
                                               HorizontalAlignment="Center"
                                               Style="{StaticResource A_Style_FZTextBlock_TitleInListboxItem}"
                                               Margin="0" />
                        </Decorator>
                    </Grid>
                </local:FZButton>
            </DataTemplate>

            <Thickness x:Key="A_Thickness_ConfirmMargin">0,4,0,0</Thickness>

            <DataTemplate DataType="{x:Type local:ConfirmButtonSettingItem}">
                <local:FZButton Command="{Binding ConfirmCommand, RelativeSource={RelativeSource AncestorType=Page}}"
                                Content="{local:Loc PopupOptions.IDS_Confirm}"
                                Template="{StaticResource A_ControlTemplate_Button_TextMenu}"
                                local:AncestorPropertySetter.Type="{x:Type ListBoxItem}"
                                local:AncestorPropertySetter.Property="Margin"
                                local:AncestorPropertySetter.Value="{StaticResource A_Thickness_ConfirmMargin}" 
                                FocusSelf.WhenTrue="{Binding IsFocused, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, FallbackValue=False}">
                    <local:FZButton.Style>
                        <Style TargetType="{Type FZButton}">
                            <Style.Triggers>
                                <Trigger Property="IsKeyboardFocusWithin" Value="True">
                                    <Setter Property="local:ScreenReader.Line" Value="{local:Loc PopupOptions.IDS_Confirm}" />
                                    <Setter Property="local:ScreenReader.Event" Value="OnChange" />
                                    <Setter Property="local:ScreenReader.LineType" Value="SelectedItem" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </local:FZButton.Style>
                </local:FZButton>
            </DataTemplate>

            <Style x:Key="A_Style_ListBox_TextMenu_SettingsPopup"
                   TargetType="{x:Type local:CommonListBox}"
                   BasedOn="{StaticResource A_Style_ListBox_TextMenu}">
            </Style>

            <Style x:Key="A_Style_ListBoxItem_SettingsPopup"
                   BasedOn="{StaticResource A_Style_ListBoxItem_TextMenu_Gaps}"
                   TargetType="ListBoxItem">
                <Setter Property="Margin"
                        Value="0,0,0,4" />
                <Setter Property="IsEnabled" Value="{Binding Enabled, FallbackValue=True}"/>
            </Style>
        </ResourceDictionary>
    </Page.Resources>

    <Grid>

        <Grid Visibility="{Binding ShowBlur, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
            <local:FZMaterialGlassCapture />
            <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Popup_Background}"/>
        </Grid>
        <!-- Bars -->
        <ContentControl x:Name="BottomBar"
                        Style="{StaticResource A_Style_ButtonBar}">
            <ContentControl x:Name="PART_DefaultHelpPanel"
                            local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                            Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
        </ContentControl>

        <Grid Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
            <StackPanel x:Name="MainContent"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Width="{StaticResource A_Double_PanelWidth}"
                        Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">

                <ContentControl Content="{Binding Title}"
                                Style="{StaticResource A_Style_ContentControl_PopupTitleBlock}"
                                Width="Auto"/>

                <ContentControl Style="{StaticResource A_Style_ContentControl_PopupContentBlock}" Visibility="{Binding HasMessage, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                    <local:FZTextBlock Text="{Binding Message}"
                                       Style="{StaticResource A_Style_FZTextBlock_PopupText}"/>
                </ContentControl>

                <local:CommonListBox x:Name="PART_Menu"
                                    Style="{StaticResource A_Style_ListBox_TextMenu_SettingsPopup}"
                                    ItemContainerStyle="{StaticResource A_Style_ListBoxItem_SettingsPopup}"
                                    ItemsSource="{Binding Settings}"
                                    SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                                    MaxHeight="648"
                                    local:FocusOnPageFocusGained.SelectorSelectedItem="True" />
            </StackPanel>
        </Grid>
    </Grid>
</AuctionStartPopup>
