using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.Device
{
///
/// 设备的历史版本
///
public class DeviceHistoryFirmwareVersionForm : UserCenterCommonForm
{
///
/// 升级的设备
///
private List listUpdateDevice = null;
///
/// 列表控件
///
private VerticalScrolViewLayout listView = null;
///
/// 界面关闭的Action
///
public Action FormCloseAction = null;
///
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
///
/// 设备
public void ShowForm(List i_listdevice)
{
this.listUpdateDevice = i_listdevice;
//设置标题信息
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uHistoryVersion));
//初始化中部控件
this.InitMiddleFrame();
}
///
/// 初始化中部控件
///
private void InitMiddleFrame()
{
listView = new VerticalScrolViewLayout();
listView.Height = bodyFrameLayout.Height;
bodyFrameLayout.AddChidren(listView);
//拥有200端口这个东西的时候,才会显示
var oTADevice = Common.LocalDevice.Current.GetOTADevice(listUpdateDevice[0].DeviceAddr);
if (oTADevice == null || oTADevice.ImgVersion == -1)
{
return;
}
//获取历史版本
var listData = FirmwareUpdateLogic.GetFirmwareVersionListInfo(FirmwareLevelType.ZigbeeDevice,
oTADevice.HwVersion.ToString(),
oTADevice.ImgTypeId.ToString());
var btnTemp = new ButtonCommon();
Common.LocalDevice.Current.SetDeviceBeloneIconToControl(btnTemp, listUpdateDevice);
new System.Threading.Thread(() =>
{
string ImagType = oTADevice.ImgTypeId.ToString();
foreach (var data in listData)
{
if (data.ImagType == ImagType && oTADevice.ImgVersion == data.FirmwareVersion)
{
//同一个东西,不显示出来
continue;
}
Application.RunOnMainThread(() =>
{
this.AddRowlayout(data, btnTemp.UnSelectedImagePath, btnTemp.SelectedImagePath);
});
}
})
{ IsBackground = true }.Start();
}
///
/// 添加行
///
///
///
///
private void AddRowlayout(FirmwareVersionInfo info, string unSelPath,string selPath)
{
var rowlayout = new StatuRowLayout(listView);
//图标
var btnIcon = new RowLeftIconView();
btnIcon.UnSelectedImagePath = unSelPath;
btnIcon.SelectedImagePath = selPath;
rowlayout.AddChidren(btnIcon);
//指定的设备
var btnDevice = new RowTopBlackView();
btnDevice.BackgroundColor = UserCenterColor.Current.Transparent;
btnDevice.Text = info.ShowName;
rowlayout.AddChidren(btnDevice);
//固件信息
var btnVersion = new RowBottomBlackView();
btnVersion.Text = Common.LocalDevice.Current.AppendVersion(info.FirmwareVersion);
rowlayout.AddChidren(btnVersion);
//向右的图标
rowlayout.AddRightIconControl();
rowlayout.MouseUpEvent += (sender, e) =>
{
string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(this.listUpdateDevice[0]);
if (FirmwareUpdateResourse.dicDeviceUpdateList.ContainsKey(mainKeys) == true)
{
this.CloseForm();
return;
}
if (FormCloseAction != null)
{
FormCloseAction(info);
}
this.CloseForm();
};
}
}
}