using System; using System.Collections.Generic; using System.Text; using ZigBee.Device; namespace Shared.Phone.UserCenter { /// /// 做成一个显示设备类型+设备MAC注名的RowLayout /// public class DeviceObjectViewRow : StatuRowLayout { /// /// 设备 /// public List listDevice = null; /// /// 图标控件 /// public RowLeftIconView btnIcon = null; /// /// 设备类型控件 /// public RowTopBlackView btnDeviceObject = null; /// /// 设备备注控件 /// public RowBottomGrayView btnDeviceName = null; /// /// 设备在线状态控件 /// public RowSecondRightTextView btnOnline = null; /// /// 做成一个显示设备类型+设备MAC注名的RowLayout /// /// 列表控件 /// 设备对象 public DeviceObjectViewRow(VerticalScrolViewLayout listView, List i_listdevice) { this.listDevice = i_listdevice; listView.AddChidren(this); //初始化内部控件 this.InitControl(); } /// /// 做成一个显示设备类型+设备MAC注名的RowLayout,加入父容器后,调用InitControl()执行初始化 /// /// 设备对象 public DeviceObjectViewRow(List i_listdevice) { this.listDevice = i_listdevice; } /// /// 初始化内部控件 /// 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); } /// /// 设置在线状态的特效 /// /// 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; } } /// /// 设置设备在线状态的缓存 /// /// private void SetDeviceMenmoryOnlineStatu(bool isOnline) { foreach (var device in this.listDevice) { device.IsOnline = isOnline == true ? 1 : 0; } } } }