using System;
using Shared;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using System.Collections.Generic;
using HDL_ON.DAL;
using HDL_ON.DAL.Server;
namespace HDL_ON.UI
{
public partial class MemberFunctionPermissionPage : FrameLayout
{
MemberFunctionPermissionPage bodyView;
FrameLayout allRoomView;
///
/// 全选按钮
///
Button btnChooseAll;
///
/// 功能显示区域
///
VerticalScrolViewLayout contentView;
///
/// 底部操作按钮
///
Button btnOption;
///
/// 页面标题ID
///
int titleId;
ResidenceMemberInfo memberInfo;
///
/// 当前的房间roomId
/// 如果为空,则代表管理无分配区域的功能分享
///
string roomId;
///
/// 房间所有功能和场景列表
///
List roomFunctionOrSceneList = new List();
///
/// 刷新回调Action
///
Action refreshAction;
///
/// 当前账号的所有分享列表
///
List curResidenceShareData;
///
/// 属于当前房间最终的设备分享列表
///
List funs_RoomAll;
//shareDataList = new List();
///
/// 删除的分享列表
///
List funs_Del;
///
///
///
///
/// 房间所有功能和场景列表
///
///
public MemberFunctionPermissionPage(ResidenceMemberInfo mInfo, List roomFunctionOrSceneList, List funs_RoomAll, string roomId, Action refreshAction)
{
bodyView = this;
this.memberInfo = mInfo;
this.roomFunctionOrSceneList = roomFunctionOrSceneList;
this.roomId = roomId;
//this.curResidenceShareData = new List();
this.curResidenceShareData = memberInfo.CurResidenceShareData;
this.funs_RoomAll = new List();
this.funs_RoomAll.AddRange(funs_RoomAll);
this.funs_Del = new List();
this.refreshAction = refreshAction;
}
public void LoadPage(int tId)
{
titleId = tId;
new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView();
allRoomView = new FrameLayout()
{
Y = Application.GetRealHeight(64),
Height = Application.GetRealHeight(50),
BackgroundColor = CSS_Color.MainBackgroundColor,
};
bodyView.AddChidren(allRoomView);
Button btnAllRoomText = new Button()
{
X = Application.GetRealWidth(16),
Width = Application.GetRealWidth(280),
TextID = StringId.SelectedAll,
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.FirstLevelTitleColor,
TextAlignment = TextAlignment.CenterLeft,
};
allRoomView.AddChidren(btnAllRoomText);
btnChooseAll = new Button()
{
X = Application.GetRealWidth(331),
Gravity = Gravity.CenterVertical,
Width = Application.GetMinRealAverage(28),
Height = Application.GetMinRealAverage(28),
UnSelectedImagePath = "Public/ChooseIcon.png",
SelectedImagePath = "Public/ChooseOnIcon.png",
IsSelected = true,
};
allRoomView.AddChidren(btnChooseAll);
allRoomView.AddChidren(new Button()
{
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight(49),
Height = Application.GetMinReal(1),
Width = Application.GetRealWidth(343),
BackgroundColor = CSS_Color.DividingLineColor,
});
contentView = new VerticalScrolViewLayout()
{
Y = Application.GetRealHeight(64+50),
Height = Application.GetRealHeight(450),
};
bodyView.AddChidren(contentView);
btnOption = new Button()
{
Y = Application.GetRealHeight(519 + 64),
Gravity = Gravity.CenterHorizontal,
Width = Application.GetRealWidth(220),
Height = Application.GetRealWidth(44),
BackgroundColor = CSS_Color.MainColor,
TextAlignment = TextAlignment.Center,
TextColor = CSS_Color.MainBackgroundColor,
TextID = titleId == StringId.MemberPermissionManagement ? StringId.Confirm : StringId.Shared,
TextSize = CSS_FontSize.SubheadingFontSize,
IsBold = true,
Radius = (uint)Application.GetRealWidth(22),
BorderColor = 0x00000000,
BorderWidth = 0,
};
bodyView.AddChidren(btnOption);
LoadFunctionRow(funs_RoomAll);
LoadEventList();
}
///
/// 加载功能列表
///
void LoadFunctionRow(List shareDatas)
{
contentView.RemoveAll();
foreach (var roomData in roomFunctionOrSceneList)
{
var roomView = new FrameLayout()
{
Height = Application.GetRealHeight(50),
BackgroundColor = CSS_Color.MainBackgroundColor,
Tag = "row"
};
contentView.AddChidren(roomView);
Button btnRoomText = new Button()
{
X = Application.GetRealWidth(16),
Width = Application.GetRealWidth(280),
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.FirstLevelTitleColor,
TextAlignment = TextAlignment.CenterLeft,
Text = roomData.name,
};
roomView.AddChidren(btnRoomText);
Button btnChoose = new Button()
{
X = Application.GetRealWidth(331),
Gravity = Gravity.CenterVertical,
Width = Application.GetMinRealAverage(28),
Height = Application.GetMinRealAverage(28),
UnSelectedImagePath = "Public/ChooseIcon.png",
SelectedImagePath = "Public/ChooseOnIcon.png",
Tag = "ChooseIcon"
};
roomView.AddChidren(btnChoose);
var shareData = shareDatas.Find((obj) => obj.shareTypeId == roomData.shareTypeId);
if (shareData != null)
{
btnChoose.IsSelected = true;
//刷新属于当前房间的分享统计
//funs_New.Add(shareData);
}
else
{
if (btnChooseAll.IsSelected)
btnChooseAll.IsSelected = false;
}
LoadMethod_SharedDataChange(btnChoose, btnRoomText, roomView, roomData);
var btnLine = new Button()
{
Gravity = Gravity.CenterHorizontal,
//Y = Application.GetRealHeight(49),
Height = Application.GetRealHeight(1),
Width = Application.GetRealWidth(343),
BackgroundColor = CSS_Color.DividingLineColor,
};
contentView.AddChidren(btnLine);
}
}
}
///
/// 房间所有功能和者场景列表
///
public class RoomData
{
///
/// 设备名字或者场景名字
///
public string shareTypeId;
///
/// 设备名字或者场景名字
///
public string name;
///
/// 分享类型 1.ROOM 2.DEVICE 3.SCENE
///
public string shareType = ShareType.DEVICE.ToString();
}
}