陈嘉乐
2020-05-28 f759dc1e6f49c53733eafda82207c85af18f9931
ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindTargetsPage.cs
@@ -55,7 +55,7 @@
        /// </summary>
        private System.Collections.Generic.List<CommonDevice> localDeviceList = new System.Collections.Generic.List<CommonDevice>();
        /// <summary>
        /// 本地场景列表
        /// 本地场景列表
        /// </summary>
        private System.Collections.Generic.List<SceneUI> scList = new System.Collections.Generic.List<SceneUI> { };
        /// <summary>
@@ -66,10 +66,6 @@
        /// 动态获取按键支持的模式大类型
        /// </summary>
        List<int> typeModeList;
        /// <summary>
        /// 网关中的场景列表
        /// </summary>
        public List<ScenesListInfo> gwScenesList = new List<ScenesListInfo>();
        /// <summary>
        /// 是否支持读取
        /// </summary>
@@ -95,21 +91,12 @@
                    }
                    //获取本地场景列表
                    scList = HdlSceneLogic.Current.GetAllRoomSceneList();
                    //获取网关场景表
                    if (gwScenesList.Count == 0)
                    {
                        var gwSceneObj = await currentKey.GetSceneInfoAsync();
                        if (gwSceneObj != null && gwSceneObj.getSceneInfo != null)
                        {
                            gwScenesList = gwSceneObj.getSceneInfo.ScenesList;
                        }
                    }
                    //动态获取按键支持的大类
                    typeModeList = await GetTypeMode();
                    #region 读取面板当前模式
                    //读取按键当前模式
                    var tempDeata = await currentKey.ReadPanelConfigureInfoAsync();
                    var tempDeata = HdlDeviceBindLogic.Current.ReadPanelConfigureInfoAsync(currentKey);
                    if (tempDeata != null && tempDeata.deviceStatusReportData != null)
                    {
                        foreach (var attr in tempDeata.deviceStatusReportData.AttriBute)
@@ -136,7 +123,7 @@
                            GetDeviceBindResponseAllData getBindList = null;
                            if (IsRead)
                            {
                                getBindList = await currentKey.GetDeviceBindAsync();
                                getBindList = HdlDeviceBindLogic.Current.GetDeviceBindAsync(currentKey);
                                var bindDeviceListTemp = new System.Collections.Generic.List<BindListResponseObj> { };
                                var bindSceneListTemp = new System.Collections.Generic.List<BindListResponseObj> { };
                                if (getBindList != null && getBindList.getAllBindResponseData != null)
@@ -206,7 +193,7 @@
                            }
                            currentKey.ReSave();
                        }
                        #endregion
                        #endregion
                        Application.RunOnMainThread(() =>
                        {
                            RefreshList();
@@ -246,7 +233,7 @@
            var btnAddFrameLayout = new FrameLayout()
            {
                X = Application.GetRealWidth(888),
                X = Application.GetRealWidth(772 - 58),
                Width = Application.GetRealWidth(192),
            };
            this.titleFrameLayout.AddChidren(btnAddFrameLayout);
@@ -254,8 +241,8 @@
            var btnBindAdd = new Button
            {
                X = Application.GetRealWidth(62),
                Height = Application.GetRealHeight(72),
                Width = Application.GetRealWidth(72),
                Height = Application.GetMinReal(72),
                Width = Application.GetMinReal(72),
                UnSelectedImagePath = "BindPic/BindAdd.png",
            };
            btnAddFrameLayout.AddChidren(btnBindAdd);
@@ -270,7 +257,7 @@
                    {
                        currentClusterID = 6;
                        currentKey.panelMode = 1;
                        var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey, gwScenesList);
                        var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey);
                        Shared.Phone.UserView.HomePage.Instance.AddChidren(addScenePage);
                        Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                        addScenePage.Show();
@@ -352,6 +339,7 @@
            InitListInfo();
        }
        /// <summary>
        /// 中部布局
        /// </summary>
@@ -359,6 +347,7 @@
        {
            midVerticalRefreshLayout = new VerticalFrameRefreshControl(29)
            {
                Height = this.midFrameLayout.Height + 1,
            };
            this.midFrameLayout.AddChidren(midVerticalRefreshLayout);
            midVerticalRefreshLayout.BeginHeaderRefreshingAction += () =>
@@ -403,13 +392,13 @@
        }
        /// <summary>
        /// 按键绑定表显示
        /// </summary>
        /// </summary>
        async void RefreshList()
        {
            midVerticalRefreshLayout.RemoveAll();
            this.midFrameLayout.RemoveAll();
            middleFrameLayout();
            #region 数据处理
            #region 数据处理
            if (currentKey.bindList.Count == 0)
            {
                entryStatusPic.Height = Application.GetRealHeight(556);
@@ -489,6 +478,10 @@
                            {
                                btnFloorRoomNameText = myName;
                            }
                            else
                            {
                                btnFloorRoomNameText = Language.StringByID(R.MyInternationalizationString.Undistributed);
                            }
                        }
                    }
                    else
@@ -511,11 +504,25 @@
                                    var tempDevFloorName = Common.Config.Instance.Home.GetFloorNameById(tempDevFloorId);
                                    if (string.IsNullOrEmpty(tempDevFloorName))
                                    {
                                        btnFloorRoomNameText = tempDevRoomName;
                                        if (string.IsNullOrEmpty(tempDevRoomName))
                                        {
                                            btnFloorRoomNameText = Language.StringByID(R.MyInternationalizationString.Undistributed);
                                        }
                                        else
                                        {
                                            btnFloorRoomNameText = tempDevRoomName;
                                        }
                                    }
                                    else
                                    {
                                        btnFloorRoomNameText = tempDevFloorName + "," + tempDevRoomName;
                                        if (string.IsNullOrEmpty(tempDevRoomName))
                                        {
                                            btnFloorRoomNameText = Language.StringByID(R.MyInternationalizationString.Undistributed);
                                        }
                                        else
                                        {
                                            btnFloorRoomNameText = tempDevFloorName + "," + tempDevRoomName;
                                        }
                                    }
                                }
@@ -627,7 +634,7 @@
                     try
                     {
                         CommonPage.Loading.Start("");
                         var bindResult = await currentKey.ClearBindInfoAsync();
                         var bindResult = HdlDeviceBindLogic.Current.ClearBindInfoAsync(currentKey);
                         if (bindResult != null && bindResult.clearBindInfoResponseData != null)
                         {
                             if (bindResult.clearBindInfoResponseData.Result != 0)
@@ -638,11 +645,11 @@
                             }
                             else
                             {
                                 var temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Default);
                                 if (temp.setWritableValueResponData?.Status != 0)
                                 var temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Default);
                                 if (temp != null && temp.setWritableValueResponData?.Status != 0)
                                 {
                                     var temp1 = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Default);
                                     if (temp1.setWritableValueResponData?.Status != 0)
                                     var temp1 = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Default);
                                     if (temp1 != null && temp1.setWritableValueResponData?.Status != 0)
                                     {
                                         new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ChangeBindMode), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel);
                                     }
@@ -671,7 +678,6 @@
                             currentKey.bindList.Clear();
                             RefreshList();
                             //如果是场景,用户删除清空当前到房间列表
                             currentKey.RoomId = "";
                             currentKey.ReSave();
                         }
                         CommonPage.Loading.Hide();
@@ -698,8 +704,8 @@
            var sidelipFrameLayout = new FrameLayout()
            {
                Height = Application.GetRealHeight(628),
                Width = Application.GetRealWidth(415),
                Height = Application.GetMinReal(628),
                Width = Application.GetMinReal(415),
                Y = Application.GetRealHeight(115 + 45),
                X = Application.GetRealWidth(605),
                BackgroundImagePath = "DoorLock/SideslipPic.png",
@@ -720,26 +726,34 @@
            if (typeModeList == null)
            {
                //再次动态获取按键支持的大类
                CommonPage.Loading.Start();
                Application.RunOnMainThread(() =>
                {
                    CommonPage.Loading.Start();
                });
                typeModeList = await GetTypeMode();
                if (typeModeList == null)
                {
                    Application.RunOnMainThread(() =>
                    {
                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                        CommonPage.Loading.Hide();
                    });
                    CommonPage.Loading.Hide();
                    dialog.Close();
                    return;
                }
                else
                {
                    CommonPage.Loading.Hide();
                    Application.RunOnMainThread(() =>
                    {
                        CommonPage.Loading.Hide();
                    });
                }
            }
            int count = 0;
            foreach (var value in typeModeList)
            {
                count++;
                #region  rowView
                var rowView = new FrameLayout()
                {
@@ -875,7 +889,7 @@
                                     var result = await RemoveTargets(bindSc, line2);
                                     if (result == 0)
                                     {
                                         var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey, gwScenesList);
                                         var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey);
                                         Shared.Phone.UserView.HomePage.Instance.AddChidren(addScenePage);
                                         Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                                         addScenePage.Show();
@@ -898,7 +912,7 @@
                        }
                        else
                        {
                            var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey, gwScenesList);
                            var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey);
                            Shared.Phone.UserView.HomePage.Instance.AddChidren(addScenePage);
                            Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                            addScenePage.Show();
@@ -1102,6 +1116,13 @@
        /// <returns></returns>
        private async System.Threading.Tasks.Task<List<int>> GetTypeMode()
        {
            //如果当前住宅是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                //则默认全部功能都给它
                typeModeList = new List<int>() { 1, 100, 200, 300, 0, 101, 102 };
                return typeModeList;
            }
            if (typeModeList != null)
            {
                typeModeList.Clear();
@@ -1157,7 +1178,7 @@
            {
                CommonPage.Loading.Start("");
                var delResult = new DelDeviceBindResponseAllData();
                delResult = await currentKey.DelDeviceBindAsync(delDevice);
                delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice);
                if (delResult != null && delResult.delDeviceBindResponseData != null)
                {
                    if (delResult.delDeviceBindResponseData?.RemoveBindList != null)
@@ -1174,7 +1195,6 @@
                                    {
                                        currentKey.panelMode = 65535;
                                    }
                                    currentKey.RoomId = "";
                                    currentKey.ReSave();
                                    return 0;
                                    break;
@@ -1184,7 +1204,7 @@
                                    {
                                        CommonPage.Loading.Start("");
                                        var getBindList = await currentKey.GetDeviceBindAsync();
                                        var getBindList = HdlDeviceBindLogic.Current.GetDeviceBindAsync(currentKey);
                                        var bindDeviceListTemp = new System.Collections.Generic.List<BindListResponseObj> { };
                                        var bindSceneListTemp = new System.Collections.Generic.List<BindListResponseObj> { };
                                        if (getBindList != null)
@@ -1280,3 +1300,4 @@
        }
    }
}