黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFirmwareUpdateForm.cs
@@ -12,9 +12,9 @@
    {
        #region ■ 变量声明___________________________
        /// <summary>
        /// 设备mac地址
        /// </summary>
        /// <summary>
        /// 设备mac地址
        /// </summary>
        private string deviceMac = null;
        /// <summary>
        /// 固件信息
@@ -28,37 +28,44 @@
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_deviceMac">设备mac地址</param>
        public void ShowForm(string i_deviceMac)
        /// <param name="i_deviceMac">设备mac地址</param>
        public void ShowForm(string i_deviceMac)
        {
            if (deviceMac != null && deviceMac != i_deviceMac)
            {
                //不是同一个东西
                return;
            }
            this.deviceMac = i_deviceMac;
            //设置标题信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uFirmwareUpdate));
            //初始化中部控件
            this.InitMiddleFrame();
            //历史版本
            this.InitTopRightMenu();
        }
            this.deviceMac = i_deviceMac;
            //设置标题信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uFirmwareUpdate));
            //初始化中部控件
            this.InitMiddleFrame();
            //历史版本
            this.InitTopRightMenu();
        }
        /// <summary>
        /// 初始化中部控件
        /// </summary>
        private void InitMiddleFrame()
        /// </summary>
        private void InitMiddleFrame()
        {
            var oTADevice = Common.LocalDevice.Current.GetOTADevice(deviceMac);
            var oTADevice = HdlDeviceCommonLogic.Current.GetOTADevice(deviceMac);
            //获取设备最新版本
            this.deviceFirmware = HdlFirmwareUpdateLogic.GetFirmwareMostVersionInfo(FirmwareLevelType.ZigbeeDevice,
            this.deviceFirmware = HdlFirmwareUpdateLogic.Current.GetFirmwareMostVersionInfo(FirmwareLevelType.A设备,
                oTADevice.HwVersion.ToString(),
                oTADevice.ImgTypeId.ToString(),
                oTADevice.ImgVersion);
            //如果当前住宅是虚拟住宅,或者是展示模板,则没有新版本的说法
            if (Common.Config.Instance.Home.IsVirtually == true
                || Common.Config.Instance.Home.IsShowTemplate == true)
            {
                this.deviceFirmware = null;
            }
            if (deviceFirmware != null && deviceFirmware.FirmwareVersion > oTADevice.ImgVersion)
            {
@@ -69,18 +76,22 @@
            {
                //没有新版本
                this.InitControlByNotNewVersion();
            }
            }
        }
        #endregion
        #region ■ 右上角菜单_________________________
        #region ■ 右上角菜单_________________________
        /// <summary>
        /// 初始化右上角菜单
        /// </summary>
        /// </summary>
        private void InitTopRightMenu()
        {
            if (HdlUserCenterResourse.HideOption.DeviceHistory != 1)
            {
                return;
            }
            var btnIcon = new MostRightIconControl(69, 69);
            btnIcon.UnSelectedImagePath = "Item/More.png";
            topFrameLayout.AddChidren(btnIcon);
@@ -94,10 +105,10 @@
        /// <summary>
        /// 显示右上角菜单界面
        /// </summary>
        /// </summary>
        private void ShowTopRightMenu()
        {
            var frame = new TopRightMenuControl(1);
            var frame = new TopRightMenuControl(1, 2);
            //历史版本
            var deviceMenu = Language.StringByID(R.MyInternationalizationString.uHistoryVersion);
            frame.AddRowMenu(deviceMenu, "", "", () =>
@@ -125,7 +136,7 @@
            //清空bodyFrame
            this.ClearBodyFrame();
            var oTADevice = Common.LocalDevice.Current.GetOTADevice(deviceMac);
            var oTADevice = HdlDeviceCommonLogic.Current.GetOTADevice(deviceMac);
            //升级
            var btnUpdate = new BottomClickButton();
@@ -151,7 +162,7 @@
            frameNow.Y = Application.GetRealHeight(20);
            frameWhiteBack.AddChidren(frameNow);
            frameNow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uNowFirmwareVersion), 500);
            frameNow.AddMostRightView(Common.LocalDevice.Current.AppendVersion(oTADevice.ImgVersion), 500);
            frameNow.AddMostRightView(HdlDeviceCommonLogic.Current.AppendVersion(oTADevice.ImgVersion), 500);
            frameNow.AddBottomLine();
            //最新固件版本
@@ -160,11 +171,11 @@
            frameNew.Y = frameNow.Bottom + Application.GetRealHeight(12);
            frameWhiteBack.AddChidren(frameNew);
            frameNew.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uNewFirmwareVersion), 500);
            frameNew.AddMostRightView(Common.LocalDevice.Current.AppendVersion(deviceFirmware.FirmwareVersion), 500);
            frameNew.AddMostRightView(HdlDeviceCommonLogic.Current.AppendVersion(deviceFirmware.FirmwareVersion), 500);
            frameNew.AddBottomLine();
            //添加固件介绍行
            int maxHeight = btnUpdate.Y - ControlCommonResourse.BottomButtonAndListViewSpace - frameNew.Bottom;
            int maxHeight = btnUpdate.Y - HdlControlResourse.BottomButtonAndListViewSpace - frameNew.Bottom;
            this.AddUpdateContent(deviceFirmware, maxHeight, frameNew.Bottom);
        }
@@ -180,7 +191,7 @@
            //清空bodyFrame
            this.ClearBodyFrame();
            var oTADevice = Common.LocalDevice.Current.GetOTADevice(deviceMac);
            var oTADevice = HdlDeviceCommonLogic.Current.GetOTADevice(deviceMac);
            var frameWhiteBack = new FrameLayout();
            frameWhiteBack.Height = Application.GetRealHeight(308);
@@ -193,7 +204,7 @@
            frameNow.Y = Application.GetRealHeight(20);
            frameWhiteBack.AddChidren(frameNow);
            frameNow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uNowFirmwareVersion), 500);
            frameNow.AddMostRightView(Common.LocalDevice.Current.AppendVersion(oTADevice.ImgVersion), 500);
            frameNow.AddMostRightView(HdlDeviceCommonLogic.Current.AppendVersion(oTADevice.ImgVersion), 500);
            frameNow.AddBottomLine();
            //最新固件版本
@@ -214,7 +225,7 @@
        /// </summary>
        /// <param name="versionInfo">固件对象</param>
        /// <param name="Maxheight">最大高度</param>
        /// <param name="YY"></param>
        /// <param name="YY"></param>
        private void AddUpdateContent(FirmwareVersionInfo versionInfo, int Maxheight,int YY)
        {
            FrameListControl listFrame = null;
@@ -351,12 +362,12 @@
            ProgressFormBar.Current.CloseEvent += () =>
            {
                //升级对象
                if (FirmwareUpdateResourse.dicUpdateList.ContainsKey(deviceMac) == true
                    && FirmwareUpdateResourse.dicUpdateList[deviceMac].IsFinishUpdate == true)
                if (HdlFirmwareUpdateResourse.dicUpdateList.ContainsKey(deviceMac) == true
                    && HdlFirmwareUpdateResourse.dicUpdateList[deviceMac].IsFinishUpdate == true)
                {
                    //如果设备已经升级完成,界面关闭时,则移除内存
                    FirmwareUpdateResourse.dicUpdateList[deviceMac].Dispose();
                    FirmwareUpdateResourse.dicUpdateList.Remove(deviceMac);
                    HdlFirmwareUpdateResourse.dicUpdateList[deviceMac].Dispose();
                    HdlFirmwareUpdateResourse.dicUpdateList.Remove(deviceMac);
                }
            };
        }