HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
@@ -44,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);
@@ -102,27 +106,19 @@
            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, name);
                        });
                    },
                    Language.StringByID(R.MyInternationalizationString.uSelectAdrress),
                    Language.StringByID(R.MyInternationalizationString.uSave),
                    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);
@@ -326,6 +322,11 @@
            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
            {
                //查看模板时,不允许编辑
                if (Common.Config.Instance.Home.IsShowTemplate == true)
                {
                    return;
                }
                //更改
                var btnChanged = frameRow.AddEditorControl();
                btnChanged.TextID = R.MyInternationalizationString.uChanged1;
@@ -363,6 +364,7 @@
                            //删除当前楼层的话,需要去刷新主页左边的房间列表
                            HdlRoomLogic.Current.RefreshRoomListView();
                        }
                        var uploadRoom = false;
                        var listDeleteId = new List<string>();
                        var listAllRoom = HdlRoomLogic.Current.GetAllListRooms();
                        for (int i = 0; i < listAllRoom.Count; i++)
@@ -370,6 +372,11 @@
                            if (listAllRoom[i].FloorId == keys)
                            {
                                listDeleteId.Add(listAllRoom[i].Id);
                            }
                            if (listAllRoom[i].ListDevice.Count > 0)
                            {
                                //需要上传空间区域
                                uploadRoom = true;
                            }
                        }
                        //删除房间
@@ -404,6 +411,11 @@
                            frameRow.RemoveFromParent();
                            //调整桌布高度
                            this.AdjustContrlTableHeight();
                        }
                        if (uploadRoom == true)
                        {
                            //上传空间区域信息
                            HdlRoomLogic.Current.SetRoomInfoToGateway();
                        }
                        //删除楼层的话,主页需要重新刷新
                        UserView.UserPage.Instance.RefreshAllForm = true;
@@ -460,13 +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)
                    {
                        //创建第一个新的楼层的话,需要去刷新主页左边的房间列表
                        HdlRoomLogic.Current.RefreshRoomListView();
                    }
                    if (btnFloor != null)
                    {
                        btnFloor.Text = textValue;
@@ -580,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) =>
@@ -616,6 +635,11 @@
                        frameRow.RemoveFromParent();
                        //调整桌布高度
                        this.AdjustContrlTableHeight();
                    }
                    if (room.ListDevice.Count > 0)
                    {
                        //上传空间区域信息
                        HdlRoomLogic.Current.SetRoomInfoToGateway();
                    }
                    //删除房间的话,主页需要重新刷新
                    UserView.UserPage.Instance.RefreshAllForm = true;
@@ -693,7 +717,7 @@
            var myHouse = HdlResidenceLogic.Current.GetHouseByFilePath(Common.Config.Instance.HomeFilePathList[index]);
            //切换住宅
            Common.Config.Instance.HomeId = myHouse.Id;
            Common.Config.Instance.Home = HdlResidenceLogic.Current.GetHouseByHouseId(myHouse.Id);
            Common.Config.Instance.Home = myHouse;
            Common.Global.CreateHomeDirectory(myHouse.Id);
            Common.Config.Instance.Save();
@@ -717,6 +741,66 @@
        #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
        #region ■ 保存住宅地图地址___________________
        /// <summary>