using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.Device
{
///
/// 设备固件信息界面
///
public class DeviceFirmwareInfoForm : UserCenterCommonForm
{
#region ■ 变量声明___________________________
///
/// 列表控件
///
private VerticalScrolViewLayout listView = null;
///
/// 设备对象
///
private List listNewDevice = null;
///
/// OTADevice
///
private OTADevice oTADevice = null;
#endregion
#region ■ 初始化_____________________________
///
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
///
/// 设备列表
public void ShowForm(List 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();
}
///
/// 初始化中部控件
///
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行_______________________
///
/// 添加镜像ID行
///
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 ■ 添加固件版本行_____________________
///
/// 添加固件版本行
///
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 ■ 添加硬件版本行_____________________
///
/// 添加硬件版本行
///
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 ■ 添加固件升级行_____________________
///
/// 添加固件升级行
///
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
}
}