123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- using PDF_Office.Helper;
- using PDF_Office.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_Office.ViewModels.Dialog.ServiceDialog
- {
- public class PasswordUpdataRegionViewModel : BindableBase, INavigationAware
- {
- private string uuid = ServiceHelper.GetDeviceSerialNumber();
- 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>("LoginDialogViewModel", out LoginDialogViewModel);
- LoginEmail = LoginDialogViewModel.LoginEmail;
- }
- 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);
- PasswordUpdatalookVis = Visibility.Collapsed;
- if (string.IsNullOrEmpty(LoginPassword))
- {
- ChkVis = Visibility.Collapsed;
- }
- else
- {
- ChkVis = Visibility.Visible;
- }
- CheckEnableNextStepEncrypt();
- }
- }
- private string _LoginPasswordMsg = "Enter the new password again";
- public string LoginPasswordMsg
- {
- get { return _LoginPasswordMsg; }
- set
- {
- SetProperty(ref _LoginPasswordMsg, value);
- }
- }
- 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 string _LoginPassword2 = "";
- public string LoginPassword2
- {
- get { return _LoginPassword2; }
- set
- {
- SetProperty(ref _LoginPassword2, value);
- PasswordUpdatalookVis = Visibility.Collapsed;
- if (string.IsNullOrEmpty(LoginPassword2))
- {
- ChkVis2 = Visibility.Collapsed;
- }
- else
- {
- ChkVis2 = Visibility.Visible;
- }
- CheckEnableNextStepEncrypt();
- }
- }
- private string _LoginPasswordMsg2 = "Enter your password";
- public string LoginPasswordMsg2
- {
- get { return _LoginPasswordMsg2; }
- set
- {
- SetProperty(ref _LoginPasswordMsg2, 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 Visibility _PasswordUpdatalookVis = Visibility.Collapsed;
- public Visibility PasswordUpdatalookVis
- {
- get { return _PasswordUpdatalookVis; }
- set { SetProperty(ref _PasswordUpdatalookVis, value); }
- }
- public DelegateCommand<object> DisplayPasswordCommand { get; set; }
- public DelegateCommand<object> 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;
- DisplayPasswordCommand = new DelegateCommand<object>(DisplayPassword);
- DisplayPasswordCommand2 = new DelegateCommand<object>(DisplayPassword2);
- PasswordUpdataCommand = new DelegateCommand(PasswordUpdata);
- LoginPasswordChangedCommand = new DelegateCommand(LoginPasswordChanged);
- LoginPasswordChanged2Command = new DelegateCommand(LoginPasswordChanged2);
- }
- private void LoginPasswordChanged()
- {
- if (LoginPassword.Length < 6)
- {
- LoginPasswordlook = "At least 6 characters";
- }
- else if (LoginPassword.Length > 24)
- {
- LoginPasswordlook = "Up to 24 characters";
- }
- else
- {
- LoginPasswordlook = "";
- }
- }
- private void LoginPasswordChanged2()
- {
- if (LoginPassword2.Length < 6)
- {
- LoginPasswordlook2 = "At least 6 characters";
- }
- else if (LoginPassword2.Length > 24)
- {
- LoginPasswordlook2 = "Up to 24 characters";
- }
- else
- {
- LoginPasswordlook2 = "";
- }
- }
- private void PasswordUpdata()
- {
-
-
- if (ServiceHelper.Rebirth(LoginEmail, LoginPassword2, LoginPassword, LoginDialogViewModel.PasswordCode) == "success")
- {
- LoginDialogViewModel.RegionMan("LoginRegion");
- }
- else
- {
- PasswordUpdatamsglook = ServiceHelper.Rebirth(LoginEmail, LoginPassword2, LoginPassword, LoginDialogViewModel.PasswordCode);
- PasswordUpdatalookVis = Visibility.Visible;
- }
- }
- private void CheckEnableNextStepEncrypt()
- {
- EnableNextStep = true;
- if (LoginPassword.Length < 6 || LoginPassword.Length > 24 || LoginPassword2.Length < 6 || LoginPassword2.Length > 24)
- {
- 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;
- }
- }
- }
- }
- }
|