<UserControl x:Class="GitHub.InlineReviews.Views.PullRequestStatusView"
             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:ghfvs="https://github.com/github/VisualStudio"
             xmlns:ui="clr-namespace:GitHub.UI;assembly=GitHub.UI"
             xmlns:vsshell="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0"
             xmlns:local="clr-namespace:GitHub.InlineReviews.Views"
             mc:Ignorable="d" 
             d:DesignHeight="20" d:DesignWidth="60">

    <UserControl.Resources>
        <Style TargetType="Button">
            <Setter Property="Background" Value="Transparent" />

            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
                            <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>

                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="border" Property="Background">
                                    <Setter.Value>
                                        <SolidColorBrush Color="White" Opacity="0.2" />
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <StackPanel Orientation="Horizontal">
        <Grid Visibility="{Binding Number, Converter={ui:EqualsToVisibilityConverter {x:Null}}}">
            <Button
            Foreground="{DynamicResource VsBrush.StatusBarText}"
            BorderThickness="0"
            Padding="4 0"
            Command="{Binding OpenPullRequestsCommand}">

                <StackPanel Orientation="Horizontal">
                    <ui:OcticonPath
                        Fill="White"
                        VerticalAlignment="Bottom"
                        Margin="0 0 4 0 "
                        Icon="mark_github" />
                    <TextBlock VerticalAlignment="Center">
                        <Run Text="{Binding RepositoryOwner}" /> / <Run Text="{Binding RepositoryName}" />
                    </TextBlock>
                </StackPanel>
            </Button>
            <Grid.ToolTip>
                <TextBlock VerticalAlignment="Center" Text="{x:Static ghfvs:Resources.ViewCheckoutOrCreateAPullRequest}"/>
            </Grid.ToolTip>
        </Grid>

        <Grid Visibility="{Binding Number, Converter={ui:NotEqualsToVisibilityConverter {x:Null}}}">
            <Button
                Foreground="{DynamicResource VsBrush.StatusBarText}"
                BorderThickness="0"
                Padding="4 0"
                Command="{Binding ShowCurrentPullRequestCommand}">

                <StackPanel Orientation="Horizontal">
                    <ui:OcticonPath
                        Fill="White"
                        VerticalAlignment="Bottom"
                        Margin="0 0 4 0 "
                        Icon="git_pull_request" />
                    <TextBlock VerticalAlignment="Center">
                        #<Run Text="{Binding Number}" />
                    </TextBlock>
                </StackPanel>
            </Button>
            <Grid.ToolTip>
                <TextBlock VerticalAlignment="Center">
                    #<Run Text="{Binding Number}" /> - <Run Text="{Binding Title}" />
                </TextBlock>
            </Grid.ToolTip>
        </Grid>
    </StackPanel>
</UserControl>
