浏览代码

一卡通

Lishi
xxe 2 年前
父节点
当前提交
b8ab4f2ead
共有 3 个文件被更改,包括 333 次插入57 次删除
  1. +23
    -0
      HKCardIN/ValidataRule.cs
  2. +74
    -0
      HKCardIN/ViewModels/RootViewModel.cs
  3. +236
    -57
      HKCardIN/Views/RootView.xaml

+ 23
- 0
HKCardIN/ValidataRule.cs 查看文件

@@ -0,0 +1,23 @@
using HandyControl.Tools.Extension;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace HKCardIN
{
public class ValidataRule : ValidationRule
{
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
if(value.ToString().IsNullOrEmpty()) return ValidationResult.ValidResult;
var reg = Regex.IsMatch(value.ToString(), "\\d+");
if (!reg) return new ValidationResult(false, "请输入正整数");
else return ValidationResult.ValidResult;
}
}
}

+ 74
- 0
HKCardIN/ViewModels/RootViewModel.cs 查看文件

@@ -1,12 +1,86 @@
using Stylet;
using System.Windows;

namespace HKCardIN.ViewModels
{
public class RootViewModel : Conductor<IScreen>
{
bool IsLocker = false;

public RootViewModel()
{
CodeVisible = Visibility.Collapsed;
ContentVisible = Visibility.Visible;
}

#region 属性
decimal _ShowMoney;
public decimal ShowMoney
{
get => _ShowMoney;
set => SetAndNotify(ref _ShowMoney, value);
}
Visibility _ContentVisible;
public Visibility ContentVisible
{
get => _ContentVisible;
set => SetAndNotify(ref _ContentVisible, value);
}
Visibility _CodeVisible;
public Visibility CodeVisible
{
get => _CodeVisible;
set => SetAndNotify(ref _CodeVisible, value);
}
string _LockCode;
public string LockCode
{
get => _LockCode;
set => SetAndNotify(ref _LockCode, value);
}
string _InputMoney;
public string InputMoney
{
get => _InputMoney;
set
{
SetAndNotify(ref _InputMoney, value);
decimal.TryParse(value, out decimal data);
ShowMoney = data;
}
}
#endregion

#region 命令
public void InputAction(string input)
{
if (IsLocker) return;
ShowMoney = decimal.Parse(input);
}
public void LockSreenAction()
{
IsLocker = true;
ContentVisible = Visibility.Collapsed;
CodeVisible = Visibility.Visible;
}
public void UnLockAction()
{
if (LockCode.Equals("123"))
{
IsLocker = false;
CodeVisible = Visibility.Collapsed;
ContentVisible = Visibility.Visible;
LockCode = string.Empty;
}
}
public void ResetAction()
{
LockCode = string.Empty;
}
public void SaveAction()
{

}
#endregion
}
}

+ 236
- 57
HKCardIN/Views/RootView.xaml 查看文件

@@ -4,105 +4,284 @@
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"
Title="海科智慧一卡通平台"
Width="800"
Height="500"
Width="700"
Height="420"
d:DataContext="{d:DesignInstance Type=viewModels:RootViewModel}"
ShowMaxButton="False"
ShowTitle="True"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<hc: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>
</hc:Window.Resources>
<hc:Window.InputBindings>
<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}" />
</hc:Window.InputBindings>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel Margin="0,12,0,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border
Width="100"
Height="120"
BorderBrush="BlanchedAlmond"
BorderThickness="1">
<Border.Effect>
<DropShadowEffect ShadowDepth="1" Color="Black" />
</Border.Effect>
<Image
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Visibility="{Binding CodeVisible}">
<TextBox
Width="200"
hc:InfoElement.Placeholder="请输入解锁码"
Style="{StaticResource TextBoxExtend}"
Text="{Binding LockCode}" />
<WrapPanel Margin="0,10,0,0" HorizontalAlignment="Center">
<Button
Width="60"
Height="40"
Margin="0,0,10,0"
Command="{s:Action UnLockAction}"
Content="确定"
FontSize="15" />
<Button
Width="60"
Height="40"
Margin="10,0,0,0"
Command="{s:Action ResetAction}"
Content="取消"
FontSize="15" />
</WrapPanel>
</StackPanel>
<Grid Visibility="{Binding ContentVisible}">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<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"
Source="/HKResouces/头像.png"
Stretch="UniformToFill" />
</Border>
<StackPanel Grid.Column="1">
BorderBrush="BlanchedAlmond"
BorderThickness="1">
<Border.Effect>
<DropShadowEffect ShadowDepth="1" Color="Black" />
</Border.Effect>
<Image
Width="100"
Height="120"
Source="/HKResouces/头像.png"
Stretch="UniformToFill" />
</Border>
<StackPanel Grid.Column="1">
<WrapPanel>
<TextBlock
FontSize="18"
Style="{StaticResource TextBlockDefaultBold}"
Text="姓名:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="李四" />
</WrapPanel>
<WrapPanel Margin="0,20,0,0">
<TextBlock
FontSize="18"
Style="{StaticResource TextBlockDefaultBold}"
Text="手机:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="13812345678" />
</WrapPanel>
<WrapPanel Margin="0,20,0,0">
<TextBlock
FontSize="18"
Style="{StaticResource TextBlockDefaultBold}"
Text="员工号:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="001" />
</WrapPanel>
</StackPanel>
</Grid>
<hc:Divider
Content="卡信息"
FontSize="16"
FontWeight="Bold" />
<StackPanel Margin="20,0,0,0">
<WrapPanel>
<TextBlock
FontSize="18"
Style="{StaticResource TextBlockDefaultBold}"
Text="姓名:" />
Text="卡号:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="123456" />
</WrapPanel>
<WrapPanel Margin="0,20,0,0">
<TextBlock
FontSize="18"
Style="{StaticResource TextBlockDefaultBold}"
Text="卡状态:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="李四" />
Text="正常" />
</WrapPanel>
<WrapPanel Margin="0,20,0,0">
<TextBlock
FontSize="18"
Style="{StaticResource TextBlockDefaultBold}"
Text="手机:" />
Text="卡上余额:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="13812345678" />
Text="123456" />
</WrapPanel>
<WrapPanel Margin="0,20,0,0">
<TextBlock
FontSize="18"
Style="{StaticResource TextBlockDefaultBold}"
Text="员工号:" />
Text="启用日期:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="001" />
Text="2021-01-01" />
</WrapPanel>
</StackPanel>
</Grid>
<hc:Divider
Content="卡信息"
FontSize="16"
FontWeight="Bold" />
<StackPanel Margin="20,0,0,0">
</StackPanel>
<StackPanel Grid.Column="1">
<hc:Divider
Content="充值金额"
FontSize="16"
FontWeight="Bold" />
<TextBlock Margin="5,0,0,0" FontSize="15">
<Run Text="当前充值金额:" />
<Run Foreground="Red" Text="{Binding ShowMoney}" />
</TextBlock>
<WrapPanel>
<TextBlock
FontSize="18"
Style="{StaticResource TextBlockDefaultBold}"
Text="卡号:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="123456" />
<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 Margin="0,20,0,0">
<TextBlock
FontSize="18"
Style="{StaticResource TextBlockDefaultBold}"
Text="卡上余额:" />
<TextBlock
FontSize="18"
Foreground="Red"
Style="{StaticResource TextBlockDefaultBold}"
Text="123456" />
<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>
<hc:Divider
Content="操作"
FontSize="16"
FontWeight="Bold" />
<WrapPanel HorizontalAlignment="Center">
<Button
Command="{s:Action SaveAction}"
Content="确定[Enter]"
IsDefault="True"
Style="{StaticResource 操作}" />
<Button
Command="{s:Action LockSreenAction}"
Content="锁屏[F5]"
IsDefault="True"
Style="{StaticResource 操作}" />
</WrapPanel>
</StackPanel>
</StackPanel>
</Grid>
</Grid>
</hc:Window>

正在加载...
取消
保存