Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

119 linhas
3.3 KiB

  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 _LockCode;
  37. public string LockCode
  38. {
  39. get => _LockCode;
  40. set => SetAndNotify(ref _LockCode, value);
  41. }
  42. string _InputMoney;
  43. public string InputMoney
  44. {
  45. get => _InputMoney;
  46. set
  47. {
  48. SetAndNotify(ref _InputMoney, value);
  49. decimal.TryParse(value, out decimal data);
  50. ShowMoney = data;
  51. }
  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()
  67. {
  68. if (LockCode.Equals(DataBus.LockCode))
  69. {
  70. IsLocker = false;
  71. CodeVisible = Visibility.Collapsed;
  72. ContentVisible = Visibility.Visible;
  73. LockCode = string.Empty;
  74. }
  75. }
  76. public void ResetAction()
  77. {
  78. LockCode = string.Empty;
  79. }
  80. public void SaveAction()
  81. {
  82. if (!DataBus.NetWordState)
  83. {
  84. HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络!!!");
  85. return;
  86. }
  87. }
  88. #endregion
  89. #region 方法
  90. private void MainThread() {
  91. ThreadManage.GetInstance().StartLong(new Action(() =>
  92. {
  93. try
  94. {
  95. //1.检测网络上下线
  96. bool network = HKHelper.GetInstance().GetNetworkState();
  97. if (network != DataBus.NetWordState)
  98. {
  99. if (network) HandyControl.Controls.Growl.InfoGlobal("网络连接成功");
  100. else HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络!!!");
  101. DataBus.NetWordState = network;
  102. }
  103. Thread.Sleep(3000);
  104. }
  105. catch (Exception ex)
  106. {
  107. HandyControl.Controls.Growl.InfoGlobal(ex.Message);
  108. }
  109. }), "循环状态监测线程", false);
  110. }
  111. #endregion
  112. }
  113. }