AutorizahonPagesViewModel.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. using Avalonia;
  2. using Avalonia.Controls;
  3. using Avalonia.Controls.Shapes;
  4. using Avalonia.Interactivity;
  5. using Avalonia.Layout;
  6. using Avalonia.Markup.Xaml;
  7. using Avalonia.Media;
  8. using Culusas;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Reflection.Metadata;
  13. using System.Security.Claims;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using static System.Net.Mime.MediaTypeNames;
  17. using System.Xml.Linq;
  18. using System.Drawing.Imaging;
  19. using System.Drawing;
  20. using Culusas.Views;
  21. using ReactiveUI;
  22. using Avalonia.Threading;
  23. using Culusas.Models;
  24. using System.Runtime.Intrinsics.Arm;
  25. using WECPOFLogic;
  26. namespace Culusas.ViewModels
  27. {
  28. public class AutorizahonPagesViewModel : ReactiveObject
  29. {
  30. private string Log;
  31. private string Pass;
  32. private Canvas Chap;
  33. private bool Dip = true;
  34. private bool Visibility = false;
  35. private string CapHa;
  36. public string Password
  37. {
  38. get => Pass;
  39. set => this.RaiseAndSetIfChanged(ref Pass, value);
  40. }
  41. public string Login
  42. {
  43. get => Log;
  44. set => this.RaiseAndSetIfChanged(ref Log, value);
  45. }
  46. public Canvas Caph
  47. {
  48. get => Chap;
  49. set => this.RaiseAndSetIfChanged(ref Chap, value);
  50. }
  51. public bool Dilai
  52. {
  53. get => Dip;
  54. set => this.RaiseAndSetIfChanged(ref Dip, value);
  55. }
  56. private bool Prosmotr = false;
  57. public bool Visibilitys
  58. {
  59. get => Prosmotr;
  60. set => this.RaiseAndSetIfChanged(ref Prosmotr, value);
  61. }
  62. public string CaphaText
  63. {
  64. get => CapHa;
  65. set => this.RaiseAndSetIfChanged(ref CapHa, value);
  66. }
  67. private void Parah(object? sender, EventArgs e)
  68. {
  69. Dilai = true;
  70. Visibilitys = true;
  71. }
  72. public bool NextCulucu()
  73. {
  74. if (!Visibilitys)
  75. {
  76. if (Log == UserBD.Logi && Pass == UserBD.Pass)
  77. {
  78. // var box = MessageBoxManager
  79. //.GetMessageBoxStandard("Вход", "Вы вошли");
  80. // box.ShowAsync();
  81. return true;
  82. }
  83. else
  84. {
  85. // var box = MessageBoxManager
  86. //.GetMessageBoxStandard("Вход", "Введите правельные данные");
  87. // box.ShowAsync();
  88. Visibility = true;
  89. CaphaCreate();
  90. return false;
  91. }
  92. }
  93. else
  94. {
  95. if (Log == UserBD.Logi && Pass == UserBD.Pass && CapHa.ToUpper() == UserBD.Cupch)
  96. {
  97. //var box = MessageBoxManager.GetMessageBoxStandard("Вход", "Вы вошли");
  98. //box.ShowAsync();
  99. return true;
  100. }
  101. else
  102. {
  103. Login = "";
  104. Password = "";
  105. CaphaText = "";
  106. Dilai = false;
  107. Visibility = false;
  108. // var box = MessageBoxManager
  109. //.GetMessageBoxStandard("Вход", "Вы не правильно заполнили поля, они заблокированы на 10 секунд");
  110. // box.ShowAsync();
  111. disTaim.Tick += new EventHandler(Parah);
  112. disTaim.Interval = new TimeSpan(0, 0, 10);
  113. disTaim.Start();
  114. return false;
  115. }
  116. }
  117. }
  118. public DispatcherTimer disTaim = new DispatcherTimer();
  119. bool ZcanTM = true;
  120. public bool ConechTM
  121. {
  122. get => ZcanTM;
  123. set => this.RaiseAndSetIfChanged(ref ZcanTM, value);
  124. }
  125. bool TimEye = false;
  126. public bool TimersEye
  127. {
  128. get => TimEye;
  129. set => this.RaiseAndSetIfChanged(ref TimEye, value);
  130. }
  131. //public void VisibleED(object? sender, EventArgs e)
  132. //{
  133. // VisabilityBD = true;
  134. // ConechTM = true;
  135. //}
  136. //public void Taimers()
  137. //{
  138. // disTaim.Tick += new EventHandler(VisibleED);
  139. // disTaim.Interval = new TimeSpan(0, 0, 10);
  140. // disTaim.Start();
  141. // VisabilityBD = false;
  142. // ConechTM = false;
  143. // TimersEye = true;
  144. // AutorixVM.Login = " ";
  145. // AutorixVM.Password = " ";
  146. //}
  147. //Canvas can;
  148. //public Canvas Can
  149. //{
  150. // get => can;
  151. // set => this.RaiseAndSetIfChanged(ref can, value);
  152. //}
  153. //bool visa = false;
  154. //public bool VisabilityBD
  155. //{
  156. // get => visa;
  157. // set => this.RaiseAndSetIfChanged(ref visa, value);
  158. //}
  159. public void CaphaCreate()
  160. {
  161. UserBD.Cupch = "";
  162. SolidColorBrush color = new SolidColorBrush(Colors.Yellow);
  163. Canvas canava = new Canvas()
  164. {
  165. Width = 200,
  166. Height = 200,
  167. Background = color,
  168. Margin = new Thickness(0, 10, 0, 0)
  169. };
  170. Random r = new Random();
  171. int fs;
  172. Avalonia.Media.FontStyle fontStyle = Avalonia.Media.FontStyle.Normal;
  173. FontWeight fontWeight = FontWeight.Normal;
  174. for (int i = 1; i <= 10; i++)
  175. {
  176. fs = r.Next(1, 3);
  177. if (fs == 1)
  178. {
  179. fontStyle = Avalonia.Media.FontStyle.Oblique;
  180. }
  181. if (fs == 2)
  182. {
  183. fontWeight = FontWeight.Bold;
  184. }
  185. if (fs == 3)
  186. {
  187. fontWeight = FontWeight.Bold;
  188. fontStyle = Avalonia.Media.FontStyle.Italic;
  189. }
  190. TextBlock tb = new TextBlock()
  191. {
  192. Padding = new Thickness(i * 19, r.Next(100), 0, r.Next(100)),
  193. Foreground = new SolidColorBrush(Colors.LimeGreen),
  194. FontStyle = fontStyle,
  195. FontWeight = fontWeight
  196. };
  197. if (i % 2 == 0)
  198. {
  199. tb.Text = Convert.ToString((char)r.Next(65, 90));
  200. }
  201. else
  202. {
  203. tb.Text = Convert.ToString(r.Next(1, 9));
  204. }
  205. UserBD.Cupch += tb.Text;
  206. canava.Children.Add(tb);
  207. Line line = new Line()
  208. {
  209. StartPoint = new Avalonia.Point(r.Next(200), r.Next(200)),
  210. EndPoint = new Avalonia.Point(r.Next(200), r.Next(200)),
  211. Stroke = Avalonia.Media.Brushes.Red,
  212. StrokeThickness = 3
  213. };
  214. canava.Children.Add(line);
  215. }
  216. Chap = canava;
  217. }
  218. }
  219. }