using System;
using System.Collections.Generic;
using HDL_ON.Entity;
using HDL_ON.Stan;
using HDL_ON.UI.CSS;
using HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock;
using Shared;
namespace HDL_ON.UI.UI2.FuntionControlView.Aks
{
///
/// 影音中控列表界面
///
public class AksListPage : EditorCommonForm
{
#region ■ 变量声明___________________________
///
/// 影音中控设备列表
///
private List listDevice = new List();
///
/// 电池控件列表(key:设备的sid)
///
private Dictionary dicBatteryContr = new Dictionary();
///
/// 列表控件
///
private VerticalListControl listView = null;
///
/// 删除设备后需要更新界面的回调
///
public Action action;
#endregion
#region ■ 初始化_____________________________
public AksListPage(Action action)
{
this.action = action;
}
///
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
///
/// 门锁设备列表
public void ShowForm(List i_listDevice)
{
this.listDevice.AddRange(i_listDevice);
//家庭影院
base.SetTitleText(Language.StringByID(StringId.jiatingyingyuan));
//初始化中部信息
this.InitMiddleFrame();
}
///
/// 初始化中部信息
///
private void InitMiddleFrame()
{
//清空bodyFrame
this.ClearBodyFrame();
string nowSelectId = string.Empty;
//楼层下拉图标
var btnFloor = new NormalViewControl(500, 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) =>
{
btnFloor.Width = btnFloor.GetRealWidthByText();//重置文本宽度
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 = "AksIcon/yingyinzhongkong2.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;
btnName.TextSize = CSS_FontSize.TextFontSize;
frameBack.AddChidren(btnName, ChidrenBindMode.BindEvent);
var btnCollection = new Button()
{
X = Application.GetRealWidth(299),
Y = Application.GetRealHeight(10),
Width = Application.GetRealWidth(40),
Height = Application.GetRealWidth(40),
SelectedImagePath = "Collection/CollectionIcon.png",
UnSelectedImagePath = "Collection/CollectionGrayIcon.png",
IsSelected = i_device.collect
};
frameBack.AddChidren(btnCollection, 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;
EventHandler CommonClick = (sender, e) =>
{
var form = new AksPage(i_device, btnName, btnRoom, CommonMethod.Comerom.function, () =>
{
this.CloseForm();
this.action?.Invoke();
});
MainPage.BasePageView.AddChidren(form);
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
form.Show();
};
frameBack.MouseUpEventHandler += CommonClick;
btnIcon.MouseUpEventHandler += CommonClick;
btnName.MouseUpEventHandler += CommonClick;
btnRoom.MouseUpEventHandler += CommonClick;
//收藏
btnCollection.MouseUpEventHandler += (sender, e) =>
{
btnCollection.IsSelected = i_device.collect = !btnCollection.IsSelected;
i_device.CollectFunction();
};
//底部再加个间距
var frameSpace = new FrameLayout();
frameSpace.Height = Application.GetRealHeight(12);
this.listView.AddChidren(frameSpace);
}
#endregion
#region ■ 设备状态推送_______________________
///
/// 设备状态推送
///
///
public override void DeviceStatuPush(Function i_LocalDevice)
{
//不是目标设备
if (this.dicBatteryContr.ContainsKey(i_LocalDevice.sid) == false)
{
return;
}
}
#endregion
}
}