黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
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
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:缓存中的网关 3:广播搜到的网关</param>
        public void ShowForm(int i_GatewayDiv)
        {
            if (i_GatewayDiv == 1)
            {
                //设置标题信息
                base.SetTitleText("本地网关");
            }
            else if (i_GatewayDiv == 2)
            {
                //设置标题信息
                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 if (i_GatewayDiv == 2)
            {
                listway = ZbGateway.GateWayList;
            }
            else
            {
                listway = new List<ZbGateway>();
                foreach (var way in HdlGatewayResourse.DicReceiveGatewayTest.Values)
                {
                    listway.Add(way);
                }
            }
            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 btnLink = new NormalViewControl(Application.GetRealWidth(700), gatewayRow.btnIp.Height, false);
            btnLink.TextSize = 12;
            btnLink.X = gatewayRow.btnIp.Right;
            btnLink.Y = gatewayRow.btnIp.Y;
            btnLink.Text = "本地连接:" + i_gateway.LocalIsConnected.ToString();
            gatewayRow.frameTable.AddChidren(btnLink);
 
            //定位
            var btnPosition = gatewayRow.AddEditorControl(false);
            btnPosition.TextID = R.MyInternationalizationString.uFixedPosition;
            btnPosition.ButtonClickEvent += (sender, e) =>
            {
                //发送定位命令
                HdlGatewayLogic.Current.SetFixedPositionCommand(i_gateway);
            };
            gatewayRow.frameTable.ButtonClickEvent += (sender, e) =>
            {
                var form = new HideOptionGatewayInfoMenuForm();
                form.AddForm(i_gateway);
            };
        }
 
        #endregion
    }
}