using System;
namespace Shared.SimpleControl.Phone
{
public class RemoteUnLockPasswordSetOrModify : FrameLayout
{
DoorLock doorLock;
public RemoteUnLockPasswordSetOrModify (DoorLock doorLock)
{
this.doorLock = doorLock;
BackgroundColor = SkinStyle.Current.MainColor;
}
///
/// 读门锁时钟
///
/// Door lock.
void readStatus (DoorLock door_lock)
{
System.Threading.Tasks.Task.Run (() => {
byte [] resultBytes = Control.ControlBytesSendHasReturn (Command.ReadDoorLockClock, door_lock.SubnetID, door_lock.DeviceID, new byte [] { door_lock.LoopID });
IO.FileUtils.SaveEquipmentMessage (door_lock, door_lock.LoopID.ToString ());
});
}
public void ShowShowUserRemoteUnLock ()
{
#region 标题
var topView = new FrameLayout () {
Y = Application.GetRealHeight (36),
Height = Application.GetRealHeight (90),
BackgroundColor = SkinStyle.Current.MainColor,
};
AddChidren (topView);
var title = new Button () {
TextAlignment = TextAlignment.Center,
TextID = R.MyInternationalizationString.RemoteUnLockPasswordSetOrModify,
TextColor = SkinStyle.Current.TextColor1,
TextSize = 19,
};
topView.AddChidren (title);
var logo = new Button () {
Width = Application.GetRealWidth (154),
Height = Application.GetRealHeight (90),
X = Application.GetRealWidth (486),
UnSelectedImagePath = MainPage.LogoString,
Gravity = Gravity.CenterVertical,
};
topView.AddChidren (logo);
var 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
#region bodyScrolView
VerticalScrolViewLayout bodyFrameLayout = new VerticalScrolViewLayout () {
Height = Application.GetRealHeight (1136 - 126),
BackgroundColor = SkinStyle.Current.ViewColor,
Y = topView.Bottom,
};
AddChidren (bodyFrameLayout);
for (int i = 0; i < 2; i++) {
FrameLayout RowView = new FrameLayout () {
Height = Application.GetRealHeight (110),
BackgroundColor = SkinStyle.Current.ViewColor,
};
bodyFrameLayout.AddChidren (RowView);
Button btnIcon = new Button () {
Width = Application.GetRealHeight (13),
Height = Application.GetRealHeight (13),
X = Application.GetRealWidth (40),
UnSelectedImagePath = "Item/Point.png",
SelectedImagePath = "Item/PointSelected.png",
Gravity = Gravity.CenterVertical,
};
RowView.AddChidren (btnIcon);
Button UserManagement = new Button () {
X = btnIcon.Right + Application.GetRealWidth (20),
Width = Application.GetRealWidth (300),
Height = Application.GetRealHeight (110),
TextAlignment = TextAlignment.CenterLeft,
TextColor = SkinStyle.Current.TextColor1,
};
RowView.AddChidren (UserManagement);
if (i == 0) {
UserManagement.TextID = R.MyInternationalizationString.ResetPassword;
} else if (i == 1) {
UserManagement.TextID = R.MyInternationalizationString.SetPassword;
}
var btnRight = new Button () {
Width = Application.GetRealWidth (28),
Height = Application.GetRealHeight (40),
X = UserManagement.Right + Application.GetRealWidth (200),
UnSelectedImagePath = "Item/Right.png",
SelectedImagePath = "Item/RightSelected.png",
Gravity = Gravity.CenterVertical,
};
RowView.AddChidren (btnRight);
var line2 = new Button () {
Y = RowView.Height - 1,
Height = 1,
BackgroundColor = SkinStyle.Current.TitileView,
};
RowView.AddChidren (line2);
int currentIndex = i;
EventHandler eHandler = (sender, e) => {
if (currentIndex == 0) {
if (doorLock.GetDoorLockPassword () != null) {
this.RemoveFromParent ();
RemoteUnLockPasswordReset unlockView = new RemoteUnLockPasswordReset (doorLock);
UserMiddle.DevicePageView.AddChidren (unlockView);
unlockView.showRemoteUnLockPasswordReset ();
UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;
} else {
new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.NoPassword), Direction = AMPopTipDirection.Down, CloseTime = 2 }.Show ((View)sender);
}
} else if (currentIndex == 1) {
if (doorLock.GetDoorLockPassword () == null) {
this.RemoveFromParent ();
RemoteUnlockPasswordSet unlockView = new RemoteUnlockPasswordSet (doorLock);
UserMiddle.DevicePageView.AddChidren (unlockView);
unlockView.ShowDoorLockRemoteSetPassword ();
UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;
} else {
new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.RemoteUnLockPasswordExist), Direction = AMPopTipDirection.Down, CloseTime = 2 }.Show ((View)sender);
}
}
};
btnRight.MouseUpEventHandler += eHandler;
btnIcon.MouseUpEventHandler += eHandler;
RowView.MouseUpEventHandler += eHandler;
UserManagement.MouseUpEventHandler += eHandler;
if (doorLock.GetDoorLockPassword () != null) {
i++;
}
}
#endregion
}
void ResetPassword ()
{
Dialog dialog = new Dialog ();
var dialogBodyView = new FrameLayout () {
Width = Application.GetRealWidth (400),
Height = Application.GetRealHeight (402),
//BackgroundColor = SkinStyle.Current.DialogColor,
BackgroundColor = 0xff000000,
Radius = 5,
BorderColor = SkinStyle.Current.Transparent,
BorderWidth = 0,
Gravity = Gravity.Center
};
dialog.AddChidren (dialogBodyView);
var btnTitle = new Button () {
Height = Application.GetRealHeight (80),
BackgroundColor = SkinStyle.Current.DialogTitle,
TextAlignment = TextAlignment.Center,
TextID = R.MyInternationalizationString.ResetPassword,
};
dialogBodyView.AddChidren (btnTitle);
var oldPassword = new EditText () {
X = Application.GetRealWidth (30),
Y = btnTitle.Bottom + Application.GetRealHeight (25),
Height = Application.GetRealHeight (85),
Width = Application.GetRealWidth (340),
Gravity = Gravity.CenterHorizontal,
TextSize = 15,
UnSelectedImagePath = "Register/Register_Password_kuang.png",
PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseEnterOldPassword),
PlaceholderTextColor = SkinStyle.Current.PlaceholderTextColor,
TextAlignment = TextAlignment.Center,
Radius = (uint)Application.GetRealHeight (0),
TextColor = SkinStyle.Current.TextColor1,
};
dialogBodyView.AddChidren (oldPassword);
var newPassword = new EditText () {
X = Application.GetRealWidth (30),
Y = oldPassword.Bottom + Application.GetRealHeight (25),
Height = Application.GetRealHeight (85),
Width = Application.GetRealWidth (340),
TextSize = 15,
Gravity = Gravity.CenterHorizontal,
UnSelectedImagePath = "Register/Register_Password_kuang.png",
PlaceholderText = Language.StringByID (R.MyInternationalizationString.NewPassword),
PlaceholderTextColor = SkinStyle.Current.PlaceholderTextColor,
TextAlignment = TextAlignment.Center,
Radius = (uint)Application.GetRealHeight (0),
TextColor = SkinStyle.Current.TextColor1,
};
dialogBodyView.AddChidren (newPassword);
var bottomView = new FrameLayout () {
Y = dialogBodyView.Height - Application.GetRealHeight (80),
Height = Application.GetRealHeight (80),
BackgroundColor = SkinStyle.Current.DialogTitle,
};
dialogBodyView.AddChidren (bottomView);
var btnBack = new Button () {
Width = Application.GetRealWidth (119),
UnSelectedImagePath = "Item/PositioningDialogBack.png",
SelectedImagePath = "Item/PositioningDialogBack.png",
};
bottomView.AddChidren (btnBack);
btnBack.MouseUpEventHandler += (sender1, e1) => {
dialog.Close ();
};
var btnLineH = new Button () {
Width = 1,
Height = LayoutParams.MatchParent,
BackgroundColor = SkinStyle.Current.White20Transparent,
X = btnBack.Right,
};
bottomView.AddChidren (btnLineH);
Button btnSave = new Button () {
Width = Application.GetRealWidth (280),
X = btnLineH.Right,
TextID = R.MyInternationalizationString.SAVE,
TextAlignment = TextAlignment.Center,
Radius = 1,
};
bottomView.AddChidren (btnSave);
btnSave.MouseUpEventHandler += (sender, e) => {
if (oldPassword.Text != doorLock.GetDoorLockPassword ()) {
new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.OldPasswordIsError), Direction = AMPopTipDirection.Down, CloseTime = 2 }.Show ((View)sender);
return;
}
if (string.IsNullOrEmpty (newPassword.Text.Trim ())) {
new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.NewPasswordIsEmpty), Direction = AMPopTipDirection.Down, CloseTime = 2 }.Show ((View)sender);
return;
}
//if (newPassword.Text.Trim ().Length != 6) {
// new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.PasswordNotFormedFromSixDigitalCodes), Direction = AMPopTipDirection.Down, CloseTime = 4 }.Show ((View)sender);
// return;
//}
//string SuID = newPassword.Text;
//Regex reg = new Regex ("^[0-9]+$"); //判断是不是数据,要不是就表示没有选择,则从隐藏域里读出来
//Match ma = reg.Match (SuID);
//if (ma.Success) {
// //是数字时的操作
//} else {
// new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.PasswordNotFormedFromSixDigitalCodes), Direction = AMPopTipDirection.Down, CloseTime = 4 }.Show ((View)sender);
// return;
//}
doorLock.AddDoorLockPassword (newPassword.Text.Trim ());
dialog.Close ();
};
dialog.Show ();
}
}
}