IAPCompareDialogViewModel.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. using PDF_Master.DataConvert;
  2. using PDF_Master.Helper;
  3. using PDF_Master.Properties;
  4. using Prism.Commands;
  5. using Prism.Mvvm;
  6. using Prism.Regions;
  7. using Prism.Services.Dialogs;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Diagnostics;
  11. using System.Windows;
  12. using System.Windows.Controls;
  13. using System.Windows.Data;
  14. namespace PDF_Master.ViewModels.Dialog.ServiceDialog
  15. {
  16. public class IAPCompareDialogViewModel : BindableBase,IDialogAware
  17. {
  18. public string Title => "";
  19. public event Action<IDialogResult> RequestClose;
  20. #region 文案
  21. #endregion
  22. /// <summary>
  23. /// 价格优惠bord
  24. /// </summary>
  25. private Visibility _Vishalfprice = Visibility.Visible;
  26. public Visibility Vishalfprice
  27. {
  28. get { return _Vishalfprice; }
  29. set
  30. {
  31. SetProperty(ref _Vishalfprice, value);
  32. }
  33. }
  34. /// <summary>
  35. /// 价格优惠
  36. /// </summary>
  37. private string _Textprice = "$39.99";
  38. public string Textprice
  39. {
  40. get { return _Textprice; }
  41. set
  42. {
  43. SetProperty(ref _Textprice, value);
  44. }
  45. }
  46. private string _Text_Signup = "";
  47. public string Text_Signup
  48. {
  49. get { return _Text_Signup; }
  50. set
  51. {
  52. SetProperty(ref _Text_Signup, value);
  53. }
  54. }
  55. private string _uristore = "https://www.pdfreaderpro.com/windows/store/permanent";
  56. public string Uristore
  57. {
  58. get { return _uristore; }
  59. set
  60. {
  61. SetProperty(ref _uristore, value);
  62. }
  63. }
  64. public DelegateCommand LinkstoreCommand { get; set; }
  65. private void InitString()
  66. {
  67. }
  68. public bool CanCloseDialog()
  69. {
  70. return true;
  71. }
  72. public void OnDialogClosed()
  73. {
  74. }
  75. public void OnDialogOpened(IDialogParameters parameters)
  76. {
  77. }
  78. public DelegateCommand GoLoginCommand { get; set; }
  79. public DelegateCommand RefreshCommand { get; set; }
  80. public IAPCompareDialogViewModel(IRegionManager regionManager, IDialogService dialogService)
  81. {
  82. LinkstoreCommand = new DelegateCommand(Linkstore);
  83. RefreshCommand = new DelegateCommand(Refresh);
  84. InitString();
  85. if (Settings.Default.UserDate.subscribestatus == 2 )
  86. {
  87. Textprice = "$79.99";
  88. Vishalfprice = Visibility.Collapsed;
  89. }
  90. else
  91. {
  92. Textprice = "$39.99";
  93. Vishalfprice = Visibility.Visible;
  94. }
  95. }
  96. public void Close()
  97. {
  98. RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
  99. }
  100. private void Linkstore()
  101. {
  102. Process.Start(new ProcessStartInfo(Uristore));
  103. }
  104. /// <summary>
  105. /// 刷新订阅状态按钮
  106. /// </summary>
  107. private void Refresh()
  108. {
  109. if (Settings.Default.AppProperties.LoginToken != "")
  110. {
  111. if (ServiceHelper.GetUser() == "401")
  112. {
  113. App.mainWindowViewModel.UserVis = Visibility.Collapsed;
  114. App.mainWindowViewModel.LoginVis = Visibility.Visible;
  115. App.mainWindowViewModel.OphVis = Visibility.Visible;
  116. if (Settings.Default.UserDate.IsLoginoff == false)
  117. {
  118. App.mainWindowViewModel.OpenLoginoff();
  119. Settings.Default.UserDate.IsLoginoff = true;
  120. Settings.Default.Save();
  121. }
  122. }
  123. }
  124. else
  125. {
  126. App.mainWindowViewModel.UserVis = Visibility.Collapsed;
  127. App.mainWindowViewModel.LoginVis = Visibility.Visible;
  128. App.mainWindowViewModel.OphVis = Visibility.Visible;
  129. }
  130. if (Settings.Default.UserDate.subscribestatus == 1&&App.IsLogin==true)
  131. {
  132. Close();
  133. }
  134. }
  135. }
  136. }