<Window x:Class="BodyshopPartner.Views.Login"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:BodyshopPartner.Views"
        xmlns:vm="clr-namespace:BodyshopPartner.ViewModels"
        mc:Ignorable="d"
        Title="{x:Static p:Resources.Title_Login}"
        Height="325"
        Width="475"
        xmlns:p="clr-namespace:BodyshopPartner.Properties"
        xmlns:util="clr-namespace:BodyshopPartner.Utils"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        TextElement.Foreground="{DynamicResource MaterialDesignBody}"
        TextElement.FontWeight="Regular"
        TextElement.FontSize="13"
        TextOptions.TextFormattingMode="Ideal"
        TextOptions.TextRenderingMode="Auto"
        Background="{DynamicResource MaterialDesignPaper}"
        FontFamily="{DynamicResource MaterialDesignFont}"
        Closing="Window_Closing"
        ResizeMode="NoResize"
        WindowStartupLocation="CenterScreen">
    <Window.DataContext>
        <vm:LoginViewModel />
    </Window.DataContext>
    <Window.Resources>
        <util:NullVisibilityConverter x:Key="NullVisibilityConverter" />

        <Style TargetType="StackPanel">
            <Setter Property="Margin"
                    Value="8" />
        </Style>
        <Style TargetType="TextBox"
               BasedOn="{StaticResource MaterialDesignFloatingHintTextBox}">
            <Setter Property="Margin"
                    Value="8" />
        </Style>
        <Style TargetType="materialDesign:PackIcon">
            <Setter Property="Margin"
                    Value="8" />
        </Style>
        <Style TargetType="Image">
            <Setter Property="Margin"
                    Value="8" />
        </Style>
    </Window.Resources>

    <StackPanel>
        <StackPanel Orientation="Horizontal">
            <Image Source="/Assets/logo1024.png"
                   Height="48"
                   Width="48"
                   VerticalAlignment="Center" />

            <TextBlock Text="{x:Static p:Resources.Title_Login_Header}"
                       Style="{StaticResource MaterialDesignHeadline6TextBlock}"
                       VerticalAlignment="Center" />
        </StackPanel>

        <StackPanel Orientation="Vertical"
                    HorizontalAlignment="Center">
            <StackPanel Orientation="Horizontal">
                <materialDesign:PackIcon Kind="Person"
                                         VerticalAlignment="Center" />
                <TextBox materialDesign:HintAssist.Hint="{x:Static p:Resources.Username}"
                         Width="300"
                         Text="{Binding UserName}" />
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <materialDesign:PackIcon Kind="Key"
                                         VerticalAlignment="Center" />
                <PasswordBox materialDesign:HintAssist.Hint="{x:Static p:Resources.Password}"
                             KeyDown="PasswordBox_KeyDown"
                             PasswordChanged="PasswordBox_PasswordChanged"
                             Width="300" />
            </StackPanel>
        </StackPanel>

        <TextBlock Text="{Binding ErrorMsg}"
                   Visibility="{Binding ErrorMsg, Converter={StaticResource NullVisibilityConverter}}" />

        <Button Command="{Binding LoginCommand}"
                CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
                Content="{x:Static p:Resources.Login}"
                Style="{StaticResource MaterialDesignRaisedButton}"
                IsDefault="True"
                materialDesign:ButtonProgressAssist.Value="-1"
                materialDesign:ButtonProgressAssist.IsIndicatorVisible="True"
                materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Loading}" />
    </StackPanel>
</Window>
