using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using Newtonsoft.Json;
|
using Shared.Common;
|
using Shared.Phone.UserCenter.Device;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.UserCenter.DoorLock
|
{
|
public class EntryStatusPage : DoorLockCommonLayout, ZigBee.Common.IStatus
|
{
|
/// 构造函数
|
/// </summary>
|
/// <param name="doorLock"></param>
|
public EntryStatusPage(ZigBee.Device.DoorLock doorLock, Shared.Phone.UserCenter.MemberInfoRes accountObj, string entryType)
|
{
|
this.doorLock = doorLock;
|
this.curAccountObj = accountObj;
|
this.currentType = entryType;
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
|
}
|
|
#region ◆ 变量申明__________________________
|
ZigBee.Device.DoorLock doorLock;
|
Shared.Phone.UserCenter.MemberInfoRes curAccountObj;
|
string currentType = string.Empty;
|
FrameLayout bottomFrameLayout;
|
|
#endregion
|
|
/// <summary>
|
/// UI显示
|
/// </summary>
|
public void Show()
|
{
|
this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.AddNewUnlockMethod));
|
|
EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
|
{
|
RemoveFromParent();
|
};
|
this.btnBack.MouseUpEventHandler += eHandlerBack;
|
this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
|
this.MidFrameLayout(this);
|
|
MidFrameLayoutContent();
|
}
|
|
public void MidFrameLayoutContent()
|
{
|
var entryStatusPic = new Button
|
{
|
X = Application.GetRealWidth(297),
|
Y = Application.GetRealHeight(268),
|
Height = Application.GetRealHeight(363),
|
Width = Application.GetRealWidth(452),
|
UnSelectedImagePath = "DoorLock/EntrySuccessIcon.png",
|
};
|
this.midFrameLayout.AddChidren(entryStatusPic);
|
|
var btnPicTip = new Button
|
{
|
X = Application.GetRealWidth(372),
|
Y = Application.GetRealHeight(634),
|
Height = Application.GetRealHeight(81),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
|
Gravity = Gravity.CenterHorizontal,
|
TextSize = 20,
|
};
|
this.midFrameLayout.AddChidren(btnPicTip);
|
|
if (currentType == "password")
|
{
|
btnPicTip.Text = Language.StringByID(R.MyInternationalizationString.EntryPasswordSuccess);
|
}
|
else if (currentType == "fingerprint")
|
{
|
btnPicTip.Text = Language.StringByID(R.MyInternationalizationString.EntryFingerprintSuccess);
|
}
|
else
|
{
|
btnPicTip.Text = Language.StringByID(R.MyInternationalizationString.EntryProximitySuccess);
|
}
|
|
BottomFrameLayoutContent();
|
}
|
|
public void BottomFrameLayoutContent()
|
{
|
bottomFrameLayout = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(737),
|
Y = Application.GetRealHeight(999),
|
BackgroundColor = ZigbeeColor.Current.XMWhite,
|
};
|
this.midFrameLayout.AddChidren(bottomFrameLayout);
|
|
var passwordRemarkFrameLayout = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(965),
|
Height = Application.GetRealHeight(127),
|
X = Application.GetRealWidth(58),
|
Y = Application.GetRealHeight(81),
|
};
|
bottomFrameLayout.AddChidren(passwordRemarkFrameLayout);
|
|
var btnPasswordRemark = new Button()
|
{
|
Width = Application.GetRealWidth(222),
|
Height = Application.GetRealHeight(58),
|
Y = Application.GetRealHeight(35),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 14,
|
};
|
passwordRemarkFrameLayout.AddChidren(btnPasswordRemark);
|
|
var btnPasswordRemarkContent = new EditText()
|
{
|
Width = Application.GetRealWidth(965 - 222),
|
Height = Application.GetRealHeight(58),
|
X = Application.GetRealWidth(223),
|
Y = Application.GetRealHeight(35),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 14,
|
PlaceholderTextColor = ZigbeeColor.Current.XMGray3,
|
TextColor = ZigbeeColor.Current.XMBlack
|
};
|
passwordRemarkFrameLayout.AddChidren(btnPasswordRemarkContent);
|
|
var btnLine = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(965),
|
Height = Application.GetRealHeight(5),
|
X = Application.GetRealWidth(58),
|
Y = Application.GetRealHeight(81 + 127),
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
|
};
|
bottomFrameLayout.AddChidren(btnLine);
|
|
var personRemarkRemarkFrameLayout = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(965),
|
Height = Application.GetRealHeight(127),
|
X = Application.GetRealWidth(58),
|
Y = btnLine.Bottom + Application.GetRealHeight(2),
|
};
|
bottomFrameLayout.AddChidren(personRemarkRemarkFrameLayout);
|
|
var btnMatchPersonRemark = new Button()
|
{
|
Width = Application.GetRealWidth(222),
|
Height = Application.GetRealHeight(58),
|
Y = Application.GetRealHeight(35),
|
Text = Language.StringByID(R.MyInternationalizationString.MatchPerson),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 14,
|
};
|
personRemarkRemarkFrameLayout.AddChidren(btnMatchPersonRemark);
|
|
var btnMatchPersonContent = new Button()
|
{
|
Width = Application.GetRealWidth(965 - 222),
|
Height = Application.GetRealHeight(58),
|
X = Application.GetRealWidth(223),
|
Y = Application.GetRealHeight(35),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 14,
|
Text = curAccountObj.UserName,
|
};
|
personRemarkRemarkFrameLayout.AddChidren(btnMatchPersonContent);
|
|
var completeBtn = new Button
|
{
|
X = Application.GetRealWidth(86),
|
Y = Application.GetRealHeight(472),
|
Height = Application.GetRealHeight(127),
|
Width = Application.GetRealWidth(907),
|
Text = Language.StringByID(R.MyInternationalizationString.DoorLockComplete),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
|
Gravity = Gravity.CenterHorizontal,
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack,
|
Radius = 10,
|
TextSize = 16,
|
};
|
bottomFrameLayout.AddChidren(completeBtn);
|
|
if (currentType == "password")
|
{
|
btnPasswordRemark.Text = Language.StringByID(R.MyInternationalizationString.PasswordRemark);
|
btnPasswordRemarkContent.PlaceholderText = Language.StringByID(R.MyInternationalizationString.Password) + "-" + doorLock.doorLockProgrammingEventNotificationCommand.UserID;
|
}
|
else if (currentType == "fingerprint")
|
{
|
btnPasswordRemark.Text = Language.StringByID(R.MyInternationalizationString.FingerprintRemark);
|
btnPasswordRemarkContent.PlaceholderText = Language.StringByID(R.MyInternationalizationString.Fingerprint) + "-" + doorLock.doorLockProgrammingEventNotificationCommand.UserID;
|
}
|
else
|
{
|
btnPasswordRemark.Text = Language.StringByID(R.MyInternationalizationString.ProximityRemark);
|
btnPasswordRemarkContent.PlaceholderText = Language.StringByID(R.MyInternationalizationString.ProximityCard) + "-" + doorLock.doorLockProgrammingEventNotificationCommand.UserID;
|
}
|
|
completeBtn.MouseDownEventHandler += async (sender, e) =>
|
{
|
completeBtn.Enable = false;
|
var addLockInfo = new ZigBee.Device.DoorLock.AddDoorLockData();
|
addLockInfo.CloudAccountId = curAccountObj.SubAccountDistributedMark;
|
if (doorLock.DeviceAddr != null)
|
{
|
addLockInfo.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
|
}
|
addLockInfo.OpenLockMode = doorLock.doorLockProgrammingEventNotificationCommand.ProgramEventSoure;
|
addLockInfo.DoorLockLocalUserId = doorLock.doorLockProgrammingEventNotificationCommand.UserID.ToString();
|
//var entryTime = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetLocalTime(doorLock.doorLockProgrammingEventNotificationCommand.ZigbeeLocalTime);
|
addLockInfo.EntryTime = System.DateTime.Now;
|
if (btnPasswordRemarkContent.Text != "")
|
{
|
addLockInfo.UserIdRemarks = btnPasswordRemarkContent.Text;
|
}
|
else
|
{
|
addLockInfo.UserIdRemarks = btnPasswordRemarkContent.PlaceholderText;
|
}
|
try
|
{
|
var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/AddDoorLock", addLockInfo);
|
if (result != null && result.StateCode == "Success")
|
{
|
if (doorLock.localDoorLockUserList.ContainsKey(doorLock.doorLockProgrammingEventNotificationCommand.UserID))
|
{
|
doorLock.localDoorLockUserList.Remove(doorLock.doorLockProgrammingEventNotificationCommand.UserID);
|
|
var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
|
localDoorLockObj.UserID = doorLock.doorLockProgrammingEventNotificationCommand.UserID;
|
localDoorLockObj.UnlockType = addLockInfo.OpenLockMode;
|
localDoorLockObj.EntryTime = addLockInfo.EntryTime;
|
localDoorLockObj.UserName = addLockInfo.UserIdRemarks;
|
localDoorLockObj.ConnectedAccount = curAccountObj.SubAccountDistributedMark;
|
doorLock.localDoorLockUserList.Add(doorLock.doorLockProgrammingEventNotificationCommand.UserID, localDoorLockObj);
|
|
completeBtn.Enable = true;
|
this.RemoveFromParent();
|
|
for (int i = UserView.HomePage.Instance.ChildrenCount - 1; i >= 0; i--)
|
{
|
var form = UserView.HomePage.Instance.GetChildren(i);
|
|
if (form is UnLockMethod)
|
{
|
((UnLockMethod)form).RefreshList();
|
break;
|
}
|
else
|
{
|
form.RemoveFromParent();
|
}
|
}
|
}
|
}
|
else
|
{
|
completeBtn.Enable = true;
|
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ModigfyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnPasswordRemarkContent);
|
}
|
}
|
catch { }
|
};
|
}
|
|
public void MatchUsersFrameLayout()
|
{
|
var flMain = new FrameLayout { BackgroundColor = 0x0f000000 };
|
this.midFrameLayout.AddChidren(flMain);
|
flMain.MouseUpEventHandler += (sender11, e11) =>
|
{
|
flMain.RemoveFromParent();
|
bottomFrameLayout.RemoveAll();
|
BottomFrameLayoutContent();
|
};
|
bottomFrameLayout = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(100),
|
Y = Application.GetRealHeight(930),
|
Radius = 17,
|
BackgroundColor = ZigbeeColor.Current.XMWhite,
|
};
|
flMain.AddChidren(bottomFrameLayout);
|
|
var bottomFrameLayout1 = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(806 - 50),
|
Y = Application.GetRealHeight(930 + 48),
|
BackgroundColor = ZigbeeColor.Current.XMWhite,
|
};
|
flMain.AddChidren(bottomFrameLayout1);
|
|
var bottomFrameLayout2 = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(806),
|
Y = Application.GetRealHeight(930),
|
};
|
flMain.AddChidren(bottomFrameLayout2);
|
|
var matchUsersFrameLayout = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(138),
|
};
|
bottomFrameLayout2.AddChidren(matchUsersFrameLayout);
|
|
var btnCancel = new Button
|
{
|
X = Application.GetRealWidth(81),
|
Y = Application.GetRealHeight(40),
|
Height = Application.GetRealHeight(58),
|
Width = Application.GetRealWidth(101),
|
Text = Language.StringByID(R.MyInternationalizationString.Cancel),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
|
TextSize = 14,
|
};
|
matchUsersFrameLayout.AddChidren(btnCancel);
|
|
var btnMatchUser = new Button
|
{
|
X = Application.GetRealWidth(446),
|
Y = Application.GetRealHeight(35),
|
Height = Application.GetRealHeight(63),
|
Width = Application.GetRealWidth(284),
|
Text = Language.StringByID(R.MyInternationalizationString.MatchPerson),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
|
TextSize = 16,
|
};
|
matchUsersFrameLayout.AddChidren(btnMatchUser);
|
|
var btnFinish = new Button
|
{
|
X = Application.GetRealWidth(919),
|
Y = Application.GetRealHeight(40),
|
Height = Application.GetRealHeight(58),
|
Width = Application.GetRealWidth(101),
|
Text = Language.StringByID(R.MyInternationalizationString.Complete),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
|
TextSize = 14,
|
};
|
matchUsersFrameLayout.AddChidren(btnFinish);
|
|
var btnTopLine = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(5),
|
Y = Application.GetRealHeight(138),
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.XMGray3,
|
};
|
bottomFrameLayout2.AddChidren(btnTopLine);
|
|
var matchUserHorizontalScrolViewLayout = new VerticalScrolViewLayout()
|
{
|
Y = Application.GetRealHeight(207),
|
Height = Application.GetRealHeight(806 - 207),
|
};
|
bottomFrameLayout2.AddChidren(matchUserHorizontalScrolViewLayout);
|
|
for (var i = 0; i < 4; i++)
|
{
|
var rowFrameLayout = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(127),
|
};
|
matchUserHorizontalScrolViewLayout.AddChidren(rowFrameLayout);
|
|
var btnUserName = new Button()
|
{
|
Width = Application.GetRealWidth(743),
|
Height = Application.GetRealHeight(58),
|
X = Application.GetRealWidth(81),
|
Y = Application.GetRealHeight(37),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
|
TextSize = 14,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
rowFrameLayout.AddChidren(btnUserName);
|
|
var btnChoose = new Button()
|
{
|
Width = Application.GetRealWidth(58),
|
Height = Application.GetRealHeight(58),
|
X = Application.GetRealWidth(861 + 81),
|
Y = Application.GetRealHeight(35),
|
BackgroundColor = ZigbeeColor.Current.XMOrange,
|
};
|
rowFrameLayout.AddChidren(btnChoose);
|
|
var btnLine = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(919),
|
Height = Application.GetRealHeight(5),
|
X = Application.GetRealWidth(81),
|
Y = Application.GetRealHeight(122),
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.XMGray3,
|
};
|
rowFrameLayout.AddChidren(btnLine);
|
}
|
}
|
|
#region ◆ 接口实现__________________________
|
/// <summary>
|
/// 处理变化事件 --将弃用 改用DeviceInfoChange()
|
/// </summary>
|
/// <returns>The changed.</returns>
|
/// <param name="common">Common.</param>
|
public void Changed(CommonDevice common)
|
{
|
|
}
|
/// <summary>
|
/// 处理变化事件
|
/// </summary>
|
/// <param name="common"></param>
|
/// <param name="typeTag"></param>
|
public void DeviceInfoChange(CommonDevice common, string typeTag)
|
{
|
}
|
/// <summary>
|
/// Changeds the IL ogic status.
|
/// </summary>
|
/// <param name="logic">Logic.</param>
|
public void ChangedILogicStatus(ZigBee.Device.Logic logic)
|
{
|
}
|
/// <summary>
|
/// Changeds the IS cene status.
|
/// </summary>
|
/// <param name="scene">Scene.</param>
|
public void ChangedISceneStatus(Scene scene)
|
{
|
}
|
#endregion
|
}
|
}
|