黄学彪
2019-12-05 b3e96fce4cc01113128ddf8e0a18fc19594a9e56
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
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.HideOption
{
    /// <summary>
    /// 隐匿功能的网关列表界面
    /// </summary>
    public class HideOptionGatewayListForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalListControl listview = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_GatewayDiv">网关区分,1:本地网关 2:广播搜到的网关</param>
        public void ShowForm(int i_GatewayDiv)
        {
            if (i_GatewayDiv == 1)
            {
                //设置标题信息
                base.SetTitleText("本地网关");
            }
            else
            {
                //设置标题信息
                base.SetTitleText("广播搜到的网关");
            }
 
            //初始化中部控件
            this.InitMiddleFrame(i_GatewayDiv);
        }
 
        /// <summary>
        /// 初始化中部控件
        /// </summary>
        private void InitMiddleFrame(int i_GatewayDiv)
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            listview = new VerticalListControl(29);
            listview.Height = bodyFrameLayout.Height;
            listview.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(listview);
 
            HdlThreadLogic.Current.RunMainInThread(() =>
            {
                //设定中部信息
                this.SetMiddleFrameInfo(i_GatewayDiv);
            });
        }
 
        /// <summary>
        /// 设定中部信息
        /// </summary>
        private void SetMiddleFrameInfo(int i_GatewayDiv)
        {
            List<ZbGateway> listway = null;
            if (i_GatewayDiv == 1)
            {
                //获取本地全部网关对象
                listway = HdlGatewayLogic.Current.GetAllLocalGateway();
            }
            else
            {
                listway = ZbGateway.GateWayList;
            }
            for (int i = 0; i < listway.Count; i++)
            {
                //添加行
                this.AddRowLayout(listway[i], i != listway.Count - 1);
            }
 
            //调整列表控件的高度
            this.listview.AdjustRealHeight(Application.GetRealHeight(23));
        }
 
        #endregion
 
        #region ■ 添加网关行_________________________
 
        /// <summary>
        /// 添加行
        /// </summary>
        /// <param name="i_gateway">i_gateway</param>
        /// <param name="addLine">是否添加底线</param>
        private void AddRowLayout(ZbGateway i_gateway, bool addLine)
        {
            //网关控件
            var gatewayRow = new GatewayRowControl(i_gateway, listview.rowSpace / 2);
            listview.AddChidren(gatewayRow);
            gatewayRow.InitControl(81);
            if (addLine == true)
            {
                gatewayRow.frameTable.AddBottomLine();
            }
 
            //定位
            var btnPosition = new NormalViewControl(Application.GetRealWidth(184), gatewayRow.Height, false);
            btnPosition.BackgroundColor = 0xff4a4a4a;
            btnPosition.TextAlignment = TextAlignment.Center;
            btnPosition.TextColor = UserCenterColor.Current.White;
            btnPosition.TextSize = 12;
            btnPosition.TextID = R.MyInternationalizationString.uFixedPosition;
            gatewayRow.AddRightView(btnPosition);
            btnPosition.ButtonClickEvent += (sender, e) =>
            {
                //发送定位命令
                HdlGatewayLogic.Current.SetFixedPositionCommand(i_gateway);
            };
        }
 
        #endregion
    }
}