using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.UserCenter
|
{
|
/// <summary>
|
/// 做成一个显示设备类型+设备MAC注名的RowLayout
|
/// </summary>
|
public class DeviceObjectViewRow : StatuRowLayout
|
{
|
/// <summary>
|
/// 设备
|
/// </summary>
|
public List<CommonDevice> listDevice = null;
|
/// <summary>
|
/// 图标控件
|
/// </summary>
|
public RowLeftIconView btnIcon = null;
|
/// <summary>
|
/// 设备类型控件
|
/// </summary>
|
public RowTopBlackView btnDeviceObject = null;
|
/// <summary>
|
/// 设备备注控件
|
/// </summary>
|
public RowBottomGrayView btnDeviceName = null;
|
/// <summary>
|
/// 设备在线状态控件
|
/// </summary>
|
public RowSecondRightTextView btnOnline = null;
|
|
/// <summary>
|
/// 做成一个显示设备类型+设备MAC注名的RowLayout
|
/// </summary>
|
/// <param name="listView">列表控件</param>
|
/// <param name="i_listdevice">设备对象</param>
|
public DeviceObjectViewRow(VerticalScrolViewLayout listView, List<CommonDevice> i_listdevice)
|
{
|
this.listDevice = i_listdevice;
|
|
listView.AddChidren(this);
|
//初始化内部控件
|
this.InitControl();
|
}
|
|
/// <summary>
|
/// 做成一个显示设备类型+设备MAC注名的RowLayout,加入父容器后,调用InitControl()执行初始化
|
/// </summary>
|
/// <param name="i_listdevice">设备对象</param>
|
public DeviceObjectViewRow(List<CommonDevice> i_listdevice)
|
{
|
this.listDevice = i_listdevice;
|
}
|
|
/// <summary>
|
/// 初始化内部控件
|
/// </summary>
|
public void InitControl()
|
{
|
//图标
|
btnIcon = new RowLeftIconView();
|
Common.LocalDevice.Current.SetDeviceBeloneIconToControl(btnIcon, listDevice);
|
this.AddChidren(btnIcon);
|
|
//设备类型
|
btnDeviceObject = new RowTopBlackView();
|
btnDeviceObject.Text = Common.LocalDevice.Current.GetDeviceObjectText(listDevice);
|
this.AddChidren(btnDeviceObject);
|
|
//设备
|
btnDeviceName = new RowBottomGrayView();
|
btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceMacName(listDevice[0]);
|
this.AddChidren(btnDeviceName);
|
|
//在线状态
|
this.btnOnline = new RowSecondRightTextView();
|
//设置在线状态的特效
|
this.SetOnlineStatu(listDevice[0].IsOnline == 1);
|
this.AddChidren(btnOnline, ChidrenBindMode.BindEventOnly);
|
}
|
|
/// <summary>
|
/// 设置在线状态的特效
|
/// </summary>
|
/// <param name="isOnline"></param>
|
public void SetOnlineStatu(bool isOnline)
|
{
|
//设置设备在线状态的缓存
|
this.SetDeviceMenmoryOnlineStatu(isOnline);
|
|
if (isOnline == false)
|
{
|
//初始值:离线
|
btnOnline.TextID = R.MyInternationalizationString.uOffLine;
|
//初始值:灰色
|
btnOnline.TextColor = UserCenterColor.Current.Gray;
|
}
|
else
|
{
|
//在线
|
btnOnline.TextID = R.MyInternationalizationString.uOnline;
|
//绿色
|
btnOnline.TextColor = UserCenterColor.Current.Green;
|
}
|
}
|
|
/// <summary>
|
/// 设置设备在线状态的缓存
|
/// </summary>
|
/// <param name="isOnline"></param>
|
private void SetDeviceMenmoryOnlineStatu(bool isOnline)
|
{
|
foreach (var device in this.listDevice)
|
{
|
device.IsOnline = isOnline == true ? 1 : 0;
|
}
|
}
|
}
|
}
|