<UserControl x:Class="GitHub.VisualStudio.Views.Dialog.ForkRepositorySelectView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:cache="clr-namespace:GitHub.UI.Helpers;assembly=GitHub.UI"
             xmlns:ui="clr-namespace:GitHub.UI;assembly=GitHub.UI"
             xmlns:ghfvs="https://github.com/github/VisualStudio"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:GitHub.VisualStudio.Views.Dialog"
             xmlns:sampleData="clr-namespace:GitHub.SampleData;assembly=GitHub.App"
             mc:Ignorable="d" 
             xmlns:vs="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.14.0"
             Background="{DynamicResource {x:Static vs:ThemedDialogColors.WindowPanelBrushKey}}"
             Foreground="{DynamicResource {x:Static vs:ThemedDialogColors.WindowPanelTextBrushKey}}"
             d:DesignHeight="414" d:DesignWidth="440">

  <Control.Resources>
    <ResourceDictionary Source="DialogStyles.xaml" />
  </Control.Resources>

  <d:DesignProperties.DataContext>
    <sampleData:ForkRepositorySelectViewModelDesigner IsLoading="True"/>
  </d:DesignProperties.DataContext>

  <DockPanel Margin="0 8">
    <TextBlock FontSize="16" Margin="8" DockPanel.Dock="Top">
      Where should we fork this repository?
    </TextBlock>

    <ui:GitHubProgressBar DockPanel.Dock="Top"
                          IsIndeterminate="True"
                          Style="{DynamicResource GitHubProgressBar}"
                          Visibility="{Binding IsLoading, Converter={ui:BooleanToHiddenVisibilityConverter}}"/>

    <ListBox Name="accountsListBox"
             BorderThickness="0"
             ItemsSource="{Binding Accounts}"
             VerticalContentAlignment="Top"
             HorizontalContentAlignment="Stretch"
             Padding="8"
             DockPanel.Dock="Top"
             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
             SelectionChanged="accountsListBox_SelectionChanged">
      <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
          <UniformGrid Columns="3" IsItemsHost="True" />
        </ItemsPanelTemplate>
      </ListBox.ItemsPanel>
      <ListBox.ItemTemplate>
        <DataTemplate>
          <Border Margin="4" CornerRadius="3">
            <DockPanel>
              <TextBlock DockPanel.Dock="Bottom"
                                Margin="4,0,4,4"
                                Text="{Binding Login, StringFormat=@{0}}"
                                TextAlignment="Center"
                                TextTrimming="CharacterEllipsis"/>
              <Image Margin="4"
                     Width="100"
                     Height="100"
                     Stretch="Uniform"
                     Source="{Binding AvatarUrl}" />
            </DockPanel>
          </Border>
        </DataTemplate>
      </ListBox.ItemTemplate>
    </ListBox>

    <DockPanel Margin="0 16 0 0"
               DockPanel.Dock="Bottom"
               Visibility="{Binding ExistingForks, Converter={ui:HasItemsVisibilityConverter}}">
      <TextBlock DockPanel.Dock="Top" Margin="8 0">
            <Run FontWeight="SemiBold">Can't find what you're looking for?</Run>
            <LineBreak/>
            <Run>You have existing forks of this repository:</Run>
      </TextBlock>

      <ItemsControl ItemsSource="{Binding ExistingForks}" DockPanel.Dock="Bottom" MaxHeight="120" Padding="8 0" ScrollViewer.VerticalScrollBarVisibility="Auto">
        <ItemsControl.ItemTemplate>
          <DataTemplate>
            <StackPanel Orientation="Horizontal" Margin="0 4 0 0">
              <ui:OcticonImage Icon="repo_forked" Margin="0,0,2,-2"/>
              <TextBlock Text="{Binding Owner, Mode=OneWay}"/>
              <TextBlock Text="/"/>
              <TextBlock Text="{Binding Name, Mode=OneWay}"/>
            </StackPanel>
          </DataTemplate>
        </ItemsControl.ItemTemplate>
      </ItemsControl>
    </DockPanel>
  </DockPanel>
</UserControl>
