using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using Shared.Common;
|
|
namespace Shared.Phone.UserCenter.DoorLock
|
{
|
public class UnLockMethod : DoorLockCommonLayout
|
{
|
/// 构造函数
|
/// </summary>
|
/// <param name="doorLock"></param>
|
public UnLockMethod(ZigBee.Device.DoorLock doorLock, Shared.Phone.UserCenter.MemberInfoRes accountObj)
|
{
|
this.doorLock = doorLock;
|
this.curAccountObj = accountObj;
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
|
}
|
|
#region ◆ 变量申明__________________________
|
ZigBee.Device.DoorLock doorLock;
|
VerticalScrolViewLayout bodyView;
|
Button currentMethod;// 当前选择的方式
|
Shared.Phone.UserCenter.MemberInfoRes curAccountObj;
|
Button entryStatusPic;
|
Button btnPicTip;
|
Button btnPicTip1;
|
bool isSecondDel;
|
#endregion
|
|
|
/// <summary>
|
/// UI显示
|
/// </summary>
|
public void Show()
|
{
|
//ReadDoorLockUserInfo();
|
this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.LockMethod));
|
this.btnTitleLine.Visible = false;
|
EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
|
{
|
RemoveFromParent();
|
};
|
this.btnBack.MouseUpEventHandler += eHandlerBack;
|
this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
|
this.MidFrameLayout(this);
|
|
var btnAddFrameLayout = new FrameLayout
|
{
|
X = Application.GetRealWidth(953),
|
Height = Application.GetRealHeight(72),
|
Width = Application.GetRealWidth(72),
|
};
|
this.titleFrameLayout.AddChidren(btnAddFrameLayout);
|
|
var btnAdd = new Button
|
{
|
Height = Application.GetRealHeight(69),
|
Width = Application.GetRealWidth(69),
|
UnSelectedImagePath = "DoorLock/AddIcon.png",
|
};
|
btnAddFrameLayout.AddChidren(btnAdd);
|
btnAdd.MouseDownEventHandler += (sender, e) =>
|
{
|
var addUnLockMethod = new Shared.Phone.UserCenter.DoorLock.AddUnLockMethod(doorLock, curAccountObj);
|
Shared.Phone.UserView.HomePage.Instance.AddChidren(addUnLockMethod);
|
Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
|
addUnLockMethod.Show();
|
};
|
|
MidFrameLayoutContent();
|
}
|
//中部布局
|
void MidFrameLayoutContent()
|
{
|
var midTopFrameLayout = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(115),
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.XMTopFrameLayout,
|
};
|
this.midFrameLayout.AddChidren(midTopFrameLayout);
|
|
var btnAllMethod = new Button()
|
{
|
Height = Application.GetRealHeight(49),
|
Width = Application.GetRealWidth(141 + 100),
|
Y = Application.GetRealHeight(35),
|
X = Application.GetRealWidth(812 - 100),
|
TextAlignment = TextAlignment.Center,
|
Text = Language.StringByID(R.MyInternationalizationString.LockMethod),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
|
TextSize = 12,
|
};
|
midTopFrameLayout.AddChidren(btnAllMethod);
|
|
var btnNext = new Button()
|
{
|
X = Application.GetRealWidth(953),
|
Y = Application.GetRealHeight(20),
|
Height = Application.GetRealHeight(69),
|
Width = Application.GetRealWidth(69),
|
UnSelectedImagePath = "DoorLock/UnLockSideslipIcon.png",
|
SelectedImagePath = "DoorLock/UnLockSideslipIcon.png",
|
};
|
midTopFrameLayout.AddChidren(btnNext);
|
|
entryStatusPic = new Button
|
{
|
X = Application.GetRealWidth(164),
|
Y = Application.GetRealHeight(492),
|
Height = Application.GetRealHeight(435),
|
Width = Application.GetRealWidth(757),
|
Visible = false,
|
UnSelectedImagePath = "DoorLock/UnLockBlankPic.png",
|
};
|
this.midFrameLayout.AddChidren(entryStatusPic);
|
|
btnPicTip = new Button
|
{
|
X = Application.GetRealWidth(397),
|
Y = Application.GetRealHeight(1143 - 184),
|
Height = Application.GetRealHeight(98 / 2),
|
Text = Language.StringByID(R.MyInternationalizationString.NoPasswordInformation),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
|
Gravity = Gravity.CenterHorizontal,
|
Visible = false,
|
};
|
this.midFrameLayout.AddChidren(btnPicTip);
|
|
btnPicTip1 = new Button
|
{
|
X = Application.GetRealWidth(397),
|
Y = btnPicTip.Bottom,
|
Height = Application.GetRealHeight(98 / 2),
|
Text = Language.StringByID(R.MyInternationalizationString.NoPasswordInformation1),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
|
Gravity = Gravity.CenterHorizontal,
|
Visible = false,
|
};
|
this.midFrameLayout.AddChidren(btnPicTip1);
|
|
var btnLine = new Button
|
{
|
Y = midTopFrameLayout.Bottom,
|
Height = 1,
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.XMTitleLine,
|
};
|
this.midFrameLayout.AddChidren(btnLine);
|
|
bodyView = new VerticalScrolViewLayout()
|
{
|
Y = btnLine.Bottom,
|
};
|
this.midFrameLayout.AddChidren(bodyView);
|
|
btnNext.MouseUpEventHandler += (sender, e) =>
|
{
|
SideslipFramelayout();
|
};
|
|
RefreshList();
|
}
|
|
/// <summary>
|
/// 刷新列表
|
/// </summary>
|
/// <param name="gateway"></param>
|
/// <param name="key"></param>
|
public void RefreshList()
|
{
|
bodyView.RemoveAll();
|
var curAccountDoorLockUserList = new Dictionary<int, ZigBee.Device.DoorLock.LocaDoorLockObj>();
|
|
foreach (var curUserId in doorLock.localDoorLockUserList.Keys)
|
{
|
var curDoorLockUser = doorLock.localDoorLockUserList[curUserId];
|
|
if (curDoorLockUser.ConnectedAccount == "" || curDoorLockUser.ConnectedAccount != curAccountObj.SubAccountDistributedMark)
|
{
|
continue;
|
}
|
else
|
{
|
curAccountDoorLockUserList.Add(curDoorLockUser.UserID, curDoorLockUser);
|
}
|
}
|
|
if (curAccountDoorLockUserList.Count == 0)
|
{
|
entryStatusPic.Visible = true;
|
btnPicTip.Visible = true;
|
btnPicTip1.Visible = true;
|
}
|
else
|
{
|
entryStatusPic.Visible = false;
|
btnPicTip.Visible = false;
|
btnPicTip1.Visible = false;
|
}
|
|
foreach (var curUserId in curAccountDoorLockUserList.Keys)
|
{
|
var curDoorLockUser = curAccountDoorLockUserList[curUserId];
|
#region UI
|
var rowFrameLayout = new RowLayout()
|
{
|
Height = Application.GetRealHeight(173),
|
X = Application.GetRealWidth(58),
|
Width = Application.GetRealWidth(965),
|
LineColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
|
};
|
bodyView.AddChidren(rowFrameLayout);
|
|
var btnPicFrameLayout = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(81),
|
Height = Application.GetRealHeight(81),
|
X = Application.GetRealWidth(40),
|
Y = Application.GetRealHeight(49),
|
};
|
rowFrameLayout.AddChidren(btnPicFrameLayout);
|
|
var btnPic = new Button()
|
{
|
Width = Application.GetRealWidth(84),
|
Height = Application.GetRealHeight(84),
|
UnSelectedImagePath = "DoorLock/DoorLockUserPic.png",
|
};
|
btnPicFrameLayout.AddChidren(btnPic);
|
|
var btnDoorlockUser = new EditText()
|
{
|
Width = Application.GetRealWidth(1080 - 173),
|
Height = Application.GetRealHeight(60),
|
X = Application.GetRealWidth(173),
|
Y = Application.GetRealHeight(35),
|
TextSize = 14,
|
PlaceholderTextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
|
TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
rowFrameLayout.AddChidren(btnDoorlockUser);
|
|
var btnMember = new Button()
|
{
|
Width = Application.GetRealWidth(1080 - 173),
|
Height = Application.GetRealHeight(49),
|
X = Application.GetRealWidth(173),
|
Y = Application.GetRealHeight(95),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
|
TextSize = 14,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
rowFrameLayout.AddChidren(btnMember);
|
|
var btnDel = new Button()
|
{
|
Width = Application.GetRealWidth(1080 - 173),
|
Height = Application.GetRealHeight(49),
|
X = Application.GetRealWidth(173),
|
Y = Application.GetRealHeight(95),
|
Text = Language.StringByID(R.MyInternationalizationString.DelBindDevice),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
|
TextSize = 12,
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.XMDel,
|
};
|
rowFrameLayout.AddRightView(btnDel);
|
#endregion
|
#region 数据处理
|
switch (curDoorLockUser.UnlockType)
|
{
|
case 0:
|
if (curDoorLockUser.UserName != "")
|
{
|
btnDoorlockUser.Text = curDoorLockUser.UserName;
|
}
|
else
|
{
|
btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Password) + "ID" + curDoorLockUser.UserID;
|
}
|
break;
|
case 3:
|
if (curDoorLockUser.UserName != "")
|
{
|
btnDoorlockUser.Text = curDoorLockUser.UserName;
|
}
|
else
|
{
|
btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.IcCard) + "ID" + curDoorLockUser.UserID;
|
}
|
break;
|
case 15:
|
if (curDoorLockUser.UserName != "")
|
{
|
btnDoorlockUser.Text = curDoorLockUser.UserName;
|
}
|
else
|
{
|
btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Fingerprint) + "ID" + +curDoorLockUser.UserID;
|
}
|
break;
|
}
|
|
if (curAccountObj.UserName == "")
|
{
|
btnMember.Text = curAccountObj.Account;
|
}
|
else
|
{
|
btnMember.Text = curAccountObj.UserName;
|
}
|
|
Action<Shared.View> action = async (obj) =>
|
{
|
var refreshDoorLockData = new ZigBee.Device.DoorLock.RefreshDoorLockData();
|
if (UserCenterResourse.UserInfo.AuthorityNo != 1)
|
{
|
refreshDoorLockData.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
|
refreshDoorLockData.IsOtherAccountCtrl = true;
|
}
|
refreshDoorLockData.CloudAccountId = curAccountObj.SubAccountDistributedMark;
|
if (doorLock.DeviceAddr != null)
|
{
|
refreshDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
|
}
|
refreshDoorLockData.OpenLockMode = curDoorLockUser.UnlockType;
|
refreshDoorLockData.DoorLockLocalUserId = curDoorLockUser.UserID.ToString();
|
refreshDoorLockData.PrimaryId = curDoorLockUser.PrimaryId;
|
refreshDoorLockData.UserIdRemarks = btnDoorlockUser.Text;
|
var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/UpdateDoorLock", refreshDoorLockData);
|
if (result != null && result.StateCode == "Success")
|
{
|
if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID))
|
{
|
doorLock.localDoorLockUserList.Remove(curDoorLockUser.UserID);
|
var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
|
localDoorLockObj.UserID = curDoorLockUser.UserID;
|
localDoorLockObj.UnlockType = curDoorLockUser.UnlockType;
|
localDoorLockObj.EntryTime = curDoorLockUser.EntryTime;
|
localDoorLockObj.UserName = refreshDoorLockData.UserIdRemarks;
|
localDoorLockObj.ConnectedAccount = curAccountObj.SubAccountDistributedMark;
|
doorLock.localDoorLockUserList.Add(curDoorLockUser.UserID, localDoorLockObj);
|
RefreshList();
|
}
|
}
|
else
|
{
|
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ModigfyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
|
}
|
};
|
btnDoorlockUser.EditorEnterAction += action;
|
|
btnDel.MouseUpEventHandler += (sender, e) =>
|
{
|
var alert = new Alert(Language.StringByID(R.MyInternationalizationString.Tip), Language.StringByID(R.MyInternationalizationString.SureToDelUnlockMethod),
|
Language.StringByID(R.MyInternationalizationString.Cancel), Language.StringByID(R.MyInternationalizationString.Confrim));
|
alert.Show();
|
alert.ResultEventHandler += async (sender1, e1) =>
|
{
|
if (e1)
|
{
|
var passData = doorLock.SetUserAccessData(curDoorLockUser.UserID, ZigBee.Device.DoorLock.AccessType.DelCurrentUser);
|
var resultData = await doorLock.DefaultControlAsync(passData);
|
if (resultData != null && resultData.defaultControlResponseData != null)
|
{
|
if (resultData.defaultControlResponseData.status == 0 || resultData.defaultControlResponseData.status == 2)
|
{
|
var deleteDoorLockData = new ZigBee.Device.DoorLock.DeleteDoorLockData();
|
if (UserCenterResourse.UserInfo.AuthorityNo != 1)
|
{
|
deleteDoorLockData.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
|
deleteDoorLockData.IsOtherAccountCtrl = true;
|
}
|
if (doorLock.DeviceAddr != null)
|
{
|
deleteDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
|
}
|
deleteDoorLockData.DoorLockLocalUserId = curDoorLockUser.UserID.ToString();
|
deleteDoorLockData.PrimaryId = curDoorLockUser.PrimaryId;
|
deleteDoorLockData.DelDoorLockDelType = 2;
|
var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/DelDoorLock", deleteDoorLockData);
|
if (result != null && result.StateCode == "Success")
|
{
|
isSecondDel = false;
|
if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID))
|
{
|
doorLock.localDoorLockUserList.Remove(curDoorLockUser.UserID);
|
var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
|
localDoorLockObj.UserID = curDoorLockUser.UserID;
|
doorLock.localDoorLockUserList.Remove(curUserId);
|
RefreshList();
|
}
|
}
|
else
|
{
|
isSecondDel = true;
|
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
|
}
|
}
|
else
|
{
|
if (isSecondDel)
|
{
|
var deleteDoorLockData = new ZigBee.Device.DoorLock.DeleteDoorLockData();
|
if (UserCenterResourse.UserInfo.AuthorityNo != 1)
|
{
|
deleteDoorLockData.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
|
deleteDoorLockData.IsOtherAccountCtrl = true;
|
}
|
if (doorLock.DeviceAddr != null)
|
{
|
deleteDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
|
}
|
deleteDoorLockData.DoorLockLocalUserId = curDoorLockUser.UserID.ToString();
|
deleteDoorLockData.PrimaryId = curDoorLockUser.PrimaryId;
|
deleteDoorLockData.DelDoorLockDelType = 2;
|
var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/DelDoorLock", deleteDoorLockData);
|
if (result != null && result.StateCode == "Success")
|
{
|
isSecondDel = false;
|
if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID))
|
{
|
doorLock.localDoorLockUserList.Remove(curDoorLockUser.UserID);
|
var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
|
localDoorLockObj.UserID = curDoorLockUser.UserID;
|
doorLock.localDoorLockUserList.Remove(curUserId);
|
RefreshList();
|
}
|
}
|
else
|
{
|
isSecondDel = true;
|
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
|
}
|
}
|
else
|
{
|
if (curDoorLockUser.UserID < 10)
|
{
|
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.OnlyBeDeletedOnTheDevice), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
|
}
|
else
|
{
|
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
|
}
|
}
|
}
|
}
|
else
|
{
|
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel);
|
}
|
}
|
};
|
};
|
#endregion
|
}
|
}
|
|
// 侧边导航栏
|
void SideslipFramelayout()
|
{
|
var dialog = new Dialog
|
{
|
};
|
dialog.Show();
|
|
var flMain = new FrameLayout { BackgroundColor = 0x00000000 };
|
dialog.AddChidren(flMain);
|
flMain.MouseUpEventHandler += (sender11, e11) =>
|
{
|
dialog.Close();
|
};
|
|
var sidelipFrameLayout = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(625),
|
Width = Application.GetRealWidth(449),
|
Y = Application.GetRealHeight(115 + 160),
|
X = Application.GetRealWidth(596),
|
BackgroundImagePath = "DoorLock/SideslipPic.png",
|
};
|
flMain.AddChidren(sidelipFrameLayout);
|
|
var sidelipVerticalScrolViewLayout = new VerticalScrolViewLayout()
|
{
|
Height = Application.GetRealHeight(600),
|
Y = Application.GetRealHeight(28),
|
};
|
sidelipFrameLayout.AddChidren(sidelipVerticalScrolViewLayout);
|
Button oldbutton = null;
|
Button oldbuttonText = null;
|
for (var i = 0; i < 4; i++)
|
{
|
var rowFrameLayout = new RowLayout()
|
{
|
Height = Application.GetRealHeight(150),
|
};
|
sidelipVerticalScrolViewLayout.AddChidren(rowFrameLayout);
|
|
var btnAllMethod = new Button()
|
{
|
Width = Application.GetRealWidth(81),
|
Height = Application.GetRealHeight(81),
|
X = Application.GetRealWidth(81),
|
Y = Application.GetRealHeight(55),
|
};
|
rowFrameLayout.AddChidren(btnAllMethod);
|
|
var btnMethodText = new Button()
|
{
|
Width = Application.GetRealWidth(311),
|
Height = Application.GetRealHeight(58),
|
X = Application.GetRealWidth(173),
|
Y = Application.GetRealHeight(69),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
|
TextSize = 14,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
rowFrameLayout.AddChidren(btnMethodText);
|
|
EventHandler<MouseEventArgs> hander = (sender, e) =>
|
{
|
if (!btnAllMethod.IsSelected)
|
{
|
if (oldbutton != null)
|
{
|
oldbutton.IsSelected = false;
|
}
|
if (oldbuttonText != null)
|
{
|
oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
|
}
|
oldbutton = btnAllMethod;
|
oldbuttonText = btnMethodText;
|
doorLock.currentUserDisplayMethod = btnMethodText.Text;
|
btnAllMethod.IsSelected = true;
|
oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
|
|
// 类型区分
|
if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.AllMethod))
|
{
|
RefreshList();
|
}
|
if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.PasswordUnlock))
|
{
|
DisplayByType(0);
|
}
|
if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FingerprintUnlock))
|
{
|
DisplayByType(15);
|
}
|
if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock))
|
{
|
DisplayByType(3);
|
}
|
}
|
dialog.Close();
|
};
|
rowFrameLayout.MouseUpEventHandler += hander;
|
btnAllMethod.MouseUpEventHandler += hander;
|
btnMethodText.MouseUpEventHandler += hander;
|
|
switch (i)
|
{
|
case 0:
|
btnAllMethod.UnSelectedImagePath = "DoorLock/AllMethod.png";
|
btnAllMethod.SelectedImagePath = "DoorLock/AllMethodOn.png";
|
btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.AllMethod);
|
break;
|
case 1:
|
btnAllMethod.UnSelectedImagePath = "DoorLock/Password.png";
|
btnAllMethod.SelectedImagePath = "DoorLock/PasswordOn.png";
|
btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.PasswordUnlock);
|
break;
|
case 2:
|
btnAllMethod.UnSelectedImagePath = "DoorLock/Fingerprint.png";
|
btnAllMethod.SelectedImagePath = "DoorLock/FingerprintOn.png";
|
btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.FingerprintUnlock);
|
break;
|
case 3:
|
btnAllMethod.UnSelectedImagePath = "DoorLock/proximityCard.png";
|
btnAllMethod.SelectedImagePath = "DoorLock/proximityCardOn.png";
|
btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock);
|
break;
|
}
|
|
if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.AllMethod) && i == 0)
|
{
|
btnAllMethod.IsSelected = true;
|
btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
|
oldbutton = btnAllMethod;
|
oldbuttonText = btnMethodText;
|
}
|
if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.PasswordUnlock) && i == 1)
|
{
|
btnAllMethod.IsSelected = true;
|
btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
|
oldbutton = btnAllMethod;
|
oldbuttonText = btnMethodText;
|
}
|
if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FingerprintUnlock) && i == 2)
|
{
|
btnAllMethod.IsSelected = true;
|
btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
|
oldbutton = btnAllMethod;
|
oldbuttonText = btnMethodText;
|
}
|
if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock) && i == 3)
|
{
|
btnAllMethod.IsSelected = true;
|
btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
|
oldbutton = btnAllMethod;
|
oldbuttonText = btnMethodText;
|
}
|
}
|
}
|
|
/// <summary>
|
/// 通过类型筛选显示
|
/// </summary>
|
public void DisplayByType(int unlockMethod)
|
{
|
bodyView.RemoveAll();
|
var curAccountDoorLockUserList = new Dictionary<int, ZigBee.Device.DoorLock.LocaDoorLockObj>();
|
|
foreach (var curUserId in doorLock.localDoorLockUserList.Keys)
|
{
|
var curDoorLockUser = doorLock.localDoorLockUserList[curUserId];
|
|
if (curDoorLockUser.ConnectedAccount == "" || curDoorLockUser.ConnectedAccount != curAccountObj.SubAccountDistributedMark)
|
{
|
continue;
|
}
|
else
|
{
|
curAccountDoorLockUserList.Add(curDoorLockUser.UserID, curDoorLockUser);
|
}
|
}
|
|
if (curAccountDoorLockUserList.Count == 0)
|
{
|
entryStatusPic.Visible = true;
|
btnPicTip.Visible = true;
|
btnPicTip1.Visible = true;
|
}
|
else
|
{
|
entryStatusPic.Visible = false;
|
btnPicTip.Visible = false;
|
btnPicTip1.Visible = false;
|
}
|
|
foreach (var curUserId in curAccountDoorLockUserList.Keys)
|
{
|
var curDoorLockUser = curAccountDoorLockUserList[curUserId];
|
if (curDoorLockUser.UnlockType != unlockMethod)
|
{
|
continue;
|
}
|
#region UI
|
var rowFrameLayout = new RowLayout()
|
{
|
Height = Application.GetRealHeight(173),
|
X = Application.GetRealWidth(58),
|
Width = Application.GetRealWidth(965),
|
LineColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
|
};
|
bodyView.AddChidren(rowFrameLayout);
|
|
var btnPicFrameLayout = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(81),
|
Height = Application.GetRealHeight(81),
|
X = Application.GetRealWidth(40),
|
Y = Application.GetRealHeight(49),
|
};
|
rowFrameLayout.AddChidren(btnPicFrameLayout);
|
|
var btnPic = new Button()
|
{
|
Width = Application.GetRealWidth(84),
|
Height = Application.GetRealHeight(84),
|
UnSelectedImagePath = "DoorLock/DoorLockUserPic.png",
|
};
|
btnPicFrameLayout.AddChidren(btnPic);
|
|
var btnDoorlockUser = new EditText()
|
{
|
Width = Application.GetRealWidth(1080 - 173),
|
Height = Application.GetRealHeight(60),
|
X = Application.GetRealWidth(173),
|
Y = Application.GetRealHeight(35),
|
TextSize = 14,
|
PlaceholderTextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
|
TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
rowFrameLayout.AddChidren(btnDoorlockUser);
|
|
var btnMember = new Button()
|
{
|
Width = Application.GetRealWidth(1080 - 173),
|
Height = Application.GetRealHeight(49),
|
X = Application.GetRealWidth(173),
|
Y = Application.GetRealHeight(95),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
|
TextSize = 14,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
rowFrameLayout.AddChidren(btnMember);
|
|
var btnDel = new Button()
|
{
|
Width = Application.GetRealWidth(1080 - 173),
|
Height = Application.GetRealHeight(49),
|
X = Application.GetRealWidth(173),
|
Y = Application.GetRealHeight(95),
|
Text = Language.StringByID(R.MyInternationalizationString.DelBindDevice),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
|
TextSize = 12,
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.XMDel,
|
};
|
rowFrameLayout.AddRightView(btnDel);
|
#endregion
|
#region 数据处理
|
switch (curDoorLockUser.UnlockType)
|
{
|
case 0:
|
if (curDoorLockUser.UserName != "")
|
{
|
btnDoorlockUser.Text = curDoorLockUser.UserName;
|
}
|
else
|
{
|
btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Password) + "ID" + curDoorLockUser.UserID;
|
}
|
break;
|
case 3:
|
if (curDoorLockUser.UserName != "")
|
{
|
btnDoorlockUser.Text = curDoorLockUser.UserName;
|
}
|
else
|
{
|
btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.IcCard) + "ID" + curDoorLockUser.UserID;
|
}
|
break;
|
case 15:
|
if (curDoorLockUser.UserName != "")
|
{
|
btnDoorlockUser.Text = curDoorLockUser.UserName;
|
}
|
else
|
{
|
btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Fingerprint) + "ID" + +curDoorLockUser.UserID;
|
}
|
break;
|
}
|
|
if (curAccountObj.UserName == "")
|
{
|
btnMember.Text = curAccountObj.Account;
|
}
|
else
|
{
|
btnMember.Text = curAccountObj.UserName;
|
}
|
|
Action<Shared.View> action = async (obj) =>
|
{
|
var refreshDoorLockData = new ZigBee.Device.DoorLock.RefreshDoorLockData();
|
if (UserCenterResourse.UserInfo.AuthorityNo != 1)
|
{
|
refreshDoorLockData.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
|
refreshDoorLockData.IsOtherAccountCtrl = true;
|
}
|
refreshDoorLockData.CloudAccountId = curAccountObj.SubAccountDistributedMark;
|
if (doorLock.DeviceAddr != null)
|
{
|
refreshDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
|
}
|
refreshDoorLockData.OpenLockMode = curDoorLockUser.UnlockType;
|
refreshDoorLockData.DoorLockLocalUserId = curDoorLockUser.UserID.ToString();
|
refreshDoorLockData.PrimaryId = curDoorLockUser.PrimaryId;
|
refreshDoorLockData.UserIdRemarks = btnDoorlockUser.Text;
|
var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/UpdateDoorLock", refreshDoorLockData);
|
if (result != null && result.StateCode == "Success")
|
{
|
if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID))
|
{
|
doorLock.localDoorLockUserList.Remove(curDoorLockUser.UserID);
|
var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
|
localDoorLockObj.UserID = curDoorLockUser.UserID;
|
localDoorLockObj.UnlockType = curDoorLockUser.UnlockType;
|
localDoorLockObj.EntryTime = curDoorLockUser.EntryTime;
|
localDoorLockObj.UserName = refreshDoorLockData.UserIdRemarks;
|
localDoorLockObj.ConnectedAccount = curAccountObj.SubAccountDistributedMark;
|
doorLock.localDoorLockUserList.Add(curDoorLockUser.UserID, localDoorLockObj);
|
RefreshList();
|
}
|
}
|
else
|
{
|
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ModigfyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
|
}
|
};
|
btnDoorlockUser.EditorEnterAction += action;
|
|
btnDel.MouseUpEventHandler += (sender, e) =>
|
{
|
var alert = new Alert(Language.StringByID(R.MyInternationalizationString.Tip), Language.StringByID(R.MyInternationalizationString.SureToDelUnlockMethod),
|
Language.StringByID(R.MyInternationalizationString.Cancel), Language.StringByID(R.MyInternationalizationString.Confrim));
|
alert.Show();
|
alert.ResultEventHandler += async (sender1, e1) =>
|
{
|
if (e1)
|
{
|
var passData = doorLock.SetUserAccessData(curDoorLockUser.UserID, ZigBee.Device.DoorLock.AccessType.DelCurrentUser);
|
var resultData = await doorLock.DefaultControlAsync(passData);
|
if (resultData != null && resultData.defaultControlResponseData != null)
|
{
|
if (resultData.defaultControlResponseData.status == 0)
|
{
|
var deleteDoorLockData = new ZigBee.Device.DoorLock.DeleteDoorLockData();
|
if (UserCenterResourse.UserInfo.AuthorityNo != 1)
|
{
|
deleteDoorLockData.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
|
deleteDoorLockData.IsOtherAccountCtrl = true;
|
}
|
if (doorLock.DeviceAddr != null)
|
{
|
deleteDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
|
}
|
deleteDoorLockData.DoorLockLocalUserId = curDoorLockUser.UserID.ToString();
|
deleteDoorLockData.PrimaryId = curDoorLockUser.PrimaryId;
|
deleteDoorLockData.DelDoorLockDelType = 2;
|
var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/DelDoorLock", deleteDoorLockData);
|
if (result != null && result.StateCode == "Success")
|
{
|
if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID))
|
{
|
doorLock.localDoorLockUserList.Remove(curDoorLockUser.UserID);
|
var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
|
localDoorLockObj.UserID = curDoorLockUser.UserID;
|
|
//new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveSuccess), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel);
|
doorLock.localDoorLockUserList.Remove(curUserId);
|
RefreshList();
|
}
|
}
|
else
|
{
|
if (curDoorLockUser.UserID < 10)
|
{
|
|
}
|
else
|
{
|
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ModigfyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
|
}
|
}
|
}
|
else
|
{
|
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel);
|
}
|
|
}
|
else
|
{
|
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel);
|
}
|
}
|
};
|
};
|
#endregion
|
}
|
}
|
|
}
|
}
|