using ComPDFKit.PDFWatermark; using ComPDFKitViewer.PdfViewer; using PDF_Master.Helper; using PDF_Master.Model; using PDF_Master.Model.EditTools.Watermark; using PDF_Master.Properties; using PDFReader_WPF.Helper; using Prism.Commands; using Prism.Mvvm; using Prism.Regions; using Prism.Services.Dialogs; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Media.Imaging; using System.Windows.Resources; namespace PDF_Master.ViewModels.Dialog.ServiceDialog { public class SubscriptionDialogViewModel : BindableBase, IDialogAware { public string Title => ""; private ViewContentViewModel viewContentViewModel; private string open; public event Action RequestClose; #region 文案 #endregion /// /// 价格优惠bord /// private Visibility _Vishalfprice = Visibility.Visible; public Visibility Vishalfprice { get { return _Vishalfprice; } set { SetProperty(ref _Vishalfprice, value); } } private double _RightBtnWidth = 394; public double RightBtnWidth { get { return _RightBtnWidth; } set { SetProperty(ref _RightBtnWidth, value); } } /// /// 左边按钮的vis /// private Visibility _LeftBtnVis = Visibility.Visible; public Visibility LeftBtnVis { get { return _LeftBtnVis; } set { SetProperty(ref _LeftBtnVis, value); } } /// /// 价格优惠 /// private string _Textprice = "$39.99/year"; public string Textprice { get { return _Textprice; } set { SetProperty(ref _Textprice, value); } } private string _TextSubscriptionBenefit; public string TextSubscriptionBenefit { get { return _TextSubscriptionBenefit; } set { SetProperty(ref _TextSubscriptionBenefit, value); } } private string _TextSavewithout; public string TextSavewithout { get { return _TextSavewithout; } set { SetProperty(ref _TextSavewithout, value); } } private string _TextWhenyou; public string TextWhenyou { get { return _TextWhenyou; } set { SetProperty(ref _TextWhenyou, value); } } private string _TextConvertPDF; public string TextConvertPDF { get { return _TextConvertPDF; } set { SetProperty(ref _TextConvertPDF, value); } } private string _TextConvertPDFto; public string TextConvertPDFto { get { return _TextConvertPDFto; } set { SetProperty(ref _TextConvertPDFto, value); } } private string _TextAIassitant; public string TextAIassitant { get { return _TextAIassitant; } set { SetProperty(ref _TextAIassitant, value); } } private string _TextSupportAI; public string TextSupportAI { get { return _TextSupportAI; } set { SetProperty(ref _TextSupportAI, value); } } private string _BtnTextSavewithWatermark; public string BtnTextSavewithWatermark { get { return _BtnTextSavewithWatermark; } set { SetProperty(ref _BtnTextSavewithWatermark, value); } } private string _Textoff; public string Textoff { get { return _Textoff; } set { SetProperty(ref _Textoff, value); } } private string _TextBatchProcessing; public string TextBatchProcessing { get { return _TextBatchProcessing; } set { _TextBatchProcessing = value; } } private string _TextBatch; public string TextBatch { get { return _TextBatch; } set { _TextBatch = value; } } private string _BtnTextSubscribe; public string BtnTextSubscribe { get { return _BtnTextSubscribe; } set { SetProperty(ref _BtnTextSubscribe, value); } } private string _uristore = ServiceHelper.WebHost + "/windows/store/master?email=" + Settings.Default.UserDate.Email; public string Uristore { get { return _uristore; } set { SetProperty(ref _uristore, value); } } public DelegateCommand LinkstoreCommand { get; set; } public DelegateCommand WarermarkSavingCommand { get; set; } public DelegateCommand RefreshCommand { get; set; } private void InitString() { TextSubscriptionBenefit = App.ServiceLoader.GetString("TextSubscriptionBenefit"); TextSavewithout = App.ServiceLoader.GetString("TextSavewithout"); TextWhenyou = App.ServiceLoader.GetString("TextWhenyou"); TextConvertPDF = App.ServiceLoader.GetString("TextConvertPDFwithout"); TextConvertPDFto = App.ServiceLoader.GetString("TextConvertPDFto"); TextAIassitant = App.ServiceLoader.GetString("TextAIassitant"); TextSupportAI = App.ServiceLoader.GetString("TextSupportAI"); Textoff = App.ServiceLoader.GetString("Textoff"); BtnTextSubscribe = App.ServiceLoader.GetString("BtnTextSubscribe"); TextBatch = App.ServiceLoader.GetString("TextBatch"); TextBatchProcessing = App.ServiceLoader.GetString("TextBatchProcessing"); BtnTextSavewithWatermark = App.ServiceLoader.GetString("BtnTextSavewithWatermark"); } public SubscriptionDialogViewModel(IRegionManager regionManager, IDialogService dialogService) { LinkstoreCommand = new DelegateCommand(Linkstore); WarermarkSavingCommand = new DelegateCommand(WarermarkSaving); InitString(); if (Settings.Default.UserDate.subscribestatus == 2) { Textprice = "$79.99/year"; Vishalfprice = Visibility.Collapsed; } else { Textprice = "$39.99/year"; Vishalfprice = Visibility.Visible; } } private void Linkstore() { DataTrackingHelper.AddThirdPath(); DataTrackingHelper.SendPurchaseEvent(); DataTrackingHelper.SendEvent(DataTrackingHelper.EventType.PUW, "Sub_PUW", "PUW_Sub_Subscribe"); Process.Start(new ProcessStartInfo(Uristore)); } /// /// 水印保存 /// private void WarermarkSaving() { DataTrackingHelper.SendEvent(DataTrackingHelper.EventType.PUW, "Sub_PUW", "PUW_Sub_SaveWatermark"); String IsFormSave = "FormSave"; if(open== "saveAs") { RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK)); } else { if(viewContentViewModel != null&&viewContentViewModel.saveAsFile(null, IsFormSave)==false) { RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel)); } else { RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK)); } } } public void Close() { RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel)); } public bool CanCloseDialog() { return true; } public void OnDialogClosed() { } public void OnDialogOpened(IDialogParameters parameters) { parameters.TryGetValue(ParameterNames.ViewContentViewModel, out viewContentViewModel); parameters.TryGetValue(ParameterNames.Open, out open); //AI目前策略不会弹出权益弹窗 //if (open == "AI") //{ // LeftBtnVis = Visibility.Collapsed; // RightBtnWidth = 280; //} // //if (open == "Auto") //{ // BtnTextSavewithWatermark = App.ServiceLoader.GetString("BtnTextContinue"); //} //else //{ // BtnTextSavewithWatermark = App.ServiceLoader.GetString("BtnTextSavewithWatermark"); //} } } }