gxc
2020-01-02 00ab3ddb140ba8bb88b5cf572b004a85e1da85e9
ZigbeeApp/Shared/Phone/Device/Logic/MemberList.cs
@@ -15,12 +15,13 @@
        }
        Button selectedIcon = new Button();
        public static bool edit = false;
        VerticalScrolViewLayout middle;
        public async void Show(CommonDevice common, Dictionary<string, string> editdeviceConditionsInfo = null)
        VerticalRefreshLayout middle;
        CommonDevice common;
        Dictionary<string, string> editdeviceConditionsInfo;
        public void Show(CommonDevice commondevice, Dictionary<string, string> editdeviceConditions = null)
        {
            common = commondevice;
            editdeviceConditionsInfo = editdeviceConditions;
            UserView.HomePage.Instance.ScrollEnabled = false;
            this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
            #region  最上面的布局代码
@@ -42,6 +43,7 @@
                Height = Application.GetRealHeight(69),
                Y = Application.GetRealHeight(92),
                TextID = MyInternationalizationString.userlist,
                IsBold = true,
            };
            topRowLayout.AddChidren(titleName);
@@ -73,14 +75,37 @@
            };
            #endregion
            middle = new VerticalScrolViewLayout
            middle = new VerticalRefreshLayout
            {
                Y = topRowLayout.Bottom,
                Height = Application.GetRealHeight(1920 - 184),
                BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
            };
            this.AddChidren(middle);
            middle.BeginHeaderRefreshingAction += () =>
            {
                //重新刷新logic列表
                string macport = common.DeviceAddr + "_" + common.DeviceEpoint.ToString();
                for (int i = 0; i < Send.LockList.Count; i++)
                {
                    if (Send.LockList[i].DoorLockMacPort == macport)
                    {
                        ///从列表移除当前门锁全部的旧数据;
                        Send.LockList.Remove(Send.LockList[i]);
                        i--;
                    }
                }
                Read();
                //关闭刷新View;
                middle.EndHeaderRefreshing();
            };
            Read();
        }
        /// <summary>
        /// 读取当前门锁的云端数据;
        /// </summary>
        public void Read()
        {
            bool d = false;
            string macport = common.DeviceAddr + "_" + common.DeviceEpoint.ToString();
@@ -94,22 +119,36 @@
                }
            }
            CommonPage.Loading.Start();
            if (!d)
            {
                var allMemberslist = await Send.AllMembers(common.DeviceAddr);
                Send.LockList.AddRange(allMemberslist);
            }
            UserList(macport, common, editdeviceConditionsInfo);
            CommonPage.Loading.Hide();
            middle.RemoveAll();
            System.Threading.Tasks.Task.Run(async () =>
           {
               try
               {
                   if (!d)
                   {
                       var allMemberslist = await Send.AllMembers(macport);
                       Send.LockList.AddRange(allMemberslist);
                   }
               }
               catch { }
               finally
               {
                   Application.RunOnMainThread(() =>
                   {
                       CommonPage.Loading.Hide();
                       UserList(macport);
                   });
               }
           });
        }
        /// <summary>
        /// 成员列表的方法
        /// </summary>
        /// <param name="macport"></param>
        void UserList(string macport, CommonDevice common, Dictionary<string, string> editdeviceConditionsInfo)
        public void UserList(string macport)
        {
            foreach (var user in Send.LockList)
            {
                if (user.DoorLockMacPort != macport)
@@ -156,7 +195,7 @@
                EventHandler<MouseEventArgs> useridclick = (sender, e) =>
                {
                    User(user, common, editdeviceConditionsInfo);
                    User(user);
                };
                userBtn.MouseUpEventHandler += useridclick;
@@ -167,12 +206,12 @@
            }
        }
        }
        /// <summary>
        /// 当前成员信息的方法
        /// </summary>
        /// <param name="user"></param>
        void User(Send.MembershipIfon user, CommonDevice common, Dictionary<string, string> editdeviceConditionsInfo)
        public void User(Send.MembershipIfon user)
        {
            var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
            this.AddChidren(flMain);
@@ -257,6 +296,13 @@
            string SelectedDeviceStatuscondition = "";
            lockcolorfra1.Y = Application.GetRealHeight(1920 - 140 - (160 * user.UserIdMode.Count) - 20 - 50);
            lockcolorfra1.Height = Application.GetRealHeight(140 + (160 * user.UserIdMode.Count) + 20 + 50);
            if (user.UserIdMode.Count > 10)
            {
                ///元素超出10个,暂时默认显示10;
                lockcolorfra1.Y = Application.GetRealHeight(1920 - 140 - (160 * 10) - 20 - 50);
                lockcolorfra1.Height = Application.GetRealHeight(140 + (160 * 10) + 20 + 50);
            }
            for (int i = 0; i < user.UserIdMode.Count; i++)
            {
                var userifon = user.UserIdMode[i];
@@ -404,9 +450,9 @@
                {
                    if (!edit)
                    {
                        var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
                                               Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
                                               Language.StringByID(MyInternationalizationString.complete));
                        var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
                         Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
                         Language.StringByID(MyInternationalizationString.confrim));
                        alert.Show();
                        return;
                    }