<UserControl x:Class="GitHub.InlineReviews.Views.InlineCommentPeekView"
             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:GitHub.InlineReviews.Views"
             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:imaging="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.Imaging"
             xmlns:catalog="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.ImageCatalog" 
             mc:Ignorable="d" 
             d:DesignHeight="200" d:DesignWidth="500">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <cache:SharedDictionaryManager Source="pack://application:,,,/GitHub.UI;component/SharedDictionary.xaml" />
                <cache:SharedDictionaryManager Source="pack://application:,,,/GitHub.UI.Reactive;component/SharedDictionary.xaml" />
                <cache:SharedDictionaryManager Source="pack://application:,,,/GitHub.VisualStudio.UI;component/SharedDictionary.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <Style x:Key="GitHubToolbarButton" TargetType="{x:Type Button}">
                <Setter Property="Background" Value="Transparent" />

                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <Border Background="{TemplateBinding Background}" BorderThickness="1">
                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>

                <Style.Triggers>
                    <Trigger Property="IsEnabled" Value="False">
                        <Setter Property="Opacity" Value="0.25" />
                    </Trigger>

                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Background" Value="{DynamicResource VsBrush.CommandBarHover}" />
                    </Trigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>

    <DockPanel>
        <Border DockPanel.Dock="Top"
                Background="{DynamicResource {x:Static SystemColors.InfoBrushKey}}"
                Padding="8">
            <Border.Style>
                <Style TargetType="Border">
                    <Setter Property="Visibility" Value="Collapsed"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Thread.NeedsPush}" Value="True">
                            <Setter Property="Visibility" Value="Visible"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Border.Style>
            <DockPanel>
                <ui:OcticonImage DockPanel.Dock="Left" Icon="alert" Margin="0 0 8 0"/>
                <TextBlock TextWrapping="Wrap" Text="{x:Static ghfvs:Resources.YouMustCommitAndPushYourChangesToAddACommentHere}"/>
            </DockPanel>
        </Border>

        <Border DockPanel.Dock="Top"
                BorderThickness="0 0 0 1"
                Background="{DynamicResource VsBrush.CommandBarOptionsBackground}"
                BorderBrush="{DynamicResource GitHubVsBrandedUIBorder}">
            <StackPanel Orientation="Horizontal"
                    HorizontalAlignment="Left" >
                <Button Margin="2 0" Padding="2" Command="{Binding PreviousComment}"
                        Style="{StaticResource GitHubToolbarButton}">
                    <Button.ToolTip>
                        <TextBlock FontSize="11" Text="{x:Static ghfvs:Resources.PreviousComment}"/>
                    </Button.ToolTip>
                    <Canvas Width="16" Height="16">
                        <!-- TODO: Double check these brushes since they don't seem like the right fill colors -->
                        <Polygon Points="10 2 5 8 8 8 8 12 12 12 12 8 15 8" Fill="{DynamicResource VsBrush.CommandBarOptionsGlyph}" StrokeThickness="1"/>
                        <Rectangle Canvas.Left="1.25" Canvas.Top="9" Width="6" Height="1" Fill="{DynamicResource VsBrush.CommandBarOptionsGlyph}" StrokeThickness="1"/>
                        <Rectangle Canvas.Left="1.25" Canvas.Top="10.75" Width="6" Height="1" Fill="{DynamicResource VsBrush.CommandBarOptionsGlyph}" StrokeThickness="1"/>
                        <Rectangle Canvas.Left="1.25" Canvas.Top="12.75" Width="6" Height="1" Fill="{DynamicResource VsBrush.CommandBarOptionsGlyph}" StrokeThickness="1"/>
                    </Canvas>
                </Button>

                <Button Margin="2 0" Padding="2" Command="{Binding NextComment}"
                        Style="{StaticResource GitHubToolbarButton}">
                    <Button.ToolTip>
                        <TextBlock FontSize="11" Text="{x:Static ghfvs:Resources.NextComment}"/>
                    </Button.ToolTip>

                    <Canvas Width="16" Height="16">
                        <!-- TODO: Double check these brushes since they don't seem like the right fill colors -->
                        <Polygon Points="8 8 8 4 4 4 4 8 1 8 6 14 11 8" Fill="{DynamicResource VsBrush.CommandBarOptionsGlyph}" StrokeThickness="1"/>
                        <Rectangle Canvas.Left="9" Canvas.Top="2" Width="6" Height="1" Fill="{DynamicResource VsBrush.CommandBarOptionsGlyph}" StrokeThickness="1"/>
                        <Rectangle Canvas.Left="9" Canvas.Top="4" Width="6" Height="1" Fill="{DynamicResource VsBrush.CommandBarOptionsGlyph}" StrokeThickness="1"/>
                        <Rectangle Canvas.Left="9" Canvas.Top="6" Width="6" Height="1" Fill="{DynamicResource VsBrush.CommandBarOptionsGlyph}" StrokeThickness="1"/>
                    </Canvas>
                </Button>
                <Separator Background="{DynamicResource GitHubButtonBorderBrush}" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
            </StackPanel>
        </Border>

        <Border DockPanel.Dock="Top"
                Background="{DynamicResource VsBrush.InfoBackground}"
                BorderThickness="1 0 0 1"
                Padding="4">
            <Border.Style>
                <Style TargetType="Border">
                    <Setter Property="Visibility" Value="Collapsed"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Thread.IsResolved}" Value="True">
                            <Setter Property="Visibility" Value="Visible"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Border.Style>
            <DockPanel>
                <imaging:CrispImage Margin="4 0" Width="16" Height="16" Moniker="{x:Static catalog:KnownMonikers.StatusInformation}" Visibility="{Binding Model.AnnotationLevel, Converter={ghfvs:EqualsToVisibilityConverter Notice}}"/>
                <TextBlock Foreground="{DynamicResource VsBrush.InfoText}"  TextWrapping="Wrap" Text="{x:Static ghfvs:Resources.ThisConversationWasMarkedAsResolved}"/>
            </DockPanel>
        </Border>

        <ScrollViewer Name="threadScroller"
                      VerticalScrollBarVisibility="Auto"
                      Background="{DynamicResource GitHubPeekViewBackground}">
            <StackPanel Orientation="Vertical">
                <ItemsControl x:Name="annotationsView" ItemsSource="{Binding Annotations}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <ghfvs:InlineAnnotationView />
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>

                <ghfvs:CommentThreadView x:Name="threadView"
                                         Visibility="{Binding DataContext.AvailableForComment, Converter={ghfvs:BooleanToVisibilityConverter}, ElementName=annotationsView}"
                                         DataContext="{Binding Thread}"/>
            </StackPanel>
        </ScrollViewer>
    </DockPanel>
</UserControl>
