123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498 |
- using PDF_Master.Helper;
- using PDF_Master.Model;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Regions;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- namespace PDF_Master.ViewModels.Dialog.ServiceDialog
- {
- public class RegisterRegionViewModel : BindableBase, INavigationAware
- {
- private RegisterDialogViewModel RegisterDialogViewModel;
- private ErrorCodeHelper ErrorCodeHelper = new ErrorCodeHelper();
- public IDialogService dialogs;
-
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
-
- }
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- navigationContext.Parameters.TryGetValue<RegisterDialogViewModel>("RegisterDialogViewModel", out RegisterDialogViewModel);
- }
- #region 文案
-
- private string _Text_Signup = "";
- public string Text_Signup
- {
- get { return _Text_Signup; }
- set { SetProperty(ref _Text_Signup, value); }
- }
- private string _registerText1 = "";
- public string Registertext1
- {
- get { return _registerText1; }
- set
- {
- SetProperty(ref _registerText1, value);
- }
- }
- private string _registerNextStep = "";
- public string RegisterNextStep
- {
- get { return _registerNextStep; }
- set
- {
- SetProperty(ref _registerNextStep, value);
- }
- }
- private string _registerEmailMsg = "";
- public string RegisterEmailMsg
- {
- get { return _registerEmailMsg; }
- set
- {
- SetProperty(ref _registerEmailMsg, value);
- }
- }
- private string _registerPasswordMsg = "";
- public string RegisterPasswordMsg
- {
- get { return _registerPasswordMsg; }
- set
- {
- SetProperty(ref _registerPasswordMsg, value);
- }
- }
- private string _Text_Login = "";
- public string Text_Login
- {
- get { return _Text_Login; }
- set { SetProperty(ref _Text_Login, value); }
- }
- private string _Text_remsg = "";
- public string Text_remsg
- {
- get { return _Text_remsg; }
- set
- {
- SetProperty(ref _Text_remsg, value);
- }
- }
- private string _Text_privary = "";
- public string Text_privary
- {
- get { return _Text_privary; }
- set
- {
- SetProperty(ref _Text_privary, value);
- }
- }
- private string _Text_and = "";
- public string Text_and
- {
- get { return _Text_and; }
- set
- {
- SetProperty(ref _Text_and, value);
- }
- }
- private string _Text_licens = "";
- public string Text_licens
- {
- get { return _Text_licens; }
- set
- {
- SetProperty(ref _Text_licens, value);
- }
- }
- private string _Containspaces = "";
- public string Containspaces
- {
- get { return _Containspaces; }
- set
- {
- SetProperty(ref _Containspaces, value);
- }
- }
- private string _Codemax = "";
- public string Codemax
- {
- get { return _Codemax; }
- set
- {
- SetProperty(ref _Codemax, value);
- }
- }
- private string _Codemin = "";
- public string Codemin
- {
- get { return _Codemin; }
- set
- {
- SetProperty(ref _Codemin, value);
- }
- }
- private string _Mailerr = "";
- public string Mailerr
- {
- get { return _Mailerr; }
- set
- {
- SetProperty(ref _Mailerr, value);
- }
- }
-
- private void InitString()
- {
- ErrorCodeHelper.InitString();
- Containspaces = App.ServiceLoader.GetString("code327");
- Text_Signup = App.ServiceLoader.GetString("Text_Signup");
- Registertext1 = App.ServiceLoader.GetString("Registertext1");
- RegisterEmailMsg = App.ServiceLoader.GetString("RegisterEmailMsg");
- RegisterPasswordMsg = App.ServiceLoader.GetString("RegisterPasswordMsg");
- RegisterNextStep = App.ServiceLoader.GetString("RegisterNextStep");
- Text_Login = App.ServiceLoader.GetString("Text_Login");
- Text_remsg = App.ServiceLoader.GetString("Text_remsg");
- Text_privary = App.ServiceLoader.GetString("Text_privary");
- Text_and = App.ServiceLoader.GetString("Text_and");
- Text_licens = App.ServiceLoader.GetString("Text_licens");
- Codemax = App.ServiceLoader.GetString("Codemax");
- Codemin = App.ServiceLoader.GetString("Codemin");
- Mailerr = App.ServiceLoader.GetString("Mailerr");
- }
- #endregion
- private bool enableNextStep = false;
- public bool EnableNextStep
- {
- get { return enableNextStep; }
- set { SetProperty(ref enableNextStep, value); }
- }
-
- private string _registerEmaillook;
- public string RegisterEmaillook
- {
- get { return _registerEmaillook; }
- set { SetProperty(ref _registerEmaillook, value); }
- }
- private string _registerePasswordlook;
- public string RegisterePasswordlook
- {
- get { return _registerePasswordlook; }
- set { SetProperty(ref _registerePasswordlook, value); }
- }
- private string _uriPolivy = "https://www.pdfreaderpro.com/privacy-policy";
- public string UriPolivy
- {
- get { return _uriPolivy; }
- set
- {
- SetProperty(ref _uriPolivy, value);
- }
- }
- private string _uriLicense = "https://www.pdfreaderpro.com/terms_of_service";
- public string UriLicense
- {
- get { return _uriLicense; }
- set
- {
- SetProperty(ref _uriLicense, value);
- }
- }
- private bool _isRegisterPasswordDisplayed = false;
- public bool IsRegisterPasswordDisplayed
- {
- get { return _isRegisterPasswordDisplayed; }
- set { SetProperty(ref _isRegisterPasswordDisplayed, value); }
- }
-
- private string _registerPassword = "";
- public string RegisterPassword
- {
- get { return _registerPassword; }
- set
- {
-
- SetProperty(ref _registerPassword, value);
- if (string.IsNullOrEmpty(RegisterPassword))
- {
- ChkVis = Visibility.Collapsed;
- }
- else
- {
- ChkVis = Visibility.Visible;
- }
- CheckEnableNextStepEncrypt();
- }
- }
- private string _registerEmail = "";
- public string RegisterEmail
- {
- get { return _registerEmail; }
- set
- {
- SetProperty(ref _registerEmail, value);
- RegisterEmaillook = "";
- //if (RegisterEmail=="")
- //{
- // RegisterEmaillook = "";
- //}
- //else
- //{
- // CheckMail(RegisterEmail);
- //}
-
- CheckEnableNextStepEncrypt();
- }
- }
-
- private Visibility _registerPasswordVisibility = Visibility.Visible;
- public Visibility RegisterPasswordVisibility
- {
- get { return _registerPasswordVisibility; }
- set
- {
- if (value == Visibility.Visible)
- {
- RegisterTextVisibility = Visibility.Collapsed;
- }
- else
- {
- RegisterTextVisibility = Visibility.Visible;
- }
- SetProperty(ref _registerPasswordVisibility, value);
- }
- }
- private Visibility _ChkVis = Visibility.Collapsed;
- public Visibility ChkVis
- {
- get { return _ChkVis; }
- set { SetProperty(ref _ChkVis, value); }
- }
-
- private Visibility _registerTextVisibility = Visibility.Collapsed;
- public Visibility RegisterTextVisibility
- {
- get { return _registerTextVisibility; }
- set { SetProperty(ref _registerTextVisibility, value); }
- }
- private bool _isPermissionsPasswordDisplayed = false;
- public bool IsPermissionsPasswordDisplayed
- {
- get { return _isPermissionsPasswordDisplayed; }
- set { SetProperty(ref _isPermissionsPasswordDisplayed, value); }
- }
-
- public DelegateCommand<object> DisplayPasswordCommand { get; set; }
- public DelegateCommand LinkPolicyCommand { get; set; }
- public DelegateCommand RegisterNextCommand { get; set; }
- public DelegateCommand GoLoginCommand { get; set; }
- public DelegateCommand RegisterPasswordChangedCommand { get; set; }
- public DelegateCommand LinkLicenseCommand { get; set; }
- RegisterRegionViewModel(IRegionManager regionManager, IDialogService dialogService)
- {
- dialogs = dialogService;
- DisplayPasswordCommand = new DelegateCommand<object>(DisplayPassword);
- LinkPolicyCommand = new DelegateCommand(LinkPolicy);
- LinkLicenseCommand = new DelegateCommand(LinkLicense);
- GoLoginCommand = new DelegateCommand(GoLogin);
- RegisterNextCommand = new DelegateCommand(RegisterNext);
- RegisterPasswordChangedCommand = new DelegateCommand(RegisterPasswordChanged);
- InitString();
- }
- private void RegisterPasswordChanged()
- {
- if(RegisterPassword.Length<6&& RegisterPassword.Length>0)
- {
- RegisterePasswordlook = Codemin;
- }
- else if(RegisterPassword.Length>24)
- {
- RegisterePasswordlook = Codemax;
- }
- else if (RegisterPassword.Contains(" ") == true)
- {
- RegisterePasswordlook = Containspaces;
- }
- else
- {
- RegisterePasswordlook = "";
- }
- }
- private void CheckMail(string mail)
- {
- string str = "^([a-z0-9_\\.-]+)@([\\da-z\\.-]+)\\.([a-z\\.]{2,6})$";
- Regex mReg = new Regex(str);
- if (mReg.IsMatch(mail))
- {
- RegisterEmaillook = "";
- }
- else
- {
- RegisterEmaillook =Mailerr;
- }
- }
- private void RegisterNext()
- {
- //去掉前后空格
- RegisterEmail = RegisterEmail.Trim();
- string code = ServiceHelper.Ok_email(RegisterEmail, "2");
- if (code == "200")
- {
- RegisterDialogViewModel.RegisterEmail = RegisterEmail;
- RegisterDialogViewModel.RegisterPassword = RegisterPassword;
-
- RegisterDialogViewModel.RegionMan("CodeRegion");
- }
- else
- {
- RegisterEmaillook = ErrorCodeHelper.Ercode(code);
- }
- }
- public void SetOpenPassword(object e)
- {
- var chk = e as CheckBox;
- if (chk != null)
- {
- IsRegisterPasswordDisplayed = false;
- RegisterPasswordVisibility = Visibility.Visible;
- }
- CheckEnableNextStepEncrypt();
- }
- private void GoLogin()
- {
- RegisterDialogViewModel.Close();
- App.mainWindowViewModel.OpenLogin();
-
- }
- private void LinkPolicy()
- {
-
- Process.Start(new ProcessStartInfo(UriPolivy));
- }
- private void LinkLicense()
- {
- Process.Start(new ProcessStartInfo(UriLicense));
- }
- private void CheckEnableNextStepEncrypt()
- {
- EnableNextStep = true;
-
- if (RegisterPassword.Length<6|| RegisterPassword.Length >24 || string.IsNullOrEmpty(RegisterEmail)|| RegisterEmaillook!= "" || RegisterPassword.Contains(" ") == true)
- {
- EnableNextStep = false;
- }
- }
- public void DisplayPassword(object e)
- {
- var chk = e as CheckBox;
- if (chk != null)
- {
-
- if (chk.IsChecked == true)
- {
- RegisterPasswordVisibility = Visibility.Collapsed;
- }
- else
- {
- RegisterPasswordVisibility = Visibility.Visible;
- }
-
- }
- }
- }
- }
|