| | |
| | | /// </summary>
|
| | | private VerticalFrameControl listBackContr = null;
|
| | | /// <summary>
|
| | | /// 楼层顺序
|
| | | /// </summary>
|
| | | private List<string> listFloorSort = new List<string>();
|
| | | /// <summary>
|
| | | /// 房间顺序
|
| | | /// </summary>
|
| | | private List<string> listRoomSort = new List<string>();
|
| | | /// <summary>
|
| | | /// 当前APP的住宅模式 0:还没有设置有模式 1:楼层模式 2:没有楼层模式
|
| | | /// </summary>
|
| | | private int AppResidenceMode = 0;
|
| | |
| | | //主人或者管理员才会出现这个菜单
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
|
| | | {
|
| | | //初始化右上角菜单
|
| | | this.InitTopRightMenu();
|
| | | //查看模板时,不允许编辑
|
| | | if (Common.Config.Instance.Home.IsShowTemplate == false)
|
| | | {
|
| | | //初始化右上角菜单
|
| | | this.InitTopRightMenu();
|
| | | }
|
| | | }
|
| | | //初始化中部信息
|
| | | this.InitMiddleFrame(i_CanDeleteResidence);
|
| | |
| | | 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);
|
| | |
| | | {
|
| | | //获取楼层
|
| | | 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);
|
| | | }
|
| | | //调整控件高度
|
| | | this.AdjustContrlTableHeight();
|
| | |
| | |
|
| | | 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;
|
| | |
| | | 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++)
|
| | |
| | | {
|
| | | listDeleteId.Add(listAllRoom[i].Id);
|
| | | }
|
| | | if (listAllRoom[i].ListDevice.Count > 0)
|
| | | {
|
| | | //需要上传空间区域
|
| | | uploadRoom = true;
|
| | | }
|
| | | }
|
| | | //删除房间
|
| | | foreach (string roomId in listDeleteId)
|
| | |
| | | HdlRoomLogic.Current.RemoveRoom(roomId);
|
| | | }
|
| | | Common.Config.Instance.Home.Save();
|
| | | //保存顺序
|
| | | listFloorSort.Remove(keys);
|
| | | HdlRoomLogic.Current.SaveFloorSort(listFloorSort);
|
| | |
|
| | | if (Common.Config.Instance.Home.FloorDics.Count == 0)
|
| | | {
|
| | |
| | | //调整桌布高度
|
| | | this.AdjustContrlTableHeight();
|
| | | }
|
| | | if (uploadRoom == true)
|
| | | {
|
| | | //上传空间区域信息
|
| | | HdlRoomLogic.Current.SetRoomInfoToGateway();
|
| | | }
|
| | | //删除楼层的话,主页需要重新刷新
|
| | | UserView.UserPage.Instance.RefreshForm = true;
|
| | | UserView.UserPage.Instance.RefreshAllForm = true;
|
| | | });
|
| | | };
|
| | | }
|
| | |
| | | {
|
| | | 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;
|
| | |
| | | this.InitFrameTableByMode();
|
| | | }
|
| | | //创建或者修改楼层的话,主页需要重新刷新
|
| | | UserView.UserPage.Instance.RefreshForm = true;
|
| | | UserView.UserPage.Instance.RefreshAllForm = true;
|
| | | }
|
| | | });
|
| | | }
|
| | |
| | | {
|
| | | //获取楼层的房间
|
| | | 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++)
|
| | | {
|
| | | //添加房间行
|
| | |
| | | //如果是分享的房间,不能编辑和修改
|
| | | return;
|
| | | }
|
| | |
|
| | | //编辑
|
| | | var btnEditor = frameRow.AddEditorControl();
|
| | | btnEditor.ButtonClickEvent += (sender, e) =>
|
| | |
| | | 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) =>
|
| | |
| | | this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteRoomMsg), () =>
|
| | | {
|
| | | 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)
|
| | |
| | | //调整桌布高度
|
| | | this.AdjustContrlTableHeight();
|
| | | }
|
| | | if (room.ListDevice.Count > 0)
|
| | | {
|
| | | //上传空间区域信息
|
| | | HdlRoomLogic.Current.SetRoomInfoToGateway();
|
| | | }
|
| | | //删除房间的话,主页需要重新刷新
|
| | | UserView.UserPage.Instance.RefreshForm = true;
|
| | | UserView.UserPage.Instance.RefreshAllForm = true;
|
| | | });
|
| | | };
|
| | | }
|
| | |
| | | /// <summary>
|
| | | /// 删除住宅
|
| | | /// </summary>
|
| | | public async void DeleteResidence()
|
| | | private void DeleteResidence()
|
| | | {
|
| | | //开启进度条
|
| | | this.ShowProgressBar();
|
| | |
| | | Pra.HomeId = Common.Config.Instance.Home.Id;
|
| | | Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
|
| | |
|
| | | bool result = await UserCenterLogic.GetResultStatuByRequestHttps("App/DelHome", true, Pra);
|
| | | bool result = UserCenterLogic.GetResultStatuByRequestHttps("App/DelHome", true, Pra);
|
| | | if (result == false)
|
| | | {
|
| | | //关闭进度条
|
| | |
| | | HomeId = Common.Config.Instance.Home.Id,
|
| | | PrimaryUserId = Common.Config.Instance.Home.MainUserDistributedMark
|
| | | };
|
| | | bool result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/SubAccountDelShareHome", false, Pra2);
|
| | | bool result = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/SubAccountDelShareHome", false, Pra2);
|
| | | if (result == false)
|
| | | {
|
| | | //关闭进度条
|
| | |
| | | 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);
|
| | | bool result2 = UserCenterLogic.InitUserCenterMenmoryAndThread(false);
|
| | | if (result2 == false)
|
| | | {
|
| | | //开启了调试功能
|
| | | return;
|
| | | }
|
| | |
|
| | | //删除住宅
|
| | | 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
|
| | |
| | | /// <param name="latitude">纬度</param>
|
| | | /// <param name="longitude">经度</param>
|
| | | /// <param name="addresName">位置名称</param>
|
| | | private async void SaveResidenceAdrress(NormalViewControl btnLocation, double latitude, double longitude, string addresName)
|
| | | private void SaveResidenceAdrress(NormalViewControl btnLocation, double latitude, double longitude, string addresName)
|
| | | {
|
| | | //如果不是虚拟住宅,才更新云端
|
| | | if (Common.Config.Instance.Home.IsVirtually == false)
|
| | |
| | | Pra.Longitude = longitude;
|
| | |
|
| | | //编辑住宅
|
| | | bool flage = await UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", true, Pra);
|
| | | bool flage = UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", true, Pra);
|
| | | if (flage == false)
|
| | | {
|
| | | //关闭进度条
|