Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

108 rader
3.1 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 _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. #endregion
  48. #region 命令
  49. public void InputAction(string input)
  50. {
  51. if (IsLocker) return;
  52. ShowMoney = decimal.Parse(input);
  53. }
  54. public void LockSreenAction()
  55. {
  56. IsLocker = true;
  57. ContentVisible = Visibility.Collapsed;
  58. CodeVisible = Visibility.Visible;
  59. }
  60. public void UnLockAction(HandyControl.Controls.PasswordBox input)
  61. {
  62. if (input.Password.Equals(DataBus.LockCode))
  63. {
  64. IsLocker = false;
  65. CodeVisible = Visibility.Collapsed;
  66. ContentVisible = Visibility.Visible;
  67. }
  68. }
  69. public void SaveAction()
  70. {
  71. if (!DataBus.NetWordState)
  72. {
  73. HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络!!!");
  74. return;
  75. }
  76. }
  77. #endregion
  78. #region 方法
  79. private void MainThread() {
  80. ThreadManage.GetInstance().StartLong(new Action(() =>
  81. {
  82. try
  83. {
  84. //1.检测网络上下线
  85. bool network = HKHelper.GetInstance().GetNetworkState();
  86. if (network != DataBus.NetWordState)
  87. {
  88. if (network) HandyControl.Controls.Growl.InfoGlobal("网络连接成功");
  89. else HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络!!!");
  90. DataBus.NetWordState = network;
  91. }
  92. Thread.Sleep(3000);
  93. }
  94. catch (Exception ex)
  95. {
  96. HandyControl.Controls.Growl.InfoGlobal(ex.Message);
  97. }
  98. }), "循环状态监测线程", false);
  99. }
  100. #endregion
  101. }
  102. }