<sharedControls:DialogUserControl
    x:Class="GitHub.UI.CredentialsControl"
    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:controls="clr-namespace:GitHub.UI"
    xmlns:properties="clr-namespace:GitHub.Authentication.Properties"
    xmlns:sharedControls="clr-namespace:GitHub.Shared.Controls"
    mc:Ignorable="d"
    d:DesignWidth="414"
    d:DesignHeight="440"
    Style="{DynamicResource DialogUserControl}">
    <DockPanel Style="{DynamicResource DialogContainerDockPanel}">
        <DockPanel.Resources>
            <Style TargetType="{x:Type sharedControls:PromptTextBox}" BasedOn="{StaticResource RoundedPromptTextBox}">
                <Setter Property="Margin" Value="0,10,0,0" />
            </Style>
            <Style TargetType="{x:Type sharedControls:MaskedPasswordBox}" BasedOn="{StaticResource RoundedPromptTextBox}">
                <Setter Property="Margin" Value="0,10,0,0" />
            </Style>
            <Style TargetType="{x:Type DockPanel}">
                <Setter Property="Margin" Value="0,20,0,0" />
                <Setter Property="LastChildFill" Value="True" />
            </Style>
            <Style x:Key="FormFieldStackPanel" TargetType="{x:Type StackPanel}">
                <Setter Property="Margin" Value="0,10,0,0" />
                <Setter Property="MaxWidth" Value="250" />
            </Style>
        </DockPanel.Resources>
        <StackPanel DockPanel.Dock="Bottom" Margin="0">
            <StackPanel
                Orientation="Horizontal"
                HorizontalAlignment="Center"
                Margin="0,0,0,15">
                <controls:OcticonCircleButton
                    TabIndex="2"
                    Icon="check"
                    IsDefault="True"
                    Command="{Binding LoginCommand}"
                    IsEnabled="{Binding IsValid, Mode=OneWay}"
                    Content="{x:Static properties:Resources.LoginLabel}" />
                <controls:OcticonCircleButton
                    TabIndex="3"
                    FontSize="12"
                    Icon="x"
                    IsCancel="True"
                    Command="{Binding CancelCommand}"
                    Margin="18,0,0,0"
                    Content="{x:Static properties:Resources.CancelText}" />
            </StackPanel>
            <TextBlock TextWrapping="Wrap" HorizontalAlignment="Center" Margin="0" Text="{x:Static properties:Resources.DoNotHaveAccountText}">
                <Hyperlink
                    ToolTip="https://github.com/pricing"
                    Command="{Binding SignUpCommand}"
                    CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=ToolTip}">
                    <TextBlock Text="{x:Static properties:Resources.SignUpLinkText}" />
                </Hyperlink>
            </TextBlock>
            <TextBlock HorizontalAlignment="Center" Margin="0,3,0,0">
                <Hyperlink
                    ToolTip="https://github.com/password_reset"
                    Command="{Binding ForgotPasswordCommand}"
                    CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=ToolTip}">
                    <TextBlock Text="{x:Static properties:Resources.ForgotPasswordText}" />
                </Hyperlink>
            </TextBlock>
        </StackPanel>

        <StackPanel DockPanel.Dock="Top">
            <controls:OcticonImage Icon="logo_github" Style="{DynamicResource GitHubLogo}" />

            <TextBlock
                HorizontalAlignment="Center"
                Margin="0,0,0,10"
                Style="{DynamicResource GitHubH1TextBlock}"
                IsHitTestVisible="False"
                Text="{x:Static properties:Resources.LoginLabel}" />

            <controls:HorizontalShadowDivider />
        </StackPanel>

        <StackPanel Style="{StaticResource FormFieldStackPanel}">

            <sharedControls:PromptTextBox
                x:Name="loginTextBox"
                PromptText="{x:Static properties:Resources.LoginPromptText}"
                Text="{Binding Login, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

            <controls:ValidationMessage Validator="{Binding LoginValidator, Mode=OneWay}" />

            <sharedControls:MaskedPasswordBox
                Password="{Binding Password, Mode=OneWayToSource}"
                PromptText="{x:Static properties:Resources.PasswordPromptText}" />

            <controls:ValidationMessage Validator="{Binding PasswordValidator, Mode=OneWay}" />
        </StackPanel>
    </DockPanel>
</sharedControls:DialogUserControl>
