using System;
|
using System.Collections.Generic;
|
using Shared.Common;
|
using Shared.Phone.Device.CommonForm;
|
using Shared.Phone.UserCenter;
|
using Shared.Phone.UserView;
|
|
namespace Shared.Phone.MainPage
|
{
|
/// <summary>
|
/// 左滑菜单的的房间列表界面
|
/// </summary>
|
public class LeftListRoomViewFrom : EditorCommonForm
|
{
|
#region ■ 变量声明___________________________
|
|
private static LeftListRoomViewFrom roomManagement = null;
|
/// <summary>
|
/// 左滑菜单的的房间对象
|
/// </summary>
|
public static LeftListRoomViewFrom Instance
|
{
|
get
|
{
|
if (roomManagement == null)
|
{
|
//初始化左滑菜单
|
roomManagement = new LeftListRoomViewFrom();
|
CommonPage.Instance.AddLeftView(roomManagement);
|
}
|
return roomManagement;
|
}
|
}
|
|
/// <summary>
|
/// 是否可以触发点击事件--是否可以跳转主页房间
|
/// </summary>
|
public bool CanClick = true;
|
/// <summary>
|
/// 是否初始化完成
|
/// </summary>
|
private bool isInitFinish = false;
|
/// <summary>
|
/// 当前楼层id
|
/// </summary>
|
private string curFloorId = string.Empty;
|
/// <summary>
|
/// 列表控件
|
/// </summary>
|
private VerticalFrameControl listView = null;
|
/// <summary>
|
/// 卡片控件集合
|
/// </summary>
|
private Dictionary<string, Controls.ListRoomCardControl> dicCardControl = new Dictionary<string, Controls.ListRoomCardControl>();
|
/// <summary>
|
/// 未分配界面(用于对应别人乱搞,在打开未分配界面不关时,去刷新场景,然后提bug说没有场景)
|
/// </summary>
|
private UnallocatedRoomForm unalloctedRoom = null;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 画面显示
|
/// </summary>
|
private void ShowForm()
|
{
|
//初始化头部信息
|
this.InitTopFrame();
|
//初始化中部控件
|
this.InitBodyFrameLayout();
|
|
//初始化中部信息
|
this.InitMiddleFrame();
|
}
|
|
/// <summary>
|
/// 初始化头部信息
|
/// </summary>
|
private void InitTopFrame()
|
{
|
//初始化头部控件
|
this.InitTopFrameLayout();
|
|
//设置头部信息
|
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.RoomList));
|
|
//重置返回按键的事件
|
var btnBack = this.GetBackButton();
|
btnBack.ButtonClickEvent = null;
|
btnBack.ButtonClickEvent += (sender, e) =>
|
{
|
//收起左菜单
|
CommonPage.Instance.CloseLeftMenu();
|
};
|
|
//获取楼层
|
var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
|
if (dicFloor.Count == 0)
|
{
|
return;
|
}
|
//楼层初始ID
|
foreach (var floorId in dicFloor.Keys)
|
{
|
this.curFloorId = floorId;
|
break;
|
}
|
|
//楼层图标
|
var btnIconContr = new MostRightIconControl(69, 69);
|
btnIconContr.UnSelectedImagePath = "Item/Drop_Down.png";
|
topFrameLayout.AddChidren(btnIconContr);
|
btnIconContr.InitControl();
|
//楼层名
|
var btnFloor = new NormalViewControl(200, 69, true);
|
btnFloor.Gravity = Gravity.CenterVertical;
|
btnFloor.X = btnIconContr.X + btnIconContr.btnIcon.X - Application.GetRealWidth(200);
|
btnFloor.TextAlignment = TextAlignment.CenterRight;
|
btnFloor.Text = HdlResidenceLogic.Current.GetFloorNameById(this.curFloorId);
|
topFrameLayout.AddChidren(btnFloor);
|
|
btnIconContr.ButtonClickEvent += (sender, e) =>
|
{
|
//楼层菜单
|
var floors = new Category.SelectFloorForm();
|
floors.CurFloorId = this.curFloorId;
|
AddChidren(floors);
|
floors.CurFloorId = this.curFloorId;
|
floors.Init(599, 161, Direction.Right);
|
floors.FloorAction += (floorId) =>
|
{
|
this.curFloorId = floorId;
|
btnFloor.Text = dicFloor[floorId];
|
//刷新Body容器
|
this.RefreshBodyFrame();
|
};
|
};
|
}
|
|
/// <summary>
|
/// 初始化中部信息
|
/// </summary>
|
private void InitMiddleFrame()
|
{
|
this.listView = new VerticalFrameControl();
|
listView.Height = bodyFrameLayout.Height;
|
listView.Width = bodyFrameLayout.Width;
|
bodyFrameLayout.AddChidren(listView);
|
//刷新Body容器
|
this.RefreshBodyFrame();
|
}
|
|
#endregion
|
|
#region ■ 刷新房间列表_______________________
|
|
/// <summary>
|
/// 刷新房间列表
|
/// </summary>
|
public void RefreshListRoom()
|
{
|
if (Config.Instance.Home.FloorDics.Count == 0)
|
{
|
//来回切换备份,会出现问题,楼层id没清除
|
this.curFloorId = string.Empty;
|
}
|
//保险起见,这里要关闭未分配界面
|
this.CloseUnallocatedRoomForm();
|
|
//如果还没有初始化完成界面的话
|
if (this.isInitFinish == false)
|
{
|
this.ShowForm();
|
this.isInitFinish = true;
|
return;
|
}
|
//把头部也一起初始化了
|
this.topFrameLayout.RemoveAll();
|
//初始化头部信息
|
this.InitTopFrame();
|
|
//刷新Body容器
|
this.RefreshBodyFrame();
|
}
|
|
/// <summary>
|
/// 刷新Body容器
|
/// </summary>
|
private void RefreshBodyFrame()
|
{
|
//先清空
|
this.listView.frameTable.RemoveAll();
|
this.listView.frameTable.Height = Application.GetRealHeight(100);
|
this.dicCardControl.Clear();
|
|
var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(curFloorId);
|
//追加我的喜爱
|
listRoom.Insert(0, HdlRoomLogic.Current.GetLoveRoom());
|
|
//X轴
|
int XX = this.GetPictrueRealSize(43);
|
//Y轴
|
int YY = this.GetPictrueRealSize(58);
|
//房间计数
|
int roomCount = 0;
|
foreach (var room in listRoom)
|
{
|
roomCount++;
|
//初始化卡片控件
|
var contr = new Controls.ListRoomCardControl();
|
contr.X = XX;
|
contr.Y = YY;
|
listView.frameTable.AddChidren(contr);
|
contr.InitControl(room);
|
//加缓存
|
this.dicCardControl[room.Id] = contr;
|
//每两个重置X轴
|
XX = roomCount % 2 == 0 ? this.GetPictrueRealSize(43) : contr.Right + this.GetPictrueRealSize(3);
|
//每两个累加Y轴
|
if (roomCount >= 2 && roomCount % 2 == 0)
|
{
|
YY = contr.Bottom + this.GetPictrueRealSize(14);
|
}
|
contr.ButtonClickEvent += (sender, e) =>
|
{
|
if (CanClick == false)
|
{
|
return;
|
}
|
CommonPage.Instance.CloseLeftMenu();
|
|
HdlThreadLogic.Current.RunThread(() =>
|
{
|
//等待控件向左移动结束
|
System.Threading.Thread.Sleep(300);
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
//点击的是收藏房间的话,不变更当前楼层id
|
if (room.FloorId != string.Empty)
|
{
|
if (Config.Instance.Home.CurrentFloorId != room.FloorId)
|
{
|
//楼层都切换的话,刷新整个主页
|
Config.Instance.Home.CurrentFloorId = room.FloorId;
|
HdlRoomLogic.Current.NowMainPageRoom = room;
|
UserPage.Instance.ReFreshControl();
|
return;
|
}
|
}
|
//如果只是切换当前楼层的其他房间,则只滑动主页的滑动控件
|
HomeMainPageForm.Instance?.SetRoomPageViewSelect(room);
|
});
|
});
|
};
|
}
|
//成员是没有未分配这个东西出来的
|
if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1 || HdlUserCenterResourse.ResidenceOption.AuthorityNo == 2)
|
{
|
//初始化未分配卡片
|
this.InitRoomCardControl(XX, YY);
|
}
|
//调整桌布高度
|
this.listView.AdjustTableHeight();
|
}
|
|
/// <summary>
|
/// 初始化未分配卡片
|
/// </summary>
|
private void InitRoomCardControl(int XX, int YY)
|
{
|
//桌布控件
|
var frameBack = new FrameLayoutStatuControl();
|
frameBack.X = XX;
|
frameBack.Y = YY;
|
frameBack.Width = this.GetPictrueRealSize(495);
|
frameBack.Height = this.GetPictrueRealSize(354);
|
listView.frameTable.AddChidren(frameBack);
|
|
//底部阴影效果
|
var btnShadow = new NormalViewControl(frameBack.Width, frameBack.Height, false);
|
btnShadow.UnSelectedImagePath = "Room/RoomCardView.png";
|
frameBack.AddChidren(btnShadow, ChidrenBindMode.NotBind);
|
|
//背景控件
|
var picBackGroud = new NormalViewControl(this.GetPictrueRealSize(467), this.GetPictrueRealSize(311), false);
|
picBackGroud.Gravity = Gravity.CenterHorizontal;
|
picBackGroud.Radius = (uint)this.GetPictrueRealSize(29);
|
picBackGroud.BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor3;
|
frameBack.AddChidren(picBackGroud, ChidrenBindMode.BindEvent);
|
|
//未分配图标
|
var btnIcon = new PicViewControl(92, 72);
|
btnIcon.X = this.GetPictrueRealSize(129);
|
btnIcon.Y = this.GetPictrueRealSize(141);
|
btnIcon.UnSelectedImagePath = "Room/NoNameRoom.png";
|
frameBack.AddChidren(btnIcon, ChidrenBindMode.BindEvent);
|
|
//未分配
|
var btnName = new NormalViewControl(250, 84, true);
|
btnName.X = this.GetPictrueRealSize(244);
|
btnName.Y = this.GetPictrueRealSize(131);
|
btnName.IsBold = true;
|
btnName.TextColor = UserCenterColor.Current.White;
|
btnName.TextID = R.MyInternationalizationString.Unallocated;
|
frameBack.AddChidren(btnName, ChidrenBindMode.BindEvent);
|
frameBack.ButtonClickEvent += (sender, e) =>
|
{
|
if (this.CanClick == false)
|
{
|
return;
|
}
|
//未分配
|
this.unalloctedRoom = new UnallocatedRoomForm();
|
this.AddChidren(unalloctedRoom);
|
unalloctedRoom.ShowForm();
|
unalloctedRoom.FormCloseEvent += () =>
|
{
|
//手动点击关闭的话,直接置空
|
this.unalloctedRoom = null;
|
};
|
};
|
}
|
|
#endregion
|
|
#region ■ 关闭未分配界面_____________________
|
|
/// <summary>
|
/// 关闭未分配界面
|
/// </summary>
|
public void CloseUnallocatedRoomForm()
|
{
|
//关闭界面
|
this.unalloctedRoom?.CloseForm();
|
this.unalloctedRoom = null;
|
}
|
|
#endregion
|
|
#region ■ 刷新指定房间_______________________
|
|
/// <summary>
|
/// 刷新指定房间
|
/// </summary>
|
/// <param name="room"></param>
|
public void RefreshRoomInfo(Room room)
|
{
|
if (this.dicCardControl.ContainsKey(room.Id) == true)
|
{
|
//刷新卡片信息
|
this.dicCardControl[room.Id].RefreshControl();
|
}
|
}
|
|
#endregion
|
}
|
}
|