IAPCompareDialogViewModel.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. GoLoginCommand = new DelegateCommand(GoLogin);
  83. LinkstoreCommand = new DelegateCommand(Linkstore);
  84. RefreshCommand = new DelegateCommand(Refresh);
  85. InitString();
  86. if (Settings.Default.UserDate.subscribestatus == 2 )
  87. {
  88. Textprice = "$79.99";
  89. Vishalfprice = Visibility.Collapsed;
  90. }
  91. else
  92. {
  93. Textprice = "$39.99";
  94. Vishalfprice = Visibility.Visible;
  95. }
  96. }
  97. private void GoLogin()
  98. {
  99. Close();
  100. App.mainWindowViewModel.OpenLogin();
  101. }
  102. public void Close()
  103. {
  104. RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
  105. }
  106. private void Linkstore()
  107. {
  108. Process.Start(new ProcessStartInfo(Uristore));
  109. }
  110. /// <summary>
  111. /// 刷新订阅状态按钮
  112. /// </summary>
  113. private void Refresh()
  114. {
  115. if (Settings.Default.AppProperties.LoginToken != "")
  116. {
  117. string code = ServiceHelper.GetUser();
  118. if (code == "330" || code == "304")
  119. {
  120. App.mainWindowViewModel.UserVis = Visibility.Collapsed;
  121. App.mainWindowViewModel.LoginVis = Visibility.Visible;
  122. App.mainWindowViewModel.OphVis = Visibility.Visible;
  123. if (Settings.Default.UserDate.IsLoginoff == false)
  124. {
  125. App.mainWindowViewModel.OpenLoginoff();
  126. Settings.Default.UserDate.IsLoginoff = true;
  127. Settings.Default.Save();
  128. }
  129. }
  130. }
  131. else
  132. {
  133. App.mainWindowViewModel.UserVis = Visibility.Collapsed;
  134. App.mainWindowViewModel.LoginVis = Visibility.Visible;
  135. App.mainWindowViewModel.OphVis = Visibility.Visible;
  136. }
  137. if (Settings.Default.UserDate.subscribestatus == 1&&App.IsLogin==true)
  138. {
  139. Close();
  140. }
  141. }
  142. }
  143. }