<Window x:Class="Txgy.EWS.Client.Start.Views.LoginView"
        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:local="clr-namespace:Txgy.EWS.Client.Start.Views"
        xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
        xmlns:controls="clr-namespace:Txgy.Controls;assembly=Txgy.Controls"
        xmlns:common="clr-namespace:Txgy.EWS.Client.Common;assembly=Txgy.EWS.Client.Common"
        xmlns:converter="clr-namespace:Txgy.EWS.Client.Common.Converters;assembly=Txgy.EWS.Client.Common"
        xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
        xmlns:pass="clr-namespace:Txgy.EWS.Client.Common.Extensions;assembly=Txgy.EWS.Client.Common"
        xmlns:prism="http://prismlibrary.com/"
        xmlns:global="clr-namespace:Txgy.EWS.Client.Common;assembly=Txgy.EWS.Client.Common"
        Name="window"
        Title="{Binding Path=(global:GlobalConfig.SystemShortName), StringFormat={}{0}登录}"
        Width="750"
        Height="463.5"
        prism:ViewModelLocator.AutoWireViewModel="true"
        ResizeMode="NoResize"
        WindowStyle="None"
        Background="Transparent"
        WindowStartupLocation="CenterScreen"
        mc:Ignorable="d">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Txgy.EWS.Client.Assets;component/Styles/BaseResources.xaml" />
                <ResourceDictionary Source="pack://application:,,,/Txgy.EWS.Client.Assets;component/Styles/ButtonStyles.xaml" />
                <ResourceDictionary>
                    <converter:Bool2BlurConverter x:Key="Bool2Blur" />
                    <converter:Bool2VisibilityConverter x:Key="Bool2Visibility" />

                    <ControlTemplate x:Key="UserNameTextBoxTemplate" TargetType="TextBox">
                        <Border x:Name="border"
                                BorderBrush="#DDD"
                                BorderThickness="0,0,0,1"
                                Background="{TemplateBinding Background}"
                                SnapsToDevicePixels="True">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="30" />
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="30" />
                                </Grid.ColumnDefinitions>
                                <TextBlock HorizontalAlignment="Center"
                                           VerticalAlignment="Center"
                                           Text="&#xeaa0;"
                                           FontFamily="{StaticResource Iconfont}"
                                           FontSize="20"
                                           Foreground="#BBB" />
                                <ScrollViewer x:Name="PART_ContentHost"
                                              Grid.Column="1"
                                              Margin="0,5,0,0"
                                              Focusable="false"
                                              HorizontalScrollBarVisibility="Hidden"
                                              VerticalScrollBarVisibility="Hidden" />
                                <TextBlock Grid.Column="2"
                                           HorizontalAlignment="Center"
                                           VerticalAlignment="Center"
                                           Text="&#xe6df;"
                                           FontFamily="{StaticResource Iconfont}"
                                           FontSize="18"
                                           Foreground="#BBB" />
                            </Grid>
                        </Border>
                    </ControlTemplate>

                    <ControlTemplate x:Key="PasswordBoxTemplate" TargetType="PasswordBox">
                        <Border x:Name="border"
                                BorderBrush="#DDD"
                                BorderThickness="0,0,0,1"
                                Background="{TemplateBinding Background}"
                                SnapsToDevicePixels="True">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="30" />
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="30" />
                                </Grid.ColumnDefinitions>
                                <TextBlock HorizontalAlignment="Center"
                                           VerticalAlignment="Center"
                                           Text="&#xe60a;"
                                           FontFamily="{StaticResource Iconfont}"
                                           FontSize="14"
                                           Foreground="#BBB" />
                                <ScrollViewer x:Name="PART_ContentHost"
                                              Grid.Column="1"
                                              Margin="0,5,0,0"
                                              Focusable="false"
                                              HorizontalScrollBarVisibility="Hidden"
                                              VerticalScrollBarVisibility="Hidden" />
                                <TextBlock Grid.Column="2"
                                           HorizontalAlignment="Center"
                                           VerticalAlignment="Center"
                                           Text="&#xe613;"
                                           FontFamily="{StaticResource Iconfont}"
                                           FontSize="16"
                                           Foreground="#BBB" />
                            </Grid>
                        </Border>
                    </ControlTemplate>

                    <Style TargetType="Hyperlink">
                        <Setter Property="Foreground" Value="#AAA" />
                        <Setter Property="TextBlock.TextDecorations" Value="{x:Null}" />
                        <Style.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Foreground" Value="#999" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>

                    <ControlTemplate x:Key="LoginButtonTemplate" TargetType="Button">
                        <Grid>
                            <Border CornerRadius="3">
                                <Border.Background>
                                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                        <GradientStop Offset="0" Color="#FF0ABEFF" />
                                        <GradientStop Offset="1" Color="#FF00B4FA" />
                                    </LinearGradientBrush>
                                </Border.Background>
                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                            </Border>
                            <Border Name="mask" CornerRadius="3" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="mask" Property="Background" Value="#22FFFFFF" />
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter TargetName="mask" Property="Background" Value="#11000000" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Window.InputBindings>
        <KeyBinding Command="{Binding LoginCommand}"
                    CommandParameter="{Binding ElementName=window}"
                    Gesture="Enter" />
    </Window.InputBindings>
    <WindowChrome.WindowChrome>
        <WindowChrome GlassFrameThickness="-1" CaptionHeight="0" />
    </WindowChrome.WindowChrome>
    <Grid Background="White">
        <Grid.Effect>
            <!--<BlurEffect Radius="{Binding IsLoading,Converter={StaticResource Bool2Blur}}"/>-->
            <DropShadowEffect ShadowDepth="0"
                              BlurRadius="10"
                              Opacity="0.8"
                              Color="#AAAAAA" />
        </Grid.Effect>
        <Grid.Style>
            <Style TargetType="Grid">
                <!-- 给阴影留出边距 -->
                <Style.Triggers>
                    <DataTrigger Binding="{Binding WindowState, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Value="Normal">
                        <Setter Property="Margin" Value="10" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding WindowState, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Value="Minimized">
                        <Setter Property="Margin" Value="10" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding WindowState, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Value="Maximized">
                        <Setter Property="Margin" Value="0" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Grid.Style>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1.5*" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="60" />
            <RowDefinition />
            <RowDefinition Height="60" />
        </Grid.RowDefinitions>
        <md:Snackbar x:Name="LoginSnakeBar"
                     Grid.RowSpan="2"
                     Grid.ColumnSpan="2"
                     Panel.ZIndex="1"
                     MessageQueue="{md:MessageQueue}" />
        <StackPanel Orientation="Horizontal">
            <Grid Background="Transparent" Visibility="{Binding IsLoading, Converter={StaticResource Bool2Visibility}}">
                <controls:Loading HorizontalAlignment="Left" />
            </Grid>
            <TextBlock x:Name="tbLoadingMessage"
                       Margin="10,10"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Center"
                       Text="{Binding LoadingMessage}"
                       Foreground="#333" />
        </StackPanel>

        <Image Grid.RowSpan="2"
               Margin="50"
               Source="pack://application:,,,/Txgy.EWS.Client.Assets;component/Images/login.png" />
        <StackPanel Grid.Column="1"
                    Margin="0,2,5,0"
                    HorizontalAlignment="Right">
            <Button Height="30"
                    Content="&#xe607;"
                    Foreground="#FF673AB7"
                    Style="{StaticResource IconButtonStyle}"
                    FontSize="20"
                    Background="Transparent"
                    Click="Button_Click" />
        </StackPanel>
        <md:Transitioner Grid.Row="1"
                         Grid.Column="1"
                         SelectedIndex="0">
            <md:TransitionerSlide>
                <DockPanel Margin="15" VerticalAlignment="Center">
                    <TextBlock Margin="0,10"
                               DockPanel.Dock="Top"
                               FontSize="22"
                               FontWeight="Bold"
                               Text="欢迎使用" />
                    <TextBox Margin="0,10"
                             md:HintAssist.Hint="请输入账号"
                             DockPanel.Dock="Top"
                             Text="{Binding UserName,UpdateSourceTrigger=PropertyChanged}" />
                    <PasswordBox Margin="0,10"
                                 md:HintAssist.Hint="请输入密码"
                                 pass:PassWordExtensions.PassWord="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                 DockPanel.Dock="Top">

                        <i:Interaction.Behaviors>
                            <pass:PasswordBehavior />
                        </i:Interaction.Behaviors>
                    </PasswordBox>
                    <Button x:Name="BtnLogin"
                            Width="120"
                            Height="40"
                            Command="{Binding LoginCommand}"
                            CommandParameter="{Binding ElementName=window}"
                            Content="登录系统"
                            DockPanel.Dock="Top"
                            Style="{StaticResource MaterialDesignFlatDarkBgButton}" />
                    <TextBlock Margin="0,5"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center"
                               Text="{Binding ErrorMsg}"
                               FontSize="14"
                               Foreground="Red" />
                    <!--#region 注册、忘记密码跳转-->
                    <!--<DockPanel Margin="0,5" LastChildFill="False">
                        <TextBlock Text="注册账号">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="MouseLeftButtonDown">
                                    <i:InvokeCommandAction Command="{Binding ExecuteCommand}" CommandParameter="ResgiterPage" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </TextBlock>
                        <TextBlock DockPanel.Dock="Right" Text="忘记密码?" />
                    </DockPanel>-->
                    <!--#endregion-->
                </DockPanel>
            </md:TransitionerSlide>
            <!--#region 注册页面-->
            <!--<md:TransitionerSlide>
                <DockPanel Margin="15" VerticalAlignment="Center">
                    <TextBlock
                        Margin="0,10"
                        DockPanel.Dock="Top"
                        FontSize="22"
                        FontWeight="Bold"
                        Text="注册账号" />

                    <TextBox
                        Margin="0,5"
                        md:HintAssist.Hint="请输入用户名"
                        DockPanel.Dock="Top"
                        Text="{Binding UserDto.Account}" />
                    <TextBox
                        Margin="0,5"
                        md:HintAssist.Hint="请输入账号"
                        DockPanel.Dock="Top"
                        Text="{Binding UserDto.UserName}" />

                    <PasswordBox
                        Margin="0,5"
                        md:HintAssist.Hint="请输入密码"

                        DockPanel.Dock="Top">
            -->
            <!-- pass:PassWordExtensions.PassWord="{Binding UserDto.PassWord, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" -->
            <!--
                        <i:Interaction.Behaviors>
                            <pass:PasswordBehavior />
                        </i:Interaction.Behaviors>
                    </PasswordBox>

                    <PasswordBox
                        Margin="0,5"
                        md:HintAssist.Hint="请再次输入密码"

                        DockPanel.Dock="Top">
            -->
            <!-- pass:PassWordExtensions.PassWord="{Binding UserDto.NewPassWord, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" -->
            <!--
                        <i:Interaction.Behaviors>
                            <pass:PasswordBehavior />
                        </i:Interaction.Behaviors>
                    </PasswordBox>

                    <Button
                        Command="{Binding ExecuteCommand}"
                        CommandParameter="Resgiter"
                        Content="注册账号"
                        DockPanel.Dock="Top" />

                    <Button
                        Margin="0,10"
                        Command="{Binding ExecuteCommand}"
                        CommandParameter="Return"
                        Content="返回登录"
                        DockPanel.Dock="Top"
                        Style="{StaticResource MaterialDesignOutlinedButton}" />
                </DockPanel>
            </md:TransitionerSlide>-->
            <!--#endregion-->
        </md:Transitioner>
    </Grid>
</Window>
