<UserControl
	DataContext="{Binding (HUDData.Data), RelativeSource={RelativeSource Self}}" 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"
	xmlns:local="clr-namespace:ForzaUI"
	mc:Ignorable="d"
	x:Class="ForzaUI.HUDProximityBlindspotControl"
	x:Name="UserControl"
    VerticalAlignment="Stretch"
    HorizontalAlignment="Stretch">
    <UserControl.Resources>
        <Color x:Key="A_Color_Radar_Background_Light">#4DFFFFFF</Color>
        <Color x:Key="A_Color_Radar_Background_Dark">#4D000000</Color>
        <Color x:Key="A_Color_Radar_Markings_Light">#33000000</Color>
        <Color x:Key="A_Color_Radar_Markings_Dark">#33FFFFFF</Color>
        <Double x:Key="A_Radar_Size">186</Double>
        <CornerRadius x:Key="A_Radar_CornerRadius">93</CornerRadius>
        <Thickness x:Key="A_Radar_Thickness">2</Thickness>

        <local:MappingConverter x:Key="A_Converter_CarClosenessEnum_to_Color" Default="{StaticResource A_Color_RadarCarCloseness_Clear}">
            <local:MappingConverterEntry Key="{x:Static local:CarClosenessEnum.Clear}" Value="{StaticResource A_Color_RadarCarCloseness_Clear}"/>
            <local:MappingConverterEntry Key="{x:Static local:CarClosenessEnum.Close}" Value="{StaticResource A_Color_RadarCarCloseness_Close}"/>
            <local:MappingConverterEntry Key="{x:Static local:CarClosenessEnum.ReallyClose}" Value="{StaticResource A_Color_RadarCarCloseness_ReallyClose}"/>
        </local:MappingConverter>

        <local:MappingConverter x:Key="A_Converter_ProximityRadarTheme_to_BackgroundColor" Default="{StaticResource A_Color_Transparent}">
            <local:MappingConverterEntry Key="{x:Static local:UIProximityRadarTheme.Lighter}" Value="{StaticResource A_Color_Radar_Background_Light}"/>
            <local:MappingConverterEntry Key="{x:Static local:UIProximityRadarTheme.Darker}" Value="{StaticResource A_Color_Radar_Background_Dark}"/>
        </local:MappingConverter>

        <local:MappingConverter x:Key="A_Converter_ProximityRadarTheme_to_BackgroundVisibility" Default="{x:Static Visibility.Hidden}">
            <local:MappingConverterEntry Key="{x:Static local:UIProximityRadarTheme.Lighter}" Value="{x:Static Visibility.Visible}"/>
            <local:MappingConverterEntry Key="{x:Static local:UIProximityRadarTheme.Darker}" Value="{x:Static Visibility.Visible}"/>
        </local:MappingConverter>
        
        <local:MappingConverter x:Key="A_Converter_ProximityRadarTheme_to_MarkingsColor" Default="{StaticResource A_Color_Transparent}">
            <local:MappingConverterEntry Key="{x:Static local:UIProximityRadarTheme.Lighter}" Value="{StaticResource A_Color_Radar_Markings_Light}"/>
            <local:MappingConverterEntry Key="{x:Static local:UIProximityRadarTheme.Darker}" Value="{StaticResource A_Color_Radar_Markings_Dark}"/>
        </local:MappingConverter>

        <local:MappingConverter x:Key="A_Converter_ProximityRadarTheme_to_BorderImageSource" Default="">
            <local:MappingConverterEntry Key="{x:Static local:UIProximityRadarTheme.Lighter}" Value="/ForzaUI;component/Textures/Anthem/HUD/Radar_Border_Light.png"/>
            <local:MappingConverterEntry Key="{x:Static local:UIProximityRadarTheme.Darker}" Value="/ForzaUI;component/Textures/Anthem/HUD/Radar_Border_Dark.png"/>
        </local:MappingConverter>

    </UserControl.Resources>
    <ContentControl x:Name="PART_LayoutRoot" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
        <VisualStateManager.VisualStateGroups   >
            <VisualStateGroup x:Name="VisualStateGroup">
                <VisualState x:Name="PART_Hidden" />
                <VisualState x:Name="PART_Shown"/>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Grid>
            <ItemsControl x:Name="ItemsControl_HudBlindspot" ItemsSource="{HUDDataBinding BlindspotItems}"  VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="White" RenderTransformOrigin="0.5,0.5" Focusable="False">
                <ItemsControl.RenderTransform>
                    <TransformGroup>
                        <SkewTransform/>
                        <RotateTransform/>
                        <TranslateTransform/>
                    </TransformGroup>
                </ItemsControl.RenderTransform>
                <ItemsControl.Template>
                    <ControlTemplate TargetType="{x:Type ItemsControl}">
                    <!-- Margin="{Binding SafeFrameMargin, RelativeSource={RelativeSource AncestorType=Page}}" -->
                        <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" IsItemsHost="True"/>
                    </ControlTemplate>
                </ItemsControl.Template>
                <ItemsControl.ItemContainerStyle>
                    <Style TargetType="{x:Type ContentPresenter}">
                        <Setter Property="VerticalAlignment" Value="Stretch"/>
                        <Setter Property="HorizontalAlignment" Value="Stretch"/>

                        <Setter Property="ContentTemplate">
                            <Setter.Value>
                                <DataTemplate>
                                    <Grid x:Name="Grid_Rotation" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
                                        <Grid.RenderTransform>
                                            <TransformGroup>
                                                <TranslateTransform X="{Binding LocationX}" Y="{Binding LocationY}"/>
                                            </TransformGroup>
                                        </Grid.RenderTransform>

                                        <FZMaterial x:Name="RadarBackground"
                                                    Height="{StaticResource A_Radar_Size}"
                                                    Width="{StaticResource A_Radar_Size}"
                                                    Opacity="{Binding RadarBackgroundOpacity}"
                                                    Color="{Binding Theme, Converter={StaticResource A_Converter_ProximityRadarTheme_to_BackgroundColor}}"
                                                    Visibility="{Binding Theme, Converter={StaticResource A_Converter_ProximityRadarTheme_to_BackgroundVisibility}}"
                                                    ImageSource="/ForzaUI;component/Textures/Anthem/HUD/Radar_BG.png">
                                            <Grid>
                                                <FZMaterial x:Name="RadarMarkings"
                                                            Height="{StaticResource A_Radar_Size}"
                                                            Width="{StaticResource A_Radar_Size}"
                                                            Color="{Binding Theme, Converter={StaticResource A_Converter_ProximityRadarTheme_to_MarkingsColor}}"
                                                            ImageSource="/ForzaUI;component/Textures/Anthem/HUD/Full_Radar_V1.png"/>

                                                <FZMaterial x:Name="RadarBorder"
                                                            Height="{StaticResource A_Radar_Size}"
                                                            Width="{StaticResource A_Radar_Size}"
                                                            ImageSource="{Binding Theme, Converter={StaticResource A_Converter_ProximityRadarTheme_to_BorderImageSource}}"/>
                                            </Grid>
                                        </FZMaterial>

                                        <Grid x:Name="Grid_Opacity" 
                                              HorizontalAlignment="Right" 
                                              VerticalAlignment="Center" 
                                              Height="{StaticResource A_Radar_Size}"
                                              Width="{StaticResource A_Radar_Size}">
                                            <local:FZMaterial x:Name="Image_BlindspotLeft" ImageSource="/ForzaUI;component/Textures/Anthem/HUD/Radar_Blindspot_Left.png" Stretch="Uniform" Color="{Binding BlindLeft, Converter={StaticResource A_Converter_CarClosenessEnum_to_Color}}"/>
                                            <local:FZMaterial x:Name="Image_BlindspotRight" ImageSource="/ForzaUI;component/Textures/Anthem/HUD/Radar_Blindspot_Right.png" Stretch="Uniform" Color="{Binding BlindRight, Converter={StaticResource A_Converter_CarClosenessEnum_to_Color}}"/>
                                            <local:FZMaterial x:Name="Image_BlindspotFront" ImageSource="/ForzaUI;component/Textures/Anthem/HUD/Radar_Blindspot_Front.png" Stretch="Uniform" Color="{Binding BlindFront, Converter={StaticResource A_Converter_CarClosenessEnum_to_Color}}"/>
                                            <local:FZMaterial x:Name="Image_BlindspotRear" ImageSource="/ForzaUI;component/Textures/Anthem/HUD/Radar_Blindspot_Rear.png" Stretch="Uniform" Color="{Binding BlindRear, Converter={StaticResource A_Converter_CarClosenessEnum_to_Color}}"/>
                                        </Grid>
                                    </Grid>
                                </DataTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ItemsControl.ItemContainerStyle>
            </ItemsControl>
            <!-- /ItemsControl_HudBlindspot -->

        </Grid>
    </ContentControl>

</UserControl>