using System;
|
namespace Shared.SimpleControl.Phone
|
{
|
public class DoorLockSystemSetting : FrameLayout
|
{
|
|
DoorLock doorLock;
|
public DoorLockSystemSetting (DoorLock doorLock)
|
{
|
this.doorLock = doorLock;
|
BackgroundColor = SkinStyle.Current.MainColor;
|
}
|
|
/// <summary>
|
/// 读门锁时钟
|
/// </summary>
|
/// <param name="door_lock">Door lock.</param>
|
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 ShowUserRemoteUnLock ()
|
{
|
#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.SystemSetting,
|
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++) {
|
//if (i == 2 || i == 4)
|
//continue;
|
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.ImprovementTime;
|
} else if (i == 1) {
|
UserManagement.TextID = R.MyInternationalizationString.RemoteUnLockPasswordSetOrModify;
|
}
|
|
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<MouseEventArgs> eHandler = (sender, e) => {
|
if (currentIndex == 0) {
|
var currentTime = DateTime.Now;
|
System.Threading.Tasks.Task.Run (() => {
|
try {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Start ("Please wait...");
|
});
|
var sendBytes = new byte [7];
|
sendBytes [0] = (byte)(currentTime.Year - 2000);
|
sendBytes [1] = (byte)(currentTime.Month);
|
sendBytes [2] = (byte)(currentTime.Day);
|
sendBytes [3] = (byte)(currentTime.Hour);
|
sendBytes [4] = (byte)(currentTime.Minute);
|
sendBytes [5] = (byte)(currentTime.Second);
|
sendBytes [6] = (byte)(currentTime.DayOfWeek);
|
// string manualSetTime = systemDateManualImprovement.Month + "/" + systemDateManualImprovement.Day + "/" + systemDateManualImprovement.Year + " " + systemTimeManualImprovement.Hour + ":" + systemTimeManualImprovement.Minute;
|
var setPasswordInfoBytes = Control.ControlBytesSendHasReturn (Command.SetDoorLockTime, doorLock.SubnetID, doorLock.DeviceID, sendBytes);
|
if (setPasswordInfoBytes != null && setPasswordInfoBytes [0] == 0xF8) {
|
Application.RunOnMainThread (() => {
|
// CurrentTimeText.Text = manualSetTime;
|
new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.SetSuccessfully), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show ((View)sender);
|
});
|
return;
|
} else {
|
Application.RunOnMainThread (() => {
|
new Alert ("", Language.StringByID (R.MyInternationalizationString.OperationFailed), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
});
|
return;
|
}
|
} catch (Exception mess) {
|
string message = mess.Message;
|
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
}
|
else if (currentIndex == 1) {
|
RemoteUnLockPasswordSetOrModify dView = new RemoteUnLockPasswordSetOrModify (doorLock);
|
UserMiddle.DevicePageView.AddChidren (dView);
|
dView.ShowShowUserRemoteUnLock ();
|
UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;
|
}
|
};
|
btnRight.MouseUpEventHandler += eHandler;
|
btnIcon.MouseUpEventHandler += eHandler;
|
RowView.MouseUpEventHandler += eHandler;
|
UserManagement.MouseUpEventHandler += eHandler;
|
}
|
|
|
#endregion
|
}
|
}
|
}
|