<pfui:VsDialogWindow 
    x:Class="NuGet.Dialog.PackageManagerUI.LicenseAcceptanceWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:self="clr-namespace:NuGet.Dialog.PackageManagerUI"
    xmlns:resources="clr-namespace:NuGet.Dialog"
    xmlns:pfui="clr-namespace:NuGet.VisualStudio;assembly=NuGet.VisualStudio"
    xmlns:vsfx="clr-namespace:NuGet.VisualStudio;assembly=NuGet.VisualStudio"
    ResizeMode="CanResize"
    MinWidth="350"
    MinHeight="300"
    Width="400"
    Height="450"
    ShowInTaskbar="False"
    WindowStyle="SingleBorderWindow"
    WindowStartupLocation="CenterOwner"
    resources:WindowSizePersistenceHelper.WindowToken="LicenseWindow"
    Title="{x:Static resources:Resources.License_DialogTitle}"
    Background="{DynamicResource {x:Static resources:UIResources.WindowBackgroundBrushKey}}"
    AutomationProperties.AutomationId="NuGetLicenseWindow"
    >
    
    <Window.Resources>
        <Style TargetType="{x:Type Button}">
            <Setter Property="Margin" Value="6,6,6,2" />
            <Setter Property="Padding" Value="10,3,10,3" />
        </Style>
        
        <self:StringCollectionsToStringConverter x:Key="authorNamesConverter" />
        
        <DataTemplate x:Key="LicenseItemTemplate">
            <StackPanel Margin="2,0,2,5">
                <TextBlock TextWrapping="Wrap">
                    <Run Text="{Binding Id, Mode=OneTime}" FontWeight="Bold" />
                    <Run Text=" " />
                    <Run Text="{Binding Authors, Mode=OneTime, StringFormat={x:Static resources:Resources.License_AuthorFormatString}, Converter={StaticResource authorNamesConverter}}" />
                </TextBlock>
                <TextBlock AutomationProperties.AutomationId="{Binding Id, Mode=OneWay, StringFormat='LicenseTerm_{0}'}">
                    <Hyperlink AutomationProperties.AutomationId="{Binding Id, Mode=OneWay, StringFormat='LicenseTermLink_{0}'}" NavigateUri="{Binding LicenseUrl, Mode=OneTime}" RequestNavigate="OnViewLicenseTermsRequestNavigate">
                        <Run Text="{x:Static resources:Resources.License_ViewLicense}" />
                    </Hyperlink>
                </TextBlock>
            </StackPanel>
        </DataTemplate>
    </Window.Resources>
    
    <DockPanel Margin="10">
        <TextBlock DockPanel.Dock="Top" Margin="0,3,0,3" Text="{x:Static resources:Resources.License_HeaderText}" TextWrapping="Wrap" Foreground="{DynamicResource {x:Static vsfx:VsBrushes.WindowTextKey}}" />        

        <StackPanel DockPanel.Dock="Bottom" Margin="0,0,0,3" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button Content="{x:Static resources:Resources.License_Decline}" AutomationProperties.AutomationId="DeclineButton" Click="OnDeclineButtonClick" IsCancel="True" />
            <Button Content="{x:Static resources:Resources.License_Accept}" AutomationProperties.AutomationId="AcceptButton" Click="OnAcceptButtonClick" />
        </StackPanel>

        <TextBlock DockPanel.Dock="Bottom" Margin="0,0,0,3" TextWrapping="Wrap" Text="{x:Static resources:Resources.License_LicenseText}" Foreground="{DynamicResource {x:Static vsfx:VsBrushes.WindowTextKey}}" />

        <ItemsControl
            Grid.Row="1" 
            Margin="0,0,0,3" 
            MinHeight="130" 
            ItemsSource="{Binding}"
            ItemTemplate="{StaticResource LicenseItemTemplate}">
            <ItemsControl.Template>
                <ControlTemplate TargetType="{x:Type ItemsControl}">
                    <Border BorderThickness="1" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
                        <ScrollViewer 
                            Padding="3" 
                            Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" 
                            CanContentScroll="True" 
                            VerticalScrollBarVisibility="Auto" 
                            HorizontalScrollBarVisibility="Disabled">
                            <ItemsPresenter></ItemsPresenter>
                        </ScrollViewer>
                    </Border>                    
                </ControlTemplate>
            </ItemsControl.Template>
        </ItemsControl>

    </DockPanel>
</pfui:VsDialogWindow>