using System;
using System.Collections.Generic;
using System.Text;
namespace Shared.Phone.UserCenter
{
///
/// 安防记录的行控件
///
public class SafeguardLogRowView : FrameLayout
{
///
/// 安防记录
///
private SafeguardAlarmInfo safeInfo = null;
///
/// 安防记录的行控件
///
/// 容器控件(可以为null,此时请调用InitControl函数)
/// 安防记录
public SafeguardLogRowView(SpecialFrameLayout frame, SafeguardAlarmInfo i_info)
{
this.safeInfo = i_info;
if (i_info.AlarmType == SafeguardAlarmType.Sensor)
{
this.Height = ControlCommonResourse.NormalControlHeight * 3;
}
else if(i_info.AlarmType == SafeguardAlarmType.Safeguard)
{
this.Height = ControlCommonResourse.NormalControlHeight + Application.GetRealHeight(10);
}
if (frame != null)
{
var view = frame.GetChildren(frame.ChildrenCount - 1);
if (view != null)
{
this.Y = view.Bottom;
}
frame.AddChidren(this);
//初始化控件
this.InitControl();
}
}
///
/// 初始化控件
///
public void InitControl()
{
if (this.safeInfo.AlarmType == SafeguardAlarmType.Safeguard)
{
//初始化布防撤防模式的控件
this.InitControlBySafeguardAlarm();
}
else if (this.safeInfo.AlarmType == SafeguardAlarmType.Sensor)
{
//初始化传感器上报模式的控件
this.InitControlBySensorAlarm();
}
}
///
/// 初始化布防撤防模式的控件
///
private void InitControlBySafeguardAlarm()
{
//防区
var btnSafeguard = new RowCenterView(false);
btnSafeguard.Text = this.safeInfo.AlarmMsg;
this.AddChidren(btnSafeguard);
//时间:时分秒
var btnTime = new RowMostRightTextView();
btnTime.Text = this.safeInfo.Time;
this.AddChidren(btnTime);
}
///
/// 初始化传感器上报模式的控件
///
private void InitControlBySensorAlarm()
{
//防区名字
var btnGarrison = new RowTopBlackView(false);
btnGarrison.TextSize = 16;
btnGarrison.Text = Common.LocalSafeguard.Current.GetGarrisonText(this.safeInfo.ZoneId);
this.AddChidren(btnGarrison);
btnGarrison.ReSetYaxis(UViewAlignment.Top);
//时间:时分秒
var btnTime = new RowMostRightTextView();
btnTime.Text = this.safeInfo.Time;
this.AddChidren(btnTime);
btnTime.ReSetYaxis(UViewAlignment.Top);
//设备
var btnDevice = new RowCenterView(false);
string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(this.safeInfo.DeviceAddr, this.safeInfo.DeviceEpoint);
var device = Common.LocalDevice.Current.GetDevice(mainkeys);
if (device == null)
{
//使用预备名字
btnDevice.Text = this.safeInfo.DeviceName;
}
else
{
//使用当前的设备名字
btnDevice.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
//房间名字
btnDevice.Text += "(" + this.safeInfo.RoomName + ")";
}
this.AddChidren(btnDevice);
//报警信息
var btnMsg = new RowBottomBlackView(false);
btnMsg.Text = this.safeInfo.AlarmMsg;
this.AddChidren(btnMsg);
btnMsg.ReSetYaxis(UViewAlignment.Bottom);
//电池电量
if (this.safeInfo.BatteryMsg != null)
{
var btnBattery = new RowMostRightTextView();
btnBattery.Text = this.safeInfo.BatteryMsg;
this.AddChidren(btnBattery);
}
//被拆报警
if (this.safeInfo.DemolishmentMsg != null)
{
var btnDemolishment = new RowMostRightTextView();
btnDemolishment.Text = this.safeInfo.DemolishmentMsg;
this.AddChidren(btnDemolishment);
btnDemolishment.ReSetYaxis(UViewAlignment.Bottom);
}
}
}
}