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.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; namespace PDF_Office.ViewModels.Dialog.ServiceDialog { public class LoginRegionViewModel : BindableBase, INavigationAware { 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); } private bool enableNextStep = false; public bool EnableNextStep { get { return enableNextStep; } set { SetProperty(ref enableNextStep, value); } } private string _LoginEmaillook; public string LoginEmaillook { get { return _LoginEmaillook; } set { SetProperty(ref _LoginEmaillook, value);} } private string _LoginNextStep = "Next Step"; public string LoginNextStep { get { return _LoginNextStep; } set { SetProperty(ref _LoginNextStep, value); } } private string _LoginEmail = ""; public string LoginEmail { get { return _LoginEmail; } set { SetProperty(ref _LoginEmail, value); if (LoginEmail == "") { LoginEmaillook = ""; } else { CheckMail(LoginEmail); } CheckEnableNextStepEncrypt(); } } private string _LoginEmailMsg = "Enter email address"; public string LoginEmailMsg { get { return _LoginEmailMsg; } set { SetProperty(ref _LoginEmailMsg, value); } } public DelegateCommand LoginNextCommand { get; set; } public DelegateCommand GoLoginCommand { get; set; } LoginRegionViewModel(IRegionManager regionManager, IDialogService dialogService) { dialogs = dialogService; LoginNextCommand = new DelegateCommand(LoginNext); GoLoginCommand = new DelegateCommand(GoLogin); } private void LoginNext() { if (ServiceHelper.Ok_email(LoginEmail, "1") == "success") { LoginDialogViewModel.LoginEmail = LoginEmail; LoginDialogViewModel.RegionMan("LoginPasswordRegion"); } else { LoginEmaillook = ServiceHelper.Ok_email(LoginEmail, "1"); } ServiceHelper.ALLEmail = LoginEmail; } 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)) { LoginEmaillook = ""; } else { LoginEmaillook = "请输入正确的邮箱格式"; } } private void GoLogin() { LoginDialogViewModel.Close(); App.mainWindowViewModel.OpenRegister(); } private void CheckEnableNextStepEncrypt() { EnableNextStep = true; if (string.IsNullOrEmpty(LoginEmail)||LoginEmaillook!="") { EnableNextStep = false; } } } }