using System; using System.Collections.Generic; using System.Text; using ZigBee.Device; namespace Shared.Phone.UserCenter.Device { /// /// 设备的历史版本 /// public class DeviceHistoryFirmwareVersionForm : EditorCommonForm { /// /// 升级的设备 /// private List listUpdateDevice = null; /// /// 列表控件 /// private VerticalListControl listView = null; /// /// 固件选择的事件 /// public Action SelectFirmwareInfoEvent = null; /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// /// 设备Mac地址 public void ShowForm(string deviceMac) { this.listUpdateDevice = HdlDeviceCommonLogic.Current.GetDevicesByMac(deviceMac); //设置标题信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uHistoryVersion)); //初始化中部控件 this.InitMiddleFrame(); } /// /// 初始化中部控件 /// private void InitMiddleFrame() { //清空bodyFrame this.ClearBodyFrame(); listView = new VerticalListControl(12); listView.Height = bodyFrameLayout.Height; listView.BackgroundColor = UserCenterColor.Current.White; bodyFrameLayout.AddChidren(listView); //拥有200端口这个东西的时候,才会显示 var oTADevice = HdlDeviceCommonLogic.Current.GetOTADevice(listUpdateDevice[0].DeviceAddr); if (oTADevice == null || oTADevice.ImgVersion == -1) { return; } //获取历史版本 var listData = HdlFirmwareUpdateLogic.Current.GetFirmwareVersionListInfo(FirmwareLevelType.A设备, oTADevice.HwVersion.ToString(), oTADevice.ImgTypeId.ToString()); string unSelectPic = string.Empty; string selectPic = string.Empty; HdlDeviceCommonLogic.Current.GetDeviceObjectIcon(listUpdateDevice, ref unSelectPic, ref selectPic); HdlThreadLogic.Current.RunThread(() => { string ImagType = oTADevice.ImgTypeId.ToString(); HdlThreadLogic.Current.RunMain(() => { foreach (var data in listData) { if (data.ImagType == ImagType && oTADevice.ImgVersion == data.FirmwareVersion) { //同一个东西,不显示出来 continue; } this.AddRowlayout(data, unSelectPic, selectPic); } }); }); } /// /// 添加行 /// /// /// /// private void AddRowlayout(FirmwareVersionInfo info, string unSelPath, string selPath) { var rowlayout = new FrameRowControl(listView.rowSpace / 2); listView.AddChidren(rowlayout); //图标 var btnIcon = rowlayout.AddLeftIcon(); btnIcon.UnSelectedImagePath = unSelPath; //指定的设备 rowlayout.AddTopView(info.ShowName, 800); //向右的图标 rowlayout.AddRightArrow(); //固件信息 string firmwareText = HdlDeviceCommonLogic.Current.AppendVersion(info.FirmwareVersion); firmwareText += " " + HdlCommonLogic.Current.ConvertUtcTimeToLocalTime(info.CreatedOnUtc).ToString("yyyy/MM/dd HH:mm:ss"); rowlayout.AddBottomView(firmwareText, 800); //底线 rowlayout.AddBottomLine(); rowlayout.ButtonClickEvent += (sender, e) => { string mainKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(this.listUpdateDevice[0]); if (HdlFirmwareUpdateResourse.dicUpdateList.ContainsKey(mainKeys) == true) { this.CloseForm(); return; } SelectFirmwareInfoEvent?.Invoke(info); SelectFirmwareInfoEvent = null; this.CloseForm(); }; } } }