| | |
| | | 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 flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; |
| | | this.AddChidren(flMain); |
| | | flMain.MouseUpEventHandler += (sender1, e1) => |
| | | { |
| | | flMain.RemoveFromParent(); |
| | | }; |
| | | |
| | | var lockcolorfra = new FrameLayout |
| | | { |
| | | Width = Application.GetRealWidth(1080), |
| | | Height = Application.GetRealHeight(100), |
| | | Y = Application.GetRealHeight(1920 - 100), |
| | | BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, |
| | | }; |
| | | flMain.AddChidren(lockcolorfra); |
| | | |
| | | var lockcolorfra1 = new FrameLayout |
| | | { |
| | | |
| | | Width = Application.GetRealWidth(1080), |
| | | Height = Application.GetRealHeight(530), |
| | | Y = Application.GetRealHeight(1920 - 530), |
| | | BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, |
| | | Radius = (uint)Application.GetRealHeight(60), |
| | | }; |
| | | flMain.AddChidren(lockcolorfra1); |
| | | |
| | | #region -------取消 完成 |
| | | var lockRow = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(140), |
| | | LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, |
| | | }; |
| | | lockcolorfra1.AddChidren(lockRow); |
| | | var Btncancel = new Button |
| | | { |
| | | TextID = MyInternationalizationString.cancel, |
| | | TextColor = ZigbeeColor.Current.LogicBtnCancelColor, |
| | | Height = Application.GetRealHeight(140), |
| | | Width = Application.GetRealWidth(200), |
| | | X = Application.GetRealWidth(80), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | lockRow.AddChidren(Btncancel); |
| | | Btncancel.MouseUpEventHandler += (sender16, e16) => |
| | | { |
| | | flMain.RemoveFromParent(); |
| | | UserView.HomePage.Instance.ScrollEnabled = true; |
| | | }; |
| | | |
| | | var Btntitle = new Button |
| | | { |
| | | TextID = MyInternationalizationString.security, |
| | | TextColor = ZigbeeColor.Current.LogicBtnTypeColor, |
| | | Height = Application.GetRealHeight(140), |
| | | Width = Application.GetRealWidth(320), |
| | | TextAlignment = TextAlignment.Center, |
| | | X = Btncancel.Right + Application.GetRealWidth(100), |
| | | TextSize = 16, |
| | | Text = user.UserName, |
| | | }; |
| | | lockRow.AddChidren(Btntitle); |
| | | var Btncomplete = new Button |
| | | { |
| | | TextID = MyInternationalizationString.complete, |
| | | TextColor = ZigbeeColor.Current.LogicBtnCompleteColor, |
| | | Height = Application.GetRealHeight(140), |
| | | Width = Application.GetRealWidth(200), |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | X = Btntitle.Right + Application.GetRealWidth(100), |
| | | |
| | | }; |
| | | lockRow.AddChidren(Btncomplete); |
| | | #endregion |
| | | |
| | | string SelectedDeviceStatuscondition = ""; |
| | | lockcolorfra1.Y = Application.GetRealHeight(1920 - 140 - (160 * uesrifonlist.Count) - 20 - 50); |
| | | lockcolorfra1.Height = Application.GetRealHeight(140 + (160 * uesrifonlist.Count) + 20 + 50); |
| | | for (int j = 0; j < uesrifonlist.Count; j++) |
| | | { |
| | | var userid = uesrifonlist[i]; |
| | | var doorlockfra = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(160), |
| | | Y = lockRow.Bottom + Application.GetRealHeight(20 + 160 * j), |
| | | }; |
| | | lockcolorfra1.AddChidren(doorlockfra); |
| | | |
| | | var doorlockRow = new RowLayout |
| | | { |
| | | Y = Application.GetRealHeight(30), |
| | | Width = Application.GetRealWidth(920), |
| | | Height = Application.GetRealHeight(130), |
| | | X = Application.GetRealWidth(80), |
| | | LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, |
| | | }; |
| | | doorlockfra.AddChidren(doorlockRow); |
| | | |
| | | var doorlockBtn = new Button |
| | | { |
| | | Width = Application.GetRealWidth(600), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, |
| | | }; |
| | | doorlockRow.AddChidren(doorlockBtn); |
| | | //(0按键/3卡/15指纹) |
| | | switch (userid.UnlockType) |
| | | { |
| | | case 0: |
| | | { |
| | | doorlockBtn.Text = Language.StringByID(MyInternationalizationString.lockpassword); |
| | | } |
| | | break; |
| | | case 3: |
| | | { |
| | | doorlockBtn.Text = Language.StringByID(MyInternationalizationString.ic); |
| | | } |
| | | break; |
| | | case 15: |
| | | { |
| | | doorlockBtn.Text = Language.StringByID(MyInternationalizationString.fingerprint); |
| | | } |
| | | break; |
| | | } |
| | | var doorlockSelected = new Button |
| | | { |
| | | X = Application.GetRealWidth(860), |
| | | Width = Application.GetMinRealAverage(60), |
| | | Height = Application.GetMinRealAverage(60), |
| | | UnSelectedImagePath = "ZigeeLogic/selected.png", |
| | | Visible = false, |
| | | Gravity = Gravity.CenterVertical, |
| | | |
| | | }; |
| | | doorlockRow.AddChidren(doorlockSelected); |
| | | if ((uesrifonlist.Count - 1) == i) |
| | | { |
| | | doorlockRow.LineColor = ZigbeeColor.Current.LogicBackgroundColor; |
| | | } |
| | | EventHandler<MouseEventArgs> doorlockclick = (sender2, e2) => |
| | | { |
| | | SelectedDeviceStatuscondition = "DoorLock"; |
| | | selectedIcon.Visible = false; |
| | | selectedIcon = doorlockSelected; |
| | | doorlockSelected.Visible = true; |
| | | //doorlockBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor; |
| | | |
| | | }; |
| | | doorlockRow.MouseUpEventHandler += doorlockclick; |
| | | doorlockBtn.MouseUpEventHandler += doorlockclick; |
| | | doorlockSelected.MouseUpEventHandler += doorlockclick; |
| | | doorlockfra.MouseUpEventHandler += doorlockclick; |
| | | |
| | | } |
| | | |
| | | |
| | | Btncomplete.MouseUpEventHandler += (sender3, e3) => |
| | | { |
| | | |
| | | |
| | | }; |
| | | |
| | | var uesrifonlist = LockIfon.GetUserIfon(usernameBtn.Tag.ToString()); |
| | | SelectedUserID(uesrifonlist, usernameBtn.Text); |
| | | }; |
| | | usernameBtn.MouseUpEventHandler += userclick; |
| | | btntimeback.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(); |
| | | }; |
| | | |
| | | var lockcolorfra = new FrameLayout |
| | | { |
| | | Width = Application.GetRealWidth(1080), |
| | | Height = Application.GetRealHeight(100), |
| | | Y = Application.GetRealHeight(1920 - 100), |
| | | BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, |
| | | }; |
| | | flMain.AddChidren(lockcolorfra); |
| | | |
| | | var lockcolorfra1 = new FrameLayout |
| | | { |
| | | |
| | | Width = Application.GetRealWidth(1080), |
| | | Height = Application.GetRealHeight(530), |
| | | Y = Application.GetRealHeight(1920 - 530), |
| | | BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, |
| | | Radius = (uint)Application.GetRealHeight(60), |
| | | }; |
| | | flMain.AddChidren(lockcolorfra1); |
| | | |
| | | #region -------取消 完成 |
| | | var lockRow = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(140), |
| | | LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, |
| | | }; |
| | | lockcolorfra1.AddChidren(lockRow); |
| | | var Btncancel = new Button |
| | | { |
| | | TextID = MyInternationalizationString.cancel, |
| | | TextColor = ZigbeeColor.Current.LogicBtnCancelColor, |
| | | Height = Application.GetRealHeight(140), |
| | | Width = Application.GetRealWidth(200), |
| | | X = Application.GetRealWidth(80), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | lockRow.AddChidren(Btncancel); |
| | | Btncancel.MouseUpEventHandler += (sender16, e16) => |
| | | { |
| | | flMain.RemoveFromParent(); |
| | | UserView.HomePage.Instance.ScrollEnabled = true; |
| | | }; |
| | | |
| | | var Btntitle = new Button |
| | | { |
| | | TextID = MyInternationalizationString.security, |
| | | TextColor = ZigbeeColor.Current.LogicBtnTypeColor, |
| | | Height = Application.GetRealHeight(140), |
| | | Width = Application.GetRealWidth(320), |
| | | TextAlignment = TextAlignment.Center, |
| | | X = Btncancel.Right + Application.GetRealWidth(100), |
| | | TextSize = 16, |
| | | Text =userName, |
| | | }; |
| | | lockRow.AddChidren(Btntitle); |
| | | var Btncomplete = new Button |
| | | { |
| | | TextID = MyInternationalizationString.complete, |
| | | TextColor = ZigbeeColor.Current.LogicBtnCompleteColor, |
| | | Height = Application.GetRealHeight(140), |
| | | Width = Application.GetRealWidth(200), |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | X = Btntitle.Right + Application.GetRealWidth(100), |
| | | |
| | | }; |
| | | lockRow.AddChidren(Btncomplete); |
| | | #endregion |
| | | |
| | | 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[j]; |
| | | var doorlockfra = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(160), |
| | | Y = lockRow.Bottom + Application.GetRealHeight(20 + 160 * j), |
| | | }; |
| | | lockcolorfra1.AddChidren(doorlockfra); |
| | | |
| | | var doorlockRow = new RowLayout |
| | | { |
| | | Y = Application.GetRealHeight(30), |
| | | Width = Application.GetRealWidth(920), |
| | | Height = Application.GetRealHeight(130), |
| | | X = Application.GetRealWidth(80), |
| | | LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, |
| | | }; |
| | | doorlockfra.AddChidren(doorlockRow); |
| | | |
| | | var doorlockBtn = new Button |
| | | { |
| | | Width = Application.GetRealWidth(600), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, |
| | | }; |
| | | doorlockRow.AddChidren(doorlockBtn); |
| | | //(0按键/3卡/15指纹) |
| | | switch (userid.UnlockType) |
| | | { |
| | | case 0: |
| | | { |
| | | doorlockBtn.Text = Language.StringByID(MyInternationalizationString.lockpassword); |
| | | } |
| | | break; |
| | | case 3: |
| | | { |
| | | doorlockBtn.Text = Language.StringByID(MyInternationalizationString.ic); |
| | | } |
| | | break; |
| | | case 15: |
| | | { |
| | | doorlockBtn.Text = Language.StringByID(MyInternationalizationString.fingerprint); |
| | | } |
| | | break; |
| | | |
| | | } |
| | | |
| | | |
| | | var doorlockSelected = new Button |
| | | { |
| | | X = Application.GetRealWidth(860), |
| | | Width = Application.GetMinRealAverage(60), |
| | | Height = Application.GetMinRealAverage(60), |
| | | UnSelectedImagePath = "ZigeeLogic/selected.png", |
| | | Visible = false, |
| | | Gravity = Gravity.CenterVertical, |
| | | |
| | | }; |
| | | doorlockRow.AddChidren(doorlockSelected); |
| | | if ((uesrifonlist.Count - 1) == j) |
| | | { |
| | | doorlockRow.LineColor = ZigbeeColor.Current.LogicBackgroundColor; |
| | | } |
| | | EventHandler<MouseEventArgs> doorlockclick = (sender2, e2) => |
| | | { |
| | | 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; |
| | | ///显示之前的状态 |
| | | if (conditionsIndex != -1) |
| | | { |
| | | 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(() => { }); |
| | | }; |
| | | } |
| | | } |
| | | } |