PasswordUpdataRegionVIewModel.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. using PDF_Office.Helper;
  2. using PDF_Office.Model;
  3. using Prism.Commands;
  4. using Prism.Mvvm;
  5. using Prism.Regions;
  6. using Prism.Services.Dialogs;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Diagnostics;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. using System.Windows.Controls;
  15. namespace PDF_Office.ViewModels.Dialog.ServiceDialog
  16. {
  17. public class PasswordUpdataRegionViewModel : BindableBase, INavigationAware
  18. {
  19. private static Guid myuuid = Guid.NewGuid();
  20. private string uuid = myuuid.ToString();
  21. private LoginDialogViewModel LoginDialogViewModel;
  22. public IDialogService dialogs;
  23. public bool IsNavigationTarget(NavigationContext navigationContext)
  24. {
  25. return true;
  26. }
  27. public void OnNavigatedFrom(NavigationContext navigationContext)
  28. {
  29. }
  30. public void OnNavigatedTo(NavigationContext navigationContext)
  31. {
  32. navigationContext.Parameters.TryGetValue<LoginDialogViewModel>("LoginDialogViewModel", out LoginDialogViewModel);
  33. LoginEmail = LoginDialogViewModel.LoginEmail;
  34. }
  35. private bool enableNextStep = false;
  36. public bool EnableNextStep
  37. {
  38. get { return enableNextStep; }
  39. set { SetProperty(ref enableNextStep, value); }
  40. }
  41. private string _LoginEmail = "";
  42. public string LoginEmail
  43. {
  44. get { return _LoginEmail; }
  45. set
  46. {
  47. SetProperty(ref _LoginEmail, value);
  48. CheckEnableNextStepEncrypt();
  49. }
  50. }
  51. private string _LoginPasswordlook;
  52. public string LoginPasswordlook
  53. {
  54. get { return _LoginPasswordlook; }
  55. set { SetProperty(ref _LoginPasswordlook, value); }
  56. }
  57. private string _LoginPassword = "";
  58. public string LoginPassword
  59. {
  60. get { return _LoginPassword; }
  61. set
  62. {
  63. SetProperty(ref _LoginPassword, value);
  64. CheckEnableNextStepEncrypt();
  65. }
  66. }
  67. private string _LoginPasswordMsg = "Enter the new password again";
  68. public string LoginPasswordMsg
  69. {
  70. get { return _LoginPasswordMsg; }
  71. set
  72. {
  73. SetProperty(ref _LoginPasswordMsg, value);
  74. }
  75. }
  76. private Visibility _LoginPasswordVisibility = Visibility.Visible;
  77. public Visibility LoginPasswordVisibility
  78. {
  79. get { return _LoginPasswordVisibility; }
  80. set
  81. {
  82. if (value == Visibility.Visible)
  83. {
  84. LoginTextVisibility = Visibility.Collapsed;
  85. }
  86. else
  87. {
  88. LoginTextVisibility = Visibility.Visible;
  89. }
  90. SetProperty(ref _LoginPasswordVisibility, value);
  91. }
  92. }
  93. private Visibility _LoginTextVisibility = Visibility.Collapsed;
  94. public Visibility LoginTextVisibility
  95. {
  96. get { return _LoginTextVisibility; }
  97. set { SetProperty(ref _LoginTextVisibility, value); }
  98. }
  99. private string _LoginPassword2 = "";
  100. public string LoginPassword2
  101. {
  102. get { return _LoginPassword2; }
  103. set
  104. {
  105. SetProperty(ref _LoginPassword2, value);
  106. CheckEnableNextStepEncrypt();
  107. }
  108. }
  109. private string _LoginPasswordMsg2 = "Enter your password";
  110. public string LoginPasswordMsg2
  111. {
  112. get { return _LoginPasswordMsg2; }
  113. set
  114. {
  115. SetProperty(ref _LoginPasswordMsg2, value);
  116. }
  117. }
  118. private Visibility _LoginPasswordVisibility2 = Visibility.Visible;
  119. public Visibility LoginPasswordVisibility2
  120. {
  121. get { return _LoginPasswordVisibility2; }
  122. set
  123. {
  124. if (value == Visibility.Visible)
  125. {
  126. LoginTextVisibility2 = Visibility.Collapsed;
  127. }
  128. else
  129. {
  130. LoginTextVisibility2 = Visibility.Visible;
  131. }
  132. SetProperty(ref _LoginPasswordVisibility2, value);
  133. }
  134. }
  135. private Visibility _LoginTextVisibility2 = Visibility.Collapsed;
  136. public Visibility LoginTextVisibility2
  137. {
  138. get { return _LoginTextVisibility2; }
  139. set { SetProperty(ref _LoginTextVisibility2, value); }
  140. }
  141. private string _PasswordUpdatamsglook = "";
  142. public string PasswordUpdatamsglook
  143. {
  144. get { return _PasswordUpdatamsglook; }
  145. set
  146. {
  147. SetProperty(ref _PasswordUpdatamsglook, value);
  148. }
  149. }
  150. private Visibility _PasswordUpdatalookVis = Visibility.Collapsed;
  151. public Visibility PasswordUpdatalookVis
  152. {
  153. get { return _PasswordUpdatalookVis; }
  154. set { SetProperty(ref _PasswordUpdatalookVis, value); }
  155. }
  156. public DelegateCommand<object> DisplayPasswordCommand { get; set; }
  157. public DelegateCommand ChangeEmailCommand { get; set; }
  158. public DelegateCommand GoCodeUpdataCommand { get; set; }
  159. public DelegateCommand PasswordUpdataCommand { get; set; }
  160. public DelegateCommand LinkLicenseCommand { get; set; }
  161. PasswordUpdataRegionViewModel(IRegionManager regionManager, IDialogService dialogService)
  162. {
  163. dialogs = dialogService;
  164. DisplayPasswordCommand = new DelegateCommand<object>(DisplayPassword);
  165. DisplayPasswordCommand = new DelegateCommand<object>(DisplayPassword2);
  166. PasswordUpdataCommand = new DelegateCommand(PasswordUpdata);
  167. }
  168. private void PasswordUpdata()
  169. {
  170. if (ServiceHelper.Rebirth(LoginEmail, LoginPassword2, LoginPassword, LoginDialogViewModel.PasswordCode) == "success")
  171. {
  172. LoginDialogViewModel.RegionMan("LoginRegion");
  173. }
  174. else
  175. {
  176. PasswordUpdatamsglook = ServiceHelper.Rebirth(LoginEmail, LoginPassword2, LoginPassword, LoginDialogViewModel.PasswordCode);
  177. PasswordUpdatalookVis = Visibility.Visible;
  178. }
  179. }
  180. private void CheckEnableNextStepEncrypt()
  181. {
  182. EnableNextStep = true;
  183. if (string.IsNullOrEmpty(LoginPassword)|| string.IsNullOrEmpty(LoginPassword2))
  184. {
  185. EnableNextStep = false;
  186. }
  187. }
  188. public void DisplayPassword(object e)
  189. {
  190. var chk = e as CheckBox;
  191. if (chk != null)
  192. {
  193. if (chk.IsChecked == true)
  194. {
  195. LoginPasswordVisibility = Visibility.Collapsed;
  196. }
  197. else
  198. {
  199. LoginPasswordVisibility = Visibility.Visible;
  200. }
  201. }
  202. }
  203. public void DisplayPassword2(object e)
  204. {
  205. var chk = e as CheckBox;
  206. if (chk != null)
  207. {
  208. if (chk.IsChecked == true)
  209. {
  210. LoginPasswordVisibility2 = Visibility.Collapsed;
  211. }
  212. else
  213. {
  214. LoginPasswordVisibility2 = Visibility.Visible;
  215. }
  216. }
  217. }
  218. }
  219. }