using Shared;
using HDL_ON.Stan;
using System;
using System.Collections.Generic;
using System.Text;
using HDL_ON.UI.CSS;
using HDL_ON.Entity;
namespace HDL_ON.UI
{
///
/// 门锁列表界面(有多个门锁的时候,才会显示的界面)
///
public class DoorLockListPage : EditorCommonForm
{
#region ■ 变量声明___________________________
///
/// 门锁设备列表
///
private List listDevice = new List();
///
/// 电池控件列表(key:设备的sid)
///
private Dictionary dicBatteryContr = new Dictionary();
///
/// 列表控件
///
private VerticalListControl listView = null;
#endregion
#region ■ 初始化_____________________________
///
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
///
/// 门锁设备列表
public void ShowForm(List i_listDevice)
{
this.listDevice.AddRange(i_listDevice);
//智能门锁
base.SetTitleText(Language.StringByID(StringId.DoorLock));
//初始化头部历史记录控件
this.InitTopHistoryControl();
//初始化中部信息
this.InitMiddleFrame();
}
///
/// 初始化中部信息
///
private void InitMiddleFrame()
{
//清空bodyFrame
this.ClearBodyFrame();
string nowSelectId = string.Empty;
//楼层下拉图标
var btnFloor = new NormalViewControl(100, Application.GetRealHeight(16), false);
var btnFloorIcon = new IconViewControl(16);
btnFloorIcon.X = HdlControlResourse.XXLeft;
btnFloorIcon.Y = Application.GetRealHeight(18);
btnFloorIcon.UnSelectedImagePath = "Public/DownIcon.png";
bodyFrameLayout.AddChidren(btnFloorIcon);
btnFloorIcon.ButtonClickEvent += (sender, e) =>
{
//显示下拉列表
var form = new FloorRoomSelectPopupView();
form.ShowDeviceFunctionView(btnFloor, this.listDevice, (selectId, listFunc) =>
{
nowSelectId = selectId;
//重新初始化门锁列表控件
this.InitDoorListControl(listFunc);
}, nowSelectId);
};
//楼层
btnFloor.X = btnFloorIcon.Right + Application.GetRealWidth(2);
btnFloor.TextColor = CSS_Color.FirstLevelTitleColor;
btnFloor.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
btnFloor.Text = DB_ResidenceData.Instance.CurFloor.roomName;
btnFloor.Width = btnFloor.GetRealWidthByText();
bodyFrameLayout.AddChidren(btnFloor);
//让它相对图标居中
btnFloor.Y = btnFloorIcon.Y + (btnFloorIcon.Height - btnFloor.Height) / 2;
btnFloor.ButtonClickEvent += (sender, e) =>
{
btnFloorIcon.ButtonClickEvent(null, null);
};
//列表控件
this.listView = new VerticalListControl();
listView.Y = Application.GetRealHeight(53);
listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(53);
bodyFrameLayout.AddChidren(listView);
//初始化门锁列表控件
this.InitDoorListControl(this.listDevice);
}
#endregion
#region ■ 添加门锁控件_______________________
///
/// 初始化门锁列表控件
///
private void InitDoorListControl(List i_listDevice)
{
this.listView.RemoveAll();
this.dicBatteryContr = new Dictionary();
//生成门锁控件
foreach (var device in i_listDevice)
{
this.AddDoorControl(device);
}
}
///
/// 添加门锁控件
///
/// 门锁对象
private void AddDoorControl(Function i_device)
{
//白色背景容器
var frameBack = new FrameLayoutStatuControl();
frameBack.Width = Application.GetRealWidth(343);
frameBack.Height = Application.GetRealHeight(96);
frameBack.Radius = (uint)Application.GetRealWidth(12);
frameBack.Gravity = Gravity.CenterHorizontal;
frameBack.BackgroundColor = CSS_Color.MainBackgroundColor;
this.listView.AddChidren(frameBack);
//门锁图标
var btnIcon = new IconViewControl(32);
btnIcon.X = Application.GetRealWidth(10);
btnIcon.Y = Application.GetRealHeight(15);
btnIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/DoorLock.png";
frameBack.AddChidren(btnIcon, ChidrenBindMode.BindEvent);
//设备名字
var btnName = new Button();
btnName.X = btnIcon.Right + Application.GetRealWidth(12);
btnName.Y = Application.GetRealHeight(12);
btnName.Width = Application.GetRealWidth(150);
btnName.Height = Application.GetRealHeight(20);
btnName.TextColor = CSS_Color.FirstLevelTitleColor;
btnName.TextAlignment = TextAlignment.CenterLeft;
btnName.Text = i_device.name;
frameBack.AddChidren(btnName, ChidrenBindMode.BindEvent);
//房间
var btnRoom = new Button();
btnRoom.X = btnName.X;
btnRoom.Y = btnName.Bottom + Application.GetRealHeight(4);
btnRoom.Width = Application.GetRealWidth(150);
btnRoom.Height = Application.GetRealHeight(15);
btnRoom.TextColor = CSS_Color.PromptingColor1;
btnRoom.TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel;
btnRoom.TextAlignment = TextAlignment.CenterLeft;
btnRoom.Text = i_device.GetRoomListName();
frameBack.AddChidren(btnRoom, ChidrenBindMode.BindEvent);
//电池图标
var btnBattery = new BatteryPersentControl();
btnBattery.Y = Application.GetRealHeight(62);
frameBack.AddChidren(btnBattery, ChidrenBindMode.BindEvent);
btnBattery.InitControl();
btnBattery.SetValue(80);
btnBattery.X = frameBack.Width - btnBattery.Width - Application.GetRealWidth(12);
this.dicBatteryContr[i_device.sid] = btnBattery;
frameBack.ButtonClickEvent += (sender, e) =>
{
var form = new DoorLockPage();
form.AddForm(i_device, new Button(), btnName, btnRoom);
};
//底部再加个间距
var frameSpace = new FrameLayout();
frameSpace.Height = Application.GetRealHeight(12);
this.listView.AddChidren(frameSpace);
}
#endregion
#region ■ 初始化头部历史记录图标_____________
///
/// 初始化头部历史记录控件
///
private void InitTopHistoryControl()
{
//历史记录图标
var btnIcon = new IconViewControl(28);
btnIcon.X = Application.GetRealWidth(337);
btnIcon.Y = Application.GetRealHeight(9);
btnIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/History.png";
topFrameLayout.AddChidren(btnIcon);
btnIcon.ButtonClickEvent += (sender, e) =>
{
var form = new DoorLockHistoryInfoPage();
form.AddForm(this.listDevice);
};
}
#endregion
#region ■ 设备状态推送_______________________
///
/// 设备状态推送
///
///
public override void DeviceStatuPush(Function i_LocalDevice)
{
//不是目标设备
if (this.dicBatteryContr.ContainsKey(i_LocalDevice.sid) == false)
{
return;
}
}
#endregion
#region ■ 一般方法___________________________
#endregion
}
}