LoginoffViewModel.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using PDF_Master.Properties;
  2. using Prism.Commands;
  3. using Prism.Mvvm;
  4. using Prism.Regions;
  5. using Prism.Services.Dialogs;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace PDF_Master.ViewModels.Dialog.ServiceDialog
  12. {
  13. public class LoginoffDialogViewModel : BindableBase, IDialogAware
  14. {
  15. public IRegionManager Region;
  16. public string Title => "";
  17. public event Action<IDialogResult> RequestClose;
  18. #region 文案
  19. private string _TextPleaseLog;
  20. public string TextPleaseLog
  21. {
  22. get { return _TextPleaseLog; }
  23. set { _TextPleaseLog = value; }
  24. }
  25. private string _TextYouraccount;
  26. public string TextYouraccount
  27. {
  28. get { return _TextYouraccount; }
  29. set { _TextYouraccount = value; }
  30. }
  31. private string _TextChange;
  32. public string TextChange
  33. {
  34. get { return _TextChange; }
  35. set { _TextChange = value; }
  36. }
  37. private string _TextOK;
  38. public string TextOK
  39. {
  40. get { return _TextOK; }
  41. set { _TextOK = value; }
  42. }
  43. private string _TextCancel;
  44. public string TextCancel
  45. {
  46. get { return _TextCancel; }
  47. set { _TextCancel = value; }
  48. }
  49. private string _TextLogin;
  50. public string TextLogin
  51. {
  52. get { return _TextLogin; }
  53. set { _TextLogin = value; }
  54. }
  55. private string _LoginoffRegionName;
  56. public string LoginoffRegionName
  57. {
  58. get { return _LoginoffRegionName; }
  59. set { _LoginoffRegionName = value; }
  60. }
  61. #endregion
  62. private void InitString()
  63. {
  64. TextPleaseLog = App.ServiceLoader.GetString("TextPleaseLog");
  65. TextYouraccount = App.ServiceLoader.GetString("TextYouraccount");
  66. TextChange = App.ServiceLoader.GetString("TextChange");
  67. TextOK = App.ServiceLoader.GetString("Text_ok");
  68. TextCancel = App.ServiceLoader.GetString("Text_cancel");
  69. TextLogin = App.ServiceLoader.GetString("Text_Login");
  70. }
  71. public bool CanCloseDialog()
  72. {
  73. return true;
  74. }
  75. public void OnDialogClosed()
  76. {
  77. }
  78. public void OnDialogOpened(IDialogParameters parameters)
  79. {
  80. Settings.Default.UserDate.IsLoginoff = true;
  81. Settings.Default.Save();
  82. }
  83. public DelegateCommand GoLoginCommand { get; set; }
  84. public DelegateCommand GoCodeCommand { get; set; }
  85. public LoginoffDialogViewModel(IRegionManager regionManager, IDialogService dialogService)
  86. {
  87. GoCodeCommand= new DelegateCommand(GoCode);
  88. GoLoginCommand = new DelegateCommand(GoLogin);
  89. LoginoffRegionName = Guid.NewGuid().ToString();
  90. InitString();
  91. }
  92. public void Close()
  93. {
  94. RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
  95. }
  96. private void GoLogin()
  97. {
  98. Close();
  99. App.mainWindowViewModel.OpenLogin();
  100. }
  101. private void GoCode()
  102. {
  103. Close();
  104. App.mainWindowViewModel.OpenLogin("Loginoff");
  105. }
  106. }
  107. }