HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
@@ -14,19 +14,15 @@
        /// <summary>
        /// 桌布控件
        /// </summary>
        private FrameLayout frameTable = null;
        private NormalFrameLayout frameTable = null;
        /// <summary>
        /// 列表控件
        /// 列表控件(白色背景)
        /// </summary>
        private VerticalListControl listView = null;
        private FrameListControl listView = null;
        /// <summary>
        /// 楼层顺序
        /// 整个界面的上下滑动控件
        /// </summary>
        private List<string> listFloorSort = new List<string>();
        /// <summary>
        /// 房间顺序
        /// </summary>
        private List<string> listRoomSort = new List<string>();
        private VerticalFrameControl listBackContr = null;
        /// <summary>
        /// 当前APP的住宅模式 0:还没有设置有模式 1:楼层模式 2:没有楼层模式
        /// </summary>
@@ -48,8 +44,12 @@
            //主人或者管理员才会出现这个菜单
            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
            {
                //初始化右上角菜单
                this.InitTopRightMenu();
                //查看模板时,不允许编辑
                if (Common.Config.Instance.Home.IsShowTemplate == false)
                {
                    //初始化右上角菜单
                    this.InitTopRightMenu();
                }
            }
            //初始化中部信息
            this.InitMiddleFrame(i_CanDeleteResidence);
@@ -64,10 +64,16 @@
            //清空bodyFrame
            this.ClearBodyFrame();
            //整个界面的上下滑动控件
            this.listBackContr = new VerticalFrameControl();
            listBackContr.Height = bodyFrameLayout.Height;
            bodyFrameLayout.AddChidren(listBackContr);
            //住宅行
            var rowHome = new RowLayoutControl();
            rowHome.Height = Application.GetRealHeight(173);
            rowHome.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(rowHome);
            listBackContr.frameTable.AddChidren(rowHome);
            rowHome.frameTable.UseClickStatu = false;
            var btnAdreeIcon = rowHome.frameTable.AddLeftIcon(81);
@@ -77,13 +83,13 @@
            var btnHomeName = rowHome.frameTable.AddLeftCaption(Common.Config.Instance.Home.Name, 700, 60);
            btnHomeName.TextSize = 15;
            btnHomeName.Y = Application.GetRealHeight(35);
            rowHome.frameTable.AddChidren(btnHomeName, ChidrenBindMode.BindEventOnly);
            rowHome.frameTable.AddChidren(btnHomeName, ChidrenBindMode.BindEvent);
            //当前住宅
            var btnNowView = rowHome.frameTable.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uNowResidence), 700, 49);
            btnNowView.TextSize = 12;
            btnNowView.Y = Application.GetRealHeight(95);
            btnNowView.TextColor = UserCenterColor.Current.TextGrayColor1;
            rowHome.frameTable.AddChidren(btnNowView, ChidrenBindMode.BindEventOnly);
            rowHome.frameTable.AddChidren(btnNowView, ChidrenBindMode.BindEvent);
            //主人或者管理员才会出现这个菜单
            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
            {
@@ -92,30 +98,27 @@
            }
            //经纬度
            var btnLocation = rowHome.frameTable.AddMostRightView(string.Empty, 500);
            btnLocation.Text = this.GetLatitudeAndLongitudeText(Common.Config.Instance.Home.Longitude, Common.Config.Instance.Home.Latitude);
            btnLocation.IsMoreLines = true;
            btnLocation.TextSize = 10;
            btnLocation.Text = Common.Config.Instance.Home.ResidenceAddressName;
            //主人或者管理员才会出现这个菜单
            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
            {
                rowHome.frameTable.UseClickStatu = true;
                //查看模板时,不允许编辑
                if (Common.Config.Instance.Home.IsShowTemplate == true)
                {
                    rowHome.frameTable.CanClick = false;
                }
                rowHome.frameTable.ButtonClickEvent += (sender, e) =>
                {
                    //默认值 23.134421,113.267189
                    double latitude = Common.Config.Instance.Home.Latitude;
                    double longitude = Common.Config.Instance.Home.Longitude;
                    //地图
                    GDMapKit.Show((mLatitude, mLongitude, mRadius, name) =>
                    {
                        HdlThreadLogic.Current.RunThread(() =>
                        {
                            //保存住宅地址
                            this.SaveResidenceAdrress(btnLocation, mLatitude, mLongitude);
                        });
                    }, Language.StringByID(R.MyInternationalizationString.uSelectAdrress), true, latitude, longitude, 100);
                    //检测权限,然后显示地图
                    this.CheckAuthorityAndShowMap(btnLocation);
                };
            }
            if (i_CanDeleteResidence == true)
            if (i_CanDeleteResidence == true && Common.Config.Instance.Home.IsShowTemplate == false)
            {
                //删除
                var btnDelete = new NormalViewControl(Application.GetRealWidth(184), rowHome.Height, false);
@@ -139,10 +142,10 @@
                };
            }
            //初始化桌布
            this.frameTable = new FrameLayout();
            this.frameTable = new NormalFrameLayout();
            frameTable.Y = rowHome.Bottom + Application.GetRealHeight(23);
            frameTable.Height = bodyFrameLayout.Height - rowHome.Bottom - Application.GetRealHeight(23);
            bodyFrameLayout.AddChidren(frameTable);
            frameTable.Height = listBackContr.frameTable.Height - rowHome.Bottom - Application.GetRealHeight(23);
            listBackContr.frameTable.AddChidren(frameTable);
            //根据指定模式,初始化桌布控件
            this.InitFrameTableByMode();
@@ -241,7 +244,7 @@
            frameFloor.UseClickStatu = false;
            frameFloor.Height = Application.GetRealHeight(115);
            frameFloor.BackgroundColor = UserCenterColor.Current.White;
            frameTable.AddChidren(frameFloor);
            this.frameTable.AddChidren(frameFloor);
            //楼层
            var btnFloor = frameFloor.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uFloor), 200, 60);
@@ -250,11 +253,11 @@
            btnFloor.TextSize = 15;
            frameFloor.AddChidren(btnFloor, ChidrenBindMode.NotBind);
            listView = new VerticalListControl(29);
            listView = new FrameListControl(29);
            listView.BackgroundColor = UserCenterColor.Current.White;
            listView.Y = frameFloor.Bottom;
            listView.Height = frameTable.Height - frameFloor.Bottom;
            frameTable.AddChidren(listView);
            this.frameTable.AddChidren(listView);
            //初始化楼层行
            this.InitFloorRow();
@@ -267,26 +270,20 @@
        {
            //获取楼层
            var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
            this.listFloorSort.Clear();
            foreach (string keys in dicFloor.Keys)
            {
                listFloorSort.Add(keys);
            }
            if (Common.Config.Instance.Home.FloorDics.Count == 0)
            if (dicFloor.Count == 0)
            {
                return;
            }
            HdlThreadLogic.Current.RunMainInThread(() =>
            {
                int count = listFloorSort.Count - 1;
                for (int i = 0; i < listFloorSort.Count; i++)
                int count = dicFloor.Count;
                foreach (var keys in dicFloor.Keys)
                {
                    string keys = listFloorSort[i];
                    this.AddFloorRow(keys, dicFloor[keys], i != count);
                    count--;
                    this.AddFloorRow(keys, dicFloor[keys], count != 0);
                }
                //调整控件高度
                listView.AdjustRealHeight(Application.GetRealHeight(23));
                this.AdjustContrlTableHeight();
            });
        }
@@ -303,6 +300,7 @@
        private void AddFloorRow(string keys, string floorName, bool addLine)
        {
            var frameRow = new RowLayoutControl(listView.rowSpace / 2);
            frameRow.MainKeys = keys;
            this.listView.AddChidren(frameRow);
            //图标
            var btnIcon = frameRow.frameTable.AddLeftIcon(81);
@@ -324,14 +322,14 @@
            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
            {
                //查看模板时,不允许编辑
                if (Common.Config.Instance.Home.IsShowTemplate == true)
                {
                    return;
                }
                //更改
                var btnChanged = new NormalViewControl(Application.GetRealWidth(184), frameRow.Height, false);
                btnChanged.BackgroundColor = 0xff4a4a4a;
                btnChanged.TextSize = 12;
                btnChanged.TextColor = UserCenterColor.Current.White;
                btnChanged.TextAlignment = TextAlignment.Center;
                var btnChanged = frameRow.AddEditorControl();
                btnChanged.TextID = R.MyInternationalizationString.uChanged1;
                frameRow.AddRightView(btnChanged);
                btnChanged.ButtonClickEvent += (sender, e) =>
                {
                    //创建或者编辑楼层
@@ -355,15 +353,18 @@
                        Common.Config.Instance.Home.FloorDics.Remove(keys);
                        if (Common.Config.Instance.Home.CurrentFloorId == keys)
                        {
                            //如果删除的是当前楼层的话
                            Common.Config.Instance.Home.CurrentFloorId = string.Empty;
                            foreach (string floorId in Common.Config.Instance.Home.FloorDics.Keys)
                            var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
                            foreach (var floorId in dicFloor.Keys)
                            {
                                //把第一个楼层ID给它
                                //把第一个楼层赋值给当前楼层
                                Common.Config.Instance.Home.CurrentFloorId = floorId;
                                break;
                            }
                            //删除当前楼层的话,需要去刷新主页左边的房间列表
                            HdlRoomLogic.Current.RefreshRoomListView();
                        }
                        var uploadRoom = false;
                        var listDeleteId = new List<string>();
                        var listAllRoom = HdlRoomLogic.Current.GetAllListRooms();
                        for (int i = 0; i < listAllRoom.Count; i++)
@@ -372,11 +373,11 @@
                            {
                                listDeleteId.Add(listAllRoom[i].Id);
                            }
                        }
                        //如果当前选择的房间是删除对象的话
                        if (HdlRoomLogic.Current.CurrentRoom.FloorId == keys)
                        {
                            HdlRoomLogic.Current.CurrentRoom = HdlRoomLogic.Current.GetLoveRoom();
                            if (listAllRoom[i].ListDevice.Count > 0)
                            {
                                //需要上传空间区域
                                uploadRoom = true;
                            }
                        }
                        //删除房间
                        foreach (string roomId in listDeleteId)
@@ -384,9 +385,6 @@
                            HdlRoomLogic.Current.RemoveRoom(roomId);
                        }
                        Common.Config.Instance.Home.Save();
                        //保存顺序
                        listFloorSort.Remove(keys);
                        HdlRoomLogic.Current.SaveFloorSort(listFloorSort);
                        if (Common.Config.Instance.Home.FloorDics.Count == 0)
                        {
@@ -395,9 +393,32 @@
                        }
                        else
                        {
                            bool canMove = false;
                            for (int i = 0; i < listView.ChildrenCount; i++)
                            {
                                var myRow = listView.GetChildren(i) as RowLayoutControl;
                                if (myRow != null && myRow.MainKeys == keys)
                                {
                                    canMove = true;
                                    continue;
                                }
                                if (canMove == true)
                                {
                                    //它之后的行,全部往上移
                                    myRow.Y -= frameRow.Height;
                                }
                            }
                            frameRow.RemoveFromParent();
                            listView.AdjustRealHeight(Application.GetRealHeight(23));
                            //调整桌布高度
                            this.AdjustContrlTableHeight();
                        }
                        if (uploadRoom == true)
                        {
                            //上传空间区域信息
                            HdlRoomLogic.Current.SetRoomInfoToGateway();
                        }
                        //删除楼层的话,主页需要重新刷新
                        UserView.UserPage.Instance.RefreshAllForm = true;
                    });
                };
            }
@@ -434,6 +455,9 @@
            //按下确认按钮
            dialogForm.ComfirmClickEvent += ((textValue) =>
            {
                //还原左右菜单
                frameRow?.HideMenu();
                if (this.CheckFloorName(keys, textValue) == false)
                {
                    //楼层名称检测
@@ -441,8 +465,6 @@
                }
                //画面关闭
                dialogForm.CloseDialog();
                //还原左右菜单
                frameRow?.HideMenu();
                if (floorName != textValue)
                {
                    //编辑或者创建楼层名称
@@ -450,12 +472,15 @@
                    {
                        keys = Guid.NewGuid().ToString();
                    }
                    bool hadFloor = Common.Config.Instance.Home.CurrentFloorId != string.Empty;
                    Common.Config.Instance.Home.FloorDics[keys] = textValue;
                    Common.Config.Instance.Home.Save();
                    if (Common.Config.Instance.Home.CurrentFloorId == string.Empty)
                    if (hadFloor == false)
                    {
                        Common.Config.Instance.Home.CurrentFloorId = keys;
                        //创建第一个新的楼层的话,需要去刷新主页左边的房间列表
                        HdlRoomLogic.Current.RefreshRoomListView();
                    }
                    if (btnFloor != null)
                    {
                        btnFloor.Text = textValue;
@@ -465,6 +490,8 @@
                        //根据指定模式,初始化桌布控件
                        this.InitFrameTableByMode();
                    }
                    //创建或者修改楼层的话,主页需要重新刷新
                    UserView.UserPage.Instance.RefreshAllForm = true;
                }
            });
        }
@@ -492,7 +519,7 @@
            btnRoomList.TextSize = 15;
            frameRoom.AddChidren(btnRoomList, ChidrenBindMode.NotBind);
            listView = new VerticalListControl(29);
            listView = new FrameListControl(29);
            listView.BackgroundColor = UserCenterColor.Current.White;
            listView.Y = frameRoom.Bottom;
            listView.Height = frameTable.Height - frameRoom.Bottom;
@@ -509,19 +536,13 @@
        {
            //获取楼层的房间
            var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(string.Empty);
            this.listRoomSort.Clear();
            for (int i = 0; i < listRoom.Count; i++)
            {
                this.listRoomSort.Add(listRoom[i].Id);
            }
            for (int i = 0; i < listRoom.Count; i++)
            {
                //添加房间行
                this.AddRoomRow(listRoom[i], i != listRoom.Count - 1);
            }
            //调整控件真实高度
            listView.AdjustRealHeight(Application.GetRealHeight(23));
            //调整桌布高度
            this.AdjustContrlTableHeight();
        }
        #endregion
@@ -536,6 +557,7 @@
        private void AddRoomRow(Common.Room room, bool addLine)
        {
            var frameRow = new RowLayoutControl(listView.rowSpace / 2);
            frameRow.MainKeys = room.Id;
            listView.AddChidren(frameRow);
            //图标
            var btnIcon = frameRow.frameTable.AddLeftIcon(81);
@@ -561,13 +583,10 @@
                //如果是分享的房间,不能编辑和修改
                return;
            }
            //编辑
            var btnEditor = frameRow.AddEditorControl();
            btnEditor.ButtonClickEvent += (sender, e) =>
            {
                //关闭左右菜单
                frameRow.HideMenu();
                var form = new EditorRoomInforForm();
                form.AddForm(room);
                form.FinishEditorEvent += (roomName) =>
@@ -575,7 +594,12 @@
                    btnName.Text = roomName;
                };
            };
            //查看模板时,不允许编辑
            if (Common.Config.Instance.Home.IsShowTemplate == true)
            {
                btnEditor.Text = Language.StringByID(R.MyInternationalizationString.uSearch1);
                return;
            }
            //删除
            var btnDelete = frameRow.AddDeleteControl();
            btnDelete.ButtonClickEvent += (sender, e) =>
@@ -583,15 +607,7 @@
                //确认删除房间?
                this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteRoomMsg), () =>
                {
                    if (HdlRoomLogic.Current.CurrentRoom.Id == room.Id)
                    {
                        //如果删除的是当前房间的话
                        HdlRoomLogic.Current.CurrentRoom = HdlRoomLogic.Current.GetLoveRoom();
                    }
                    HdlRoomLogic.Current.RemoveRoom(room.Id);
                    //保存顺序
                    this.listRoomSort.Remove(room.Id);
                    HdlRoomLogic.Current.SaveRoomSort(string.Empty, this.listRoomSort);
                    var listAllRoom = HdlRoomLogic.Current.GetAllListRooms();
                    if (listAllRoom.Count <= 1)
@@ -601,9 +617,32 @@
                    }
                    else
                    {
                        bool canMove = false;
                        for (int i = 0; i < listView.ChildrenCount; i++)
                        {
                            var myRow = listView.GetChildren(i) as RowLayoutControl;
                            if (myRow != null && myRow.MainKeys == room.Id)
                            {
                                canMove = true;
                                continue;
                            }
                            if (canMove == true)
                            {
                                //它之后的行,全部往上移
                                myRow.Y -= frameRow.Height;
                            }
                        }
                        frameRow.RemoveFromParent();
                        listView.AdjustRealHeight(Application.GetRealHeight(23));
                        //调整桌布高度
                        this.AdjustContrlTableHeight();
                    }
                    if (room.ListDevice.Count > 0)
                    {
                        //上传空间区域信息
                        HdlRoomLogic.Current.SetRoomInfoToGateway();
                    }
                    //删除房间的话,主页需要重新刷新
                    UserView.UserPage.Instance.RefreshAllForm = true;
                });
            };
        }
@@ -615,21 +654,41 @@
        /// <summary>
        /// 删除住宅
        /// </summary>
        public async void DeleteResidence()
        private void DeleteResidence()
        {
            //开启进度条
            this.ShowProgressBar();
            var Pra = new DeleteResidencePra();
            Pra.HomeId = Common.Config.Instance.Home.Id;
            Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
            bool result = await UserCenterLogic.GetResultStatuByRequestHttps("App/DelHome", true, Pra);
            if (result == false)
            if (Common.Config.Instance.Home.IsOthreShare == false)
            {
                //关闭进度条
                this.CloseProgressBar();
                return;
                //删除主人自己的住宅
                var Pra = new DeleteResidencePra();
                Pra.HomeId = Common.Config.Instance.Home.Id;
                Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
                bool result = UserCenterLogic.GetResultStatuByRequestHttps("App/DelHome", true, Pra);
                if (result == false)
                {
                    //关闭进度条
                    this.CloseProgressBar();
                    return;
                }
            }
            else
            {
                //删除分享的住宅
                var Pra2 = new
                {
                    HomeId = Common.Config.Instance.Home.Id,
                    PrimaryUserId = Common.Config.Instance.Home.MainUserDistributedMark
                };
                bool result = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/SubAccountDelShareHome", false, Pra2);
                if (result == false)
                {
                    //关闭进度条
                    this.CloseProgressBar();
                    return;
                }
            }
            //因为删除的是当前的住宅,所以需要先切换到别的住宅
@@ -655,24 +714,89 @@
                }
            }
            var myHouse = Common.House.GetHouseByFilePath(Common.Config.Instance.HomeFilePathList[index]);
            var myHouse = HdlResidenceLogic.Current.GetHouseByFilePath(Common.Config.Instance.HomeFilePathList[index]);
            //切换住宅
            Common.Config.Instance.HomeId = myHouse.Id;
            Common.Config.Instance.Home = myHouse;
            Common.Global.CreateHomeDirectory(myHouse.Id);
            Common.Config.Instance.Save();
            //刷新个人中心的内存及线程
            await UserCenterLogic.InitUserCenterMenmoryAndThread(false);
            HdlRoomLogic.Current.InitAllRoom();
            bool result2 = UserCenterLogic.InitUserCenterMenmoryAndThread(false);
            if (result2 == false)
            {
                //开启了调试功能
                return;
            }
            //删除住宅
            Common.House.DeleteHouseByHouseId(deleteId);
            HdlResidenceLogic.Current.DeleteHouseMemmory(deleteId);
            Application.RunOnMainThread(() =>
            HdlThreadLogic.Current.RunMain(() =>
            {
                //关闭界面
                this.CloseForm();
            });
        }
        #endregion
        #region ■ 显示地图___________________________
        /// <summary>
        /// 检测权限,然后显示地图
        /// </summary>
        /// <param name="btnLocation">地址显示控件</param>
        private void CheckAuthorityAndShowMap(NormalViewControl btnLocation)
        {
#if Android
            //申请定位权限
            ((BaseActivity)Application.Activity).SetGPSLocationPermission((result1) =>
            {
                if (result1 == false) { return; }
                //申请允许程序写入外部存储,如SD卡上写文件
                ((BaseActivity)Application.Activity).SetPermission((result2) =>
                {
                    if (result2 == false) { return; }
                     //读取电话状态权限
                     ((BaseActivity)Application.Activity).SetPermission((result3) =>
                     {
                         if (result3 == false) { return; }
                         //显示地图
                         this.ShowMap(btnLocation);
                     }, "android.permission.READ_PHONE_STATE");
                }, "android.permission.WRITE_EXTERNAL_STORAGE");
            });
#endif
#if iOS
            //显示地图
            this.ShowMap(btnLocation);
#endif
        }
        /// <summary>
        /// 显示地图
        /// </summary>
        /// <param name="btnLocation">地址显示控件</param>
        private void ShowMap(NormalViewControl btnLocation)
        {
            //默认值 23.134421,113.267189
            double latitude = Common.Config.Instance.Home.Latitude;
            double longitude = Common.Config.Instance.Home.Longitude;
            //地图
            GDMapKit.Show((mLatitude, mLongitude, mRadius, name) =>
            {
                HdlThreadLogic.Current.RunThread(() =>
                {
                    //保存住宅地址
                    this.SaveResidenceAdrress(btnLocation, mLatitude, mLongitude, name);
                });
            },
            Language.StringByID(R.MyInternationalizationString.uSelectAdrress),
            Language.StringByID(R.MyInternationalizationString.uSave),
            true, latitude, longitude, 100);
        }
        #endregion
@@ -685,54 +809,60 @@
        /// <param name="btnLocation">显示控件</param>
        /// <param name="latitude">纬度</param>
        /// <param name="longitude">经度</param>
        private async void SaveResidenceAdrress(NormalViewControl btnLocation, double latitude, double longitude)
        /// <param name="addresName">位置名称</param>
        private void SaveResidenceAdrress(NormalViewControl btnLocation, double latitude, double longitude, string addresName)
        {
            //开启进度条
            this.ShowProgressBar();
            var Pra = new EditorResidencePra();
            Pra.HomeId = Common.Config.Instance.Home.Id;
            Pra.Name = Common.Config.Instance.Home.Name;
            Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
            Pra.Latitude = latitude;
            Pra.Longitude = longitude;
            //编辑住宅
            bool flage = await UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", true, Pra);
            if (flage == false)
            //如果不是虚拟住宅,才更新云端
            if (Common.Config.Instance.Home.IsVirtually == false)
            {
                //关闭进度条
                this.CloseProgressBar();
                return;
            }
            //设置全部网关的住宅地址
            var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
            foreach (var gateway in listGateway)
            {
                ZigBee.Device.ZbGateway realWay = null;
                if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, gateway) == false)
                {
                    //错误:网关对象丢失
                    continue;
                }
                var result = HdlGatewayLogic.Current.SetGatewaySite(gateway, longitude, latitude, ShowErrorMode.YES);
                if (result == false)
                //开启进度条
                this.ShowProgressBar();
                var Pra = new EditorResidencePra();
                Pra.HomeId = Common.Config.Instance.Home.Id;
                Pra.Name = Common.Config.Instance.Home.Name;
                Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
                Pra.Latitude = latitude;
                Pra.Longitude = longitude;
                //编辑住宅
                bool flage = UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", true, Pra);
                if (flage == false)
                {
                    //关闭进度条
                    this.CloseProgressBar();
                    return;
                }
                //设置全部网关的住宅地址
                var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
                foreach (var gateway in listGateway)
                {
                    ZigBee.Device.ZbGateway realWay = null;
                    if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, gateway) == false)
                    {
                        //错误:网关对象丢失
                        continue;
                    }
                    var result = HdlGatewayLogic.Current.SetGatewaySite(gateway, longitude, latitude, ShowErrorMode.YES);
                    if (result == false)
                    {
                        //关闭进度条
                        this.CloseProgressBar();
                        return;
                    }
                }
                //关闭进度条
                this.CloseProgressBar();
            }
            //关闭进度条
            this.CloseProgressBar();
            //保存缓存
            Common.Config.Instance.Home.Longitude = longitude;
            Common.Config.Instance.Home.Latitude = latitude;
            Common.Config.Instance.Home.ResidenceAddressName = addresName;
            Common.Config.Instance.Home.Save();
            HdlThreadLogic.Current.RunMain(() =>
            {
                btnLocation.Text = this.GetLatitudeAndLongitudeText(longitude, latitude);
                btnLocation.Text = addresName;
            });
        }
@@ -773,7 +903,7 @@
            {
                //请输入住宅名称
                string msg = Language.StringByID(R.MyInternationalizationString.uPleaseInputFloorName);
                this.ShowMassage(ShowMsgType.Error, msg);
                this.ShowMassage(ShowMsgType.Tip, msg);
                return false;
            }
            foreach (string floorKeys in Common.Config.Instance.Home.FloorDics.Keys)
@@ -782,7 +912,7 @@
                {
                    //楼层名称已经存在
                    string msg = Language.StringByID(R.MyInternationalizationString.uFloorNameIsExist);
                    this.ShowMassage(ShowMsgType.Error, msg);
                    this.ShowMassage(ShowMsgType.Tip, msg);
                    return false;
                }
            }
@@ -790,47 +920,14 @@
        }
        /// <summary>
        /// 获取经纬度的翻译名字
        /// 调整控件桌布高度
        /// </summary>
        /// <param name="Longitude">经度</param>
        /// <param name="Latitude">纬度</param>
        /// <returns></returns>
        private string GetLatitudeAndLongitudeText(double Longitude, double Latitude)
        private void AdjustContrlTableHeight()
        {
            string value1 = string.Empty;
            string value2 = string.Empty;
            if (Longitude == 0)
            {
                //默认东经
                value1 = "0°00'E";
            }
            else if (Longitude > 0)
            {
                //东经
                value1 = Math.Round(Longitude, 2).ToString().Replace(".", "°") + "'E";
            }
            else if (Longitude < 0)
            {
                //西经
                value1 = Math.Round(-Longitude, 2).ToString().Replace(".", "°") + "'W";
            }
            if (Latitude == 0)
            {
                //默认北纬
                value2 = "0°00'N";
            }
            else if (Latitude > 0)
            {
                //北纬
                value2 = Math.Round(Latitude, 2).ToString().Replace(".", "°") + "'N";
            }
            else if (Latitude < 0)
            {
                //南纬
                value2 = Math.Round(-Latitude, 2).ToString().Replace(".", "°") + "'S";
            }
            return value1 + " " + value2;
            //调整桌布高度
            listView.AdjustRealHeight(Application.GetRealHeight(23));
            this.frameTable.Height = listView.Bottom;
            this.listBackContr.AdjustTableHeight();
        }
        #endregion