using System;
|
using System.Collections.Generic;
|
using Shared.Common;
|
using Shared.Phone.UserCenter.Device;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.UserCenter.DoorLock
|
{
|
/// <summary>
|
/// 门锁管理
|
/// </summary>
|
public class UserManagement : DoorLockCommonLayout
|
{
|
/// 构造函数
|
/// </summary>
|
/// <param name="doorLock"></param>
|
public UserManagement(ZigBee.Device.DoorLock doorLock)
|
{
|
this.doorLock = doorLock;
|
localAllAccountListTemp = doorLock.localAllAccountList;
|
localDoorLockUserListTemp = doorLock.localDoorLockUserList;
|
}
|
|
#region ◆ 变量申明__________________________
|
ZigBee.Device.DoorLock doorLock;
|
VerticalRefreshLayout midVerticalScrolViewLayout;
|
public List<MemberInfoRes> localAllAccountListTemp = new List<MemberInfoRes> { };
|
public Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj> localDoorLockUserListTemp = new Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj>();
|
|
|
#endregion
|
|
/// <summary>
|
/// 数据刷新
|
/// </summary>
|
void ReadAccountDoorLockInfoList()
|
{
|
System.Threading.Tasks.Task.Run(async () =>
|
{
|
try
|
{
|
var localAccountListTemp = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.LocalAccountList();
|
if (localAccountListTemp != null)
|
{
|
doorLock.localAllAccountList.Clear();
|
doorLock.localAllAccountList = localAccountListTemp;
|
localAllAccountListTemp = doorLock.localAllAccountList;
|
|
//初始化权限信息
|
foreach (var sub in localAccountListTemp)
|
{
|
//☆マーク☆
|
//if (doorLock.IsFreezeAccount.ContainsKey(sub.SubAccountDistributedMark) == false)
|
//{
|
// doorLock.IsFreezeAccount.Add(sub.SubAccountDistributedMark, false);
|
//}
|
//if (doorLock.HasRemoteUnlockAccess.ContainsKey(sub.SubAccountDistributedMark) == false)
|
//{
|
// doorLock.HasRemoteUnlockAccess.Add(sub.SubAccountDistributedMark, false);
|
//}
|
//if (doorLock.IsFailedToGetDoorLockInfo.ContainsKey(sub.SubAccountDistributedMark) == false)
|
//{
|
// doorLock.IsFailedToGetDoorLockInfo.Add(sub.SubAccountDistributedMark, false);
|
//}
|
}
|
|
//获取本地门锁列表
|
if (localDoorLockUserListTemp.Count == 0)
|
{
|
var list = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockAllAcountUserlist(doorLock);
|
localDoorLockUserListTemp = doorLock.localDoorLockUserList;
|
}
|
doorLock.ReSave();
|
}
|
else
|
{
|
Application.RunOnMainThread(() =>
|
{
|
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance);
|
});
|
}
|
}
|
catch { }
|
finally
|
{
|
Application.RunOnMainThread(() =>
|
{
|
MidFrameLayoutContent();
|
CommonPage.Loading.Hide();
|
midVerticalScrolViewLayout.EndHeaderRefreshing();
|
});
|
}
|
});
|
}
|
|
/// <summary>
|
/// 显示界面
|
/// </summary>
|
public void Show()
|
{
|
this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.UserManagement));
|
|
EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
|
{
|
RemoveFromParent();
|
};
|
this.btnBack.MouseUpEventHandler += eHandlerBack;
|
this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
|
this.MidFrameLayout(this);
|
|
var btnAddFrameLayout = new FrameLayout
|
{
|
X = Application.GetRealWidth(829 - 116),
|
Height = Application.GetRealHeight(72),
|
Width = Application.GetRealWidth(190),
|
};
|
this.titleFrameLayout.AddChidren(btnAddFrameLayout);
|
|
var btnUndistributeIcon = new Button
|
{
|
Height = Application.GetRealHeight(69),
|
Width = Application.GetRealWidth(69),
|
UnSelectedImagePath = "DoorLock/UndistributeIcon.png",
|
};
|
btnAddFrameLayout.AddChidren(btnUndistributeIcon);
|
|
var btnUndistributeText = new Button
|
{
|
Height = Application.GetRealHeight(72),
|
Width = Application.GetRealWidth(150),
|
TextID = R.MyInternationalizationString.Undistributed,
|
TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
|
X = btnUndistributeIcon.Right,
|
IsBold = true,
|
TextSize = 13,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
btnAddFrameLayout.AddChidren(btnUndistributeText);
|
if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 1)
|
{
|
btnAddFrameLayout.Width = 0;
|
btnUndistributeIcon.Width = 0;
|
btnUndistributeText.Width = 0;
|
}
|
EventHandler<MouseEventArgs> eHandler = (sender, e) =>
|
{
|
var undistributeDoorlockUserPage = new Shared.Phone.UserCenter.DoorLock.UndistributeDoorlockUserPage(doorLock, doorLock.localAllAccountList);
|
Shared.Phone.UserView.HomePage.Instance.AddChidren(undistributeDoorlockUserPage);
|
Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
|
undistributeDoorlockUserPage.Show();
|
};
|
btnAddFrameLayout.MouseDownEventHandler += eHandler;
|
btnUndistributeText.MouseDownEventHandler += eHandler;
|
btnUndistributeIcon.MouseDownEventHandler += eHandler;
|
midVerticalScrolViewLayout = new VerticalRefreshLayout() { };
|
this.midFrameLayout.AddChidren(midVerticalScrolViewLayout);
|
|
if (localAllAccountListTemp.Count == 0)
|
{
|
CommonPage.Loading.Start("Loading...");
|
ReadAccountDoorLockInfoList();
|
}
|
else
|
{
|
MidFrameLayoutContent();
|
}
|
|
midVerticalScrolViewLayout.BeginHeaderRefreshingAction += () =>
|
{
|
midVerticalScrolViewLayout.BeginHeaderRefreshing();
|
ReadAccountDoorLockInfoList();
|
};
|
}
|
|
/// <summary>
|
/// 中部布局显示
|
/// </summary>
|
async void MidFrameLayoutContent()
|
{
|
midVerticalScrolViewLayout.RemoveAll();
|
for (int i = 0; i < doorLock.localAllAccountList.Count; i++)
|
{
|
var currentAccount = doorLock.localAllAccountList[i];
|
var RowView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(127 + 23),
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
|
};
|
midVerticalScrolViewLayout.AddChidren(RowView);
|
|
var btnText = new Button()
|
{
|
X = Application.GetRealWidth(58),
|
Width = Application.GetRealWidth(300),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
|
Gravity = Gravity.CenterVertical,
|
TextSize = 14,
|
};
|
RowView.AddChidren(btnText);
|
|
var btnRightFrameLayout = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(110),
|
Width = Application.GetRealWidth(110),
|
X = Application.CurrentWidth - Application.GetRealWidth(150),
|
Y = Application.GetRealHeight(25),
|
};
|
RowView.AddChidren(btnRightFrameLayout);
|
|
var btnRight = new Button()
|
{
|
Height = Application.GetRealHeight(58),
|
Width = Application.GetRealWidth(58),
|
UnSelectedImagePath = "DoorLock/RightIcon.png",
|
Gravity = Gravity.Center,
|
};
|
btnRightFrameLayout.AddChidren(btnRight);
|
|
var line2 = new Button()
|
{
|
Y = RowView.Height - 1,
|
X = Application.GetRealWidth(58),
|
Width = Application.GetRealWidth(965),
|
Height = 1,
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
|
};
|
RowView.AddChidren(line2);
|
int currentIndex = i;
|
if (currentIndex == doorLock.localAllAccountList.Count - 1)
|
{
|
line2.Visible = false;
|
}
|
|
btnText.Text = currentAccount.ShowName;
|
|
EventHandler<MouseEventArgs> eHandler = (sender, e) =>
|
{
|
if (currentIndex == 0)
|
{
|
var masterManagementPage = new Shared.Phone.UserCenter.DoorLock.MasterManagementPage(doorLock, currentAccount);
|
Shared.Phone.UserView.HomePage.Instance.AddChidren(masterManagementPage);
|
Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
|
masterManagementPage.Show();
|
}
|
else
|
{
|
var memberFrozenPage = new Shared.Phone.UserCenter.DoorLock.MemberFrozenPage(doorLock, currentAccount);
|
Shared.Phone.UserView.HomePage.Instance.AddChidren(memberFrozenPage);
|
Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
|
memberFrozenPage.Show();
|
}
|
};
|
btnRight.MouseUpEventHandler += eHandler;
|
RowView.MouseUpEventHandler += eHandler;
|
btnText.MouseUpEventHandler += eHandler;
|
}
|
}
|
}
|
}
|