LoginDialogViewModel.cs 2.5 KB

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