xm
2019-07-16 b910cb79c9b5bcc204022a3cf9e6950f0a64dfbd
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
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;
            }
        }
    }
}