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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.Device
{
    /// <summary>
    /// 设备固件信息界面
    /// </summary>
    public class DeviceFirmwareInfoForm : UserCenterCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalScrolViewLayout listView = null;
        /// <summary>
        /// 设备对象
        /// </summary>
        private List<CommonDevice> listNewDevice = null;
        /// <summary>
        /// OTADevice
        /// </summary>
        private OTADevice oTADevice = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="listdevices">设备列表</param>
        public void ShowForm(List<CommonDevice> listdevices)
        {
            if (listNewDevice != null && listNewDevice[0].DeviceAddr != listdevices[0].DeviceAddr)
            {
                //不是同一个东西
                return;
            }
            this.listNewDevice = listdevices;
 
            //设置标题信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uFirmwareInformation));
 
            //拥有200端口这个东西的时候,才会显示
            this.oTADevice = Common.LocalDevice.Current.GetOTADevice(listNewDevice[0].DeviceAddr);
            if (oTADevice == null || oTADevice.ImgVersion == -1)
            {
                return;
            }
 
            //初始化中部控件
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部控件
        /// </summary>
        private void InitMiddleFrame()
        {
            bodyFrameLayout.RemoveAll();
 
            listView = new VerticalScrolViewLayout();
            listView.Height = bodyFrameLayout.Height;
            bodyFrameLayout.AddChidren(listView);
 
            //添加镜像ID行
            this.AddImageIdRow();
 
            //添加固件版本行
            this.AddFirmwareVersionRow();
 
            //添加硬件版本行
            this.AddHardwareVersionRow();
 
            //成员没有升级权限
            if (UserCenterResourse.UserInfo.AuthorityNo != 3)
            {
                //添加固件升级行
                this.AddFirmwareUpdateRow();
            }
        }
 
        #endregion
 
        #region ■ 添加镜像ID行_______________________
 
        /// <summary>
        /// 添加镜像ID行
        /// </summary>
        private void AddImageIdRow()
        {
            var row = new RowLayout();
            row.Height = ControlCommonResourse.ListViewRowHeight;
            listView.AddChidren(row);
 
            //设备镜像ID
            var btnUpview = new RowCenterView(false);
            btnUpview.TextID = R.MyInternationalizationString.uDeviceImageId;
            row.AddChidren(btnUpview);
            //镜像ID
            var btnVersion = new RowMostRightTextView();
            btnVersion.TextColor = UserCenterColor.Current.TextGrayColor;
            btnVersion.Text = oTADevice.ImgTypeId.ToString();
            row.AddChidren(btnVersion);
        }
 
        #endregion
 
        #region ■ 添加固件版本行_____________________
 
        /// <summary>
        /// 添加固件版本行
        /// </summary>
        private void AddFirmwareVersionRow()
        {
            var row = new RowLayout();
            row.Height = ControlCommonResourse.ListViewRowHeight;
            listView.AddChidren(row);
 
            //设备固件版本
            var btnUpview = new RowCenterView(false);
            btnUpview.TextID = R.MyInternationalizationString.uDeviceFirmwareVersion;
            row.AddChidren(btnUpview);
            //版本号
            var btnVersion = new RowMostRightTextView();
            btnVersion.TextColor = UserCenterColor.Current.TextGrayColor;
            btnVersion.Text = Common.LocalDevice.Current.AppendVersion(oTADevice.ImgVersion);
            row.AddChidren(btnVersion);
        }
 
        #endregion
 
        #region ■ 添加硬件版本行_____________________
 
        /// <summary>
        /// 添加硬件版本行
        /// </summary>
        private void AddHardwareVersionRow()
        {
            var row = new RowLayout();
            row.Height = ControlCommonResourse.ListViewRowHeight;
            listView.AddChidren(row);
 
            //设备硬件版本
            var btnUpview = new RowCenterView(false);
            btnUpview.TextID = R.MyInternationalizationString.uDeviceHardwareVersion;
            row.AddChidren(btnUpview);
            //版本号
            var btnVersion = new RowMostRightTextView();
            btnVersion.TextColor = UserCenterColor.Current.TextGrayColor;
            btnVersion.Text = Common.LocalDevice.Current.AppendVersion(oTADevice.HwVersion);
            row.AddChidren(btnVersion);
        }
 
        #endregion
 
        #region ■ 添加固件升级行_____________________
 
        /// <summary>
        /// 添加固件升级行
        /// </summary>
        private void AddFirmwareUpdateRow()
        {
            var statuRow = new StatuRowLayout(listView);
            //固件升级
            var btnUpview = new RowCenterView(false);
            btnUpview.TextID = R.MyInternationalizationString.uFirmwareUpdate;
            statuRow.AddChidren(btnUpview);
 
            //提示有新版本
            var btnNewVersion = new RowNewVersionTipView();
            btnNewVersion.Visible = false;
            statuRow.AddChidren(btnNewVersion);
 
            //获取设备最新版本
            var deviceFirmware = FirmwareUpdateLogic.GetFirmwareMostVersionInfo(FirmwareLevelType.ZigbeeDevice,
                oTADevice.HwVersion.ToString(),
                oTADevice.ImgTypeId.ToString(),
                oTADevice.ImgVersion);
 
            if (deviceFirmware != null)
            {
                if (deviceFirmware.FirmwareVersion > oTADevice.ImgVersion)
                {
                    btnNewVersion.Visible = true;
                }
                else
                {
                    deviceFirmware = null;
                }
            }
 
            //版本向右的图标
            statuRow.AddRightIconControl();
            statuRow.MouseUpEvent += (sender, e) =>
            {
                var form = new DeviceFirmwareUpdateForm();
                this.AddForm(form, listNewDevice, deviceFirmware, oTADevice.ImgVersion);
            };
        }
 
        #endregion
    }
}