SubscriptionDialogViewModel.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. using ComPDFKit.PDFWatermark;
  2. using ComPDFKitViewer.PdfViewer;
  3. using PDF_Master.Helper;
  4. using PDF_Master.Model;
  5. using PDF_Master.Model.EditTools.Watermark;
  6. using PDF_Master.Properties;
  7. using Prism.Commands;
  8. using Prism.Mvvm;
  9. using Prism.Regions;
  10. using Prism.Services.Dialogs;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Diagnostics;
  14. using System.IO;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Threading.Tasks;
  18. using System.Windows;
  19. using System.Windows.Media.Imaging;
  20. using System.Windows.Resources;
  21. namespace PDF_Master.ViewModels.Dialog.ServiceDialog
  22. {
  23. public class SubscriptionDialogViewModel : BindableBase, IDialogAware
  24. {
  25. public string Title => "";
  26. private ViewContentViewModel viewContentViewModel;
  27. private string open;
  28. public event Action<IDialogResult> RequestClose;
  29. #region 文案
  30. #endregion
  31. /// <summary>
  32. /// 价格优惠bord
  33. /// </summary>
  34. private Visibility _Vishalfprice = Visibility.Visible;
  35. public Visibility Vishalfprice
  36. {
  37. get { return _Vishalfprice; }
  38. set
  39. {
  40. SetProperty(ref _Vishalfprice, value);
  41. }
  42. }
  43. private double _RightBtnWidth = 192;
  44. public double RightBtnWidth
  45. {
  46. get { return _RightBtnWidth; }
  47. set
  48. {
  49. SetProperty(ref _RightBtnWidth, value);
  50. }
  51. }
  52. /// <summary>
  53. /// 左边按钮的vis
  54. /// </summary>
  55. private Visibility _LeftBtnVis = Visibility.Visible;
  56. public Visibility LeftBtnVis
  57. {
  58. get { return _LeftBtnVis; }
  59. set
  60. {
  61. SetProperty(ref _LeftBtnVis, value);
  62. }
  63. }
  64. /// <summary>
  65. /// 价格优惠
  66. /// </summary>
  67. private string _Textprice = "$39.99/year";
  68. public string Textprice
  69. {
  70. get { return _Textprice; }
  71. set
  72. {
  73. SetProperty(ref _Textprice, value);
  74. }
  75. }
  76. private string _TextSubscriptionBenefit;
  77. public string TextSubscriptionBenefit
  78. {
  79. get { return _TextSubscriptionBenefit; }
  80. set { SetProperty(ref _TextSubscriptionBenefit, value); }
  81. }
  82. private string _TextSavewithout;
  83. public string TextSavewithout
  84. {
  85. get { return _TextSavewithout; }
  86. set { SetProperty(ref _TextSavewithout, value); }
  87. }
  88. private string _TextWhenyou;
  89. public string TextWhenyou
  90. {
  91. get { return _TextWhenyou; }
  92. set { SetProperty(ref _TextWhenyou, value); }
  93. }
  94. private string _TextConvertPDF;
  95. public string TextConvertPDF
  96. {
  97. get { return _TextConvertPDF; }
  98. set { SetProperty(ref _TextConvertPDF, value); }
  99. }
  100. private string _TextConvertPDFto;
  101. public string TextConvertPDFto
  102. {
  103. get { return _TextConvertPDFto; }
  104. set { SetProperty(ref _TextConvertPDFto, value); }
  105. }
  106. private string _TextAIassitant;
  107. public string TextAIassitant
  108. {
  109. get { return _TextAIassitant; }
  110. set { SetProperty(ref _TextAIassitant, value); }
  111. }
  112. private string _TextSupportAI;
  113. public string TextSupportAI
  114. {
  115. get { return _TextSupportAI; }
  116. set { SetProperty(ref _TextSupportAI, value); }
  117. }
  118. private string _BtnTextSavewithWatermark;
  119. public string BtnTextSavewithWatermark
  120. {
  121. get { return _BtnTextSavewithWatermark; }
  122. set { SetProperty(ref _BtnTextSavewithWatermark, value); }
  123. }
  124. private string _Textoff;
  125. public string Textoff
  126. {
  127. get { return _Textoff; }
  128. set { SetProperty(ref _Textoff, value); }
  129. }
  130. private string _BtnTextSubscribe;
  131. public string BtnTextSubscribe
  132. {
  133. get { return _BtnTextSubscribe; }
  134. set { SetProperty(ref _BtnTextSubscribe, value); }
  135. }
  136. private string _uristore = "https://www.pdfreaderpro.com/windows/store/permanent";
  137. public string Uristore
  138. {
  139. get { return _uristore; }
  140. set
  141. {
  142. SetProperty(ref _uristore, value);
  143. }
  144. }
  145. public DelegateCommand LinkstoreCommand { get; set; }
  146. public DelegateCommand WarermarkSavingCommand { get; set; }
  147. public DelegateCommand RefreshCommand { get; set; }
  148. private void InitString()
  149. {
  150. TextSubscriptionBenefit = App.ServiceLoader.GetString("TextSubscriptionBenefit");
  151. TextSavewithout = App.ServiceLoader.GetString("TextSavewithout");
  152. TextWhenyou = App.ServiceLoader.GetString("TextWhenyou");
  153. TextConvertPDF = App.ServiceLoader.GetString("TextConvertPDFwithout");
  154. TextConvertPDFto = App.ServiceLoader.GetString("TextConvertPDFto");
  155. TextAIassitant = App.ServiceLoader.GetString("TextAIassitant");
  156. TextSupportAI = App.ServiceLoader.GetString("TextSupportAI");
  157. Textoff = App.ServiceLoader.GetString("Textoff");
  158. BtnTextSubscribe = App.ServiceLoader.GetString("BtnTextSubscribe");
  159. }
  160. public SubscriptionDialogViewModel(IRegionManager regionManager, IDialogService dialogService)
  161. {
  162. RefreshCommand = new DelegateCommand(Refresh);
  163. LinkstoreCommand = new DelegateCommand(Linkstore);
  164. WarermarkSavingCommand = new DelegateCommand(WarermarkSaving);
  165. InitString();
  166. if (Settings.Default.UserDate.subscribestatus == 2)
  167. {
  168. Textprice = "$79.99/year";
  169. Vishalfprice = Visibility.Collapsed;
  170. }
  171. else
  172. {
  173. Textprice = "$39.99/year";
  174. Vishalfprice = Visibility.Visible;
  175. }
  176. }
  177. private void Linkstore()
  178. {
  179. Process.Start(new ProcessStartInfo(Uristore));
  180. }
  181. /// <summary>
  182. /// 水印保存
  183. /// </summary>
  184. private void WarermarkSaving()
  185. {
  186. String IsFormSave = "FormSave";
  187. if(open!=null)
  188. {
  189. RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK));
  190. }
  191. else
  192. {
  193. if( viewContentViewModel.saveAsFile(null, IsFormSave)==false)
  194. {
  195. RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
  196. }
  197. else
  198. {
  199. RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK));
  200. }
  201. }
  202. }
  203. /// <summary>
  204. /// 刷新订阅状态按钮
  205. /// </summary>
  206. private void Refresh()
  207. {
  208. if (Settings.Default.AppProperties.LoginToken != "")
  209. {
  210. if (ServiceHelper.GetUser() == "330" || ServiceHelper.GetUser() == "304")
  211. {
  212. App.mainWindowViewModel.UserVis = Visibility.Collapsed;
  213. App.mainWindowViewModel.LoginVis = Visibility.Visible;
  214. App.mainWindowViewModel.OphVis = Visibility.Visible;
  215. if (Settings.Default.UserDate.IsLoginoff == false)
  216. {
  217. App.mainWindowViewModel.OpenLoginoff();
  218. Settings.Default.UserDate.IsLoginoff = true;
  219. Settings.Default.Save();
  220. }
  221. }
  222. }
  223. else
  224. {
  225. App.mainWindowViewModel.UserVis = Visibility.Collapsed;
  226. App.mainWindowViewModel.LoginVis = Visibility.Visible;
  227. App.mainWindowViewModel.OphVis = Visibility.Visible;
  228. }
  229. if (Settings.Default.UserDate.subscribestatus == 1&&App.IsLogin == true)
  230. {
  231. Close();
  232. }
  233. }
  234. public void Close()
  235. {
  236. RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
  237. }
  238. public bool CanCloseDialog()
  239. {
  240. return true;
  241. }
  242. public void OnDialogClosed()
  243. {
  244. }
  245. public void OnDialogOpened(IDialogParameters parameters)
  246. {
  247. parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
  248. parameters.TryGetValue<String>(ParameterNames.Open, out open);
  249. if (open == "AI")
  250. {
  251. LeftBtnVis = Visibility.Collapsed;
  252. RightBtnWidth = 280;
  253. }
  254. if (open == "Auto")
  255. {
  256. BtnTextSavewithWatermark = App.ServiceLoader.GetString("BtnTextContinue");
  257. }
  258. else
  259. {
  260. BtnTextSavewithWatermark = App.ServiceLoader.GetString("BtnTextSavewithWatermark");
  261. }
  262. }
  263. }
  264. }