<UserControl x:Class="ksBroadcastingTestClient.Autopilot.AutopilotCarView"
             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:local="clr-namespace:ksBroadcastingTestClient.Autopilot"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="{Binding PressureWidth}" />
            <ColumnDefinition Width="0.001*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <!--<Grid Background="DarkGray" Grid.Row="0" Grid.Column="0" />-->
        <ProgressBar Value="{Binding Pressure}" Foreground="DarkGray" Grid.Row="0" Grid.ColumnSpan="2" />
        
        <StackPanel Margin="3" Orientation="Horizontal" Grid.ColumnSpan="2" Grid.RowSpan="2">
            <TextBlock Width="30" Text="{Binding Position}" FontWeight="Bold" HorizontalAlignment="Left" />
            <TextBlock Width="60" Text="{Binding RaceNumber, StringFormat={}#{0}}" TextAlignment="Center" HorizontalAlignment="Left" />
            <TextBlock Width="80" Text="{Binding CurrentDriverName, StringFormat={}#{0}}"  TextAlignment="Center" HorizontalAlignment="Left" />
            <TextBlock Width="30" Text="{Binding Pressure, StringFormat=P1}" FontWeight="Bold" HorizontalAlignment="Left" />
        </StackPanel>

        <!-- And the weights -->
        <ItemsControl ItemsSource="{Binding PressureCategories}" Grid.Row="1" Grid.ColumnSpan="2">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>

            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="60" />
                            <ColumnDefinition Width="60" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="{Binding Category}" />
                        <Grid Grid.Column="1">
                            <ProgressBar Value="{Binding WeightedValue}" Minimum="0" Maximum="1"  />
                            <TextBlock Text="{Binding Hint}" Foreground="DarkGray" TextAlignment="Center" />
                        </Grid>
                    </Grid>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

    </Grid>
</UserControl>
