| | |
| | | using Shared; |
| | | using Shared.Common; |
| | | using Shared.R; |
| | | |
| | | namespace Shared.Phone.Logic.DoorLockLogic |
| | | namespace Shared.Phone.Device.Logic.DoorLockLogic |
| | | { |
| | | public class AddCondition : FrameLayout |
| | | { |
| | | public AddCondition() |
| | | { |
| | | Tag = "LockLogic"; |
| | | } |
| | | Button selectedIcon = new Button(); |
| | | |
| | | public int conditionsIndex = -1; |
| | | public void Show() |
| | | { |
| | | #region 最上面的布局代码 |
| | |
| | | |
| | | var userlist = new List<ZigBee.Device.DoorLock.LocaDoorLockObj>(); |
| | | userlist.Clear(); |
| | | |
| | | ///判断APP登录进来用户身份(主人,管理员,成员) |
| | | if (UserCenter.UserCenterResourse.UserInfo.AuthorityNo == 3) |
| | | { |
| | | var list = DoorLockIfon.GetUserIfon(DoorLockIfon.UserMemberInfoRes.SubAccountDistributedMark); |
| | | var list = LockIfon.GetUserIfon(LockIfon.UserMemberInfoRes.SubAccountDistributedMark); |
| | | foreach (var o in list) |
| | | { |
| | | if (userlist.Count != 0) |
| | |
| | | } |
| | | else |
| | | { |
| | | userlist = DoorLockIfon.GetUserList(); |
| | | userlist = LockIfon.GetUserList(); |
| | | } |
| | | |
| | | for (int i = 0; i < userlist.Count; i++) |
| | | { |
| | | var user = userlist[i]; |
| | |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | Width = Application.GetRealWidth(600), |
| | | Height = Application.GetRealHeight(130), |
| | | Tag = userlist[i].ConnectedAccount |
| | | }; |
| | | userRow.AddChidren(usernameBtn); |
| | | |
| | |
| | | |
| | | EventHandler<MouseEventArgs> userclick = (sender, e) => |
| | | { |
| | | var uesrifonlist = DoorLockIfon.GetUserIfon(user.ConnectedAccount); |
| | | var uesrifonlist = LockIfon.GetUserIfon(usernameBtn.Tag.ToString()); |
| | | SelectedUserID(uesrifonlist, usernameBtn.Text); |
| | | }; |
| | | usernameBtn.MouseUpEventHandler += userclick; |
| | | btntimeback.MouseUpEventHandler += userclick; |
| | | userFramelayout.MouseUpEventHandler += userclick; |
| | | userRow.MouseUpEventHandler += userclick; |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 选择某个用户 |
| | | /// </summary> |
| | | /// <param name="uesrifonlist">触发源列表</param> |
| | | /// <param name="userName">用户名字</param> |
| | | void SelectedUserID(List<ZigBee.Device.DoorLock.LocaDoorLockObj> uesrifonlist,string userName) { |
| | | |
| | | var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; |
| | | this.AddChidren(flMain); |
| | | |
| | | flMain.MouseUpEventHandler += (sender1, e1) => |
| | | { |
| | | flMain.RemoveFromParent(); |
| | |
| | | TextAlignment = TextAlignment.Center, |
| | | X = Btncancel.Right + Application.GetRealWidth(100), |
| | | TextSize = 16, |
| | | Text = user.UserName, |
| | | Text =userName, |
| | | }; |
| | | lockRow.AddChidren(Btntitle); |
| | | var Btncomplete = new Button |
| | |
| | | lockRow.AddChidren(Btncomplete); |
| | | #endregion |
| | | |
| | | string SelectedDeviceStatuscondition = ""; |
| | | string SelectedLockStatus = ""; |
| | | lockcolorfra1.Y = Application.GetRealHeight(1920 - 140 - (160 * uesrifonlist.Count) - 20 - 50); |
| | | lockcolorfra1.Height = Application.GetRealHeight(140 + (160 * uesrifonlist.Count) + 20 + 50); |
| | | ///定义两个变量记录选中状态; |
| | | int attriButeId = 0, attriButeData2 = 0; |
| | | for (int j = 0; j < uesrifonlist.Count; j++) |
| | | { |
| | | var userid = uesrifonlist[i]; |
| | | var userid = uesrifonlist[j]; |
| | | var doorlockfra = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(160), |
| | |
| | | doorlockBtn.Text = Language.StringByID(MyInternationalizationString.fingerprint); |
| | | } |
| | | break; |
| | | |
| | | } |
| | | |
| | | |
| | | var doorlockSelected = new Button |
| | | { |
| | | X = Application.GetRealWidth(860), |
| | |
| | | |
| | | }; |
| | | doorlockRow.AddChidren(doorlockSelected); |
| | | if ((uesrifonlist.Count - 1) == i) |
| | | if ((uesrifonlist.Count - 1) == j) |
| | | { |
| | | doorlockRow.LineColor = ZigbeeColor.Current.LogicBackgroundColor; |
| | | } |
| | | EventHandler<MouseEventArgs> doorlockclick = (sender2, e2) => |
| | | { |
| | | SelectedDeviceStatuscondition = "DoorLock"; |
| | | SelectedLockStatus = "DoorLock"; |
| | | selectedIcon.Visible = false; |
| | | selectedIcon = doorlockSelected; |
| | | doorlockSelected.Visible = true; |
| | | //doorlockBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor; |
| | | |
| | | attriButeId = userid.UnlockType; |
| | | attriButeData2 = userid.UserID; |
| | | }; |
| | | doorlockRow.MouseUpEventHandler += doorlockclick; |
| | | doorlockBtn.MouseUpEventHandler += doorlockclick; |
| | | doorlockSelected.MouseUpEventHandler += doorlockclick; |
| | | doorlockfra.MouseUpEventHandler += doorlockclick; |
| | | |
| | | } |
| | | |
| | | |
| | | Btncomplete.MouseUpEventHandler += (sender3, e3) => |
| | | ///显示之前的状态 |
| | | if (conditionsIndex != -1) |
| | | { |
| | | |
| | | |
| | | }; |
| | | |
| | | }; |
| | | usernameBtn.MouseUpEventHandler += userclick; |
| | | btntimeback.MouseUpEventHandler += userclick; |
| | | userFramelayout.MouseUpEventHandler += userclick; |
| | | userRow.MouseUpEventHandler += userclick; |
| | | |
| | | |
| | | var s = Common.Logic.CurrentLogic.Conditions[conditionsIndex]; |
| | | if (s["AttriButeId"] == userid.UnlockType.ToString() && s["AttriButeData2"] == userid.UserID.ToString()) |
| | | { |
| | | selectedIcon.Visible = false; |
| | | selectedIcon = doorlockSelected; |
| | | doorlockSelected.Visible = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | Btncomplete.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var lockConditionsInfo = new Dictionary<string, string>(); |
| | | lockConditionsInfo.Add("Type", "1"); |
| | | lockConditionsInfo.Add("IsValid", "1"); |
| | | lockConditionsInfo.Add("MacAddr", LockIfon.DoorLock.DeviceAddr); |
| | | lockConditionsInfo.Add("Epoint", LockIfon.DoorLock.DeviceEpoint.ToString()); |
| | | lockConditionsInfo.Add("Cluster_ID", "64529"); |
| | | lockConditionsInfo.Add("AttriButeId", attriButeId.ToString()); |
| | | lockConditionsInfo.Add("AttriButeData2", attriButeData2.ToString()); |
| | | lockConditionsInfo.Add("AttriButeData1", "2"); |
| | | lockConditionsInfo.Add("Range", "0"); |
| | | if (SelectedLockStatus != "") |
| | | { |
| | | if (conditionsIndex == -1) |
| | | { |
| | | Common.Logic.CurrentLogic.Conditions.Add(lockConditionsInfo); |
| | | } |
| | | else |
| | | { |
| | | Common.Logic.CurrentLogic.Conditions.RemoveAt(conditionsIndex); |
| | | Common.Logic.CurrentLogic.Conditions.Insert(conditionsIndex, lockConditionsInfo); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | if (conditionsIndex == -1) |
| | | { |
| | | var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt), |
| | | Language.StringByID(MyInternationalizationString.selectdevicestatuscondition), |
| | | Language.StringByID(MyInternationalizationString.complete)); |
| | | alert.Show(); |
| | | return; |
| | | } |
| | | } |
| | | var lockLogicCommunalPage = new LockLogicCommunalPage(); |
| | | UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | lockLogicCommunalPage.Show(() => { }); |
| | | }; |
| | | } |
| | | } |
| | | } |