MainWindowViewModel.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using Auth.Models;
  2. using Avalonia.Media;
  3. using Avalonia.Styling;
  4. using ReactiveUI;
  5. using System;
  6. using System.Drawing;
  7. using System.Security.Cryptography.X509Certificates;
  8. using Avalonia.Controls;
  9. using Avalonia.Controls.Shapes;
  10. using System.Linq;
  11. using Avalonia.Threading;
  12. using System.Runtime.CompilerServices;
  13. using Tmds.DBus.Protocol;
  14. using MsBox.Avalonia;
  15. using MsBox.Avalonia.Enums;
  16. namespace Auth.ViewModels
  17. {
  18. public class MainWindowViewModel : ViewModelBase
  19. {
  20. public UserControl _us = new Auth();
  21. public UserControl Us
  22. {
  23. get => _us;
  24. set => this.RaiseAndSetIfChanged(ref _us, value);
  25. }
  26. AuthVM _Auth = new AuthVM();
  27. public AuthVM Auth_VM
  28. {
  29. get => _Auth;
  30. set => _Auth = value;
  31. }
  32. CalcVM _Calc = new CalcVM();
  33. public CalcVM Calc_VM
  34. {
  35. get => _Calc;
  36. set => _Calc = value;
  37. }
  38. public void Knopka()
  39. {
  40. data data = new data();
  41. if (Auth_VM._login == data.login && Auth_VM._password == data.password)
  42. {
  43. Us = new Calc();
  44. }
  45. else
  46. {
  47. Auth_VM.changeMessage();
  48. Auth_VM.VisibleText = true;
  49. Auth_VM.Visible = false;
  50. Auth_VM.CreateCaptcha();
  51. }
  52. }
  53. int count = 0;
  54. public void ButtonPro()
  55. {
  56. if (Auth_VM.prov == Auth_VM.kod && Auth_VM._login == data.login && Auth_VM._password == data.password)
  57. {
  58. Us = new Calc();
  59. }
  60. else
  61. {
  62. Auth_VM.timer.Interval = new TimeSpan(0, 0, 10);
  63. Auth_VM.timer.Tick += new EventHandler(Auth_VM.timer_tick);
  64. count++;
  65. Auth_VM.Login = "";
  66. Auth_VM.Password = "";
  67. Auth_VM.CreateCaptcha();
  68. if (count == 1)
  69. {
  70. Auth_VM.changeMessage1();
  71. }
  72. if (count == 2)
  73. {
  74. Auth_VM.timer.Start();
  75. Auth_VM.Login = "";
  76. Auth_VM.Password = "";
  77. Auth_VM.changeMessage2();
  78. count = 0;
  79. Auth_VM.VisibleText = false;
  80. Auth_VM.Visible = true;
  81. Auth_VM.Enabled = false;
  82. }
  83. }
  84. }
  85. }
  86. }