New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.UserCenter |
| | | { |
| | | /// <summary> |
| | | /// 做成一个显示设备回路+房间的RowLayout |
| | | /// </summary> |
| | | public class DeviceRoomControl : RowLayoutControl |
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// 设备主键 |
| | | /// </summary> |
| | | private string mainKey = string.Empty; |
| | | /// <summary> |
| | | /// 设备对象 |
| | | /// </summary> |
| | | public CommonDevice device |
| | | { |
| | | get { return Common.LocalDevice.Current.GetDevice(mainKey); } |
| | | } |
| | | /// <summary> |
| | | /// 在线状态 |
| | | /// </summary> |
| | | private bool m_isOnline = true; |
| | | /// <summary> |
| | | /// 在线状态 |
| | | /// </summary> |
| | | public bool IsOnline |
| | | { |
| | | get { return m_isOnline; } |
| | | set |
| | | { |
| | | if (m_isOnline != value) |
| | | { |
| | | m_isOnline = value; |
| | | //设置在线状态的特效 |
| | | this.SetOnlineStatu(m_isOnline); |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 图标控件 |
| | | /// </summary> |
| | | public IconViewControl btnIcon = null; |
| | | /// <summary> |
| | | /// 设备控件 |
| | | /// </summary> |
| | | public NormalViewControl btnDevie = null; |
| | | /// <summary> |
| | | /// 房间控件 |
| | | /// </summary> |
| | | public NormalViewControl btnRoom = null; |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化_____________________________ |
| | | |
| | | /// <summary> |
| | | /// 做成一个显示设备回路+房间的RowLayout |
| | | /// </summary> |
| | | /// <param name="i_device">设备对象</param> |
| | | /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可)</param> |
| | | public DeviceRoomControl(CommonDevice i_device, int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis) |
| | | { |
| | | this.mainKey = Common.LocalDevice.Current.GetDeviceMainKeys(i_device); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 做成一个显示设备回路+房间的RowLayout |
| | | /// </summary> |
| | | /// <param name="deviceMac">设备Mac地址</param> |
| | | /// <param name="deviceEpoint">设备端口</param> |
| | | /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(真实值,有些界面需要这种特殊操作)</param> |
| | | public DeviceRoomControl(string deviceMac, int deviceEpoint, int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis) |
| | | { |
| | | this.mainKey = Common.LocalDevice.Current.GetDeviceMainKeys(deviceMac, deviceEpoint); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化内部控件 |
| | | /// </summary> |
| | | 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 ■ 刷新信息___________________________ |
| | | |
| | | /// <summary> |
| | | /// 刷新全部显示信息 |
| | | /// </summary> |
| | | /// <param name="i_device"></param> |
| | | 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 ■ 一般方法___________________________ |
| | | |
| | | /// <summary> |
| | | /// 设置在线状态的特效 |
| | | /// </summary> |
| | | /// <param name="i_isOnline"></param> |
| | | private void SetOnlineStatu(bool i_isOnline) |
| | | { |
| | | if (i_isOnline == false) |
| | | { |
| | | btnDevie.TextColor = UserCenterColor.Current.TextGrayColor1; |
| | | } |
| | | else |
| | | { |
| | | btnDevie.TextColor = UserCenterColor.Current.TextColor1; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |