RegisterDialogViewModel.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. public void Close()
  42. {
  43. RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
  44. }
  45. public bool CanCloseDialog()
  46. {
  47. return true;
  48. }
  49. public void OnDialogClosed()
  50. {
  51. }
  52. public void OnDialogOpened(IDialogParameters parameters)
  53. {
  54. if (ServiceHelper.IsConnectInternet() ==false)
  55. {
  56. RegionMan("NOInternetRegion");
  57. }
  58. else { RegionMan("RegisterRegion"); };
  59. }
  60. public DelegateCommand LinkstoreCommand { get; set; }
  61. public DelegateCommand OpenIAPCommand { get; set; }
  62. RegisterDialogViewModel(IRegionManager regionManager, IDialogService dialogService)
  63. {
  64. LinkstoreCommand = new DelegateCommand(Linkstore);
  65. OpenIAPCommand = new DelegateCommand(OpenIAP);
  66. dialogs = dialogService;
  67. this.Region = regionManager;
  68. RegisterRegionName = Guid.NewGuid().ToString();
  69. }
  70. private void Linkstore()
  71. {
  72. Process.Start(new ProcessStartInfo("https://www.pdfreaderpro.com/windows/store/permanent"));
  73. }
  74. private void OpenIAP()
  75. {
  76. dialogs.ShowDialog(DialogNames.IAPCompareDialog);
  77. }
  78. public void RegionMan(string name)
  79. {
  80. NavigationParameters param = new NavigationParameters();
  81. param.Add("RegisterDialogViewModel", this);
  82. Region.RequestNavigate(RegisterRegionName, name,e=> {
  83. var r= e.Result; }, param);
  84. }
  85. }
  86. }