<Window
    x:Class="HKCardIN.Views.RootView"
    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:hc="https://handyorg.github.io/handycontrol"
    xmlns:local="clr-namespace:HKCardIN"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:s="https://github.com/canton7/Stylet"
    xmlns:viewModels="clr-namespace:HKCardIN.ViewModels"
    x:Name="Root"
    Title="海科智慧一卡通平台"
    Width="900"
    Height="480"
    d:DataContext="{d:DesignInstance Type=viewModels:RootViewModel}"
    ResizeMode="CanMinimize"
    WindowStartupLocation="CenterScreen"
    mc:Ignorable="d">
    <Window.Resources>
        <Style
            x:Key="充值"
            BasedOn="{StaticResource ButtonDefault}"
            TargetType="Button">
            <Setter Property="Width" Value="75" />
            <Setter Property="Height" Value="75" />
            <Setter Property="Margin" Value="5" />
            <Setter Property="Foreground" Value="Red" />
            <Setter Property="FontSize" Value="18" />
        </Style>
        <Style
            x:Key="操作"
            BasedOn="{StaticResource ButtonDefault}"
            TargetType="Button">
            <Setter Property="Width" Value="120" />
            <Setter Property="Height" Value="75" />
            <Setter Property="Margin" Value="5" />
            <Setter Property="Foreground" Value="Red" />
            <Setter Property="FontSize" Value="18" />
        </Style>
        <Style
            x:Key="Title"
            BasedOn="{StaticResource TextBlockDefaultBold}"
            TargetType="TextBlock">
            <Setter Property="Foreground" Value="WhiteSmoke" />
        </Style>
    </Window.Resources>
    <Window.Background>
        <ImageBrush ImageSource="/HKResouces/背景.jpg" />
    </Window.Background>
    <Window.InputBindings>
        <KeyBinding
            Key="E"
            Command="{s:Action UnLockAction}"
            CommandParameter="{Binding ., ElementName=Pwd}" />
        <KeyBinding Key="R" Command="{s:Action ReadAction}" />
        <KeyBinding
            Key="F1"
            Command="{s:Action InputAction}"
            CommandParameter="50" />
        <KeyBinding
            Key="F2"
            Command="{s:Action InputAction}"
            CommandParameter="100" />
        <KeyBinding
            Key="F3"
            Command="{s:Action InputAction}"
            CommandParameter="200" />
        <KeyBinding
            Key="F4"
            Command="{s:Action InputAction}"
            CommandParameter="500" />
        <KeyBinding Key="F5" Command="{s:Action LockSreenAction}" />
    </Window.InputBindings>
    <Grid>
        <StackPanel
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Visibility="{Binding CodeVisible}">
            <hc:PasswordBox
                x:Name="Pwd"
                Width="200"
                hc:InfoElement.Placeholder="请输入解锁码"
                hc:PasswordBoxAttach.PasswordLength="20"
                ShowClearButton="True"
                Style="{StaticResource PasswordBoxPlusBaseStyle}" />
            <WrapPanel Margin="0,10,0,0" HorizontalAlignment="Center">
                <Button
                    Width="70"
                    Height="40"
                    Margin="0,0,10,0"
                    Command="{s:Action UnLockAction}"
                    CommandParameter="{Binding ., ElementName=Pwd}"
                    Content="确定[E]"
                    FontSize="15" />
            </WrapPanel>
        </StackPanel>
        <Grid Visibility="{Binding ContentVisible}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="13" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <StackPanel Margin="0,12,0,0">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width=".4*" />
                        <ColumnDefinition Width=".6*" />
                    </Grid.ColumnDefinitions>
                    <Border
                        Width="100"
                        Height="120"
                        BorderBrush="BlanchedAlmond"
                        BorderThickness="1">
                        <Border.Effect>
                            <DropShadowEffect ShadowDepth="1" Color="Black" />
                        </Border.Effect>
                        <Image
                            Width="100"
                            Height="120"
                            Source="{Binding Info.MemberHeadImgUrl}"
                            Stretch="UniformToFill" />
                    </Border>
                    <StackPanel Grid.Column="1">
                        <WrapPanel>
                            <TextBlock
                                FontSize="18"
                                Style="{StaticResource Title}"
                                Text="姓名：" />
                            <TextBlock
                                FontSize="18"
                                Foreground="Red"
                                Style="{StaticResource TextBlockDefaultBold}"
                                Text="{Binding Info.MemberName}" />
                        </WrapPanel>
                        <WrapPanel Margin="0,20,0,0">
                            <TextBlock
                                FontSize="18"
                                Style="{StaticResource Title}"
                                Text="手机：" />
                            <TextBlock
                                FontSize="18"
                                Foreground="Red"
                                Style="{StaticResource TextBlockDefaultBold}"
                                Text="{Binding Info.MemberPhone}" />
                        </WrapPanel>
                        <WrapPanel Margin="0,20,0,0">
                            <TextBlock
                                FontSize="18"
                                Style="{StaticResource Title}"
                                Text="身份证：" />
                            <TextBlock
                                FontSize="18"
                                Foreground="Red"
                                Style="{StaticResource TextBlockDefaultBold}"
                                Text="{Binding Info.MemberCardId}" />
                        </WrapPanel>
                    </StackPanel>
                </Grid>
                <hc:Divider
                    Content="卡信息"
                    FontSize="16"
                    FontWeight="Bold"
                    Foreground="WhiteSmoke" />
                <StackPanel Margin="20,0,0,0">
                    <WrapPanel>
                        <TextBlock
                            FontSize="18"
                            Style="{StaticResource Title}"
                            Text="卡号：" />
                        <TextBlock
                            FontSize="18"
                            Foreground="Red"
                            Style="{StaticResource TextBlockDefaultBold}"
                            Text="{Binding Info.CardNum}" />
                    </WrapPanel>
                    <WrapPanel Margin="0,30,0,0">
                        <TextBlock
                            FontSize="18"
                            Style="{StaticResource Title}"
                            Text="卡状态：" />
                        <TextBlock
                            FontSize="18"
                            Foreground="Red"
                            Style="{StaticResource TextBlockDefaultBold}"
                            Text="{Binding Info.Stutas}" />
                    </WrapPanel>
                    <WrapPanel Margin="0,30,0,0">
                        <TextBlock
                            FontSize="18"
                            Style="{StaticResource Title}"
                            Text="卡上余额：" />
                        <TextBlock
                            FontSize="18"
                            Foreground="Red"
                            Style="{StaticResource TextBlockDefaultBold}"
                            Text="{Binding Info.Money}" />
                    </WrapPanel>
                    <WrapPanel Margin="0,30,0,0">
                        <TextBlock
                            FontSize="18"
                            Style="{StaticResource Title}"
                            Text="启用日期：" />
                        <TextBlock
                            FontSize="18"
                            Foreground="Red"
                            Style="{StaticResource TextBlockDefaultBold}"
                            Text="{Binding Info.CreateAt, StringFormat={}{0:yyyy-MM-dd}}" />
                    </WrapPanel>
                </StackPanel>
            </StackPanel>
            <hc:Divider
                Grid.Column="1"
                Height="{Binding ActualHeight, ElementName=Root}"
                Orientation="Vertical" />
            <StackPanel Grid.Column="2">
                <hc:Divider
                    Content="充值金额"
                    FontSize="16"
                    FontWeight="Bold"
                    Foreground="WhiteSmoke" />
                <TextBlock
                    Margin="5,0,0,0"
                    FontSize="18"
                    Style="{StaticResource Title}">
                    <Run Foreground="WhiteSmoke" Text="当前充值金额：" />
                    <Run Foreground="Red" Text="{Binding ShowMoney}" />
                </TextBlock>
                <WrapPanel HorizontalAlignment="Center">
                    <Button
                        Command="{s:Action InputAction}"
                        CommandParameter="50"
                        Style="{StaticResource 充值}">
                        <Button.Content>
                            <StackPanel HorizontalAlignment="Center">
                                <TextBlock HorizontalAlignment="Center" Text="￥50" />
                                <TextBlock HorizontalAlignment="Center" Text="[F1]" />
                            </StackPanel>
                        </Button.Content>
                    </Button>
                    <Button
                        Command="{s:Action InputAction}"
                        CommandParameter="100"
                        Style="{StaticResource 充值}">
                        <Button.Content>
                            <StackPanel HorizontalAlignment="Center">
                                <TextBlock HorizontalAlignment="Center" Text="￥100" />
                                <TextBlock HorizontalAlignment="Center" Text="[F2]" />
                            </StackPanel>
                        </Button.Content>
                    </Button>
                    <Button
                        Command="{s:Action InputAction}"
                        CommandParameter="200"
                        Style="{StaticResource 充值}">
                        <Button.Content>
                            <StackPanel HorizontalAlignment="Center">
                                <TextBlock HorizontalAlignment="Center" Text="￥200" />
                                <TextBlock HorizontalAlignment="Center" Text="[F3]" />
                            </StackPanel>
                        </Button.Content>
                    </Button>
                    <Button
                        Command="{s:Action InputAction}"
                        CommandParameter="500"
                        Style="{StaticResource 充值}">
                        <Button.Content>
                            <StackPanel HorizontalAlignment="Center">
                                <TextBlock HorizontalAlignment="Center" Text="￥500" />
                                <TextBlock HorizontalAlignment="Center" Text="[F4]" />
                            </StackPanel>
                        </Button.Content>
                    </Button>
                </WrapPanel>
                <WrapPanel HorizontalAlignment="Center">
                    <TextBox
                        Width="330"
                        Margin="5,10,0,10"
                        HorizontalAlignment="Left"
                        hc:InfoElement.Placeholder="请输入自定义金额"
                        Style="{StaticResource TextBoxExtend}">
                        <TextBox.Text>
                            <Binding Path="InputMoney" UpdateSourceTrigger="PropertyChanged">
                                <Binding.ValidationRules>
                                    <local:ValidataRule />
                                </Binding.ValidationRules>
                            </Binding>
                        </TextBox.Text>
                    </TextBox>
                </WrapPanel>
                <WrapPanel HorizontalAlignment="Center">
                    <TextBox
                        Width="330"
                        Margin="5,0,0,10"
                        HorizontalAlignment="Left"
                        hc:InfoElement.Placeholder="手动录入卡号"
                        Style="{StaticResource TextBoxExtend}"
                        Text="{Binding CardNo}" />
                </WrapPanel>
                <hc:Divider
                    Content="操作"
                    FontSize="16"
                    FontWeight="Bold"
                    Foreground="WhiteSmoke" />
                <WrapPanel HorizontalAlignment="Center">
                    <Button
                        Command="{s:Action ReadAction}"
                        Content="读卡[R]"
                        IsDefault="True"
                        Style="{StaticResource 操作}" />
                    <Button
                        Command="{s:Action SaveAction}"
                        Content="确定[Enter]"
                        IsDefault="True"
                        Style="{StaticResource 操作}" />
                    <Button
                        Command="{s:Action LockSreenAction}"
                        Content="锁屏[F5]"
                        IsDefault="True"
                        Style="{StaticResource 操作}" />
                </WrapPanel>
            </StackPanel>
        </Grid>
    </Grid>
</Window>
