using System;
|
using System.Collections.Generic;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class DoorLockRemindSetting : FrameLayout
|
{
|
DoorLock doorLock;
|
|
public DoorLockRemindSetting (DoorLock door_lock)
|
{
|
this.doorLock = door_lock;
|
BackgroundColor = SkinStyle.Current.MainColor;
|
readStatus (door_lock);
|
}
|
|
static void readStatus (DoorLock door_lock)
|
{
|
System.Threading.Tasks.Task.Run (() => {
|
var randomNum = Control.ControlBytesSendHasReturn (Command.CreatConnection, door_lock.SubnetID, door_lock.DeviceID, new byte [] { 1 });
|
if (randomNum != null) {
|
byte [] randomBytes = new byte [8];
|
System.Array.Copy (randomNum, 1, randomBytes, 0, 8);
|
byte [] inpuptBytes = { 0x1F, 0x52, door_lock.PhysicsLoopID };
|
var encryptionBytes = Security.Encryption (randomBytes, inpuptBytes);
|
var resultBytes = Control.ControlBytesSendHasReturn (Command.SendEncryptionAfterConnected, door_lock.SubnetID, door_lock.DeviceID, encryptionBytes);
|
if (resultBytes == null) {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
});
|
return;
|
} else {
|
var ddBytes = Security.Encryption (randomBytes, resultBytes);
|
//byte[] results;
|
//results[0]= ddBytes [2]
|
var result2 = ddBytes [2];
|
if (result2 == 0xF8) {
|
} else {
|
}
|
}
|
}
|
});
|
}
|
|
public void ShowSetTempPassword ()
|
{
|
#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.RemindSetting,
|
TextSize = 19,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
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
|
var bodyScrolView = new FrameLayout () {
|
Height = Application.GetRealHeight (Application.DesignHeight - 126),
|
Y = topView.Bottom,
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
AddChidren (bodyScrolView);
|
|
var globalNoticeFrameLayout = new FrameLayout () {
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = SkinStyle.Current.TitileView,
|
};
|
bodyScrolView.AddChidren (globalNoticeFrameLayout);
|
|
var gloceNoticText = new Button () {
|
Width = Application.GetRealWidth (300),
|
X = Application.GetRealWidth (40),
|
TextID = R.MyInternationalizationString.AllNoticeRemind,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
globalNoticeFrameLayout.AddChidren (gloceNoticText);
|
|
var globalSwitch = new Button () {
|
Width = Application.GetMinRealAverage (90),
|
Height = Application.GetMinRealAverage (53),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/SwitchClose.png",
|
SelectedImagePath = "Item/SwitchOpen.png",
|
X = gloceNoticText.Right + Application.GetRealWidth (200),
|
};
|
globalNoticeFrameLayout.AddChidren (globalSwitch);
|
globalSwitch.MouseUpEventHandler += (sender, e) => {
|
globalSwitch.IsSelected = !globalSwitch.IsSelected;
|
};
|
|
var NoticeFrameLayout = new VerticalScrolViewLayout () {
|
Height = Application.GetRealHeight (Application.DesignHeight - 126 - 198),
|
Y = globalNoticeFrameLayout.Bottom,
|
};
|
bodyScrolView.AddChidren (NoticeFrameLayout);
|
|
for (int i = 0; i < 5; i++) {
|
var RowView = new FrameLayout () {
|
Height = Application.GetRealHeight (110),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
Tag = i,
|
};
|
NoticeFrameLayout.AddChidren (RowView);
|
|
var 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);
|
|
var 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.OpenOrshutDoorsRemind;
|
} else if (i == 1) {
|
UserManagement.TextID = R.MyInternationalizationString.LowVoltageAlarm;
|
} else if (i == 2) {
|
UserManagement.TextID = R.MyInternationalizationString.TamperResistantAlarm;
|
} else if (i == 3) {
|
UserManagement.TextID = R.MyInternationalizationString.DoorUncloseRemind;
|
} else if (i == 4) {
|
UserManagement.TextID = R.MyInternationalizationString.ErrorAlarm;
|
}
|
|
var btnNoticeRemind = new Button () {
|
X = UserManagement.Right + Application.GetRealWidth (20),
|
Width = Application.GetRealWidth (150),
|
Height = Application.GetRealHeight (110),
|
TextID = R.MyInternationalizationString.NotificationRemind,
|
TextAlignment = TextAlignment.CenterRight,
|
Tag = i,
|
};
|
RowView.AddChidren (btnNoticeRemind);
|
|
var btnRight = new Button () {
|
Width = Application.GetRealWidth (54),
|
Height = Application.GetRealHeight (54),
|
X = UserManagement.Right + Application.GetRealWidth (205),
|
UnSelectedImagePath = "Item/Down.png",
|
SelectedImagePath = "Item/DownSelected.png",
|
Tag = i,
|
Gravity = Gravity.CenterVertical,
|
};
|
RowView.AddChidren (btnRight);
|
|
Button line2 = new Button () {
|
Y = RowView.Height - 1,
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
};
|
RowView.AddChidren (line2);
|
|
FrameLayout itemNoticeFrameLayout = new FrameLayout () {
|
Height = Application.GetRealHeight (0),
|
};
|
NoticeFrameLayout.AddChidren (itemNoticeFrameLayout);
|
|
EventHandler<MouseEventArgs> eHandler = (sender, e) => {
|
btnRight.IsSelected = !btnRight.IsSelected;
|
//for (int j = 0; j < NoticeFrameLayout.ChildrenCount; j++) {
|
// var rowView = NoticeFrameLayout.GetChildren (j);
|
// if (rowView.GetType () == typeof (FrameLayout)) {
|
// if (currentIndex == j) {
|
// ((FrameLayout)rowView).BackgroundColor = SkinStyle.Current.SubtitleView;
|
// } else {
|
// ((FrameLayout)rowView).BackgroundColor = SkinStyle.Current.ViewColor;
|
// }
|
// }
|
//}
|
|
//if (currentIndex == 0) {
|
// noticeEHandler (btnRight, UserManagement, itemNoticeFrameLayout, (byte)currentIndex);
|
//} else if (currentIndex == 1) {
|
// noticeEHandler (btnRight, UserManagement, itemNoticeFrameLayout, (byte)currentIndex);
|
//} else if (currentIndex == 2) {
|
// noticeEHandler (btnRight, UserManagement, itemNoticeFrameLayout, (byte)currentIndex);
|
//} else if (currentIndex == 3) {
|
// noticeEHandler (btnRight, UserManagement, itemNoticeFrameLayout, (byte)currentIndex);
|
//} else if (currentIndex == 4) {
|
bool openItem = btnRight.IsSelected;
|
noticeEHandler (openItem, itemNoticeFrameLayout, Convert.ToInt32(((View)sender).Tag));
|
//}
|
};
|
|
btnRight.MouseUpEventHandler += eHandler;
|
btnIcon.MouseUpEventHandler += eHandler;
|
RowView.MouseUpEventHandler += eHandler;
|
UserManagement.MouseUpEventHandler += eHandler;
|
}
|
#endregion
|
}
|
|
void noticeEHandler (bool openItem, FrameLayout itemNoticeFrameLayout,int index )
|
{
|
if (openItem == true) {
|
itemNoticeFrameLayout.Height = Application.GetRealHeight (120);
|
} else {
|
itemNoticeFrameLayout.Height = Application.GetRealHeight (0);
|
}
|
|
Button noticeText = new Button () {
|
Width = Application.GetRealWidth (320),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
SelectedBackgroundColor = SkinStyle.Current.newDeviceBG,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.NotificationRemindByPhone,
|
};
|
itemNoticeFrameLayout.AddChidren (noticeText);
|
|
Button noticeTextLine = new Button () {
|
Width = 1,
|
Y = noticeText.Right,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
};
|
itemNoticeFrameLayout.AddChidren (noticeTextLine);
|
|
Button noticeText2 = new Button () {
|
Width = Application.GetRealWidth (320),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
SelectedBackgroundColor = SkinStyle.Current.newDeviceBG,
|
Y = noticeTextLine.Right,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.NeverRemind,
|
};
|
itemNoticeFrameLayout.AddChidren (noticeText2);
|
|
var noticeTextLine1 = new Button () {
|
Height = 1,
|
Y = itemNoticeFrameLayout.Height - 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
};
|
itemNoticeFrameLayout.AddChidren (noticeTextLine1);
|
|
EventHandler<MouseEventArgs> hander = (sender1, e1) => {
|
noticeText.IsSelected = true;
|
noticeText2.IsSelected = false;
|
};
|
noticeText.MouseUpEventHandler += hander;
|
|
EventHandler<MouseEventArgs> hander2 = (sender1, e1) => {
|
noticeText2.IsSelected = true;
|
noticeText.IsSelected = false;
|
};
|
noticeText2.MouseUpEventHandler += hander2;
|
hander (noticeText, null);
|
|
}
|
}
|
}
|