<UserControl x:Class="NuGet.PackageManagement.UI.ProjectView"
             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:NuGet.PackageManagement.UI"
             Background="{DynamicResource {x:Static local:Brushes.HeaderBackground}}"
             Foreground="{DynamicResource {x:Static local:Brushes.UIText}}"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="350">
  <UserControl.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <local:SharedResources />
      </ResourceDictionary.MergedDictionaries>
      <local:NotNullToBooleanConverter
        x:Key="NotNullToBooleanConverter" />
      <ControlTemplate
        x:Key="SeparatorControlTemplate">
        <Separator
          HorizontalAlignment="Stretch"
          IsEnabled="False" />
      </ControlTemplate>
    </ResourceDictionary>
  </UserControl.Resources>
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="auto" />
      <RowDefinition Height="10" />
      <RowDefinition Height="auto" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="auto" />
      <ColumnDefinition Width="6" />
      <ColumnDefinition Width="*" />
      <ColumnDefinition Width="6" />
      <ColumnDefinition Width="auto" />
    </Grid.ColumnDefinitions>

    <!-- row 0 -->
    <TextBlock
      Grid.Row="0"
      Grid.Column="0"
      FontWeight="Bold"
      VerticalAlignment="Center"
      Visibility="{Binding InstalledVersion, Converter={StaticResource NullToVisibilityConverter}}"
      Text="{x:Static local:Resources.Label_InstalledColon}" />

    <Border
      Grid.Row="0"
      Grid.Column="2"
      MinHeight="22"
      BorderBrush="{DynamicResource {x:Static local:Brushes.ComboBoxBorderKey}}"
      Visibility="{Binding InstalledVersion, Converter={StaticResource NullToVisibilityConverter}}"
      BorderThickness="1"
      VerticalAlignment="Center">
      <TextBox
        Style="{DynamicResource SelectableTextBlockStyle}"
        VerticalAlignment="Center"
        AutomationProperties.AutomationId="InstalledVersion"
        Margin="4,0,0,0"
        Text="{Binding InstalledVersion, Converter={StaticResource VersionToStringConverter}}" />
    </Border>

    <Button
      Grid.Row="0"
      Grid.Column="4"
      MinWidth="100"
      MinHeight="24"
      AutomationProperties.AutomationId="Project_Button_Uninstall"
      HorizontalAlignment="Left"
      Visibility="{Binding InstalledVersion, Converter={StaticResource NullToVisibilityConverter}}"
      Click="UninstallButton_Clicked"
      Content="{x:Static local:Resources.Button_Uninstall}" />

    <!-- Row 2 -->
    <TextBlock
      Grid.Row="2"
      Grid.Column="0"
      FontWeight="Bold"
      VerticalAlignment="Center"
      Text="{x:Static local:Resources.Label_Version}" />

    <ComboBox
      x:Name="_versions"
      Grid.Row="2"
      Grid.Column="2"
      MinHeight="22"
      AutomationProperties.Name="{x:Static local:Resources.Label_Version}"
      ItemsSource="{Binding Path=Versions}"
      SelectedItem="{Binding Path=SelectedVersion}" />

    <!-- install button and update button. They are in fact the same button. Which
         one is displayed depends on whether InstalledVersion is null.
    -->
    <Button
      Grid.Row="2"
      Grid.Column="4"
      MinWidth="100"
      MinHeight="24"
      HorizontalAlignment="Left"
      AutomationProperties.AutomationId="Button_Install"
      Click="InstallButton_Clicked"
      Visibility="{Binding InstalledVersion, Converter={StaticResource InverseNullToVisibilityConverter}}"
      Content="{x:Static local:Resources.Button_Install}" />

    <Button
      Grid.Row="2"
      Grid.Column="4"
      MinWidth="100"
      MinHeight="24"
      HorizontalAlignment="Left"
      AutomationProperties.AutomationId="Project_Button_Update"
      Click="InstallButton_Clicked"
      Visibility="{Binding InstalledVersion, Converter={StaticResource NullToVisibilityConverter}}"
      IsEnabled="{Binding SelectedVersion,Converter={StaticResource NotNullToBooleanConverter}}"
      Content="{x:Static local:Resources.Button_Update}" />
  </Grid>
</UserControl>