黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs
@@ -4,28 +4,49 @@
using ZigBee.Device;
namespace Shared.Phone.UserCenter.DoorLock
{
    public class UndistributeDoorlockUserPage : DoorLockCommonLayout, ZigBee.Common.IStatus
    public class UndistributeDoorlockUserPage : DoorLockCommonLayout
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="doorLock"></param>
        public UndistributeDoorlockUserPage(ZigBee.Device.DoorLock doorLock, List<Shared.Phone.UserCenter.MemberInfoRes> localAccountList)
        public UndistributeDoorlockUserPage(ZigBee.Device.DoorLock doorLock, List<MemberInfoRes> localAccountList)
        {
            this.doorLock = doorLock;
            this.localAccountList = localAccountList;
            BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
        }
        #region ◆ 变量申明__________________________
        #region 变量申明
        /// <summary>
        /// 当前门锁
        /// </summary>
        ZigBee.Device.DoorLock doorLock;
        /// <summary>
        /// 底部白色布局
        /// </summary>
        FrameLayout bottomFrameLayout;
        /// <summary>
        /// 当前类型
        /// </summary>
        string currentType = string.Empty;
        List<Shared.Phone.UserCenter.MemberInfoRes> localAccountList;
        /// <summary>
        /// 本地账户列表
        /// </summary>
        List<MemberInfoRes> localAccountList;
        /// <summary>
        /// 滑动布局View
        /// </summary>
        VerticalRefreshLayout bodyView;
        /// <summary>
        /// 保存之前搜索到本地门锁用户列表
        /// </summary>
        Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj> oldLocalDoorLockUserList = new Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj>();
        #endregion
        /// <summary>
        /// 获取所有账户的门锁用户列表
        /// </summary>
        void ReadDoorLockUserInfo()
        {
            System.Threading.Tasks.Task.Run(async () =>
@@ -35,6 +56,7 @@
                    var list = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockAllAcountUserlist(doorLock);
                    if (oldLocalDoorLockUserList.Count != 0)
                    {
                        //如果本次没有搜索到,提示网关没有回复
                        if (list.Count == 0)
                        {
                            Application.RunOnMainThread(() =>
@@ -57,8 +79,8 @@
            });
        }
        /// <summary>
        /// UI显示
        /// <summary>
        /// UI显示
        /// </summary>
        public void Show()
        {
@@ -84,6 +106,9 @@
            }
        }
        /// <summary>
        /// 中部布局
        /// </summary>
        public void MidFrameLayoutContent()
        {
            var midTopFrameLayout = new FrameLayout()
@@ -100,8 +125,9 @@
                Y = Application.GetRealHeight(35),
                X = Application.GetRealWidth(812 - 100),
                TextAlignment = TextAlignment.CenterRight,
                TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextSize = 12,
                IsBold = true,
            };
            midTopFrameLayout.AddChidren(btnAllMethod);
            // 类型区分 
@@ -136,11 +162,12 @@
                SelectedImagePath = "DoorLock/UnLockSideslipIcon.png",
            };
            midTopFrameLayout.AddChidren(btnNext);
            btnNext.MouseUpEventHandler += (sender, e) =>
            EventHandler<MouseEventArgs> handerSideLip = (sender, e) =>
            {
                SideslipFramelayout();
            };
            btnNext.MouseUpEventHandler += handerSideLip;
            btnAllMethod.MouseUpEventHandler += handerSideLip;
            var btnLine = new Button
            {
                Y = midTopFrameLayout.Bottom,
@@ -162,6 +189,9 @@
            };
        }
        /// <summary>
        /// 刷新列表
        /// </summary>
        void RefreshList(int unlockMethod = -1)
        {
            this.midFrameLayout.RemoveAll();
@@ -172,7 +202,7 @@
            foreach (var curUserId in doorLock.localDoorLockUserList.Keys)
            {
                var curDoorLockUser = doorLock.localDoorLockUserList[curUserId];
                if (curDoorLockUser.ConnectedAccount != "")
                if (!string.IsNullOrEmpty(curDoorLockUser.ConnectedAccount))
                {
                    continue;
                }
@@ -243,6 +273,7 @@
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                    Gravity = Gravity.CenterVertical,
                    TextSize = 15,
                };
                rowFrameLayout.AddChidren(btnText);
@@ -265,7 +296,7 @@
                switch (curDoorLockUser.UnlockType)
                {
                    case 0:
                        if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                        if (!string.IsNullOrEmpty(curDoorLockUser.UserName))
                        {
                            btnText.Text = curDoorLockUser.UserName;
                        }
@@ -275,7 +306,7 @@
                        }
                        break;
                    case 3:
                        if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                        if (!string.IsNullOrEmpty(curDoorLockUser.UserName))
                        {
                            btnText.Text = curDoorLockUser.UserName;
                        }
@@ -285,7 +316,7 @@
                        }
                        break;
                    case 15:
                        if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                        if (!string.IsNullOrEmpty(curDoorLockUser.UserName))
                        {
                            btnText.Text = curDoorLockUser.UserName;
                        }
@@ -309,12 +340,14 @@
            }
        }
        //本地账户
        /// <summary>
        /// 分配本地账户
        /// </summary>
        void MatchUsersFrameLayout(ZigBee.Device.DoorLock.LocaDoorLockObj curDoorLockUser)
        {
            #region  UI
            FrameLayout flMain = new FrameLayout { BackgroundColor = 0x0f000000 };
            this.midFrameLayout.AddChidren(flMain);
            this.AddChidren(flMain);
            flMain.MouseUpEventHandler += (sender11, e11) =>
            {
                flMain.RemoveFromParent();
@@ -323,24 +356,24 @@
            bottomFrameLayout = new FrameLayout()
            {
                Height = Application.GetRealHeight(100),
                Y = Application.GetRealHeight(930),
                Radius = 17,
                Y = Application.GetRealHeight(1253),
                Radius = (uint)Application.GetRealHeight(100 / 2),
                BackgroundColor = ZigbeeColor.Current.XMWhite,
            };
            flMain.AddChidren(bottomFrameLayout);
            var bottomFrameLayout1 = new FrameLayout()
            {
                Height = Application.GetRealHeight(806 - 50),
                Y = Application.GetRealHeight(930 + 48),
                Height = Application.GetRealHeight(668 - 60),
                Y = Application.GetRealHeight(1253 + 58),
                BackgroundColor = ZigbeeColor.Current.XMWhite,
            };
            flMain.AddChidren(bottomFrameLayout1);
            var bottomFrameLayout2 = new FrameLayout()
            {
                Height = Application.GetRealHeight(806),
                Y = Application.GetRealHeight(930),
                Height = Application.GetRealHeight(668),
                Y = Application.GetRealHeight(1253),
            };
            flMain.AddChidren(bottomFrameLayout2);
@@ -368,7 +401,7 @@
                Y = Application.GetRealHeight(35),
                Height = Application.GetRealHeight(63),
                Width = Application.GetRealWidth(762),
                Text = Language.StringByID(R.MyInternationalizationString.MatchPerson),
                Text = Language.StringByID(R.MyInternationalizationString.MatchUser),
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextSize = 16,
                TextAlignment = TextAlignment.Center,
@@ -429,8 +462,8 @@
                var btnChoose = new Button()
                {
                    Width = Application.GetRealWidth(60),
                    Height = Application.GetRealHeight(60),
                    Width = Application.GetMinRealAverage(60),
                    Height = Application.GetMinRealAverage(60),
                    X = Application.GetRealWidth(861 + 81),
                    Y = Application.GetRealHeight(35),
                    SelectedImagePath = "DoorLock/SelectedIcon.png",
@@ -455,25 +488,19 @@
                    btnLine.Visible = false;
                }
                if (currentAccount.UserName != "" && currentAccount.UserName != null)
                {
                    btnUserName.Text = currentAccount.UserName;
                }
                else
                {
                    btnUserName.Text = currentAccount.Account;
                }
                btnUserName.Text = currentAccount.ShowName;
                EventHandler<MouseEventArgs> eHandler = (sender, e) =>
                {
                    if (doorLock.IsFreezeAccount[currentAccount.SubAccountDistributedMark] == true)
                    {
                        Application.RunOnMainThread(() =>
                        {
                            new Tip() { MaxWidth = 150, Text = btnUserName.Text + Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                        });
                        return;
                    }
                    //☆マーク☆
                    //if (doorLock.IsFreezeAccount[currentAccount.SubAccountDistributedMark] == true)
                    //{
                    //    Application.RunOnMainThread(() =>
                    //    {
                    //        new Tip() { MaxWidth = 150, Text = btnUserName.Text + Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                    //    });
                    //    return;
                    //}
                    if (!btnChoose.IsSelected)
                    {
@@ -493,7 +520,8 @@
                        oldbuttonChoose.IsSelected = true;
                        oldbuttonChoose.Visible = true;
                        oldUserName.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                        curAccountId = currentAccount.SubAccountDistributedMark;
                        //☆マーク☆
                        //curAccountId = currentAccount.SubAccountDistributedMark;
                    }
                };
                btnChoose.MouseUpEventHandler += eHandler;
@@ -519,20 +547,21 @@
                           CommonPage.Loading.Start("");
                       });
                       if (curAccountId == "")
                       {
                       {
                           Application.RunOnMainThread(() =>
                           {
                               flMain.RemoveFromParent();
                               bottomFrameLayout.RemoveAll();
                               CommonPage.Loading.Hide ();
                               CommonPage.Loading.Hide();
                           });
                       }
                       else
                       {
                           var addLockInfo = new ZigBee.Device.DoorLock.AddDoorLockData();
                           if (UserCenterResourse.UserInfo.AuthorityNo != 1)
                           if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 1)
                           {
                               addLockInfo.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
                               //☆マーク☆
                               //addLockInfo.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
                               addLockInfo.IsOtherAccountCtrl = true;
                           }
                           addLockInfo.CloudAccountId = curAccountId;
@@ -545,7 +574,7 @@
                           switch (curDoorLockUser.UnlockType)
                           {
                               case 0:
                                   if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                                   if (!string.IsNullOrEmpty(curDoorLockUser.UserName))
                                   {
                                       addLockInfo.UserIdRemarks = curDoorLockUser.UserName;
                                   }
@@ -555,7 +584,7 @@
                                   }
                                   break;
                               case 3:
                                   if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                                   if (!string.IsNullOrEmpty(curDoorLockUser.UserName))
                                   {
                                       addLockInfo.UserIdRemarks = curDoorLockUser.UserName;
                                   }
@@ -565,7 +594,7 @@
                                   }
                                   break;
                               case 15:
                                   if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                                   if (!string.IsNullOrEmpty(curDoorLockUser.UserName))
                                   {
                                       addLockInfo.UserIdRemarks = curDoorLockUser.UserName;
                                   }
@@ -579,7 +608,7 @@
                           var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/AddDoorLock", addLockInfo);
                           if (result != null)
                           {
                               if (result.StateCode == "Success")
                               if (result.Code == HttpMessageEnum.A成功)
                               {
                                   //存门锁信息
                                   var resultList = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetCloudLocalDoorLocklist(doorLock, curAccountId);
@@ -596,11 +625,12 @@
                                   {
                                       Application.RunOnMainThread(() =>
                                       {
                                           new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.DistributeSuccess), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                                           TypeRefresh();
                                           CommonPage.Loading.Hide();
                                           flMain.RemoveFromParent();
                                           bottomFrameLayout.RemoveAll();
                                       });
                                       });
                                   }
                                   else
                                   {
@@ -637,9 +667,12 @@
           };
        }
        // 侧边导航栏
        /// <summary>
        /// 侧边导航栏搜索
        /// </summary>
        void SideslipFramelayout()
        {
            #region sidelipFrameLayout UI
            var dialog = new Dialog
            {
            };
@@ -668,10 +701,13 @@
                Y = Application.GetRealHeight(28),
            };
            sidelipFrameLayout.AddChidren(sidelipVerticalScrolViewLayout);
            #endregion
            Button oldbutton = null;
            Button oldbuttonText = null;
            for (var i = 0; i < 4; i++)
            {
                #region rowFrameLayout UI
                var rowFrameLayout = new RowLayout()
                {
                    Height = Application.GetRealHeight(150),
@@ -684,7 +720,7 @@
                {
                    Width = Application.GetRealWidth(81),
                    Height = Application.GetRealHeight(81),
                    Y = Application.GetRealHeight(55),
                    Y = Application.GetRealHeight(35),
                };
                rowFrameLayout.AddChidren(btnAllMethod);
@@ -693,13 +729,15 @@
                    Width = Application.GetRealWidth(311),
                    Height = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(92),
                    Y = Application.GetRealHeight(69),
                    Y = Application.GetRealHeight(49),
                    TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                    TextSize = 14,
                    TextAlignment = TextAlignment.CenterLeft,
                };
                rowFrameLayout.AddChidren(btnMethodText);
                #endregion
                #region 数据处理
                EventHandler<MouseEventArgs> hander = (sender, e) =>
                {
                    if (!btnAllMethod.IsSelected)
@@ -717,6 +755,7 @@
                        doorLock.currentUserDisplayMethod = btnMethodText.Text;
                        btnAllMethod.IsSelected = true;
                        oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                        oldbuttonText.IsBold = true;
                        TypeRefresh();
                    }
                    dialog.Close();
@@ -724,70 +763,35 @@
                rowFrameLayout.MouseUpEventHandler += hander;
                btnAllMethod.MouseUpEventHandler += hander;
                btnMethodText.MouseUpEventHandler += hander;
                DisplayAllUnlockMethod(i, btnAllMethod, btnMethodText);
                switch (i)
                if (string.IsNullOrEmpty(doorLock.currentUserDisplayMethod) && i == 0)
                {
                    case 0:
                        btnAllMethod.UnSelectedImagePath = "DoorLock/AllMethod.png";
                        btnAllMethod.SelectedImagePath = "DoorLock/AllMethodOn.png";
                        btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.AllMethod);
                        break;
                    case 1:
                        btnAllMethod.UnSelectedImagePath = "DoorLock/Password.png";
                        btnAllMethod.SelectedImagePath = "DoorLock/PasswordOn.png";
                        btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.PasswordUnlock);
                        break;
                    case 2:
                        btnAllMethod.UnSelectedImagePath = "DoorLock/Fingerprint.png";
                        btnAllMethod.SelectedImagePath = "DoorLock/FingerprintOn.png";
                        btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.FingerprintUnlock);
                        break;
                    case 3:
                        btnAllMethod.UnSelectedImagePath = "DoorLock/proximityCard.png";
                        btnAllMethod.SelectedImagePath = "DoorLock/proximityCardOn.png";
                        btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock);
                        break;
                }
                if (doorLock.currentUserDisplayMethod == "" && i == 0)
                {
                    btnAllMethod.IsSelected = true;
                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    oldbutton = btnAllMethod;
                    oldbuttonText = btnMethodText;
                    CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText);
                }
                if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.AllMethod) && i == 0)
                {
                    btnAllMethod.IsSelected = true;
                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    oldbutton = btnAllMethod;
                    oldbuttonText = btnMethodText;
                    CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText);
                }
                if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.PasswordUnlock) && i == 1)
                {
                    btnAllMethod.IsSelected = true;
                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    oldbutton = btnAllMethod;
                    oldbuttonText = btnMethodText;
                    CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText);
                }
                if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FingerprintUnlock) && i == 2)
                {
                    btnAllMethod.IsSelected = true;
                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    oldbutton = btnAllMethod;
                    oldbuttonText = btnMethodText;
                    CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText);
                }
                if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock) && i == 3)
                {
                    btnAllMethod.IsSelected = true;
                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    oldbutton = btnAllMethod;
                    oldbuttonText = btnMethodText;
                    CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText);
                }
                #endregion
            }
        }
        //类型区分
        /// <summary>
        /// 类型区分
        /// </summary>
        void TypeRefresh()
        {
            if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.PasswordUnlock))
@@ -807,38 +811,5 @@
                RefreshList();
            }
        }
        #region ◆ 接口实现__________________________
        /// <summary>
        /// 处理变化事件 --将弃用 改用DeviceInfoChange()
        /// </summary>
        /// <returns>The changed.</returns>
        /// <param name="common">Common.</param>
        public void Changed(CommonDevice common)
        {
        }
        /// <summary>
        /// 处理变化事件
        /// </summary>
        /// <param name="common"></param>
        /// <param name="typeTag"></param>
        public void DeviceInfoChange(CommonDevice common, string typeTag)
        {
        }
        /// <summary>
        /// Changeds the IL ogic status.
        /// </summary>
        /// <param name="logic">Logic.</param>
        public void ChangedILogicStatus(ZigBee.Device.Logic logic)
        {
        }
        /// <summary>
        /// Changeds the IS cene status.
        /// </summary>
        /// <param name="scene">Scene.</param>
        public void ChangedISceneStatus(Scene scene)
        {
        }
        #endregion
    }
}