| | |
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 桌布控件
|
| | | /// </summary>
|
| | | private FrameLayout frameTable = null;
|
| | | /// <summary>
|
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private VerticalListControl listView = null;
|
| | | /// <summary>
|
| | | /// 列表控件最大高度
|
| | | /// </summary>
|
| | | private int MaxListViewHeight = 0;
|
| | | /// <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;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | //设置头部信息
|
| | | base.SetTitleText(Common.Config.Instance.Home.Name);
|
| | |
|
| | | //判断能否删除住宅
|
| | | if (i_CanDeleteResidence == true)
|
| | | //主人或者管理员才会出现这个菜单
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
|
| | | {
|
| | | //初始化右上角菜单
|
| | | this.InitTopRightMenu();
|
| | | }
|
| | | //初始化中部信息
|
| | | this.InitMiddleFrame();
|
| | | this.InitMiddleFrame(i_CanDeleteResidence);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部信息
|
| | | /// </summary>
|
| | | private void InitMiddleFrame()
|
| | | /// <param name="i_CanDeleteResidence">能否删除当前住宅</param>
|
| | | private void InitMiddleFrame(bool i_CanDeleteResidence)
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | var frameHome = new FrameRowControl();
|
| | | frameHome.Height = Application.GetRealHeight(173);
|
| | | frameHome.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(frameHome);
|
| | | var rowHome = new RowLayoutControl();
|
| | | rowHome.Height = Application.GetRealHeight(173);
|
| | | rowHome.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(rowHome);
|
| | |
|
| | | var btnAdreeIcon = frameHome.AddLeftIcon(81);
|
| | | var btnAdreeIcon = rowHome.frameTable.AddLeftIcon(81);
|
| | | btnAdreeIcon.UnSelectedImagePath = "Item/FixedPositionSelected.png";
|
| | |
|
| | | //住宅名称
|
| | | var btnHomeName = frameHome.AddLeftCaption(Common.Config.Instance.Home.Name, 700, 60);
|
| | | var btnHomeName = rowHome.frameTable.AddLeftCaption(Common.Config.Instance.Home.Name, 700, 60);
|
| | | btnHomeName.TextSize = 15;
|
| | | btnHomeName.Y = Application.GetRealHeight(35);
|
| | | frameHome.AddChidren(btnHomeName, ChidrenBindMode.BindEventOnly);
|
| | | rowHome.frameTable.AddChidren(btnHomeName, ChidrenBindMode.BindEventOnly);
|
| | | //当前住宅
|
| | | var btnNowView = frameHome.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uNowResidence), 700, 49);
|
| | | 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;
|
| | | frameHome.AddChidren(btnNowView, ChidrenBindMode.BindEventOnly);
|
| | | rowHome.frameTable.AddChidren(btnNowView, ChidrenBindMode.BindEventOnly);
|
| | | //右箭头
|
| | | frameHome.AddRightArrow();
|
| | | rowHome.frameTable.AddRightArrow();
|
| | |
|
| | | if (i_CanDeleteResidence == true)
|
| | | {
|
| | | //删除
|
| | | var btnDelete = new NormalViewControl(Application.GetRealWidth(184), rowHome.Height, false);
|
| | | btnDelete.BackgroundColor = 0xfff75858;
|
| | | btnDelete.TextAlignment = TextAlignment.Center;
|
| | | btnDelete.TextColor = UserCenterColor.Current.White;
|
| | | btnDelete.TextSize = 12;
|
| | | btnDelete.TextID = R.MyInternationalizationString.uDelete;
|
| | | rowHome.AddRightView(btnDelete);
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //确认删除住宅及所有楼层、房间?
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeleteResidenceMsg);
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | this.DeleteResidence();
|
| | | });
|
| | | });
|
| | | };
|
| | | }
|
| | | //初始化桌布
|
| | | this.frameTable = new FrameLayout();
|
| | | frameTable.Y = rowHome.Bottom + Application.GetRealHeight(23);
|
| | | frameTable.Height = bodyFrameLayout.Height - rowHome.Bottom - Application.GetRealHeight(23);
|
| | | bodyFrameLayout.AddChidren(frameTable);
|
| | |
|
| | | //根据指定模式,初始化桌布控件
|
| | | this.InitFrameTableByMode();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据指定模式,初始化桌布控件
|
| | | /// </summary>
|
| | | private void InitFrameTableByMode()
|
| | | {
|
| | | this.frameTable.RemoveAll();
|
| | |
|
| | | //0:还没有设置有模式 1:楼层模式 2:没有楼层模式
|
| | | AppResidenceMode = this.CheckAppResidenceMode();
|
| | | if (AppResidenceMode == 1)
|
| | | {
|
| | | //初始化楼层模式
|
| | | this.InitControlByFloorMode();
|
| | | }
|
| | | else if (AppResidenceMode == 2)
|
| | | {
|
| | | //初始化无楼层模式
|
| | | this.InitControlByNotFloorMode();
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 右上角菜单_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化右上角菜单
|
| | | /// </summary>
|
| | | private void InitTopRightMenu()
|
| | | {
|
| | | var btnIcon = new MostRightIconControl(69, 69);
|
| | | btnIcon.UnSelectedImagePath = "Item/Add.png";
|
| | | topFrameLayout.AddChidren(btnIcon);
|
| | | btnIcon.InitControl();
|
| | | btnIcon.ButtonClickEvent += ((sender, e) =>
|
| | | {
|
| | | //0:还没有设置有模式 1:楼层模式 2:没有楼层模式
|
| | | AppResidenceMode = this.CheckAppResidenceMode();
|
| | | //没有设置过模式
|
| | | if (AppResidenceMode == 0)
|
| | | {
|
| | | var frame = new TopRightMenuControl(2);
|
| | | //创建楼层
|
| | | frame.AddRowMenu(Language.StringByID(R.MyInternationalizationString.uCreatFloor), "Item/CreatFloor.png", "Item/CreatFloorSelected.png", () =>
|
| | | {
|
| | | //创建楼层
|
| | | this.CreatOrEditorFloor(null, string.Empty, string.Empty);
|
| | | });
|
| | | //创建房间
|
| | | frame.AddRowMenu(Language.StringByID(R.MyInternationalizationString.uCreatRoom), "Item/RoomIcon.png", "Item/RoomIconSelected.png", () =>
|
| | | {
|
| | | var form = new AddNewRoomForm();
|
| | | form.AddForm(string.Empty);
|
| | | form.FinishEditorEvent += () =>
|
| | | {
|
| | | //根据指定模式,初始化桌布控件
|
| | | this.InitFrameTableByMode();
|
| | | };
|
| | | });
|
| | | }
|
| | | //楼层模式
|
| | | else if (AppResidenceMode == 1)
|
| | | {
|
| | | //创建楼层
|
| | | this.CreatOrEditorFloor(null, string.Empty, string.Empty);
|
| | | }
|
| | | //无楼层模式
|
| | | else if (AppResidenceMode == 2)
|
| | | {
|
| | | var form = new AddNewRoomForm();
|
| | | form.AddForm(string.Empty);
|
| | | form.FinishEditorEvent += () =>
|
| | | {
|
| | | //根据指定模式,初始化桌布控件
|
| | | this.InitFrameTableByMode();
|
| | | };
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化楼层模式_____________________
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化楼层模式
|
| | | /// </summary>
|
| | | private void InitControlByFloorMode()
|
| | | {
|
| | | var frameFloor = new FrameRowControl();
|
| | | frameFloor.UseClickStatu = false;
|
| | | frameFloor.Y = frameHome.Bottom + Application.GetRealHeight(23);
|
| | | frameFloor.Height = Application.GetRealHeight(115);
|
| | | frameFloor.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(frameFloor);
|
| | | frameTable.AddChidren(frameFloor);
|
| | |
|
| | | //楼层
|
| | | var btnFloor = frameFloor.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uFloor), 200, 60);
|
| | |
| | | btnFloor.TextColor = UserCenterColor.Current.TextColor2;
|
| | | btnFloor.TextSize = 15;
|
| | | frameFloor.AddChidren(btnFloor, ChidrenBindMode.NotBind);
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
|
| | | {
|
| | | //添加楼层
|
| | | var btnAddFloor = frameFloor.AddMostRightEmptyIcon(69, 69);
|
| | | frameFloor.ChangedChidrenBindMode(btnAddFloor, ChidrenBindMode.NotBind);
|
| | | btnAddFloor.Y = Application.GetRealHeight(46);
|
| | | btnAddFloor.UnSelectedImagePath = "Item/Add.png";
|
| | | btnAddFloor.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //创建楼层
|
| | | this.CreatOrEditorFloor(string.Empty, string.Empty);
|
| | | };
|
| | | }
|
| | |
|
| | | this.MaxListViewHeight = bodyFrameLayout.Height - frameFloor.Bottom;
|
| | | listView = new VerticalListControl(29);
|
| | | listView.BackgroundColor = UserCenterColor.Current.White;
|
| | | listView.Y = frameFloor.Bottom;
|
| | | listView.Height = MaxListViewHeight;
|
| | | bodyFrameLayout.AddChidren(listView);
|
| | | listView.Height = frameTable.Height - frameFloor.Bottom;
|
| | | frameTable.AddChidren(listView);
|
| | |
|
| | | //初始化楼层行
|
| | | this.InitFloorRow();
|
| | |
| | | listFloorSort.Add(keys);
|
| | | }
|
| | |
|
| | | listView.Height = MaxListViewHeight;
|
| | | listView.RemoveAll();
|
| | | if (Common.Config.Instance.Home.FloorDics.Count == 0)
|
| | | {
|
| | | return;
|
| | |
| | | frameRow.AddRightView(btnChanged);
|
| | | btnChanged.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //创建或者编辑楼层
|
| | | this.CreatOrEditorFloor(keys, floorName);
|
| | | //创建或者编辑楼层
|
| | | this.CreatOrEditorFloor(btnFloor, keys, floorName);
|
| | | };
|
| | |
|
| | | //删除
|
| | |
| | | frameRow.AddRightView(btnDelete);
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //删除楼层
|
| | | this.DeleteFloor(keys);
|
| | | //确认删除楼层及其所有房间?
|
| | | this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteFloorMsg), () =>
|
| | | {
|
| | | //移除楼层
|
| | | Common.Config.Instance.Home.FloorDics.Remove(keys);
|
| | | if (Common.Room.CurrentRoom == null)
|
| | | {
|
| | | Common.Room.CurrentRoom = Common.Room.Lists[0];
|
| | | }
|
| | | var listDeleteFile = new List<string>();
|
| | | for (int i = 0; i < Common.Room.Lists.Count; i++)
|
| | | {
|
| | | if (Common.Room.Lists[i].FloorId == keys)
|
| | | {
|
| | | listDeleteFile.Add(Common.Room.Lists[i].FileName);
|
| | | }
|
| | | }
|
| | | //删除房间
|
| | | foreach (string fileName in listDeleteFile)
|
| | | {
|
| | | Common.Room.CurrentRoom.Remove(fileName);
|
| | | }
|
| | | //如果当前选择的房间是删除对象的话
|
| | | if (Common.Room.CurrentRoom.FloorId == keys)
|
| | | {
|
| | | Common.Room.CurrentRoom = Common.Room.Lists[0];
|
| | | }
|
| | | Common.Config.Instance.Home.Save();
|
| | | //保存顺序
|
| | | listFloorSort.Remove(keys);
|
| | | Common.Room.CurrentRoom.SaveFloorSort(listFloorSort);
|
| | |
|
| | | if (Common.Config.Instance.Home.FloorDics.Count == 0)
|
| | | {
|
| | | //根据指定模式,初始化桌布控件
|
| | | this.InitFrameTableByMode();
|
| | | }
|
| | | else
|
| | | {
|
| | | frameRow.RemoveFromParent();
|
| | | listView.AdjustRealHeight(Application.GetRealHeight(23));
|
| | | }
|
| | | });
|
| | | };
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 创建或编辑楼层_____________________
|
| | |
|
| | | /// <summary>
|
| | | /// 创建或者编辑楼层
|
| | | /// </summary>
|
| | | /// <param name="btnFloor"></param>
|
| | | /// <param name="keys"></param>
|
| | | /// <param name="floorName"></param>
|
| | | private void CreatOrEditorFloor(string keys, string floorName)
|
| | | private void CreatOrEditorFloor(NormalViewControl btnFloor, string keys, string floorName)
|
| | | {
|
| | | //生成一个弹窗画面
|
| | | var dialogForm = new DialogInputFrameControl(this, DialogFrameMode.OnlyInput);
|
| | |
| | | }
|
| | | Common.Config.Instance.Home.FloorDics[keys] = textValue;
|
| | | Common.Config.Instance.Home.Save();
|
| | | //重新初始化楼层行
|
| | | this.InitFloorRow();
|
| | | if (btnFloor != null)
|
| | | {
|
| | | btnFloor.Text = textValue;
|
| | | }
|
| | | else
|
| | | {
|
| | | //根据指定模式,初始化桌布控件
|
| | | this.InitFrameTableByMode();
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化无楼层模式___________________
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化无楼层模式
|
| | | /// </summary>
|
| | | private void InitControlByNotFloorMode()
|
| | | {
|
| | | var frameRoom = new FrameRowControl();
|
| | | frameRoom.UseClickStatu = false;
|
| | | frameRoom.Height = Application.GetRealHeight(115);
|
| | | frameRoom.BackgroundColor = UserCenterColor.Current.White;
|
| | | frameTable.AddChidren(frameRoom);
|
| | |
|
| | | //房间列表
|
| | | var btnRoomList = frameRoom.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uRoomList), 200, 60);
|
| | | btnRoomList.Y = Application.GetRealHeight(50);
|
| | | btnRoomList.TextColor = UserCenterColor.Current.TextColor2;
|
| | | btnRoomList.TextSize = 15;
|
| | | frameRoom.AddChidren(btnRoomList, ChidrenBindMode.NotBind);
|
| | |
|
| | | listView = new VerticalListControl(29);
|
| | | listView.BackgroundColor = UserCenterColor.Current.White;
|
| | | listView.Y = frameRoom.Bottom;
|
| | | listView.Height = frameTable.Height - frameRoom.Bottom;
|
| | | frameTable.AddChidren(listView);
|
| | |
|
| | | //初始化房间列表
|
| | | this.InitRoomListRow();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化房间列表
|
| | | /// </summary>
|
| | | private void InitRoomListRow()
|
| | | {
|
| | | //获取楼层的房间
|
| | | var listRoom = Common.Room.CurrentRoom.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));
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 添加房间行_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 添加房间行
|
| | | /// </summary>
|
| | | /// <param name="room"></param>
|
| | | /// <param name="addLine"></param>
|
| | | private void AddRoomRow(Common.Room room, bool addLine)
|
| | | {
|
| | | var frameRow = new RowLayoutControl(listView.rowSpace / 2);
|
| | | listView.AddChidren(frameRow);
|
| | | //图标
|
| | | var btnIcon = frameRow.frameTable.AddLeftIcon(81);
|
| | | btnIcon.UnSelectedImagePath = "Item/RoomIconSelected.png";
|
| | | //名称
|
| | | var btnName = frameRow.frameTable.AddLeftCaption(room.Name, 600);
|
| | | btnName.TextSize = 15;
|
| | | //右箭头
|
| | | frameRow.frameTable.AddRightArrow();
|
| | | if (addLine == true)
|
| | | {
|
| | | //底线
|
| | | frameRow.frameTable.AddBottomLine();
|
| | | }
|
| | | frameRow.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new LookRoomSettionForm();
|
| | | form.AddForm(room);
|
| | | };
|
| | |
|
| | | if (room.IsSharedRoom == true)
|
| | | {
|
| | | //如果是分享的房间,不能编辑和修改
|
| | | return;
|
| | | }
|
| | |
|
| | | //编辑
|
| | | var btnEditor = new NormalViewControl(Application.GetRealWidth(184), frameRow.Height, false);
|
| | | btnEditor.BackgroundColor = 0xff4a4a4a;
|
| | | btnEditor.TextSize = 12;
|
| | | btnEditor.TextColor = UserCenterColor.Current.White;
|
| | | btnEditor.TextAlignment = TextAlignment.Center;
|
| | | btnEditor.TextID = R.MyInternationalizationString.uEditor;
|
| | | frameRow.AddRightView(btnEditor);
|
| | | btnEditor.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new EditorRoomInforForm();
|
| | | form.AddForm(room);
|
| | | form.FinishEditorEvent += (roomName) =>
|
| | | {
|
| | | btnName.Text = roomName;
|
| | | };
|
| | | };
|
| | |
|
| | | //删除
|
| | | var btnDelete = new NormalViewControl(Application.GetRealWidth(184), frameRow.Height, false);
|
| | | btnDelete.BackgroundColor = 0xfff75858;
|
| | | btnDelete.TextSize = 12;
|
| | | btnDelete.TextColor = UserCenterColor.Current.White;
|
| | | btnDelete.TextAlignment = TextAlignment.Center;
|
| | | btnDelete.TextID = R.MyInternationalizationString.uDelete;
|
| | | frameRow.AddRightView(btnDelete);
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //确认删除房间?
|
| | | this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteRoomMsg), () =>
|
| | | {
|
| | | if (Common.Room.CurrentRoom.Id == room.Id)
|
| | | {
|
| | | //如果删除的是当前房间的话
|
| | | Common.Room.CurrentRoom = Common.Room.Lists[0];
|
| | | }
|
| | | Common.Room.CurrentRoom.Remove(room.FileName);
|
| | | //保存顺序
|
| | | this.listRoomSort.Remove(room.Id);
|
| | | Common.Room.CurrentRoom.SaveRoomSort(string.Empty, this.listRoomSort);
|
| | |
|
| | | if (Common.Room.Lists.Count <= 1)
|
| | | {
|
| | | //根据指定模式,初始化桌布控件
|
| | | this.InitFrameTableByMode();
|
| | | }
|
| | | else
|
| | | {
|
| | | frameRow.RemoveFromParent();
|
| | | listView.AdjustRealHeight(Application.GetRealHeight(23));
|
| | | }
|
| | | });
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 删除住宅___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 删除住宅
|
| | | /// </summary>
|
| | | public async 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);
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | //因为删除的是当前的住宅,所以需要先切换到别的住宅
|
| | | string deleteId = Common.Config.Instance.Home.Id;
|
| | | string deleteFile = Common.Config.Instance.Home.FileName;
|
| | | int index = 0;
|
| | | for (; index < Common.Config.Instance.HomeFilePathList.Count; index++)
|
| | | {
|
| | | if (Common.Config.Instance.HomeFilePathList[index] == deleteFile)
|
| | | {
|
| | | //当前住宅所处的位置(住宅数肯定大于1,不然不会出现删除按钮)
|
| | | if (index == 0)
|
| | | {
|
| | | //取下一位
|
| | | index++;
|
| | | }
|
| | | else
|
| | | {
|
| | | //取前一位
|
| | | index--;
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | var myHouse = Common.House.GetHouseByFilePath(Common.Config.Instance.HomeFilePathList[index]);
|
| | | //切换住宅
|
| | | Common.Config.Instance.HomeId = myHouse.Id;
|
| | | Common.Global.CreateHomeDirectory(myHouse.Id);
|
| | | Common.Config.Instance.Save();
|
| | | //刷新个人中心的内存及线程
|
| | | await UserCenterLogic.InitUserCenterMenmoryAndThread();
|
| | | Common.Room.InitAllRoom();
|
| | |
|
| | | //删除住宅
|
| | | Common.House.DeleteHouseByHouseId(deleteId);
|
| | |
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //关闭界面
|
| | | this.CloseForm();
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 检测App的住宅模式 0:还没有设置有模式 1:楼层模式 2:没有楼层模式
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private int CheckAppResidenceMode()
|
| | | {
|
| | | if (Common.Config.Instance.Home.FloorDics.Count > 0)
|
| | | {
|
| | | //拥有楼层
|
| | | return 1;
|
| | | }
|
| | | if (Common.Room.Lists.Count > 1)
|
| | | {
|
| | | //无楼层模式
|
| | | return 2;
|
| | | }
|
| | |
|
| | | return 0;
|
| | | }
|
| | |
|
| | |
|
| | | /// <summary>
|
| | | /// 检测楼层名称
|
| | |
| | | }
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 删除楼层___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 删除楼层
|
| | | /// </summary>
|
| | | /// <param name="keys"></param>
|
| | | private void DeleteFloor(string keys)
|
| | | {
|
| | | //确认删除楼层及其所有房间?
|
| | | this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteFloorMsg), () =>
|
| | | {
|
| | | //移除楼层
|
| | | Common.Config.Instance.Home.FloorDics.Remove(keys);
|
| | | if (Common.Room.CurrentRoom == null)
|
| | | {
|
| | | Common.Room.CurrentRoom = Common.Room.Lists[0];
|
| | | }
|
| | | var listDeleteFile = new List<string>();
|
| | | for (int i = 0; i < Common.Room.Lists.Count; i++)
|
| | | {
|
| | | if (Common.Room.Lists[i].FloorId == keys)
|
| | | {
|
| | | listDeleteFile.Add(Common.Room.Lists[i].FileName);
|
| | | }
|
| | | }
|
| | | //删除房间
|
| | | foreach (string fileName in listDeleteFile)
|
| | | {
|
| | | Common.Room.CurrentRoom.Remove(fileName);
|
| | | }
|
| | | //如果当前选择的房间是删除对象的话
|
| | | if (Common.Room.CurrentRoom.FloorId == keys)
|
| | | {
|
| | | Common.Room.CurrentRoom = Common.Room.Lists[0];
|
| | | }
|
| | | Common.Config.Instance.Home.Save();
|
| | | //重新初始化楼层行
|
| | | listFloorSort.Remove(keys);
|
| | | this.InitFloorRow();
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 右上角菜单_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化右上角菜单
|
| | | /// </summary>
|
| | | private void InitTopRightMenu()
|
| | | {
|
| | | var btnIcon = new MostRightIconControl(69, 69);
|
| | | btnIcon.UnSelectedImagePath = "Item/More.png";
|
| | | topFrameLayout.AddChidren(btnIcon);
|
| | | btnIcon.InitControl();
|
| | | btnIcon.ButtonClickEvent += ((sender, e) =>
|
| | | {
|
| | | var frame = new TopRightMenuControl(this, 1);
|
| | | //删除住宅
|
| | | frame.AddRowMenu(Language.StringByID(R.MyInternationalizationString.uDeleteResidence), "Item/DeleteIcon2.png", "Item/DeleteIcon2Selected.png", () =>
|
| | | {
|
| | | //确认删除住宅及所有楼层、房间?
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeleteResidenceMsg);
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | this.DeleteResidence();
|
| | | });
|
| | | });
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 删除住宅
|
| | | /// </summary>
|
| | | public async 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);
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //因为删除的是当前的住宅,所以需要先切换到别的住宅
|
| | | string deleteId = Common.Config.Instance.Home.Id;
|
| | | string deleteFile = Common.Config.Instance.Home.FileName;
|
| | | int index = 0;
|
| | | for (; index < Common.Config.Instance.HomeFilePathList.Count; index++)
|
| | | {
|
| | | if (Common.Config.Instance.HomeFilePathList[index] == deleteFile)
|
| | | {
|
| | | //当前住宅所处的位置(住宅数肯定大于1,不然不会出现删除按钮)
|
| | | if (index == 0)
|
| | | {
|
| | | //取下一位
|
| | | index++;
|
| | | }
|
| | | else
|
| | | {
|
| | | //取前一位
|
| | | index--;
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | var myHouse = Common.House.GetHouseByFilePath(Common.Config.Instance.HomeFilePathList[index]);
|
| | | //切换住宅
|
| | | Common.Config.Instance.HomeId = myHouse.Id;
|
| | | Common.Global.CreateHomeDirectory(myHouse.Id);
|
| | | Common.Config.Instance.Save();
|
| | | //刷新个人中心的内存及线程
|
| | | await UserCenterLogic.InitUserCenterMenmoryAndThread();
|
| | | Common.Room.InitAllRoom();
|
| | |
|
| | | //删除住宅
|
| | | Common.House.DeleteHouseByHouseId(deleteId);
|
| | |
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //关闭界面
|
| | | this.CloseForm();
|
| | | });
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|