using System; using System.Collections.Generic; using System.Text; using ZigBee.Device; namespace Shared.Phone.UserCenter { /// /// 做成一个显示设备回路+房间的RowLayout /// public class DeviceRoomControl : RowLayoutControl { #region ■ 变量声明___________________________ /// /// 设备主键 /// private string mainKey = string.Empty; /// /// 设备对象 /// public CommonDevice device { get { return Common.LocalDevice.Current.GetDevice(mainKey); } } /// /// 在线状态 /// private bool m_isOnline = true; /// /// 在线状态 /// public bool IsOnline { get { return m_isOnline; } set { if (m_isOnline != value) { m_isOnline = value; //设置在线状态的特效 this.SetOnlineStatu(m_isOnline); } } } /// /// 图标控件 /// public IconViewControl btnIcon = null; /// /// 设备控件 /// public NormalViewControl btnDevie = null; /// /// 房间控件 /// public NormalViewControl btnRoom = null; #endregion #region ■ 初始化_____________________________ /// /// 做成一个显示设备回路+房间的RowLayout /// /// 设备对象 /// 子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可) public DeviceRoomControl(CommonDevice i_device, int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis) { this.mainKey = Common.LocalDevice.Current.GetDeviceMainKeys(i_device); } /// /// 做成一个显示设备回路+房间的RowLayout /// /// 设备Mac地址 /// 设备端口 /// 子控件Y轴偏移量(真实值,有些界面需要这种特殊操作) public DeviceRoomControl(string deviceMac, int deviceEpoint, int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis) { this.mainKey = Common.LocalDevice.Current.GetDeviceMainKeys(deviceMac, deviceEpoint); } /// /// 初始化内部控件 /// public void InitControl() { var tempDevice = device; //图标 btnIcon = frameTable.AddLeftIcon(); Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, tempDevice); //设备 btnDevie = frameTable.AddLeftCaption("", 600, 60); btnDevie.TextSize = 15; //这个坐标有点特殊 btnDevie.Y = Application.GetRealHeight(12) + this.chidrenYaxis; frameTable.AddChidren(btnDevie, ChidrenBindMode.BindEvent); if (tempDevice != null) { btnDevie.Text = Common.LocalDevice.Current.GetDeviceEpointName(tempDevice); } else { //无法识别的设备 btnDevie.Text = Language.StringByID(R.MyInternationalizationString.uUnDistinguishTheDevice); btnDevie.TextColor = 0xfff62f48; } //房间 btnRoom = frameTable.AddLeftCaption("", 600, 50, true); //这个坐标有点特殊 btnRoom.Y = Application.GetRealHeight(72) + this.chidrenYaxis; btnRoom.TextSize = 12; btnRoom.TextColor = UserCenterColor.Current.TextGrayColor1; frameTable.AddChidren(btnRoom, ChidrenBindMode.BindEvent); if (tempDevice != null) { btnRoom.Text = HdlRoomLogic.Current.GetRoomNameByDevice(tempDevice); } else { //未分配区域 btnRoom.Text = Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom); btnRoom.TextColor = 0xfff62f48; } } #endregion #region ■ 刷新信息___________________________ /// /// 刷新全部显示信息 /// /// public void RefreshControlInfo() { var tempDevice = device; if (tempDevice == null) { return; } btnDevie.Text = Common.LocalDevice.Current.GetDeviceEpointName(tempDevice); btnRoom.Text = HdlRoomLogic.Current.GetRoomNameByDevice(tempDevice); string unSelectPath = string.Empty; string selectPath = string.Empty; Common.LocalDevice.Current.GetDeviceIcon(tempDevice, ref unSelectPath, ref selectPath); btnIcon.UnSelectedImagePath = unSelectPath; } #endregion #region ■ 一般方法___________________________ /// /// 设置在线状态的特效 /// /// private void SetOnlineStatu(bool i_isOnline) { if (i_isOnline == false) { btnDevie.TextColor = UserCenterColor.Current.TextGrayColor1; } else { btnDevie.TextColor = UserCenterColor.Current.TextColor1; } } #endregion } }