RegisterDialogViewModel.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using PDF_Master.Helper;
  8. using PDF_Master.Model;
  9. using PDF_Master.Properties;
  10. using PDF_Master.Views.Dialog.ServiceDialog;
  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 RegisterDialogViewModel : BindableBase, IDialogAware
  18. {
  19. public IDialogService dialogs;
  20. public IRegionManager Region;
  21. public string Title => "注册窗口";
  22. public event Action<IDialogResult> RequestClose;
  23. private string _RegisterRegionName;
  24. public string RegisterRegionName
  25. {
  26. get { return _RegisterRegionName; }
  27. set { _RegisterRegionName = value; }
  28. }
  29. private string _registerEmail;
  30. public string RegisterEmail
  31. {
  32. get { return _registerEmail; }
  33. set { _registerEmail = value; }
  34. }
  35. private string _RegisterPassword;
  36. public string RegisterPassword
  37. {
  38. get { return _RegisterPassword; }
  39. set { _RegisterPassword = value; }
  40. }
  41. private string _TextUnlock;
  42. public string TextUnlock
  43. {
  44. get { return _TextUnlock; }
  45. set { _TextUnlock = value; }
  46. }
  47. private string _TextRegisteras;
  48. public string TextRegisteras
  49. {
  50. get { return _TextRegisteras; }
  51. set { _TextRegisteras = value; }
  52. }
  53. private string _TextEditPDF;
  54. public string TextEditPDF
  55. {
  56. get { return _TextEditPDF; }
  57. set { _TextEditPDF = value; }
  58. }
  59. private string _Textediting;
  60. public string Textediting
  61. {
  62. get { return _Textediting; }
  63. set { _Textediting = value; }
  64. }
  65. private string _TextConvert;
  66. public string TextConvert
  67. {
  68. get { return _TextConvert; }
  69. set { _TextConvert = value; }
  70. }
  71. private string _TextLimit10;
  72. public string TextLimit10
  73. {
  74. get { return _TextLimit10; }
  75. set { _TextLimit10 = value; }
  76. }
  77. private string _TextConvertPDF;
  78. public string TextConvertPDF
  79. {
  80. get { return _TextConvertPDF; }
  81. set { _TextConvertPDF = value; }
  82. }
  83. private string _TextOrganize;
  84. public string TextOrganize
  85. {
  86. get { return _TextOrganize; }
  87. set { _TextOrganize = value; }
  88. }
  89. private string _TextInsert;
  90. public string TextInsert
  91. {
  92. get { return _TextInsert; }
  93. set { _TextInsert = value; }
  94. }
  95. private string _TextSuch;
  96. public string TextSuch
  97. {
  98. get { return _TextSuch; }
  99. set { _TextSuch = value; }
  100. }
  101. private string _TextSubscribeNow;
  102. public string TextSubscribeNow
  103. {
  104. get { return _TextSubscribeNow; }
  105. set { _TextSubscribeNow = value; }
  106. }
  107. private string _TextMore;
  108. public string TextMore
  109. {
  110. get { return _TextMore; }
  111. set { _TextMore = value; }
  112. }
  113. public void Close()
  114. {
  115. RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
  116. }
  117. public bool CanCloseDialog()
  118. {
  119. return true;
  120. }
  121. public void OnDialogClosed()
  122. {
  123. }
  124. public void OnDialogOpened(IDialogParameters parameters)
  125. {
  126. if (ServiceHelper.IsConnectInternet() ==false)
  127. {
  128. RegionMan("NOInternetRegion");
  129. }
  130. else { RegionMan("RegisterRegion"); };
  131. }
  132. private void InitString()
  133. {
  134. TextUnlock = App.ServiceLoader.GetString("TextUnlock");
  135. TextRegisteras = App.ServiceLoader.GetString("TextRegisteras");
  136. TextEditPDF = App.ServiceLoader.GetString("TextEditPDF");
  137. Textediting = App.ServiceLoader.GetString("Textediting");
  138. TextConvert = App.ServiceLoader.GetString("TextConvert");
  139. TextLimit10 = App.ServiceLoader.GetString("TextLimit10");
  140. TextConvertPDF = App.ServiceLoader.GetString("TextConvertPDF");
  141. TextOrganize = App.ServiceLoader.GetString("TextOrganize");
  142. TextInsert = App.ServiceLoader.GetString("TextInsert");
  143. TextMore = App.ServiceLoader.GetString("TextMore");
  144. TextSuch = App.ServiceLoader.GetString("TextSuch");
  145. TextSubscribeNow = App.ServiceLoader.GetString("TextSubscribeNow");
  146. }
  147. public DelegateCommand LinkstoreCommand { get; set; }
  148. public DelegateCommand OpenIAPCommand { get; set; }
  149. RegisterDialogViewModel(IRegionManager regionManager, IDialogService dialogService)
  150. {
  151. LinkstoreCommand = new DelegateCommand(Linkstore);
  152. OpenIAPCommand = new DelegateCommand(OpenIAP);
  153. dialogs = dialogService;
  154. this.Region = regionManager;
  155. RegisterRegionName = Guid.NewGuid().ToString();
  156. InitString();
  157. }
  158. private void Linkstore()
  159. {
  160. Process.Start(new ProcessStartInfo("https://www.pdfreaderpro.com/windows/store/permanent"));
  161. }
  162. private void OpenIAP()
  163. {
  164. dialogs.ShowDialog(DialogNames.IAPCompareDialog);
  165. }
  166. public void RegionMan(string name)
  167. {
  168. NavigationParameters param = new NavigationParameters();
  169. param.Add("RegisterDialogViewModel", this);
  170. Region.RequestNavigate(RegisterRegionName, name,e=> {
  171. var r= e.Result; }, param);
  172. }
  173. }
  174. }