Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

RootViewModel.cs 3.3 KiB

il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using HKCardIN.Helper;
  2. using Stylet;
  3. using System;
  4. using System.Threading;
  5. using System.Windows;
  6. namespace HKCardIN.ViewModels
  7. {
  8. public class RootViewModel : Conductor<IScreen>
  9. {
  10. bool IsLocker = false;
  11. public RootViewModel()
  12. {
  13. CodeVisible = Visibility.Collapsed;
  14. ContentVisible = Visibility.Visible;
  15. MainThread();
  16. }
  17. #region 属性
  18. decimal _ShowMoney;
  19. public decimal ShowMoney
  20. {
  21. get => _ShowMoney;
  22. set => SetAndNotify(ref _ShowMoney, value);
  23. }
  24. Visibility _ContentVisible;
  25. public Visibility ContentVisible
  26. {
  27. get => _ContentVisible;
  28. set => SetAndNotify(ref _ContentVisible, value);
  29. }
  30. Visibility _CodeVisible;
  31. public Visibility CodeVisible
  32. {
  33. get => _CodeVisible;
  34. set => SetAndNotify(ref _CodeVisible, value);
  35. }
  36. string _InputMoney;
  37. public string InputMoney
  38. {
  39. get => _InputMoney;
  40. set
  41. {
  42. SetAndNotify(ref _InputMoney, value);
  43. decimal.TryParse(value, out decimal data);
  44. ShowMoney = data;
  45. }
  46. }
  47. string _CardNo;
  48. public string CardNo
  49. {
  50. get => _CardNo;
  51. set => SetAndNotify(ref _CardNo, value);
  52. }
  53. #endregion
  54. #region 命令
  55. public void InputAction(string input)
  56. {
  57. if (IsLocker) return;
  58. ShowMoney = decimal.Parse(input);
  59. }
  60. public void LockSreenAction()
  61. {
  62. IsLocker = true;
  63. ContentVisible = Visibility.Collapsed;
  64. CodeVisible = Visibility.Visible;
  65. }
  66. public void UnLockAction(HandyControl.Controls.PasswordBox input)
  67. {
  68. if (input.Password.Equals(DataBus.LockCode))
  69. {
  70. IsLocker = false;
  71. CodeVisible = Visibility.Collapsed;
  72. ContentVisible = Visibility.Visible;
  73. }
  74. }
  75. public void SaveAction()
  76. {
  77. var c = CardNo;
  78. var m = ShowMoney;
  79. if (!DataBus.NetWordState)
  80. {
  81. HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络!!!");
  82. return;
  83. }
  84. }
  85. #endregion
  86. #region 方法
  87. private void MainThread() {
  88. ThreadManage.GetInstance().StartLong(new Action(() =>
  89. {
  90. try
  91. {
  92. //1.检测网络上下线
  93. bool network = HKHelper.GetInstance().GetNetworkState();
  94. if (network != DataBus.NetWordState)
  95. {
  96. if (network) HandyControl.Controls.Growl.InfoGlobal("网络连接成功");
  97. else HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络!!!");
  98. DataBus.NetWordState = network;
  99. }
  100. Thread.Sleep(3000);
  101. }
  102. catch (Exception ex)
  103. {
  104. HandyControl.Controls.Growl.InfoGlobal(ex.Message);
  105. }
  106. }), "循环状态监测线程", false);
  107. }
  108. #endregion
  109. }
  110. }