<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_PopupSaveConflict"
    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" />
                <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>
                                </ResourceDictionary>
                            </ControlTemplate.Resources>
                            <Grid>
                                <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_TextMenu}"
                                                            ContentRadius="2"
    		                                                InnerThickness="3"
                                                            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}" />
                                </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>
            <AutoScrollSettings x:Key="A_AutoScrollSettings_OptionText"
                ScrollSeparation="50"
                InitialPause="0:0:0.5"
                Speed="40"
                ScrollOrientation="Horizontal"/>

            <Style x:Key="A_Style_FZTextBlock_AutoScroll"
                BasedOn="{StaticResource A_Style_FZTextBlock_OptionText}"
                TargetType="FZTextBlock">
                <Setter Property="MaxWidth" Value="630" />
                <Setter Property="TextWrapping" Value="NoWrap" />
                <Setter Property="Stretch" Value="None" />
                <Setter Property="TextAlignment" Value="Center" />
                <Setter Property="AutoScroll.AllowScrolling" Value="True" />
                <Setter Property="AutoScroll" Value="{StaticResource A_AutoScrollSettings_OptionText}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorLevel=2, AncestorType=ListBoxItem}}" Value="True">
                        <Setter Property="Color" Value="{StaticResource A_Color_ListItemText_Focused}" />
                        <Setter Property="MaxWidth" Value="infinity"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            <AutoScrollSettings x:Key="A_AutoScrollSettings_MessageText" 
                ScrollSeparation="50"
                InitialPause="0"
                Speed="20"
                ScrollOrientation="Vertical"/>
            <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 A_AutoScrollSettings_MessageText}" />
            </Style>
            <AutoScrollSettings x:Key="A_AutoScrollSettings_MessageSingleLineText" 
                ScrollSeparation="50"
                InitialPause="0"
                Speed="20"
                ScrollOrientation="Horizontal"/>
            <Style x:Key="A_Style_FZTextBlock_AutoScroll_MessageSingleLine"
                BasedOn="{StaticResource H_Style_Text_Description_Body_16px_Scrolling}"
                TargetType="FZTextBlock">
                <Setter Property="AutoScroll.AllowScrolling" Value="True" />
                <Setter Property="AutoScroll" Value="{StaticResource A_AutoScrollSettings_MessageSingleLineText}" />
                <Setter Property="Margin" Value="24,10"/>
                <Setter Property="HorizontalAlignment" Value="Left"/>
                <Setter Property="TextAlignment" Value="Left"/>
                <Setter Property="Visibility" Value="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource A_StringVisConverter}}"/>
            </Style>
            <DataTemplate
                x:Key="A_DataTemplate_TextMenu_Default_MessageBox">
                <DockPanel
                    x:Name="ButtonContent"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    IsHitTestVisible="False"
                    Height="{StaticResource A_Double_TextMenu_Height_Default}"
                    Margin="{StaticResource H_Margin_Text_ListOption}">
                        <FZMaterial x:Name="Icon"
                            DockPanel.Dock="Left"
                            ImageSource="{Binding IconPath}"
                            Height="40"
                            Width="40"
                            Stretch="Uniform"
                            Margin="0,0,8,0"
                            VerticalAlignment="Center"
                            Color="{StaticResource H_Color_Primary_Black}"
                            Visibility="{Binding IconPath, Converter={StaticResource A_StringVisConverter}, FallbackValue=Collapsed}"/>
                        <Decorator x:Name="IconCenteringSpacer"
                            DockPanel.Dock="Right"
                            Width="{Binding ActualWidth, ElementName=Icon}"
                            Visibility="{Binding Visibility, ElementName=Icon}"
                            Margin="8,0,0,0"/>
                        <FZTextBlock x:Name="AutoScrollTextBlock"
                            Style="{StaticResource A_Style_FZTextBlock_AutoScroll}"
                            Margin="0"
                            Text="{Binding Text}"
                            ScreenReader.Event="OnChange"
                            ScreenReader.ControlType="Button"
                            ScreenReader.LineType="SelectedItem"
                            ScreenReader.SelectedNumber="{Binding (ItemsControl.AlternationIndex), FallbackValue=0, RelativeSource={RelativeSource AncestorType={Type ListBoxItem}}, Converter={StaticResource A_IndexToNumberConverter}}"
                            ScreenReader.SelectedCount="{Binding Items.Count, FallbackValue=0, RelativeSource={RelativeSource AncestorType={Type Selector}}}"
                            MarkupConverter="{StaticResource A_MappingConverter_TextMenu}"/>
                </DockPanel>
                <DataTemplate.Triggers>
                    <DataTrigger
                        Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListBoxItem}}"
                        Value="True">
                        <Setter
                            TargetName="AutoScrollTextBlock"
                            Property="local:ScreenReader.Line"
                            Value="{Binding ScreenReaderText, Converter={StaticResource A_Converter_TrimInlineMarkup}}" />
                        <Setter
                            TargetName="Icon"
                            Property="Color"
                            Value="{StaticResource H_Color_Primary_White}"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>
            <DataTemplate DataType="{x:Type local:PopupSaveConflictSaveDataItem}">
                <DockPanel Margin="20,0">
                    <FZMaterial DockPanel.Dock="Left"
                                ImageSource="{Binding IconPath}"
                                Visibility="{Binding IconPath, Converter={StaticResource A_StringVisConverter}, FallbackValue=Collapsed}"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                GetSizeFromTexture="True"/>
                    <DockPanel>
                        <FZTextBlock Style="{StaticResource A_Style_FZTextBlock_AutoScroll_MessageSingleLine}"
                             FontFamily="Horizon_C"
                             Color="{StaticResource H_Color_Primary_Green}"
                             Text="{Binding Title}"
                             DockPanel.Dock="Top"/>
                        <FZTextBlock Style="{StaticResource A_Style_FZTextBlock_AutoScroll_MessageSingleLine}"
                            Text="{Binding SaveTime}"
                            DockPanel.Dock="Top"/>
                        <FZTextBlock Style="{StaticResource A_Style_FZTextBlock_AutoScroll_MessageSingleLine}"
                            Text="{Binding SaveTimeAgo}"
                            DockPanel.Dock="Top"/>
                        <FZTextBlock Style="{StaticResource A_Style_FZTextBlock_AutoScroll_MessageSingleLine}"
                            Text="{Binding DeviceFriendlyName}"
                            DockPanel.Dock="Top"/>
                        <FZTextBlock Style="{StaticResource A_Style_FZTextBlock_AutoScroll_MessageSingleLine}"
                            Text="{Binding SaveSize}"
                            DockPanel.Dock="Top"/>
                        <FZTextBlock Style="{StaticResource A_Style_FZTextBlock_AutoScroll_MessageSingleLine}"
                            Text="{Binding Description}"/>
                    </DockPanel>
                </DockPanel>
            </DataTemplate>
        </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}"
                MinWidth="{StaticResource H_Width_PopUp}">
                <ContentControl DockPanel.Dock="Top"
                    Style="{StaticResource A_Style_ContentControl_PopupTitleBlock}"
                    Width="Auto"
                    Content="{Binding Title}"/>
                <ContentControl  DockPanel.Dock="Top"
                    Style="{StaticResource A_Style_ContentControl_MessageBoxPopupContentBlock}"
                    Margin="0">
                    <StackPanel>
                        <Decorator Height="24" Visibility="{Binding HasMessage, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}" />
                        <FZTextBlock 
                            Visibility="{Binding HasMessage, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                            Style="{StaticResource A_Style_FZTextBlock_AutoScroll_Message}"
                            Margin="24"
                            MaxWidth="{StaticResource H_Width_PopUp}"
                            MultiStringFormatter.Format="{Binding ScreenReaderMessage, Converter={StaticResource A_Converter_PopupMarkupSubstitution}}"
                            ScreenReader.Line="{Binding (local:MultiStringFormatter.Output), RelativeSource={RelativeSource Self}, Converter={StaticResource A_Converter_TrimInlineMarkup}}"
                            ScreenReader.Event="OnLoad"
                            ScreenReader.LineType="ScreenDescription"
                            Text="{Binding Message}"
                            MarkupConverter="{StaticResource A_MappingConverter_Popup}"/>
                        <Decorator Height="24" Visibility="{Binding HasMessage, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}" />

                        <Grid HorizontalAlignment="Center" MaxWidth="1182" MaxHeight="500">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="570"/>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="570"/>
                            </Grid.ColumnDefinitions>
                            <ContentControl Grid.Column="0"
                                            Content="{Binding LocalSave}"
                                            HorizontalContentAlignment="Center"/>

                            <FZMaterial Grid.Column="1"
                                        Width="2"
                                        HorizontalAlignment="Stretch"
                                        Color="{StaticResource H_Color_Glass_Purple_20pc}"
                                        Margin="20"/>

                            <ContentControl Grid.Column="2"
                                            Content="{Binding RemoteSave}"
                                            HorizontalContentAlignment="Center"/>
                        </Grid>
                    </StackPanel>
                </ContentControl>
                <CommonListBox x:Name="PART_Menu"
                               MaxHeight="676"
                               Style="{StaticResource A_Style_ListBox_TextMenu_Default}"
                               ItemContainerStyle="{StaticResource A_Style_ListBoxItem_TextMenu_Default_MessageBox}"
                               ItemTemplate="{StaticResource A_DataTemplate_TextMenu_Default_MessageBox}"
                               ItemsSource="{Binding Options}" />
            </DockPanel>
        </Grid>
    </Grid>
</Page>