<!--
/**** Git Credential Manager for Windows ****
 *
 * Copyright (c) Atlassian
 * All rights reserved.
 *
 * MIT License
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the """"Software""""), to deal
 * in the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
**/
-->
<sharedControls:DialogUserControl
    x:Class="Atlassian.Bitbucket.Authentication.Controls.CredentialsControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:Atlassian.Bitbucket.Authentication.Controls"
    xmlns:properties="clr-namespace:Atlassian.Bitbucket.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,0,0,0" />
                <Setter Property="LastChildFill" Value="True" />
            </Style>
            <Style x:Key="FormFieldStackPanel" TargetType="{x:Type StackPanel}">
                <Setter Property="Margin" Value="0,0,0,0" />
                <Setter Property="MaxWidth" Value="400" />
                <Setter Property="Height" Value="320"/>
                <Setter Property="Background" Value="{StaticResource PrimaryForeground}"/>
            </Style>
            <Style x:Key="ExtraInformationStackPanel" TargetType="{x:Type StackPanel}">
                <Setter Property="Margin" Value="0,0,0,0" />
                <Setter Property="MaxWidth" Value="400" />
                <Setter Property="Background" Value="{StaticResource PrimaryBackground}"/>
            </Style>
        </DockPanel.Resources>
        <StackPanel DockPanel.Dock="Bottom" Margin="0">

            <StackPanel  Style="{StaticResource ExtraInformationStackPanel}">
                <TextBlock

                    HorizontalAlignment="Center" Margin="0,0,0,0">
                <Hyperlink
                    Style="{StaticResource LightHyperlink}"
                    ToolTip="https://bitbucket.org/account/password/reset/"
                    Command="{Binding ForgotPasswordCommand}"
                    CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=ToolTip}">
                    <TextBlock Text="{x:Static properties:Resources.ForgotPasswordText}" />
                </Hyperlink>
            </TextBlock>
                <TextBlock TextWrapping="Wrap" HorizontalAlignment="Center"  Margin="0,11,0,0">
                    <Hyperlink
                        Style="{StaticResource LightHyperlink}"
                    ToolTip="https://bitbucket.org/account/signup/"
                    Command="{Binding SignUpCommand}"
                    CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=ToolTip}">
                    <TextBlock Text="{x:Static properties:Resources.SignUpLinkText}" />
                </Hyperlink>
                </TextBlock>
            </StackPanel>
        </StackPanel>

        <StackPanel DockPanel.Dock="Top">
            <Image Style="{StaticResource AtlassianLogo}" 
                   HorizontalAlignment="Center"/>
            <TextBlock Style="{StaticResource LightLogoStrapline}" 
                       HorizontalAlignment="Center"
                       Text="Log in to your account"/>
        </StackPanel>

        <Border Style="{StaticResource ForegroundStackPanelBorder}"
                Margin="0,10,0,0">
            <StackPanel Style="{StaticResource FormFieldStackPanel}">
                <Border Style="{StaticResource EditableTextBoxBorder}"
                    Height="36"
                    Width="304"
                    Margin="0,11,0,0">
                    <StackPanel>
                        <sharedControls:PromptTextBox
                            x:Name="loginTextBox"
                            PromptText="{x:Static properties:Resources.LoginPromptText}"
                            Text="{Binding Login, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                            Width="288"
                            Height="22"
                            Margin="0"
                            VerticalAlignment="Center"/>    
                    </StackPanel>
                </Border>
                <StackPanel Height="22"
                            Width="288"
                            Margin="0,-11,0,11">
                    <controls:ValidationMessage Validator="{Binding LoginValidator, Mode=OneWay}" VerticalAlignment="Top"/>
                </StackPanel>
                
                <Border Style="{StaticResource EditableTextBoxBorder}"
                    Height="36"
                    Width="304"
                    Margin="0,0,0,0">
                    <StackPanel>
                        <sharedControls:MaskedPasswordBox
                            x:Name="passwordTextBox"
                            Password="{Binding Password, Mode=OneWayToSource}"
                            PromptText="{x:Static properties:Resources.PasswordPromptText}"
                            Width="288"
                            Height="22"
                            VerticalAlignment="Center"
                            Margin="0"/>
                    </StackPanel>
                </Border>
                <StackPanel Height="22"
                            Width="288"
                            Margin="0,-11,0,11">
                    <controls:ValidationMessage Validator="{Binding PasswordValidator, Mode=OneWay}" />
                </StackPanel>


                <Button
                    TabIndex="2"
                    IsDefault="True"
                    Command="{Binding LoginCommand}"
                    IsEnabled="{Binding IsValid, Mode=OneWay}"
                    Content="{x:Static properties:Resources.ContinueLabel}"
                        Style="{StaticResource PrimaryButton}"
                Width="280"
                Margin="0,0,0,11"/>
            </StackPanel>
        </Border>
        
    </DockPanel>
</sharedControls:DialogUserControl>
