<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:local="clr-namespace:ForzaUI" 
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    x:Class="ForzaUI.HUDInfoFeedControl"
    HorizontalAlignment="Left"
    VerticalAlignment="Bottom"
    Margin="0,0,0,312"
    x:Name="UserControl">

    <UserControl.Resources>
        <ResourceDictionary>

            <Style x:Key="A_Style_FZMaterial_Feed_InlineIcon" TargetType="local:FZMaterial">
                <Setter Property="Width" Value="35"/>
                <Setter Property="Height" Value="35"/>
                <Setter Property="Margin" Value="0,-8,0,-7"/>
            </Style>

            <Style x:Key="A_Style_FZRun_Markup_EliminatorFeedItem_HIGHLIGHT" TargetType="local:FZRun">
                <Setter Property="Color"  Value="{StaticResource A_Color_Eliminator}"/>
            </Style>

            <Style x:Key="A_Style_FZRun_Markup_EliminatorFeedItem_CARTIER1" TargetType="local:FZRun">
                <Setter Property="Color"  Value="{StaticResource A_Color_EliminatorCarGrade_Tier1_GradientA}"/>
            </Style>
            <Style x:Key="A_Style_FZRun_Markup_EliminatorFeedItem_CARTIER2" TargetType="local:FZRun">
                <Setter Property="Color"  Value="{StaticResource A_Color_EliminatorCarGrade_Tier2_GradientA}"/>
            </Style>
            <Style x:Key="A_Style_FZRun_Markup_EliminatorFeedItem_CARTIER3" TargetType="local:FZRun">
                <Setter Property="Color"  Value="{StaticResource A_Color_EliminatorCarGrade_Tier3_GradientA}"/>
            </Style>
            <Style x:Key="A_Style_FZRun_Markup_EliminatorFeedItem_CARTIER4" TargetType="local:FZRun">
                <Setter Property="Color"  Value="{StaticResource A_Color_EliminatorCarGrade_Tier4_GradientA}"/>
            </Style>

            <Style x:Key="A_Style_FZMaterial_EliminatorFeed_InlineIcon_Highlighted" TargetType="local:FZMaterial" BasedOn="{StaticResource A_Style_FZMaterial_Feed_InlineIcon}">
                <Setter Property="Color" Value="{StaticResource A_Color_Eliminator}"/>
            </Style>

            <Style x:Key="A_Style_FZRun_Markup_EliminatorFeedItem_ELIMINATED" TargetType="{x:Type Control}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/Eliminator/InfoFeed/Eliminated.png" Style="{StaticResource A_Style_FZMaterial_Feed_InlineIcon}" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="A_Style_FZRun_Markup_EliminatorFeedItem_ARENA" TargetType="{x:Type Control}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/Eliminator/InfoFeed/ArenaWall.png" Style="{StaticResource A_Style_FZMaterial_EliminatorFeed_InlineIcon_Highlighted}" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="A_Style_FZRun_Markup_EliminatorFeedItem_CAR" TargetType="{x:Type Control}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/Eliminator/InfoFeed/NewCar.png" Style="{StaticResource A_Style_FZMaterial_Feed_InlineIcon}" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="A_Style_FZRun_Markup_EliminatorFeedItem_TIMEOUT" TargetType="{x:Type Control}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/Eliminator/InfoFeed/DNF.png" Style="{StaticResource A_Style_FZMaterial_EliminatorFeed_InlineIcon_Highlighted}" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <local:FZMaterialPresetGlassRoundtangle x:Key="A_FZMaterialPresetGlassRoundtangle_GlassPanel_OuterAll"
        BasedOn="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_Base}"
        CornerRadius="{StaticResource A_CornerRadius_Outer_All}"/>

            <local:FZMaterialPresetGlassRoundtangle x:Key="A_FZMaterialPresetGlassRoundtangle_GlassPanel_OuterRight"
        BasedOn="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_Base}"
        CornerRadius="8,0,8,0"/>

            <local:FZMaterialPresetGlassRoundtangle x:Key="A_FZMaterialPresetGlassRoundtangle_GlassPanel_Square"
        BasedOn="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_Base}"
        CornerRadius="0,0,0,0"/>

            <local:MappingConverter x:Key="A_MappingConverter_ShowIfNotFirstItemIndex" Default="Visible">
                <local:MappingConverterEntry Key="0" Value="Hidden"/>
            </local:MappingConverter>

            <DataTemplate DataType="{x:Type local:EliminatorFeedItem}" >
                <Grid HorizontalAlignment="Left" Height="35" local:AttachedRoutedEventCommand.Command="{Binding OnFrameworkElementResize}"
                      local:AttachedRoutedEventCommand.RoutedEvent="FrameworkElement.SizeChanged" >

                    <local:FZMaterial x:Name="TopFiller" VerticalAlignment="Top" 
                                      Height="8" Color="{StaticResource A_Color_GlassPanel_NonInteractive}" 
                                      Preset="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_Square}"
                                      Visibility="{Binding (ItemsControl.AlternationIndex), RelativeSource={RelativeSource AncestorType={x:Type ContentPresenter}}, Converter={StaticResource A_MappingConverter_ShowIfNotFirstItemIndex}}"/>

                    <local:FZMaterial x:Name="BottomFiller" VerticalAlignment="Bottom" 
                                      Height="8" Color="{StaticResource A_Color_GlassPanel_NonInteractive}"
                                      Preset="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_Square}"
                                      Visibility="{Binding Path=(local:TickerItemsControlItem.IsFinalItem), Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}"/>

                    <local:FZMaterial x:Name="ItemPill" Preset="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_OuterAll}" 
                                      Color="{StaticResource A_Color_GlassPanel_NonInteractive}" Visibility="{Binding Message, Converter={StaticResource A_StringVisConverter}}">
                        <local:FZTextBlock local:TextBlockInlineMarkup.ResourceBaseName="A_Style_FZRun_Markup_EliminatorFeedItem_" VerticalAlignment="Center"
                                       local:TextBlockInlineMarkup.Markup="{Binding Message}" Color="{StaticResource A_Color_White}"
                                       FontFamily="Horizon_A" CapHeight="14" Margin="8" TextWrapping="NoWrap"/>
                    </local:FZMaterial>
                </Grid>
                
                <DataTemplate.Triggers>
                    <!-- This item is smaller than above item, use right angle right corner-->
                    <DataTrigger Binding="{Binding IsAboveItemSmaller}" Value="True">
                        <Setter TargetName="TopFiller" Property="Preset" Value="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_OuterRightOnly}"/>
                    </DataTrigger>

                    <!-- This item is smaller than below item, use right angle right corner-->
                    <DataTrigger Binding="{Binding IsBelowItemSmaller}" Value="True">
                        <Setter TargetName="BottomFiller" Property="Preset" Value="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_OuterRightOnly}"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="VisualStateGroup">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:0.0"/>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Hidden">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="LayoutRoot">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Shown"/>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <local:TickerItemsControl x:Name="Carousel" MaxWidth="400" VerticalAlignment="Bottom" AlternationCount="24"
                      ItemsSource="{Binding ActiveCollection}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical" VerticalAlignment="Top" IsItemsHost="True" MinHeight="140"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemContainerStyle>
                <Style TargetType="{x:Type ContentPresenter}">
                    <Setter Property="HorizontalAlignment" Value="Left"/>
                </Style>
            </ItemsControl.ItemContainerStyle>
        </local:TickerItemsControl>
    </Grid>
</UserControl>