RegisterDialogViewModel.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using PDF_Master.Helper;
  7. using PDF_Master.Model;
  8. using PDF_Master.Properties;
  9. using PDF_Master.Views.Dialog.ServiceDialog;
  10. using Prism.Commands;
  11. using Prism.Mvvm;
  12. using Prism.Regions;
  13. using Prism.Services.Dialogs;
  14. namespace PDF_Master.ViewModels.Dialog.ServiceDialog
  15. {
  16. public class RegisterDialogViewModel : BindableBase, IDialogAware
  17. {
  18. public IDialogService dialogs;
  19. public IRegionManager Region;
  20. public string Title => "注册窗口";
  21. public event Action<IDialogResult> RequestClose;
  22. private string _RegisterRegionName;
  23. public string RegisterRegionName
  24. {
  25. get { return _RegisterRegionName; }
  26. set { _RegisterRegionName = value; }
  27. }
  28. private string _registerEmail;
  29. public string RegisterEmail
  30. {
  31. get { return _registerEmail; }
  32. set { _registerEmail = value; }
  33. }
  34. private string _RegisterPassword;
  35. public string RegisterPassword
  36. {
  37. get { return _RegisterPassword; }
  38. set { _RegisterPassword = value; }
  39. }
  40. public void Close()
  41. {
  42. RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
  43. }
  44. public bool CanCloseDialog()
  45. {
  46. return true;
  47. }
  48. public void OnDialogClosed()
  49. {
  50. }
  51. public void OnDialogOpened(IDialogParameters parameters)
  52. {
  53. if (ServiceHelper.IsConnectInternet() ==false)
  54. {
  55. RegionMan("NOInternetRegion");
  56. }
  57. else { RegionMan("RegisterRegion"); };
  58. }
  59. public DelegateCommand OpenIAPCommand { get; set; }
  60. RegisterDialogViewModel(IRegionManager regionManager, IDialogService dialogService)
  61. {
  62. OpenIAPCommand = new DelegateCommand(OpenIAP);
  63. dialogs = dialogService;
  64. this.Region = regionManager;
  65. RegisterRegionName = Guid.NewGuid().ToString();
  66. }
  67. private void OpenIAP()
  68. {
  69. dialogs.ShowDialog(DialogNames.IAPCompareDialog);
  70. }
  71. public void RegionMan(string name)
  72. {
  73. NavigationParameters param = new NavigationParameters();
  74. param.Add("RegisterDialogViewModel", this);
  75. Region.RequestNavigate(RegisterRegionName, name,e=> {
  76. var r= e.Result; }, param);
  77. }
  78. }
  79. }