SubscriptionDialogViewModel.cs 8.9 KB

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