NoInternetRegionViewModel.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using PDF_Master.Helper;
  2. using PDF_Master.Model;
  3. using Prism.Commands;
  4. using Prism.Mvvm;
  5. using Prism.Regions;
  6. using Prism.Services.Dialogs;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Diagnostics;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Text.RegularExpressions;
  13. using System.Threading.Tasks;
  14. using System.Windows;
  15. using System.Windows.Controls;
  16. namespace PDF_Master.ViewModels.Dialog.ServiceDialog
  17. {
  18. public class NOInternetRegionViewModel : BindableBase, INavigationAware
  19. {
  20. private LoginDialogViewModel LoginDialogViewModel;
  21. private RegisterDialogViewModel RegisterDialogViewModel;
  22. private UserDialogViewModel UserDialogViewModel;
  23. public IDialogService dialogs;
  24. public bool IsNavigationTarget(NavigationContext navigationContext)
  25. {
  26. return true;
  27. }
  28. public void OnNavigatedFrom(NavigationContext navigationContext)
  29. {
  30. }
  31. public void OnNavigatedTo(NavigationContext navigationContext)
  32. {
  33. navigationContext.Parameters.TryGetValue<LoginDialogViewModel>("LoginDialogViewModel", out LoginDialogViewModel);
  34. navigationContext.Parameters.TryGetValue<RegisterDialogViewModel>("RegisterDialogViewModel", out RegisterDialogViewModel);
  35. navigationContext.Parameters.TryGetValue<UserDialogViewModel>("UserDialogViewModel", out UserDialogViewModel);
  36. }
  37. #region 文案
  38. private string _Text_nonet = "";
  39. public string Text_nonet
  40. {
  41. get { return _Text_nonet; }
  42. set
  43. {
  44. SetProperty(ref _Text_nonet, value);
  45. }
  46. }
  47. private string _Text_toconnect = "";
  48. public string Text_toconnect
  49. {
  50. get { return _Text_toconnect; }
  51. set
  52. {
  53. SetProperty(ref _Text_toconnect, value);
  54. }
  55. }
  56. private string _Text_retry = "";
  57. public string Text_retry
  58. {
  59. get { return _Text_retry; }
  60. set
  61. {
  62. SetProperty(ref _Text_retry, value);
  63. }
  64. }
  65. private void InitString()
  66. {
  67. Text_nonet = App.ServiceLoader.GetString("Text_nonet");
  68. Text_toconnect = App.ServiceLoader.GetString("Text_toconnect");
  69. Text_retry = App.ServiceLoader.GetString("Text_retry");
  70. }
  71. #endregion
  72. public DelegateCommand RetryCommand { get; set; }
  73. NOInternetRegionViewModel(IRegionManager regionManager, IDialogService dialogService)
  74. {
  75. InitString();
  76. dialogs = dialogService;
  77. RetryCommand = new DelegateCommand(Retry);
  78. }
  79. private void Retry()
  80. {
  81. if (ServiceHelper.IsConnectInternet()==true)
  82. {
  83. if (RegisterDialogViewModel != null)
  84. {
  85. RegisterDialogViewModel.RegionMan("RegisterRegion");
  86. }
  87. else if (LoginDialogViewModel != null)
  88. {
  89. LoginDialogViewModel.RegionMan("LoginRegion");
  90. }
  91. else
  92. {
  93. UserDialogViewModel.Region.Regions[UserDialogViewModel.UserRegionName].RemoveAll();
  94. }
  95. }
  96. }
  97. }
  98. }