黄学彪
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
177
178
179
180
181
182
183
184
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.Gateway
{
    /// <summary>
    /// 网关替换界面
    /// </summary>
    public class GatewayReplaceForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 当前网关对象
        /// </summary>
        private ZbGateway nowZbGateway = null;
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalListControl listView = null;
        /// <summary>
        /// 确认按钮
        /// </summary>
        private BottomClickButton btnConfirm = null;
        /// <summary>
        /// 当前选择的状态控件 MainKey是网关ID
        /// </summary>
        private MostRightIconControl btnSelectIcon = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_zbGateway">当前网关对象</param>
        public void ShowForm(ZbGateway i_zbGateway)
        {
            this.nowZbGateway = i_zbGateway;
 
            //设置标题信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uReplaceGateway));
 
            //初始化中部控件
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部控件
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            //确定按钮
            this.btnConfirm = new BottomClickButton();
            btnConfirm.TextID = R.MyInternationalizationString.uConfirm1;
            btnConfirm.oldBackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
            bodyFrameLayout.AddChidren(btnConfirm);
            btnConfirm.CanClick = false;
            btnConfirm.ButtonClickEvent += (sender, e) =>
            {
                //执行网关替换操作
                this.DoReplaceGateway();
            };
 
            //请选择被替换的网关
            var btnMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(50), false);
            btnMsg.Y = btnConfirm.Yaxis - Application.GetRealHeight(50 + 35);
            btnMsg.TextSize = 12;
            btnMsg.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnMsg.TextAlignment = TextAlignment.Center;
            btnMsg.TextID = R.MyInternationalizationString.uPleaseSelectGatewayToBeReplaced;
            bodyFrameLayout.AddChidren(btnMsg);
 
            this.listView = new VerticalListControl(29);
            listView.Height = btnMsg.Y - Application.GetRealHeight(23);
            listView.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(listView);
 
            HdlThreadLogic.Current.RunMainInThread(() =>
            {
                //设定中部信息
                this.SetMiddleFrameInfo();
            });
        }
 
        /// <summary>
        /// 设定中部信息
        /// </summary>
        private void SetMiddleFrameInfo()
        {
            //获取本地全部网关对象
            List<ZbGateway> listway = HdlGatewayLogic.Current.GetAllLocalGateway();
            var listShowWay = new List<ZbGateway>();
            for (int i = 0; i < listway.Count; i++)
            {
                //只有类型相同的网关,才能显示
                if (listway[i].GwId != this.nowZbGateway.GwId && listway[i].LinuxImageType == this.nowZbGateway.LinuxImageType)
                {
                    listShowWay.Add(listway[i]);
                }
            }
            for (int i = 0; i < listShowWay.Count; i++)
            {
                //添加行
                this.AddRowLayout( listShowWay[i], i != listShowWay.Count - 1);
            }
 
            //调整列表控件的高度
            this.listView.AdjustRealHeight(Application.GetRealHeight(23));
        }
 
        #endregion
 
        #region ■ 添加网关行_________________________
 
        /// <summary>
        /// 添加行
        /// </summary>
        /// <param name="localWay">本地网关</param>
        /// <param name="addLine">是否添加底线</param>
        private void AddRowLayout(ZbGateway localWay, bool addLine)
        {
            var frameRow = new FrameRowControl(this.listView.rowSpace / 2);
            this.listView.AddChidren(frameRow);
 
            //图标
            var btnIcon = frameRow.AddLeftIcon();
            HdlGatewayLogic.Current.SetGatewayIcon(btnIcon, localWay);
 
            //显示文本
            var wayName = HdlGatewayLogic.Current.GetGatewayName(localWay);
            if (wayName == string.Empty)
            {
                //无法识别的网关设备
                wayName = Language.StringByID(R.MyInternationalizationString.uUnDistinguishTheGatewayDevice);
            }
            frameRow.AddTopView(wayName, 700);
 
            //房间
            var room = HdlRoomLogic.Current.GetRoomByGateway(localWay.GwId);
            var roomName = HdlRoomLogic.Current.GetRoomName(room);
            frameRow.AddBottomView(roomName, 700);
 
            //选择状态
            var btnSelect = frameRow.AddMostRightEmptyIcon(58, 58);
            btnSelect.MainKey = localWay.GwId;
            btnSelect.Visible = false;
            btnSelect.UnSelectedImagePath = "Item/ItemSelected.png";
 
            if (addLine == true)
            {
                //底线
                frameRow.AddBottomLine();
            }
            btnSelect.ButtonClickEvent += (sender, e) =>
            {
                if (this.btnSelectIcon != null) { this.btnSelectIcon.IsSelected = false; }
 
                btnSelect.IsSelected = true;
                this.btnSelectIcon = btnSelect;
                this.btnConfirm.CanClick = true;
            };
        }
 
        #endregion
 
        #region ■ 执行网关替换操作___________________
 
        /// <summary>
        /// 执行网关替换操作
        /// </summary>
        private void DoReplaceGateway()
        {
        }
 
        #endregion
    }
}