黄学彪
2020-09-22 ade5917841b0fdcb1df7353ef7c56b1a1bdc9282
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
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.Residence
{
    /// <summary>
    /// 房间设备一览界面
    /// </summary>
    public class LookRoomDeviceListForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="titleName">标题</param>
        /// <param name="detailTile">明细标题</param>
        /// <param name="listDevice">设备列表(主键)</param>
        public void ShowForm(string titleName, string detailTile, List<string> listDevice)
        {
            //设置头部信息
            base.SetTitleText(titleName);
 
            //初始化中部信息
            this.InitMiddleFrame(detailTile, listDevice);
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame(string detailTile, List<string> listDevice)
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            var frameTitle = new FrameLayout();
            frameTitle.BackgroundColor = UserCenterColor.Current.White;
            frameTitle.Height = Application.GetRealHeight(115);
            bodyFrameLayout.AddChidren(frameTitle);
            var btnTitle = new NormalViewControl(800, 60, true);
            btnTitle.Y = Application.GetRealHeight(49);
            btnTitle.X = ControlCommonResourse.XXLeft;
            btnTitle.TextSize = 15;
            btnTitle.TextColor = UserCenterColor.Current.TextColor2;
            btnTitle.Text = detailTile;
            frameTitle.AddChidren(btnTitle);
 
            var listView = new VerticalListControl(23);
            listView.Y = frameTitle.Bottom;
            listView.Height = bodyFrameLayout.Height - frameTitle.Height;
            listView.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(listView);
 
            HdlThreadLogic.Current.RunMainInThread(() =>
            {
                for (int i = 0; i < listDevice.Count; i++)
                {
                    //获取设备
                    var device = Common.LocalDevice.Current.GetDevice(listDevice[i]);
                    if (device == null)
                    {
                        continue;
                    }
                    //添加设备行
                    this.AddDeviceRow(listView, device, i != listDevice.Count - 1);
                }
                listView.AdjustRealHeight(Application.GetRealHeight(23));
            });
        }
 
        #endregion
 
        #region ■ 添加设备行_________________________
 
        /// <summary>
        /// 添加设备行
        /// </summary>
        /// <param name="listView"></param>
        /// <param name="device"></param>
        /// <param name="addLine"></param>
        private void AddDeviceRow(VerticalListControl listView, CommonDevice device, bool addLine)
        {
            var frameRow = new FrameRowControl(listView.rowSpace / 2);
            frameRow.UseClickStatu = false;
            listView.AddChidren(frameRow);
            //图标
            var btnIcon = frameRow.AddLeftIcon(81);
            Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device);
            //设备名字
            var btnName = frameRow.AddLeftCaption(Common.LocalDevice.Current.GetDeviceEpointName(device), 700);
            btnName.TextSize = 15;
            if (Common.LocalDevice.Current.CheckDeviceIsOnline(device) == false)
            {
                btnName.TextColor = UserCenterColor.Current.TextGrayColor1;
            }
            //底线
            if (addLine == true)
            {
                frameRow.AddBottomLine();
            }
        }
 
        #endregion
    }
}