黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
 
namespace Shared.Phone
{
    /// <summary>
    /// 做成一个显示设备回路+房间的RowLayout
    /// </summary>
    public class DeviceRoomControl : RowLayoutControl
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 设备主键
        /// </summary>
        private string mainKey = string.Empty;
        /// <summary>
        /// 设备对象
        /// </summary>
        public CommonDevice device
        {
            get { return HdlDeviceCommonLogic.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 = HdlDeviceCommonLogic.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 = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(deviceMac, deviceEpoint);
        }
 
        /// <summary>
        /// 初始化内部控件
        /// </summary>
        public void InitControl()
        {
            var tempDevice = device;
            //图标
            btnIcon = frameTable.AddLeftIcon();
            HdlDeviceCommonLogic.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 = HdlDeviceCommonLogic.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 = HdlDeviceCommonLogic.Current.GetDeviceEpointName(tempDevice);
            btnRoom.Text = HdlRoomLogic.Current.GetRoomNameByDevice(tempDevice);
 
            string unSelectPath = string.Empty;
            string selectPath = string.Empty;
            HdlDeviceCommonLogic.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
    }
}