using System; using System.Text.RegularExpressions; namespace Shared.SimpleControl.Phone { public class RemoteUnLockForgetPassword : FrameLayout { DoorLock doorLock; static string unlockPassword = null; string getNum () { return unlockPassword; } public RemoteUnLockForgetPassword (DoorLock doorLock) { this.doorLock = doorLock; BackgroundColor = SkinStyle.Current.MainColor; } public void ShowDoorLockRemoteSetPassword () { #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, TextID = R.MyInternationalizationString.RemoteUnlock, 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 (1136 - 126), BackgroundColor = SkinStyle.Current.ViewColor, }; AddChidren (bodyView); var btnpassword = new Button () { Width = Application.GetRealWidth (500), Height = Application.GetRealHeight (85), Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight (20), TextID = R.MyInternationalizationString.Account, TextAlignment = TextAlignment.CenterLeft, TextSize = 12, TextColor = SkinStyle.Current.TextColor1, }; bodyView.AddChidren (btnpassword); var etPassword = new EditText () { Width = Application.GetRealWidth (500), Height = Application.GetRealHeight (85), Gravity = Gravity.CenterHorizontal, Y = btnpassword.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 (etPassword); var btnConfirmPassword = new Button () { Width = Application.GetRealWidth (500), Height = Application.GetRealHeight (85), Gravity = Gravity.CenterHorizontal, Y = etPassword.Bottom + Application.GetRealHeight (20), TextID = R.MyInternationalizationString.Password, TextAlignment = TextAlignment.CenterLeft, TextSize = 12, TextColor = SkinStyle.Current.TextColor1, }; bodyView.AddChidren (btnConfirmPassword); var etConfirmPasswrod = 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), SecureTextEntry = true, //Text = "123456" }; bodyView.AddChidren (etConfirmPasswrod); var btnConfirmpassword = new Button () { Width = Application.GetRealWidth (500), Height = Application.GetRealHeight (85), Gravity = Gravity.CenterHorizontal, Y = etConfirmPasswrod.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), SecureTextEntry = true, //Text = "123456" }; 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, 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 (etPassword.Text == "" && etConfirmPasswrod.Text == "") { new Alert ("", Language.StringByID (R.MyInternationalizationString.PleaseWriteTheCompleteContent), Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; } if (etPassword.Text.Trim ().Length != 6) { new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.PasswordNotFormedFromSixDigitalCodes), Direction = AMPopTipDirection.Down, CloseTime = 4 }.Show ((View)sender); return; } if (etPassword.Text.Trim () != etConfirmPasswrod.Text.Trim ()) { new Alert ("", 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.RemoteDoorLockPassword = etPassword.Text.Trim (); doorLock.AddDoorLockPassword (etPassword.Text.Trim ()); IO.FileUtils.SaveEquipmentMessage (doorLock); new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.SetSuccessfully), Direction = AMPopTipDirection.Down, CloseTime = 2 }.Show ((View)sender); RemotelyUnlock unlockView = new RemotelyUnlock (doorLock); UserMiddle.DevicePageView.AddChidren (unlockView); unlockView.ShowUserRemoteUnLock (); UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1; this.RemoveFromParent (); }; } } }