LoginDialogViewModel.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Runtime.InteropServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using PDF_Master.Helper;
  9. using PDF_Master.Model;
  10. using PDF_Master.Properties;
  11. using Prism.Commands;
  12. using Prism.Mvvm;
  13. using Prism.Regions;
  14. using Prism.Services.Dialogs;
  15. namespace PDF_Master.ViewModels.Dialog.ServiceDialog
  16. {
  17. public class LoginDialogViewModel : BindableBase, IDialogAware
  18. {
  19. public IDialogService dialogs;
  20. public IRegionManager Region;
  21. public string Title => "登录窗口";
  22. private string Loginoff;
  23. public event Action<IDialogResult> RequestClose;
  24. private bool _IsReset=false;
  25. public bool IsReset
  26. {
  27. get { return _IsReset; }
  28. set { _IsReset = value; }
  29. }
  30. private string _PasswordCode="";
  31. public string PasswordCode
  32. {
  33. get { return _PasswordCode; }
  34. set { _PasswordCode = value; }
  35. }
  36. private string _LoginRegionName;
  37. public string LoginRegionName
  38. {
  39. get { return _LoginRegionName; }
  40. set { _LoginRegionName = value; }
  41. }
  42. private string _LoginEmail;
  43. public string LoginEmail
  44. {
  45. get { return _LoginEmail; }
  46. set { _LoginEmail = value; }
  47. }
  48. private string _LoginPassword;
  49. public string LoginPassword
  50. {
  51. get { return _LoginPassword; }
  52. set { _LoginPassword = value; }
  53. }
  54. private string _TextUnlock;
  55. public string TextUnlock
  56. {
  57. get { return _TextUnlock; }
  58. set { _TextUnlock = value; }
  59. }
  60. private string _TextRegisteras;
  61. public string TextRegisteras
  62. {
  63. get { return _TextRegisteras; }
  64. set { _TextRegisteras = value; }
  65. }
  66. private string _TextEditPDF;
  67. public string TextEditPDF
  68. {
  69. get { return _TextEditPDF; }
  70. set { _TextEditPDF = value; }
  71. }
  72. private string _Textediting;
  73. public string Textediting
  74. {
  75. get { return _Textediting; }
  76. set { _Textediting = value; }
  77. }
  78. private string _TextConvert;
  79. public string TextConvert
  80. {
  81. get { return _TextConvert; }
  82. set { _TextConvert = value; }
  83. }
  84. private string _TextLimit10;
  85. public string TextLimit10
  86. {
  87. get { return _TextLimit10; }
  88. set { _TextLimit10 = value; }
  89. }
  90. private string _TextConvertPDF;
  91. public string TextConvertPDF
  92. {
  93. get { return _TextConvertPDF; }
  94. set { _TextConvertPDF = value; }
  95. }
  96. private string _TextOrganize;
  97. public string TextOrganize
  98. {
  99. get { return _TextOrganize; }
  100. set { _TextOrganize = value; }
  101. }
  102. private string _TextInsert;
  103. public string TextInsert
  104. {
  105. get { return _TextInsert; }
  106. set { _TextInsert = value; }
  107. }
  108. private string _TextMore;
  109. public string TextMore
  110. {
  111. get { return _TextMore; }
  112. set { _TextMore = value; }
  113. }
  114. private string _TextSuch;
  115. public string TextSuch
  116. {
  117. get { return _TextSuch; }
  118. set { _TextSuch = value; }
  119. }
  120. private string _TextSubscribeNow;
  121. public string TextSubscribeNow
  122. {
  123. get { return _TextSubscribeNow; }
  124. set { _TextSubscribeNow = value; }
  125. }
  126. public bool CanCloseDialog()
  127. {
  128. return true;
  129. }
  130. public void OnDialogClosed()
  131. {
  132. App.LoginOpen = false;
  133. }
  134. public void OnDialogOpened(IDialogParameters parameters)
  135. {
  136. if (ServiceHelper.IsConnectInternet() == false)
  137. {
  138. RegionMan("NOInternetRegion");
  139. }
  140. else { RegionMan("LoginRegion"); }
  141. parameters.TryGetValue<String>(ParameterNames.Loginoff, out Loginoff);
  142. if (Loginoff != null)
  143. {
  144. LoginEmail = Settings.Default.UserDate.Email;
  145. IsReset = true;
  146. RegionMan("CodeRegion");
  147. }
  148. }
  149. private void InitString()
  150. {
  151. TextUnlock = App.ServiceLoader.GetString("TextUnlock");
  152. TextRegisteras = App.ServiceLoader.GetString("TextRegisteras");
  153. TextEditPDF = App.ServiceLoader.GetString("TextEditPDF");
  154. Textediting = App.ServiceLoader.GetString("Textediting");
  155. TextConvert = App.ServiceLoader.GetString("TextConvert");
  156. TextLimit10 = App.ServiceLoader.GetString("TextLimit10");
  157. TextConvertPDF = App.ServiceLoader.GetString("TextConvertPDF");
  158. TextOrganize = App.ServiceLoader.GetString("TextOrganize");
  159. TextInsert = App.ServiceLoader.GetString("TextInsert");
  160. TextMore = App.ServiceLoader.GetString("TextMore");
  161. TextSuch = App.ServiceLoader.GetString("TextSuch");
  162. TextSubscribeNow = App.ServiceLoader.GetString("TextSubscribeNow");
  163. }
  164. public DelegateCommand LinkstoreCommand { get; set; }
  165. public DelegateCommand OpenIAPCommand { get; set; }
  166. LoginDialogViewModel(IRegionManager regionManager, IDialogService dialogService)
  167. {
  168. LinkstoreCommand = new DelegateCommand(Linkstore);
  169. OpenIAPCommand = new DelegateCommand(OpenIAP);
  170. dialogs = dialogService;
  171. this.Region = regionManager;
  172. LoginRegionName = Guid.NewGuid().ToString();
  173. InitString();
  174. }
  175. private void OpenIAP()
  176. {
  177. dialogs.ShowDialog(DialogNames.IAPCompareDialog);
  178. }
  179. private void Linkstore()
  180. {
  181. Process.Start(new ProcessStartInfo("https://www.pdfreaderpro.com/windows/store/permanent"));
  182. }
  183. public void Close()
  184. {
  185. RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
  186. }
  187. public void RegionMan(string name)
  188. {
  189. NavigationParameters param = new NavigationParameters();
  190. param.Add("LoginDialogViewModel", this);
  191. param.Add("IsReset", IsReset);
  192. Region.RequestNavigate(LoginRegionName, name, e => {
  193. var r = e.Result;
  194. }, param);
  195. }
  196. }
  197. }