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, ZigBee.Common.IStatus
|
{
|
/// <summary>
|
/// 按键模式接收
|
/// </summary>
|
/// <param name="common">Common.</param>
|
public void Changed(CommonDevice common)
|
{
|
//if (common.Type != ZigBee.Device.DeviceType.OnOffSwitch)
|
//{
|
// return;
|
//}
|
|
Shared.Application.RunOnMainThread(() =>
|
{
|
//var dev = common as Panel;
|
});
|
}
|
|
|
/// 构造函数
|
/// </summary>
|
/// <param name="doorLock"></param>
|
public UserManagement(ZigBee.Device.DoorLock doorLock)
|
{
|
this.doorLock = doorLock;
|
}
|
|
#region ◆ 变量申明__________________________
|
ZigBee.Device.DoorLock doorLock;
|
List<Shared.Phone.UserCenter.MemberInfoRes> localAccountList = new List<Shared.Phone.UserCenter.MemberInfoRes> { };
|
#endregion
|
|
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),
|
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(121),
|
TextID = R.MyInternationalizationString.Undistributed,
|
TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
|
X = btnUndistributeIcon.Right,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
btnAddFrameLayout.AddChidren(btnUndistributeText);
|
|
EventHandler<MouseEventArgs> eHandler = (sender, e) =>
|
{
|
var undistributeDoorlockUserPage = new Shared.Phone.UserCenter.DoorLock.UndistributeDoorlockUserPage(doorLock, localAccountList);
|
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;
|
|
MidFrameLayoutContent();
|
}
|
|
async void MidFrameLayoutContent()
|
{
|
List<Shared.Phone.UserCenter.MemberInfoRes> SubAccounList = null;
|
if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
|
{
|
SubAccounList = await ZigBee.Device.DoorLock.GetSubAccountByDistributedMark();
|
}
|
|
var masterAccount = new Shared.Phone.UserCenter.MemberInfoRes();
|
masterAccount.Account = Shared.Common.Config.Instance.Account;
|
masterAccount.AccountType = Shared.Common.Config.Instance.AccountType;
|
masterAccount.SubAccountDistributedMark = Shared.Common.Config.Instance.Guid;
|
masterAccount.UserName = UserCenterResourse.UserInfo.UserName;
|
localAccountList.Add(masterAccount);
|
localAccountList.AddRange(SubAccounList);
|
|
var bodyView = new VerticalScrolViewLayout()
|
{
|
};
|
this.midFrameLayout.AddChidren(bodyView);
|
|
doorLock.localAllAccountList = localAccountList;
|
for (int i = 0; i < localAccountList.Count; i++)
|
{
|
var currentAccount = localAccountList[i];
|
var RowView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(161),
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.XMTopFrameLayout,
|
};
|
bodyView.AddChidren(RowView);
|
|
var btnText = new Button()
|
{
|
X = Application.GetRealWidth(58),
|
Width = Application.GetRealWidth(300),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
|
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 == localAccountList.Count - 1)
|
{
|
line2.Visible = false;
|
}
|
|
if (currentAccount.UserName != null)
|
{
|
btnText.Text = currentAccount.UserName;
|
}
|
else
|
{
|
btnText.Text = currentAccount.Account;
|
}
|
|
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;
|
}
|
}
|
|
public void DeviceInfoChange(CommonDevice common, string typeTag)
|
{
|
}
|
|
public void ChangedILogicStatus(ZigBee.Device.Logic logic)
|
{
|
}
|
|
public void ChangedISceneStatus(Scene scene)
|
{
|
}
|
}
|
}
|