using System; using System.Text.RegularExpressions; namespace Shared.SimpleControl.Phone { public class RemoteUnLockPasswordReset : FrameLayout { DoorLock doorLock; static string unlockPassword = null; string getNum () { return unlockPassword; } public RemoteUnLockPasswordReset (DoorLock doorLock) { this.doorLock = doorLock; BackgroundColor = SkinStyle.Current.MainColor; } public void showRemoteUnLockPasswordReset () { #region 标题 FrameLayout topView = new FrameLayout () { Y = Application.GetRealHeight (36), Height = Application.GetRealHeight (90), BackgroundColor = SkinStyle.Current.MainColor, }; AddChidren (topView); Button title = new Button () { TextAlignment = TextAlignment.Center, TextColor = SkinStyle.Current.TextColor1, TextID = R.MyInternationalizationString.ResetPassword, TextSize = 19, }; topView.AddChidren (title); Button logo = new Button () { Width = Application.GetRealWidth (154), Height = Application.GetRealHeight (90), X = Application.GetRealWidth (486), UnSelectedImagePath = MainPage.LogoString, Gravity = Gravity.CenterVertical, }; topView.AddChidren (logo); Button back = new Button () { Height = Application.GetRealHeight (90), Width = Application.GetRealWidth (85), UnSelectedImagePath = "Item/Back.png", SelectedImagePath = "Item/BackSelected.png", Gravity = Gravity.CenterVertical, }; topView.AddChidren (back); back.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent (); }; #endregion var bodyView = new FrameLayout () { Y = topView.Bottom, Height = Application.GetRealHeight (Application.DesignHeight - 126), BackgroundColor = SkinStyle.Current.ViewColor, }; AddChidren (bodyView); var btnOrigialPassword = new Button () { Width = Application.GetRealWidth (500), Height = Application.GetRealHeight (85), Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight (20), TextID = R.MyInternationalizationString.PleaseEnterOldPassword, TextAlignment = TextAlignment.CenterLeft, TextSize = 12, TextColor = SkinStyle.Current.TextColor1, }; bodyView.AddChidren (btnOrigialPassword); var etOrigialPassword = new EditText () { Width = Application.GetRealWidth (500), Height = Application.GetRealHeight (85), Gravity = Gravity.CenterHorizontal, Y = btnOrigialPassword.Bottom, TextAlignment = TextAlignment.Center, Radius = (uint)Application.GetRealHeight (3), BorderColor = (uint)Application.GetMinRealAverage (3), UnSelectedImagePath = "Register/Register_Password_kuang.png", //Text = "1270166900@qq.com" }; bodyView.AddChidren (etOrigialPassword); var btnNewPassword = new Button () { Width = Application.GetRealWidth (500), Height = Application.GetRealHeight (85), Gravity = Gravity.CenterHorizontal, Y = etOrigialPassword.Bottom + Application.GetRealHeight (20), TextID = R.MyInternationalizationString.SetTheNewSixDigitPassword, TextAlignment = TextAlignment.CenterLeft, TextSize = 12, TextColor = SkinStyle.Current.TextColor1, }; bodyView.AddChidren (btnNewPassword); var etNewPasswrod = new EditText () { Width = Application.GetRealWidth (500), Height = Application.GetRealHeight (85), Gravity = Gravity.CenterHorizontal, Y = btnNewPassword.Bottom, UnSelectedImagePath = "Register/Register_Password_kuang.png", TextAlignment = TextAlignment.Center, Radius = (uint)Application.GetRealHeight (0), //Text = "123456" }; bodyView.AddChidren (etNewPasswrod); var btnConfirmpassword = new Button () { Width = Application.GetRealWidth (500), Height = Application.GetRealHeight (85), Gravity = Gravity.CenterHorizontal, Y = etNewPasswrod.Bottom + Application.GetRealHeight (20), TextID = R.MyInternationalizationString.RepeatPassword, TextAlignment = TextAlignment.CenterLeft, TextSize = 12, TextColor = SkinStyle.Current.TextColor1, }; bodyView.AddChidren (btnConfirmpassword); var etConfirmPassword = new EditText () { Width = Application.GetRealWidth (500), Height = Application.GetRealHeight (85), Gravity = Gravity.CenterHorizontal, Y = btnConfirmpassword.Bottom, UnSelectedImagePath = "Register/Register_Password_kuang.png", TextAlignment = TextAlignment.Center, Radius = (uint)Application.GetRealHeight (0), }; bodyView.AddChidren (etConfirmPassword); var btnOK = new Button () { Width = Application.GetRealWidth (247), Height = Application.GetRealHeight (89), X = Application.GetRealWidth ((640 - 247) / 2), Y = Application.GetRealHeight (700), BackgroundColor = SkinStyle.Current.MainColor, SelectedBackgroundColor = SkinStyle.Current.SelectedColor, TextID = R.MyInternationalizationString.OK, TextColor = SkinStyle.Current.TextColor1, Radius = 5, BorderColor = SkinStyle.Current.Transparent, BorderWidth = 0, TextSize = 18, }; bodyView.AddChidren (btnOK); btnOK.MouseDownEventHandler += (sender, e) => { btnOK.IsSelected = true; }; btnOK.MouseUpEventHandler += (sender, e) => { btnOK.IsSelected = false; }; btnOK.MouseUpEventHandler += (sender, e) => { if (etOrigialPassword.Text == "" || etNewPasswrod.Text == "" || etConfirmPassword.Text == "") { new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseWriteTheCompleteContent), Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; } if (etOrigialPassword.Text != doorLock.GetDoorLockPassword ()) { new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.OldPasswordIsError), Direction = AMPopTipDirection.Down, CloseTime = 2 }.Show ((View)sender); return; } if (etNewPasswrod.Text.Trim ().Length != 6) { new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.PasswordNotFormedFromSixDigitalCodes), Direction = AMPopTipDirection.Down, CloseTime = 4 }.Show ((View)sender); return; } if (etNewPasswrod.Text.Trim () != etConfirmPassword.Text.Trim ()) { new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.RepeatPasswordsDidNotmatch), Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; } //string SuID = textButton.Text; //Regex reg = new Regex ("^[0-9]+$"); //判断是不是数据,要不是就表示没有选择,则从隐藏域里读出来 //Match ma = reg.Match (SuID); //if (ma.Success) { // //是数字时的操作 //} else { // return; //} doorLock.AddDoorLockPassword (etNewPasswrod.Text.Trim ()); IO.FileUtils.SaveEquipmentMessage (doorLock); new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.SetSuccessfully), Direction = AMPopTipDirection.Down, CloseTime = 2 }.Show ((View)sender); this.RemoveFromParent (); RemotelyUnlock unlockView = new RemotelyUnlock (doorLock); UserMiddle.DevicePageView.AddChidren (unlockView); unlockView.ShowUserRemoteUnLock (); UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1; }; } } }