﻿<pu:WindowX x:Class="WPFProject.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:WPFProject"
            xmlns:pu="https://opensource.panuon.com/wpf-ui"
            xmlns:purs="clr-namespace:Panuon.WPF.UI.Resources;assembly=Panuon.WPF.UI"
            xmlns:dp="clr-namespace:HMI.UI.DpUtil;assembly=HMI.UI"
            mc:Ignorable="d"
            Title="{DynamicResource App.Login}"
            pu:WindowXCaption.Foreground="#FFF"
            Height="420"
            Width="380"
            pu:WindowXCaption.Background="Transparent"
            WindowStartupLocation="CenterScreen"
            Background="{StaticResource VerBar}"
            Closed="window_Closed"
            ContentRendered="WindowX_ContentRendered"
            pu:WindowXCaption.Buttons="Close">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <pu:StyleDictionary Includes="PasswordBox"/>
                <ResourceDictionary Source="/HMI.UI;component/Resources/Font/Font.xaml"/>
                <ResourceDictionary Source="/HMI.UI;component/Style/Colors.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <Style x:Key="SignInButtonStyle" TargetType="Button" BasedOn="{StaticResource PrimaryButton}">
                <Setter Property="pu:ButtonHelper.PendingSpinStyle">
                    <Setter.Value>
                        <Style TargetType="pu:Spin" BasedOn="{StaticResource {x:Static pu:ButtonHelper.PendingSpinStyleKey}}">
                            <Setter Property="SpinStyle" Value="Ring2" />
                        </Style>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="pu:ButtonHelper.IsPending" Value="True">
                        <Setter Property="IsEnabled" Value="False"/>
                        <Setter Property="pu:ButtonHelper.ClickEffect" Value="Shake" />
                        <Setter Property="ContentTemplate">
                            <Setter.Value>
                                <DataTemplate>
                                    <TextBlock Text="{DynamicResource App.PleaseWait}" />
                                </DataTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="RememberMeSwitchStyle"
       TargetType="pu:Switch">
                <Setter Property="ContentPlacement"
            Value="Left" />
                <Setter Property="BoxHeight"
            Value="16" />
                <Setter Property="BoxWidth"
            Value="32" />
                <Setter Property="CheckedBackground"
            Value="#6CBCEA" />
                <Setter Property="Background"
            Value="#DEDEDE" />
                <Setter Property="BorderBrush"
            Value="#DEDEDE" />
                <Setter Property="Foreground"
            Value="DimGray" />
                <Setter Property="ToggleSize"
            Value="10" />
                <Setter Property="ToggleShadowColor"
            Value="{x:Null}" />
                <Setter Property="CheckedBorderBrush"
            Value="#6CBCEA" />
            </Style>

            <Style TargetType="pu:FormGroup" BasedOn="{StaticResource InputFormGroupStyle}">
                <Setter Property="Width" Value="250" />
                <Setter Property="HeaderForeground" Value="White" />
            </Style>

        </ResourceDictionary>
    </Window.Resources>

    <Grid HorizontalAlignment="Center"
      VerticalAlignment="Center"
      Margin="0,-30,0,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Image Height="25"
               Stretch="Uniform"
           HorizontalAlignment="Left"
           Source="/Icon/JingCeLogo.png"
           RenderOptions.BitmapScalingMode="HighQuality" />
        <StackPanel Margin="0,50,0,0" Grid.Row="1" x:Name="formPanel" dp:StackPanelHelper.ChildSpace="20" >
            <pu:FormGroup x:Name="FrmAccount"
                          dp:FormGroupHelper.IsRequired="True">
                <TextBox x:Name="TbAccount" Style="{StaticResource EditorTextBoxStyle}"
         Background="White"
         pu:TextBoxHelper.InputLimit="UpperCaseLetters,LowerCaseLetters,Digit"
         pu:TextBoxHelper.Watermark="{DynamicResource App.Username}"/>
            </pu:FormGroup>
            <pu:FormGroup x:Name="FrmPassword" HeaderPadding="0,0,0,10"
          dp:FormGroupHelper.IsRequired="True"
          MinMessageHeight="22">
                <PasswordBox x:Name="PwdPassword" VerticalContentAlignment="Center" 
                             Style="{StaticResource SignInPasswordBoxStyle}" 
                             pu:PasswordBoxHelper.Watermark="{DynamicResource App.Password}"/>
            </pu:FormGroup>
        </StackPanel>

        <pu:Switch Grid.Row="3"
               HorizontalAlignment="Right"
               Margin="0,25,0,0"
                   x:Name="SwRememberMe"
                   Cursor="Hand"
                  Unchecked="SwRememberMe_Unchecked"
               Foreground="{StaticResource PrimaryColorContract}"
               Style="{StaticResource RememberMeSwitchStyle}"
               Content="{DynamicResource App.RememberMe}" />
        
        <Button Grid.Row="4"
            Margin="0,20,0,0"
            Height="40"
            Content="{DynamicResource App.Login}"
            Style="{StaticResource SignInButtonStyle}" x:Name="BtnLogin" Click="Button_Click">
        </Button>
    </Grid>
</pu:WindowX>
