using System;
|
using Shared;
|
using HDL_ON.UI.CSS;
|
using System.Collections.Generic;
|
using System.Threading;
|
using HDL_ON.DAL.Server;
|
using HDL_ON.Entity;
|
|
namespace HDL_ON.UI
|
{
|
|
/// <summary>
|
/// 房间列表
|
/// </summary>
|
public class SmartSpeakerRoomListPage : FrameLayout
|
{
|
/// <summary>
|
/// bodyView
|
/// </summary>
|
FrameLayout bodyView;
|
|
/// <summary>
|
/// 当前主滑动View
|
/// </summary>
|
VerticalScrolViewLayout bodyScrolView;
|
/// <summary>
|
/// 音箱参数
|
/// </summary>
|
SpeakerInfo speakerInfo;
|
|
/// <summary>
|
/// 房间列表和无区域功能页面
|
/// </summary>
|
/// <param name="speakerInfo">音箱参数</param>
|
public SmartSpeakerRoomListPage(SpeakerInfo speakerInfo)
|
{
|
bodyView = this;
|
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
|
this.speakerInfo = speakerInfo;
|
}
|
|
/// <summary>
|
/// 加载视图
|
/// </summary>
|
public void LoadPage()
|
{
|
new TopViewDiv(bodyView, Language.StringByID(StringId.DataManagement)).LoadTopView();
|
|
int bodyY = Application.GetRealHeight(64);
|
bodyScrolView = new VerticalScrolViewLayout()
|
{
|
Y = bodyY,
|
Height = bodyView.Height - bodyY,
|
BackgroundColor = CSS_Color.BackgroundColor,
|
|
};
|
bodyView.AddChidren(bodyScrolView);
|
|
//加载房间列表
|
ShowRoomListView();
|
}
|
|
/// <summary>
|
/// 加载房间列表
|
/// </summary>
|
void ShowRoomListView()
|
{
|
bodyScrolView.RemoveAll();
|
|
var titleView = new FrameLayout()
|
{
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
Height = Application.GetRealWidth(53),
|
};
|
bodyScrolView.AddChidren(titleView);
|
//箭头图标
|
var btnResidenceDownIcon = new Button()
|
{
|
Width = Application.GetMinRealAverage(16),
|
Height = Application.GetMinRealAverage(16),
|
X = Application.GetRealWidth(12),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Public/DownIcon.png",
|
};
|
titleView.AddChidren(btnResidenceDownIcon);
|
//住宅标题
|
var btnHomeTitle = new Button()
|
{
|
X = btnResidenceDownIcon.Right + Application.GetRealWidth(1),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
|
Text = DB_ResidenceData.Instance.CurrentRegion.Name,
|
};
|
titleView.AddChidren(btnHomeTitle);
|
|
//var btnLine = new Button()
|
//{
|
// X = Application.GetRealWidth(16),
|
// Y = titleView.Height - Application.GetRealHeight(2),
|
// Width = Application.GetRealWidth(360),
|
// Height = Application.GetRealHeight(1),
|
// BackgroundColor = CSS_Color.DividingLineColor,
|
//};
|
//titleView.AddChidren(btnLine);
|
|
//---------------------------------------------
|
//未分配区域的功能
|
List<Function> allFunctionList = FunctionList.List.GetDeviceFunctionList();
|
//未分配区域的功能
|
List<Function> unallocatedList = new List<Function>();
|
//
|
foreach (var function in allFunctionList)
|
{
|
function.roomIds.Remove(null);
|
if (function.roomIds.Count == 0)
|
{
|
unallocatedList.Add(function);
|
}
|
}
|
|
//所有场景
|
List<Scene> allSceneList = FunctionList.List.scenes;
|
//全局场景场景
|
List<Scene> globalSceneList = new List<Scene>();
|
//找出所有的全局场景
|
foreach (var mScene in allSceneList)
|
{
|
|
//roomIds大于0 代表分配到房间
|
mScene.roomIds.Remove(null);
|
if (mScene.roomIds.Count == 0)
|
{
|
globalSceneList.Add(mScene);
|
}
|
}
|
|
|
try
|
{
|
//房间列表
|
foreach (var room in SpatialInfo.CurrentSpatial.RoomList)
|
{
|
AddRoomFunctionRowLayout(room);
|
}
|
//2020-12-16 加载未分配区域功能RowLayout
|
AddNoAreaFunctionRowLayout(unallocatedList, globalSceneList);
|
}
|
catch
|
{
|
Utlis.WriteLine("AddRoomFunctionRowLayout error");
|
}
|
}
|
|
|
/// <summary>
|
/// 添加房间列表
|
/// </summary>
|
/// <param name="mRoom"></param>
|
void AddRoomFunctionRowLayout(Room mRoom)
|
{
|
ShowBaseRoomFunOrNoAreaFunRowLayout(mRoom, null, null);
|
}
|
|
/// <summary>
|
/// 添加无区域的功能
|
/// </summary>
|
/// <param name="unallocatedList">未分配的所有功能列表</param>
|
/// <param name="globalSceneList">全区域的场景</param>
|
void AddNoAreaFunctionRowLayout(List<Function> unallocatedList, List<Scene> globalSceneList)
|
{
|
ShowBaseRoomFunOrNoAreaFunRowLayout(null, unallocatedList, globalSceneList);
|
}
|
|
/// <summary>
|
/// 2020-12-17 重新调整
|
/// 添加房间分享或者无区域分配 个数统计状态的RowLayout
|
/// </summary>
|
/// <param name="room">如果房间为空,代表管理无分配区域</param>
|
/// <param name="unallocatedList">管理无分配区域才有效</param>
|
/// <param name="globalSceneList">全局场景</param>
|
void ShowBaseRoomFunOrNoAreaFunRowLayout(Room mRoom, List<Function> unallocatedList, List<Scene> globalSceneList)
|
{
|
/// 房间所有功能和者场景列表
|
List<SpeakerTargetInfo> roomFunctionOrSceneList = new List<SpeakerTargetInfo>();
|
|
var roomView = new RowLayout()
|
{
|
Height = Application.GetRealWidth(50),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
LineColor = CSS_Color.MainBackgroundColor,
|
};
|
bodyScrolView.AddChidren(roomView);
|
|
var btnRoomName = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealWidth(10),
|
Width = Application.GetRealWidth(330),
|
Height = Application.GetRealWidth(30),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
//Text = room.roomName,
|
};
|
roomView.AddChidren(btnRoomName);
|
|
var btnRight = new Button()
|
{
|
X = Application.GetRealWidth(351),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage(16),
|
Height = Application.GetMinRealAverage(16),
|
UnSelectedImagePath = "Public/Right.png",
|
};
|
roomView.AddChidren(btnRight);
|
|
//如果房间为空,代表管理无分配区域
|
if (mRoom != null)
|
{
|
//显示房间名
|
btnRoomName.Text = mRoom.roomName;
|
var mRoomFunctionList = mRoom.GetRoomFunctions(false);
|
var mRoomSceneList = mRoom.GetRoomScenes(true);
|
//遍历所有功能列表
|
if (mRoomFunctionList != null)
|
{
|
foreach (var fun in mRoomFunctionList)
|
{
|
roomFunctionOrSceneList.Add(new SpeakerTargetInfo()
|
{
|
targetId = fun.deviceId,
|
targetName = fun.name,
|
isDevice = true
|
});
|
}
|
}
|
|
//遍历所有场景列表
|
if (mRoomSceneList != null)
|
{
|
foreach (var roomScene in mRoomSceneList)
|
{
|
roomFunctionOrSceneList.Add(new SpeakerTargetInfo()
|
{
|
targetId = roomScene.userSceneId,
|
targetName = roomScene.name,
|
isDevice = false
|
});
|
}
|
}
|
|
//roomId = mRoom.roomId;
|
//添加分割线
|
var lineView = new LineView(roomView.Height - Application.GetRealHeight(1));
|
roomView.AddChidren(lineView);
|
}
|
else
|
{
|
//显示无区域功能
|
btnRoomName.TextID = StringId.NoAreaFunction;
|
|
//遍历所有功能列表
|
if (unallocatedList != null)
|
{
|
foreach (var fun in unallocatedList)
|
{
|
roomFunctionOrSceneList.Add(new SpeakerTargetInfo()
|
{
|
targetId = fun.deviceId,
|
targetName = fun.name,
|
isDevice = true
|
});
|
}
|
}
|
|
//遍历所有场景列表
|
if (globalSceneList != null)
|
{
|
foreach (var roomScene in globalSceneList)
|
{
|
roomFunctionOrSceneList.Add(new SpeakerTargetInfo()
|
{
|
targetId = roomScene.userSceneId,
|
targetName = roomScene.name,
|
isDevice = false
|
});
|
}
|
}
|
}
|
|
|
//点击调整事件
|
EventHandler<MouseEventArgs> eHandler = (sender, e) =>
|
{
|
var page = new SmartSpeakerSelectDevicesPage(speakerInfo, roomFunctionOrSceneList);
|
MainPage.BasePageView.AddChidren(page);
|
page.LoadPage();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
};
|
roomView.MouseUpEventHandler = eHandler;
|
btnRoomName.MouseUpEventHandler = eHandler;
|
btnRight.MouseUpEventHandler = eHandler;
|
|
}
|
|
}
|
|
|
|
}
|