using System;
|
using System.Text.RegularExpressions;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class RemoteUnlockPasswordSet : FrameLayout
|
{
|
|
DoorLock doorLock;
|
public RemoteUnlockPasswordSet (DoorLock dl)
|
{
|
this.doorLock = dl;
|
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.ResetPassword,
|
TextSize = 19,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
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 btnpassword = new Button () {
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (85),
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight (150),
|
TextID = R.MyInternationalizationString.SetTheSixDigitPassword,
|
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",
|
TextColor = SkinStyle.Current.TextColor1,
|
SecureTextEntry = true,
|
};
|
bodyView.AddChidren (etPassword);
|
|
var btnConfirmPassword = new Button () {
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (85),
|
Gravity = Gravity.CenterHorizontal,
|
Y = etPassword.Bottom + Application.GetRealHeight (70),
|
TextID = R.MyInternationalizationString.ConfirmPassword,
|
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),
|
TextColor = SkinStyle.Current.TextColor1,
|
SecureTextEntry = true,
|
//Text = "123456"
|
};
|
bodyView.AddChidren (etConfirmPasswrod);
|
|
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.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextID = R.MyInternationalizationString.OK,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
TextColor = SkinStyle.Current.TextColor1,
|
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.Tip), 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.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 (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);
|
this.RemoveFromParent ();
|
|
RemotelyUnlock unlockView = new RemotelyUnlock (doorLock);
|
UserMiddle.DevicePageView.AddChidren (unlockView);
|
unlockView.ShowUserRemoteUnLock ();
|
UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;
|
|
};
|
|
}
|
}
|
}
|