<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_ViewAuction"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <Page.Resources>
        <ResourceDictionary>

            <Style x:Key="A_Style_FZMaterial_BidBoxIcon_Large"
                   TargetType="{x:Type local:FZMaterial}"
                   BasedOn="{StaticResource A_Style_FZMaterial_BidBoxIcon_Default}">
                <Setter Property="ImageSourceNoPreload" Value="/ForzaUI;component/Textures/Anthem/Icons/CRIcon/CR_85_FilledCircle.png" />
            </Style>

            <Style x:Key="A_Style_ContentControl_BidBox_Bid"
                   TargetType="ContentControl"
                   BasedOn="{StaticResource A_Style_ContentControl_BidBox_HighestBid}">
                <Style.Resources>
                    <System:Double x:Key="A_Double_BidBox_CreditIconSize">43</System:Double>
                    <TextAlignment x:Key="A_TextAlignment_BidBox_Title">Left</TextAlignment>
                    <Style x:Key="A_Style_FZMaterial_BidBoxIcon_Dynamic"
                           TargetType="{x:Type local:FZMaterial}"
                           BasedOn="{StaticResource A_Style_FZMaterial_BidBoxIcon_Large}" />
                </Style.Resources>
            </Style>

            <Style x:Key="A_Style_ContentControl_BidBox_Buyout"
                   TargetType="ContentControl">
                <Style.Resources>
                    <System:Double x:Key="A_Double_BidBox_CreditIconSize">43</System:Double>
                    <TextAlignment x:Key="A_TextAlignment_BidBox_Title">Left</TextAlignment>
                    <Style x:Key="A_Style_FZMaterial_BidBoxIcon_Dynamic"
                           TargetType="{x:Type local:FZMaterial}"
                           BasedOn="{StaticResource A_Style_FZMaterial_BidBoxIcon_Large}" />
                </Style.Resources>
                <Setter Property="Template"
                        Value="{StaticResource A_Template_ContentControl_BidBox}" />
                <Setter Property="Tag"
                        Value="{Binding Source={local:Loc AuctionHouse.IDS_AuctionHouseDetails_Buyout}, Converter={StaticResource A_StringToUpper}}" />
            </Style>

            <Style x:Key="A_Style_FZTextBlock_BidBox_Value"
                   TargetType="{x:Type local:FZTextBlock}"
                   BasedOn="{StaticResource A_Style_FZTextBlock_Auction_CanExpire}">
                <Setter Property="Text" Value="{Binding Tag, RelativeSource={RelativeSource AncestorType=ContentControl}}" />
                <Setter Property="CapHeight" Value="34" />
                <Setter Property="FontFamily" Value="Horizon_A" />
                <Setter Property="TextAlignment" Value="Right" />
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="Margin" Value="12,0,0,0" />
            </Style>

            <Style x:Key="A_Style_Border_ScenePadding_ViewAuction"
                TargetType="Border"
                BasedOn="{StaticResource A_Style_Border_ScenePadding_Opus}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Collection.Count}" Value="3">
                        <Setter Property="Padding" Value="78,94,78,152"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <local:FZMaterialPresetAcrylicPanel x:Key="A_FZMaterialPresetAcrylicPanel_BodyPanel_ColouredFront"
                                                FrontEdgeTransparency="0.1"
                                                BasedOn="{StaticResource A_FZMaterialPresetAcrylicPanel_BodyPanel}" />
        </ResourceDictionary>
    </Page.Resources>
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup>
            <VisualState Name="Bars">
                <VisualState.Storyboard>
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Bars"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                                    Value="{x:Static Visibility.Visible}" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_DriveTrainControl"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                                    Value="{x:Static Visibility.Visible}" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_CarClassControl"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                                    Value="{x:Static Visibility.Visible}" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState.Storyboard>
            </VisualState>
            <VisualState Name="Stats">
                <VisualState.Storyboard>
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Stats"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                                    Value="{x:Static Visibility.Visible}" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_DriveTrainControl"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                                    Value="{x:Static Visibility.Visible}" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_CarClassControl"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                                    Value="{x:Static Visibility.Visible}" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState.Storyboard>
            </VisualState>
            <VisualState Name="Collaborators">
                <VisualState.Storyboard>
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Collaborators"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                                    Value="{x:Static Visibility.Visible}" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_CarInfoContainer"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                                    Value="{x:Static Visibility.Collapsed}" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState.Storyboard>
            </VisualState>
            <VisualState Name="Bids">
                <VisualState.Storyboard>
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Bids"
                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                                    Value="{x:Static Visibility.Visible}" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState.Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}" />
    </local:UIPageTransitionManager.TransitionManager>

    <Grid>
        <Grid Style="{StaticResource A_Style_FrameworkElement_FadeOnlyTransition}">
            <local:PlayerBarControl Style="{StaticResource A_Style_PlayerBarControl}"
                                    x:Name="TopBar" />
        </Grid>

        <local:RoutedEventCommand x:Name="ToggleStatsRoutedEventCommand"
                                  RoutedEvent="UIElement.MouseLeftButtonUp"
                                  Command="{Binding ToggleStatsCommand, RelativeSource={RelativeSource AncestorType=Page}}" />

        <ContentControl x:Name="BottomBar"
                        Style="{StaticResource A_Style_ButtonBar}">
            <local:ControllerButtonPanel x:Name="HelpPanel"
                                         Style="{StaticResource A_Style_ControllerButtonPanel_Default}">
                <local:ControllerButtonControl Button="A"
                                               Description="{local:Loc HelpButtons.IDS_Select}" />
                <local:ControllerButtonControl Button="B"
                                               Description="{local:Loc HelpButtons.IDS_Back}" />
                <local:ControllerButtonControl Button="X"
                                               Description="{local:Loc HelpButtons.IDS_ChangeCamera}" />
                <local:ControllerButtonControl Button="DPadHorizontal"
                                               Description="{local:Loc HelpButtons.IDS_Toggle}"
                                               Visibility="{Binding IsControllerActiveInput, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
                <local:ControllerButtonControl Description="{local:Loc HelpButtons.IDS_Toggle}"
                                               local:RoutedEventCommand.Action="{Binding ElementName=ToggleStatsRoutedEventCommand}"
                                               Visibility="{Binding IsControllerActiveInput, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}" 
                                               InputOverride="{local:Input Command=INPUTCMD_UI_DPAD_RIGHT_PRESS, Context=INPUTCONTEXT_UI}"/>
            </local:ControllerButtonPanel>
        </ContentControl>

        <Border Style="{StaticResource A_Style_Border_ScenePadding_ViewAuction}">
            <StackPanel Orientation="Vertical"
                        Width="342"
                        HorizontalAlignment="Left"
                        Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                <ContentControl Tag="{local:Loc AuctionHouse.IDS_AuctionDetails}"
                                Template="{StaticResource A_ControlTemplate_SidePanel}"
                                Height="411">
                    <DockPanel Height="339">
                        <Grid Margin="30,20"
                              DataContext="{Binding Auction}"
                              x:Name="PART_CarInfoContainer"
                              Visibility="Visible"
                              DockPanel.Dock="Bottom">
                            <Control Style="{StaticResource A_Style_Control_CarClassBadge_Small}"
                                     local:BindingProxy.B="{Binding CarClass}"
                                     local:BindingProxy.A="{Binding CarPI}"
                                     HorizontalAlignment="Left"
                                     x:Name="PART_CarClassControl"
                                     Height="42" />
                            <Decorator HorizontalAlignment="Right"
                                       VerticalAlignment="Center"
                                       x:Name="PART_DriveTrainControl">
                                <Control Style="{StaticResource A_Style_Control_DriveTrainDisplay}"
                                         VerticalAlignment="Center"
                                         HorizontalAlignment="Center"
                                         Height="42" />
                            </Decorator>
                        </Grid>
                        <Grid VerticalAlignment="Stretch">

                            <Grid Margin="30,27,30,0"
                                  x:Name="PART_Bars"
                                  Visibility="Collapsed"
                                  DataContext="{Binding Stats}">
                                <StackPanel Orientation="Vertical">
                                    <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Speed}" />
                                    <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Handling}" />
                                    <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Acceleration}" />
                                    <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Launch}" />
                                    <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Upgrades_Braking}" />
                                </StackPanel>
                            </Grid>

                            <Grid Margin="30,30,30,0"
                                  Visibility="Collapsed"
                                  x:Name="PART_Stats"
                                  DataContext="{Binding Stats}">
                                <Control Style="{StaticResource A_Style_Control_CarPerfStats}"
                                         Tag="{Binding Upgraded}" />
                            </Grid>

                            <Grid Margin="30,40,30,60"
                                  Visibility="Collapsed"
                                  x:Name="PART_Collaborators"
                                  DataContext="{Binding Auction}">

                                <!-- Painter -->
                                <Control Template="{StaticResource A_Template_Control_Auction_Collaborator}"
                                         VerticalAlignment="Top"
                                         HorizontalContentAlignment="Left"
                                         local:BindingProxy.A="{Binding Painter}"
                                         local:BindingProxy.B="{x:Static local:UGCThreadType.Vinyl}"
                                         local:BindingProxy.C="{local:Loc AuctionHouse.IDS_Paint}"
                                         Tag="{Binding VinylGroupContributors}" />

                                <!-- Tuner -->
                                <Control Template="{StaticResource A_Template_Control_Auction_Collaborator}"
                                         VerticalAlignment="Bottom"
                                         HorizontalContentAlignment="Left"
                                         local:BindingProxy.A="{Binding Tuner}"
                                         local:BindingProxy.B="{x:Static local:UGCThreadType.Tuning}"
                                         local:BindingProxy.C="{local:Loc AuctionHouse.IDS_Tune}" />

                            </Grid>

                            <DockPanel Margin="30,30,30,0"
                                  Visibility="Collapsed"
                                  x:Name="PART_Bids"
                                  DataContext="{Binding Auction}">
                                <StackPanel Orientation="Vertical"
                                            DockPanel.Dock="Top"
                                            HorizontalAlignment="Left"
                                            Margin="0,0,0,20">
                                    <!-- Seller -->
                                    <local:FZTextBlock Height="16"
                                                       Stretch="Uniform"
                                                       StretchDirection="Both"
                                                       TextAlignment="Left"
                                                       FontFamily="Horizon_A"
                                                       Color="{StaticResource A_Color_SubHeader_Text}"
                                                       Text="{local:Loc AuctionHouse.IDS_Seller}" />
                                    <Decorator Height="10" />
                                    <Control Template="{StaticResource A_Template_ClubAndGamertag}"
                                             DataContext="{Binding Seller}"
                                             Height="22" />
                                </StackPanel>

                                <Grid HorizontalAlignment="Left"
                                      MaxWidth="135"
                                      DockPanel.Dock="Bottom"
                                      Margin="0,10,0,0">
                                    <Control Style="{StaticResource A_Style_Control_AuctionHouse_RarityPill}" />
                                    <Control Style="{StaticResource A_Style_Control_AuctionHouse_BarnFindPill}" />
                                </Grid>

                                <!-- High bidder -->
                                <Control Style="{StaticResource A_Style_Control_Auction_HighestBidder}"
                                         local:BindingProxy.A="{StaticResource A_Color_SubHeader_Text}"
                                         local:BindingProxy.B="{StaticResource A_Color_SubHeader_Text}"
                                         HorizontalAlignment="Left"
                                         VerticalAlignment="Center" />

                            </DockPanel>
                        </Grid>
                    </DockPanel>
                </ContentControl>
                <Decorator Height="5" />
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_FlatPanel_Tile}"
                                  GreedyMeasure="True"
                                  DataContext="{Binding Auction}"
                                  Height="310">
                    <DockPanel>
                        <Grid DockPanel.Dock="Bottom"
                              Margin="12"
                              Width="316"
                              Height="53">
                            <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetRoundtangleStroke_AuctionHouse_CurrentBidNotSet}"
                                              Color="{StaticResource A_Color_AuctionHouse_BidNow_Dark}"
                                              Visibility="{Binding State, Converter={StaticResource A_Converter_BidNowPill}}">
                                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_Auction_Banner}"
                                                   Text="{Binding Source={local:Loc AuctionHouse.IDS_BidNow}, Converter={StaticResource A_StringToUpper}}"
                                                   Color="{StaticResource A_Color_AuctionHouse_BidNow_Dark}"
                                                   CapHeight="18"
                                                   Margin="9,7" />
                            </local:FZMaterial>
                            <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Auction_Banner}">
                                <Viewbox StretchDirection="DownOnly">
                                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_Auction_Banner}"
                                                       Margin="9,7" />
                                </Viewbox>
                            </local:FZMaterial>
                        </Grid>
                        <StackPanel Margin="28,25,28,25"
                                    Orientation="Vertical">

                            <ContentControl Style="{StaticResource A_Style_ContentControl_BidBox_Bid}"
                                            local:BindingProxy.A="{StaticResource A_Color_AuctionHouse_CurrentBidPrice}">
                                <Grid HorizontalAlignment="Stretch">
                                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_BidBox_Value}"
                                                       local:BindingProxy.A="{StaticResource A_Color_AuctionHouse_CurrentBidPrice}"
                                                       Text="{Binding HighestBid, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}}" />
                                </Grid>
                            </ContentControl>

                            <Decorator Height="16" />

                            <ContentControl Style="{StaticResource A_Style_ContentControl_BidBox_Buyout}"
                                            local:BindingProxy.B="{StaticResource A_Color_AuctionHouse_BuyOutPrice}">
                                <Grid HorizontalAlignment="Stretch">
                                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_BidBox_Value}"
                                                       local:BindingProxy.A="{StaticResource A_Color_AuctionHouse_BuyOutPrice}"
                                                       Text="{Binding Buyout, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}}" />
                                </Grid>
                            </ContentControl>

                            <Decorator Height="16" />

                            <local:FZMaterial Height="2"
                                              Margin="-14,0"
                                              Color="{StaticResource A_Color_AuctionHouse_ItemSeparator}" />

                            <Decorator Height="19" />

                            <Control Template="{StaticResource A_ControlTemplate_AuctionDetails_TimeRemaining}"
                                     VerticalAlignment="Center"
                                     local:BindingProxy.A="True" />
                        </StackPanel>
                    </DockPanel>
                </local:FZMaterial>
                <Decorator Height="5" />
                <local:CommonListBox Style="{StaticResource A_Style_ListBox_TextMenu}"
                                     SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"
                                     ItemContainerStyle="{StaticResource A_Style_ListBoxItem_TextMenu_Default}"
                                     ItemTemplate="{StaticResource A_DataTemplate_TextMenu_AuctionDetails}"
                                     ItemsSource="{Binding Collection}"
                                     x:Name="PART_List"
                                     local:FocusOnPageFocusGained.SelectorSelectedItem="True" />
            </StackPanel>
        </Border>
    </Grid>
</Page>