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.Threading.Tasks; using System.Windows; using System.Windows.Controls; namespace PDF_Master.ViewModels.Dialog.ServiceDialog { public class PasswordUpdataRegionViewModel : BindableBase, INavigationAware { private string uuid = ServiceHelper.GetDeviceSerialNumber(); private ErrorCodeHelper ErrorCodeHelper = new ErrorCodeHelper(); private LoginDialogViewModel LoginDialogViewModel; public IDialogService dialogs; public bool IsNavigationTarget(NavigationContext navigationContext) { return true; } public void OnNavigatedFrom(NavigationContext navigationContext) { } public void OnNavigatedTo(NavigationContext navigationContext) { navigationContext.Parameters.TryGetValue("LoginDialogViewModel", out LoginDialogViewModel); LoginEmail = LoginDialogViewModel.LoginEmail; } #region 文案 private string _Text_passuodata = ""; public string Text_passuodata { get { return _Text_passuodata; } set { SetProperty(ref _Text_passuodata, value); } } private string _LoginPasswordMsg = ""; public string LoginPasswordMsg { get { return _LoginPasswordMsg; } set { SetProperty(ref _LoginPasswordMsg, value); } } private string _LoginPasswordMsg2 = ""; public string LoginPasswordMsg2 { get { return _LoginPasswordMsg2; } set { SetProperty(ref _LoginPasswordMsg2, value); } } private string _Text_ok = ""; public string Text_ok { get { return _Text_ok; } set { SetProperty(ref _Text_ok, value); } } private void InitString() { Codemax = App.ServiceLoader.GetString("Codemax"); Codemin = App.ServiceLoader.GetString("Codemin"); Containspaces = App.ServiceLoader.GetString("code327"); Text_passuodata = App.ServiceLoader.GetString("Text_toocode"); LoginPasswordMsg = App.ServiceLoader.GetString("LoginPasswordMsg"); LoginPasswordMsg2 = App.ServiceLoader.GetString("LoginPasswordMsg2"); Text_ok = App.ServiceLoader.GetString("Text_ok"); } #endregion private bool enableNextStep = false; public bool EnableNextStep { get { return enableNextStep; } set { SetProperty(ref enableNextStep, value); } } private string _LoginEmail = ""; public string LoginEmail { get { return _LoginEmail; } set { SetProperty(ref _LoginEmail, value); CheckEnableNextStepEncrypt(); } } private string _LoginPasswordlook; public string LoginPasswordlook { get { return _LoginPasswordlook; } set { SetProperty(ref _LoginPasswordlook, value); } } private string _LoginPasswordlook2; public string LoginPasswordlook2 { get { return _LoginPasswordlook2; } set { SetProperty(ref _LoginPasswordlook2, value); } } private string _LoginPassword = ""; public string LoginPassword { get { return _LoginPassword; } set { SetProperty(ref _LoginPassword, value); if (string.IsNullOrEmpty(LoginPassword)) { ChkVis = Visibility.Collapsed; } else { ChkVis = Visibility.Visible; } CheckEnableNextStepEncrypt(); } } private string _LoginPassword2 = ""; public string LoginPassword2 { get { return _LoginPassword2; } set { SetProperty(ref _LoginPassword2, value); if (string.IsNullOrEmpty(LoginPassword2)) { ChkVis2 = Visibility.Collapsed; } else { ChkVis2 = Visibility.Visible; } CheckEnableNextStepEncrypt(); } } private Visibility _ChkVis = Visibility.Collapsed; public Visibility ChkVis { get { return _ChkVis; } set { SetProperty(ref _ChkVis, value); } } private Visibility _ChkVis2 = Visibility.Collapsed; public Visibility ChkVis2 { get { return _ChkVis2; } set { SetProperty(ref _ChkVis2, value); } } private Visibility _LoginPasswordVisibility = Visibility.Visible; public Visibility LoginPasswordVisibility { get { return _LoginPasswordVisibility; } set { if (value == Visibility.Visible) { LoginTextVisibility = Visibility.Collapsed; } else { LoginTextVisibility = Visibility.Visible; } SetProperty(ref _LoginPasswordVisibility, value); } } private Visibility _LoginTextVisibility = Visibility.Collapsed; public Visibility LoginTextVisibility { get { return _LoginTextVisibility; } set { SetProperty(ref _LoginTextVisibility, value); } } private Visibility _LoginPasswordVisibility2 = Visibility.Visible; public Visibility LoginPasswordVisibility2 { get { return _LoginPasswordVisibility2; } set { if (value == Visibility.Visible) { LoginTextVisibility2 = Visibility.Collapsed; } else { LoginTextVisibility2 = Visibility.Visible; } SetProperty(ref _LoginPasswordVisibility2, value); } } private Visibility _LoginTextVisibility2 = Visibility.Collapsed; public Visibility LoginTextVisibility2 { get { return _LoginTextVisibility2; } set { SetProperty(ref _LoginTextVisibility2, value); } } private string _PasswordUpdatamsglook = ""; public string PasswordUpdatamsglook { get { return _PasswordUpdatamsglook; } set { SetProperty(ref _PasswordUpdatamsglook, 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 Visibility _PasswordUpdatalookVis = Visibility.Collapsed; public Visibility PasswordUpdatalookVis { get { return _PasswordUpdatalookVis; } set { SetProperty(ref _PasswordUpdatalookVis, value); } } public DelegateCommand DisplayPasswordCommand { get; set; } public DelegateCommand DisplayPasswordCommand2 { get; set; } public DelegateCommand ChangeEmailCommand { get; set; } public DelegateCommand GoCodeUpdataCommand { get; set; } public DelegateCommand PasswordUpdataCommand { get; set; } public DelegateCommand LinkLicenseCommand { get; set; } public DelegateCommand LoginPasswordChangedCommand { get; set; } public DelegateCommand LoginPasswordChanged2Command { get; set; } PasswordUpdataRegionViewModel(IRegionManager regionManager, IDialogService dialogService) { dialogs = dialogService; InitString(); DisplayPasswordCommand = new DelegateCommand(DisplayPassword); DisplayPasswordCommand2 = new DelegateCommand(DisplayPassword2); PasswordUpdataCommand = new DelegateCommand(PasswordUpdata); LoginPasswordChangedCommand = new DelegateCommand(LoginPasswordChanged); LoginPasswordChanged2Command = new DelegateCommand(LoginPasswordChanged2); } private void LoginPasswordChanged() { if (LoginPassword.Length < 6 && LoginPassword.Length > 0) { LoginPasswordlook = Codemin; } else if (LoginPassword.Length > 24) { LoginPasswordlook = Codemax; } else if (LoginPassword.Contains(" ") == true) { LoginPasswordlook = Containspaces; } else if (LoginPassword != LoginPassword2 && LoginPassword != "" && LoginPassword2 != "") { LoginPasswordlook = ErrorCodeHelper.Ercode("320"); } else { LoginPasswordlook = ""; LoginPasswordlook2 = ""; } } private void LoginPasswordChanged2() { if (LoginPassword2.Length < 6 && LoginPassword2.Length > 0) { LoginPasswordlook2 = Codemin; } else if (LoginPassword2.Length > 24) { LoginPasswordlook2 =Codemax; } else if (LoginPassword2.Contains(" ") == true) { LoginPasswordlook2 = Containspaces; } else if (LoginPassword != LoginPassword2 && LoginPassword != "" && LoginPassword2 != "") { LoginPasswordlook = ErrorCodeHelper.Ercode("320"); LoginPasswordlook2 = ""; } else { LoginPasswordlook = ""; LoginPasswordlook2 = ""; } } private void PasswordUpdata() { string code = ServiceHelper.Rebirth(LoginEmail, LoginPassword2, LoginPassword, LoginDialogViewModel.PasswordCode); if (code == "200") { LoginDialogViewModel.RegionMan("LoginRegion"); } else { PasswordUpdatamsglook = ErrorCodeHelper.Ercode(code); PasswordUpdatalookVis = Visibility.Visible; } } private void CheckEnableNextStepEncrypt() { EnableNextStep = true; if (LoginPassword.Length < 6 || LoginPassword.Length > 24|| (LoginPassword!= LoginPassword2) || LoginPassword.Contains(" ") == true) { EnableNextStep = false; } } public void DisplayPassword(object e) { var chk = e as CheckBox; if (chk != null) { if (chk.IsChecked == true) { LoginPasswordVisibility = Visibility.Collapsed; } else { LoginPasswordVisibility = Visibility.Visible; } } } public void DisplayPassword2(object e) { var chk = e as CheckBox; if (chk != null) { if (chk.IsChecked == true) { LoginPasswordVisibility2 = Visibility.Collapsed; } else { LoginPasswordVisibility2 = Visibility.Visible; } } } } }