using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using ZigBee.Device; namespace Shared.Phone.UserCenter.SharedContent { /// /// 查看已共享内容的房间列表界面★ /// public class LookSharedListRoomForm : EditorCommonForm { #region ■ 变量声明___________________________ /// /// 列表控件 /// private VerticalFrameControl listView = null; /// /// 成员ID /// private string ChildAccountId = string.Empty; #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// /// 成员信息 /// 成员的共享信息 public void ShowForm(string i_ChildAccountId) { this.ChildAccountId = i_ChildAccountId; //设置头部信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uShared2)); //添加图标 var btnAdd = new MostRightIconControl(69, 69); btnAdd.UnSelectedImagePath = "Item/Add.png"; btnAdd.ButtonClickEvent += (sender, e) => { var form = new AddNewSharedListRoomForm(); form.AddForm(this.ChildAccountId); }; topFrameLayout.AddChidren(btnAdd); btnAdd.InitControl(); //初始化中部信息 this.InitMiddleFrame(); } /// /// 初始化中部信息 /// private void InitMiddleFrame() { //清空bodyFrame this.ClearBodyFrame(); HdlThreadLogic.Current.RunThread(() => { //初始化成员的共享列表 var result = HdlShardLogic.Current.InitMemberShardContentListAndSetToLocation(this.ChildAccountId); if (result == false) { //显示重新加载的界面 this.ShowReLoadView(); return; } //初始化区域列表 this.InitAreaListRow(); }); } #endregion #region ■ 区域列表___________________________ /// /// 初始化区域列表 /// private void InitAreaListRow() { var dicShardRoom = HdlShardLogic.Current.GetShardRoomFromMemory(); if (dicShardRoom.Count == 0) { HdlThreadLogic.Current.RunMain(() => { bodyFrameLayout.RemoveAll(); //还没有共享区域给成员{0}可点击右上角“+”添加 string msg = Language.StringByID(R.MyInternationalizationString.uNotShardComtentMsg); string[] Arry = msg.Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries); this.ShowNotDataImage(bodyFrameLayout, Arry, "Item/NotShardPic.png", 383, 279); }); } else { //合并同一楼层的房间 var dicGroup = new Dictionary>(); foreach (var room in dicShardRoom.Values) { if (dicGroup.ContainsKey(room.FloorId) == false) { dicGroup[room.FloorId] = new List(); } dicGroup[room.FloorId].Add(room); } //获取分享的楼层(排序) var dicSortFloor = HdlShardLogic.Current.GetShardFloorFormMemory(); dicSortFloor = HdlRoomLogic.Current.GetFloorSortList(dicSortFloor); HdlThreadLogic.Current.RunMain(() => { bodyFrameLayout.RemoveAll(); this.listView = new VerticalFrameControl(29); listView.Height = bodyFrameLayout.Height; bodyFrameLayout.AddChidren(listView); foreach (var floorId in dicSortFloor.Keys) { if (dicGroup.ContainsKey(floorId) == true) { //添加各自楼层的房间列表 this.AddRoomListRow(floorId, dicSortFloor[floorId], dicGroup[floorId]); dicGroup.Remove(floorId); } } //添加各自楼层的房间列表(这里是指定楼层并不在排序记录里面的) foreach (var floorId in dicGroup.Keys) { this.AddRoomListRow(floorId, string.Empty, dicGroup[floorId]); } //调整桌布高度 listView.AdjustTableHeight(); }); } } /// /// 添加房间列表行 /// /// private void AddRoomListRow(string floorId, string floorName, List listRoom) { var frameBack = new FrameListControl(29); frameBack.BackgroundColor = UserCenterColor.Current.White; frameBack.Height = 10; this.listView.AddChidren(frameBack); //楼层 if (string.IsNullOrEmpty(floorId) == false) { var btnFloor = new NormalViewControl(800, 60, true); btnFloor.X = HdlControlResourse.XXLeft; btnFloor.Y = Application.GetRealHeight(52); btnFloor.TextColor = UserCenterColor.Current.TextColor2; btnFloor.TextSize = 15; frameBack.AddChidren(btnFloor); if (floorName != string.Empty) { btnFloor.Text = floorName; } else if (floorId == "Other") { //未分配区域 btnFloor.Text = Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom); } else { btnFloor.Text = "UnKnown"; } } //房间排序 var listSortRoom = HdlRoomLogic.Current.SortRoom(listRoom); for (int i = 0; i < listSortRoom.Count; i++) { var room = listSortRoom[i]; var frameRow = new RowLayoutControl(frameBack.rowSpace / 2); frameBack.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 (i != listSortRoom.Count - 1) { //底线 frameRow.frameTable.AddBottomLine(); } frameRow.frameTable.ButtonClickEvent += (sender, e) => { var form = new LookSharedContentForm(); form.AddForm(room, this.ChildAccountId); }; //删除 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) => { //确认删除共享房间? string msg = Language.StringByID(R.MyInternationalizationString.uDeleteShardRoomMsg); this.ShowMassage(ShowMsgType.Confirm, msg, () => { //删除共享区域 this.DoDeleteShardContentByRoom(room); }); }; } //调整子控件Frame高度 this.listView.AdjustChidrenFrameHeight(frameBack, Application.GetRealHeight(29)); } #endregion #region ■ 删除共享区域_______________________ /// /// 删除共享区域 /// /// 指定要删除的共享区域 public void DoDeleteShardContentByRoom(Common.Room room) { HdlThreadLogic.Current.RunThread(() => { //执行删除 var result = HdlShardLogic.Current.DeleteSharedRoom(this.ChildAccountId, new List { room }); if (result == true) { HdlThreadLogic.Current.RunMain(() => { //重新刷新界面 this.InitMiddleFrame(); }); } }); } #endregion #region ■ 界面重新激活事件___________________ /// /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件 /// public override int FormActionAgainEvent() { //重新刷新界面 this.InitMiddleFrame(); return 1; } #endregion } }