123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- using System;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media;
- using PDF_Master.CustomControl;
- using PDF_Master.Helper;
- using PDF_Master.Properties;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Regions;
- using Prism.Services.Dialogs;
- namespace PDF_Master.ViewModels.Dialog.ServiceDialog
- {
- public class UserDialogViewModel : BindableBase, IDialogAware
- {
- private string uuid = ServiceHelper.GetDeviceSerialNumber();
- public IRegionManager Region;
- public string Title => "";
- public event Action<IDialogResult> RequestClose;
- public void Close()
- {
- RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
- }
- public bool CanCloseDialog()
- {
- return true;
- }
- public void OnDialogClosed()
- {
- App.UserOpen = false;
- }
- public void OnDialogOpened(IDialogParameters parameters)
- {
- }
- #region 文案
- private string _Text_useracc = "";
- public string Text_useracc
- {
- get { return _Text_useracc; }
- set
- {
- SetProperty(ref _Text_useracc, value);
- }
- }
- private string _Text_admail = "";
- public string Text_admail
- {
- get { return _Text_admail; }
- set
- {
- SetProperty(ref _Text_admail, value);
- }
- }
- private string _Text_logout = "";
- public string Text_logout
- {
- get { return _Text_logout; }
- set
- {
- SetProperty(ref _Text_logout, value);
- }
- }
- private string _Text_cancel = "";
- public string Text_cancel
- {
- get { return _Text_cancel; }
- set
- {
- SetProperty(ref _Text_cancel, value);
- }
- }
- private string _Text_no = "";
- public string Text_no
- {
- get { return _Text_no; }
- set
- {
- SetProperty(ref _Text_no, value);
- }
- }
- private string _Text_yes = "";
- public string Text_yes
- {
- get { return _Text_yes; }
- set
- {
- SetProperty(ref _Text_yes, value);
- }
- }
- private string _Text_useroutmsg = "";
- public string Text_useroutmsg
- {
- get { return _Text_useroutmsg; }
- set
- {
- SetProperty(ref _Text_useroutmsg, value);
- }
- }
- private string _Text_userouttol = "";
- public string Text_userouttol
- {
- get { return _Text_userouttol; }
- set
- {
- SetProperty(ref _Text_userouttol, value);
- }
- }
-
- private Brush _TextSubscribeStateColor = (Brush)new BrushConverter().ConvertFromString("#252629");
- public Brush TextSubscribeStateColor
- {
- get { return _TextSubscribeStateColor; }
- set
- {
- SetProperty(ref _TextSubscribeStateColor, value);
- }
- }
- private string _TextSubscribeState = "";
- public string TextSubscribeState
- {
- get { return _TextSubscribeState; }
- set
- {
- SetProperty(ref _TextSubscribeState, value);
- }
- }
- private string _TextSubscribeEndtime = "";
- public string TextSubscribeEndtime
- {
- get { return _TextSubscribeEndtime; }
- set
- {
- SetProperty(ref _TextSubscribeEndtime, value);
- }
- }
- private string _TextSubscribetimetext = "";
- public string TextSubscribetimetext
- {
- get { return _TextSubscribetimetext; }
- set
- {
- SetProperty(ref _TextSubscribetimetext, value);
- }
- }
- private string _TextStatus;
- public string TextStatus
- {
- get { return _TextStatus; }
- set { _TextStatus = value; }
- }
- private string _TextOnTrial;
- public string TextOnTrial
- {
- get { return _TextOnTrial; }
- set { _TextOnTrial = value; }
- }
- private string _TextTrialExpired;
- public string TextTrialExpired
- {
- get { return _TextTrialExpired; }
- set { _TextTrialExpired = value; }
- }
- private string _TextSubscriptionExpired;
- public string TextSubscriptionExpired
- {
- get { return _TextSubscriptionExpired; }
- set { _TextSubscriptionExpired = value; }
- }
- private string _TextAutorenewal;
- public string TextAutorenewal
- {
- get { return _TextAutorenewal; }
- set { _TextAutorenewal = value; }
- }
- private string _TextSubscription;
- public string TextSubscription
- {
- get { return _TextSubscription; }
- set { _TextSubscription = value; }
- }
- private string _TextOrderInformation;
- public string TextOrderInformation
- {
- get { return _TextOrderInformation; }
- set { _TextOrderInformation = value; }
- }
- private string _BtnTextSubscribe;
- public string BtnTextSubscribe
- {
- get { return _BtnTextSubscribe; }
- set { _BtnTextSubscribe = value; }
- }
- private void InitString()
- {
- Text_useracc = App.ServiceLoader.GetString("Text_useracc");
- Text_admail = App.ServiceLoader.GetString("Text_admail");
- Text_logout = App.ServiceLoader.GetString("Text_logout");
- Text_cancel = App.ServiceLoader.GetString("Text_cancel");
-
- Text_userouttol = App.ServiceLoader.GetString("Text_userouttol");
- Text_useroutmsg = App.ServiceLoader.GetString("Text_useroutmsg");
- Text_yes = App.ServiceLoader.GetString("Text_yes");
- Text_no = App.ServiceLoader.GetString("Text_no");
- TextStatus = App.ServiceLoader.GetString("TextStatus");
- TextOnTrial = App.ServiceLoader.GetString("TextOnTrial");
- TextTrialExpired = App.ServiceLoader.GetString("TextTrialExpired");
- TextSubscriptionExpired = App.ServiceLoader.GetString("TextSubscriptionExpired");
- TextAutorenewal = App.ServiceLoader.GetString("TextAutorenewal");
- TextSubscription = App.ServiceLoader.GetString("TextSubscription");
- TextOrderInformation = App.ServiceLoader.GetString("TextOrderInformation");
- BtnTextSubscribe = App.ServiceLoader.GetString("BtnTextSubscribe");
- }
- #endregion
- private string _Useremailchar = Settings.Default.UserDate.Email.Substring(0, 1);
- public string Useremailchar
- {
- get { return _Useremailchar; }
- set
- {
- SetProperty(ref _Useremailchar, value);
- }
- }
- private string _UserEmail = Settings.Default.UserDate.Email;
- public string UserEmail
- {
- get { return _UserEmail; }
- set { _UserEmail = value; }
- }
- private string _UserRegionName;
- public string UserRegionName
- {
- get { return _UserRegionName; }
- set { _UserRegionName = value; }
- }
-
- private Visibility _LinkuserdataVis = Visibility.Collapsed;
- public Visibility LinkuserdataVis
- {
- get { return _LinkuserdataVis; }
- set { _LinkuserdataVis = value; }
- }
- private Visibility _Subscriptionbox =Visibility.Collapsed;
- public Visibility Subscriptionbox
- {
- get { return _Subscriptionbox; }
- set { _Subscriptionbox = value; }
- }
- private Visibility _Subscriptionbtn = Visibility.Collapsed;
- public Visibility Subscriptionbtn
- {
- get { return _Subscriptionbtn; }
- set { _Subscriptionbtn = value; }
- }
- private Visibility _Subscriptionauto = Visibility.Collapsed;
- public Visibility Subscriptionauto
- {
- get { return _Subscriptionauto; }
- set { _Subscriptionauto = value; }
- }
- private string _uristore = ServiceHelper.WebHost + "/windows/store/master-subscription?email=" + Settings.Default.UserDate.Email;
- public string Uristore
- {
- get { return _uristore; }
- set
- {
- SetProperty(ref _uristore, value);
- }
- }
- private string _Uriuserdata = ServiceHelper.WebHost + "/windows/account/master-subscription?appid=16&productId=22&token=" + Settings.Default.AppProperties.LoginToken;
- public string Uriuserdata
- {
- get { return _Uriuserdata; }
- set
- {
- SetProperty(ref _Uriuserdata, value);
- }
- }
- public DelegateCommand LinkstoreCommand { get; set; }
- public DelegateCommand UserOutCommand { get; set; }
- public DelegateCommand LogOutCommand { get; set; }
- public DelegateCommand LinkuserdataCommand { get; set; }
-
- UserDialogViewModel(IRegionManager regionManager, IDialogService dialogService)
- {
- this.Region = regionManager;
- InitString();
- UserRegionName = Guid.NewGuid().ToString();
- UserOutCommand = new DelegateCommand(UserOut);
- LogOutCommand = new DelegateCommand(LogOut);
- LinkstoreCommand = new DelegateCommand(Linkstore);
- LinkuserdataCommand = new DelegateCommand(Linkuserdata);
- TextSubscribeEndtime = Settings.Default.UserDate.subscribeendDate;
- UserEmail = Settings.Default.UserDate.Email;
- if(Settings.Default.UserDate.subscribestatus==1&& Settings.Default.UserDate.subscribepayType==1)
- {
- LinkuserdataVis = Visibility.Collapsed;
- Subscriptionbox = Visibility.Visible;
- Subscriptionauto= Visibility.Visible;
- TextSubscribeState= App.ServiceLoader.GetString("TextSubscribeStateOnTrial");
- TextSubscribeStateColor = (Brush)new BrushConverter().ConvertFromString("#252629");
- TextSubscribetimetext = App.ServiceLoader.GetString("TextSubscribetimetextOnTrial");
- }
- else if(Settings.Default.UserDate.subscribestatus == 1 && Settings.Default.UserDate.subscribepayType == 0)
- {
- LinkuserdataVis = Visibility.Collapsed;
- Subscriptionbox = Visibility.Visible;
- Subscriptionbtn = Visibility.Visible;
- Subscriptionauto = Visibility.Hidden;
- TextSubscribeState = App.ServiceLoader.GetString("TextSubscribeStateOnTrial");
- TextSubscribeStateColor = (Brush)new BrushConverter().ConvertFromString("#252629");
- TextSubscribetimetext = App.ServiceLoader.GetString("TextSubscribetimeExpired");
- }
- else if (Settings.Default.UserDate.subscribestatus == 2 )
- {
- LinkuserdataVis = Visibility.Collapsed;
- Subscriptionbox = Visibility.Visible;
- Subscriptionbtn = Visibility.Visible;
- Subscriptionauto = Visibility.Hidden;
- TextSubscribeState = App.ServiceLoader.GetString("TextSubscribeStateExpired");
- TextSubscribeStateColor= (Brush)new BrushConverter().ConvertFromString("#F3465B");
- TextSubscribetimetext = App.ServiceLoader.GetString("TextSubscribetimeExpired");
- }
- else
- {
- LinkuserdataVis = Visibility.Visible;
- Subscriptionbox = Visibility.Collapsed;
- Subscriptionbtn = Visibility.Collapsed;
- TextSubscribeState = App.ServiceLoader.GetString("TextSubscribeStateExpired");
- TextSubscribeStateColor = (Brush)new BrushConverter().ConvertFromString("#F3465B");
- TextSubscribetimetext = App.ServiceLoader.GetString("TextSubscribetimeExpired");
- }
-
- }
- private void Linkstore()
- {
- Process.Start(new ProcessStartInfo(Uristore));
- }
- private void Linkuserdata()
- {
- Process.Start(new ProcessStartInfo(Uriuserdata));
- }
- public void UserOut()
- {
- if(Settings.Default.UserDate.subscribestatus == 1)
- {
- AlertsMessage alertsMessage = new AlertsMessage();
- alertsMessage.ShowDialog(App.ServiceLoader.GetString("TextCancellationtop"), App.ServiceLoader.GetString("TextCancellation"), App.ServiceLoader.GetString("Text_ok"),IconType.Tip);
- }
- else
- {
- AlertsMessage alertsMessage = new AlertsMessage();
- alertsMessage.ShowDialog(Text_userouttol, Text_useroutmsg, App.ServiceLoader.GetString("Text_yes"), App.ServiceLoader.GetString("Text_no"), IconType.Tip);
- //调整按钮显示位置,cancel按钮表示确认退出
- //目的是尽量引导用户不注销
- if (alertsMessage.result == ContentResult.MiddleCancel)
- {
- RegionMan("UserOutCodeRegion");
- }
- }
-
- }
- public void LogOut()
- {
- ServiceHelper.Logout(uuid);
- Settings.Default.AppProperties.LoginToken = "";
- Settings.Default.Save();
- App.mainWindowViewModel.UserVis = Visibility.Collapsed;
- App.mainWindowViewModel.RegisterVis = Visibility.Collapsed;
- App.mainWindowViewModel.LoginVis = Visibility.Visible;
- Close();
- }
- public void RegionMan(string name)
- {
- NavigationParameters param = new NavigationParameters();
- param.Add("UserDialogViewModel", this);
- Region.RequestNavigate(UserRegionName, name, e => {
- var r = e.Result;
- }, param);
- }
- }
- }
|