From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期一, 14 十二月 2020 09:59:01 +0800 Subject: [PATCH] 请合并代码,完成晾衣架最终功能。 --- ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFirmwareUpdateForm.cs | 377 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 377 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFirmwareUpdateForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFirmwareUpdateForm.cs new file mode 100755 index 0000000..223988d --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFirmwareUpdateForm.cs @@ -0,0 +1,377 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.Device +{ + /// <summary> + /// 璁惧鍥轰欢鍗囩骇鐣岄潰 + /// </summary> + public class DeviceFirmwareUpdateForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 璁惧mac鍦板潃 + /// </summary> + private string deviceMac = null; + /// <summary> + /// 鍥轰欢淇℃伅 + /// </summary> + private FirmwareVersionInfo deviceFirmware = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + /// <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(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄦ帶浠� + /// </summary> + private void InitMiddleFrame() + { + var oTADevice = Common.LocalDevice.Current.GetOTADevice(deviceMac); + //鑾峰彇璁惧鏈�鏂扮増鏈� + this.deviceFirmware = HdlFirmwareUpdateLogic.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) + { + //鎷ユ湁鏂扮増鏈� + this.InitControlByNewVersion(); + } + else + { + //娌℃湁鏂扮増鏈� + this.InitControlByNotNewVersion(); + } + } + + #endregion + + #region 鈻� 鍙充笂瑙掕彍鍗昣________________________ + + /// <summary> + /// 鍒濆鍖栧彸涓婅鑿滃崟 + /// </summary> + private void InitTopRightMenu() + { + if (UserCenterResourse.HideOption.DeviceHistory != 1) + { + return; + } + var btnIcon = new MostRightIconControl(69, 69); + btnIcon.UnSelectedImagePath = "Item/More.png"; + topFrameLayout.AddChidren(btnIcon); + btnIcon.InitControl(); + btnIcon.ButtonClickEvent += ((sender, e) => + { + //鏄剧ず鍙充笂瑙掕彍鍗曠晫闈� + this.ShowTopRightMenu(); + }); + } + + /// <summary> + /// 鏄剧ず鍙充笂瑙掕彍鍗曠晫闈� + /// </summary> + private void ShowTopRightMenu() + { + var frame = new TopRightMenuControl(1, 2); + //鍘嗗彶鐗堟湰 + var deviceMenu = Language.StringByID(R.MyInternationalizationString.uHistoryVersion); + frame.AddRowMenu(deviceMenu, "", "", () => + { + var form = new DeviceHistoryFirmwareVersionForm(); + form.AddForm(deviceMac); + form.SelectFirmwareInfoEvent += (info) => + { + this.deviceFirmware = info; + //鎷ユ湁鏂扮増鏈� + this.InitControlByNewVersion(); + }; + }); + } + + #endregion + + #region 鈻� 鎷ユ湁鏂扮増鏈琠________________________ + + /// <summary> + /// 鎷ユ湁鏂扮増鏈� + /// </summary> + private void InitControlByNewVersion() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + var oTADevice = Common.LocalDevice.Current.GetOTADevice(deviceMac); + + //鍗囩骇 + var btnUpdate = new BottomClickButton(); + btnUpdate.TextID = R.MyInternationalizationString.uLevelUp; + bodyFrameLayout.AddChidren(btnUpdate); + btnUpdate.ButtonClickEvent += (sender, e) => + { + //璁惧鍗囩骇 + HdlThreadLogic.Current.RunThread(() => + { + this.DoDeviceUpdate(oTADevice); + }); + }; + + var frameWhiteBack = new FrameLayout(); + frameWhiteBack.Height = Application.GetRealHeight(286); + frameWhiteBack.BackgroundColor = UserCenterColor.Current.White; + bodyFrameLayout.AddChidren(frameWhiteBack); + + //褰撳墠鍥轰欢鐗堟湰 + var frameNow = new FrameRowControl(); + frameNow.UseClickStatu = false; + 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.AddBottomLine(); + + //鏈�鏂板浐浠剁増鏈� + var frameNew = new FrameRowControl(); + frameNew.UseClickStatu = false; + 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.AddBottomLine(); + + //娣诲姞鍥轰欢浠嬬粛琛� + int maxHeight = btnUpdate.Y - ControlCommonResourse.BottomButtonAndListViewSpace - frameNew.Bottom; + this.AddUpdateContent(deviceFirmware, maxHeight, frameNew.Bottom); + } + + #endregion + + #region 鈻� 娌℃湁鏂扮増鏈琠________________________ + + /// <summary> + /// 娌℃湁鏂扮増鏈� + /// </summary> + private void InitControlByNotNewVersion() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + var oTADevice = Common.LocalDevice.Current.GetOTADevice(deviceMac); + + var frameWhiteBack = new FrameLayout(); + frameWhiteBack.Height = Application.GetRealHeight(308); + frameWhiteBack.BackgroundColor = UserCenterColor.Current.White; + bodyFrameLayout.AddChidren(frameWhiteBack); + + //褰撳墠鍥轰欢鐗堟湰 + var frameNow = new FrameRowControl(); + frameNow.UseClickStatu = false; + 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.AddBottomLine(); + + //鏈�鏂板浐浠剁増鏈� + var frameNew = new FrameRowControl(); + frameNew.UseClickStatu = false; + frameNew.Y = frameNow.Bottom + Application.GetRealHeight(12); + frameWhiteBack.AddChidren(frameNew); + frameNew.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uNewFirmwareVersion), 500); + frameNew.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uNothing), 500); + } + + #endregion + + #region 鈻� 娣诲姞鍥轰欢浠嬬粛琛宊____________________ + + /// <summary> + /// 娣诲姞鍥轰欢浠嬬粛琛� + /// </summary> + /// <param name="versionInfo">鍥轰欢瀵硅薄</param> + /// <param name="Maxheight">鏈�澶ч珮搴�</param> + /// <param name="YY"></param> + private void AddUpdateContent(FirmwareVersionInfo versionInfo, int Maxheight,int YY) + { + FrameListControl listFrame = null; + VerticalListControl listView = null; + + var realHeight = Application.GetRealHeight(40 + 12) * versionInfo.UpdateContent.Count; + realHeight += Application.GetRealHeight(17 + 12 + 49 + 8 + 63); + + //琛岄棿璺� + int rowSpace = 0; + if (realHeight > Maxheight) + { + realHeight = Maxheight; + listView = new VerticalListControl(12); + listView.Height = realHeight; + listView.Y = YY; + listView.BackgroundColor = UserCenterColor.Current.White; + bodyFrameLayout.AddChidren(listView); + rowSpace = listView.rowSpace / 2; + } + else + { + listFrame = new FrameListControl(12); + listFrame.Height = realHeight; + listFrame.Y = YY; + listFrame.BackgroundColor = UserCenterColor.Current.White; + bodyFrameLayout.AddChidren(listFrame); + rowSpace = listFrame.rowSpace / 2; + } + + //娣诲姞澶撮儴绌虹櫧闂撮殭 + var frameSpace1 = new FrameLayout(); + frameSpace1.Height = Application.GetRealHeight(17); + listView?.AddChidren(frameSpace1); + listFrame?.AddChidren(frameSpace1); + + //淇敼鍐呭 + var btnContentRow = new FrameRowControl(rowSpace); + btnContentRow.UseClickStatu = false; + btnContentRow.Height = Application.GetRealHeight(49); + listView?.AddChidren(btnContentRow); + listFrame?.AddChidren(btnContentRow); + var btnContent = btnContentRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uEditorContent), 500); + btnContent.TextSize = 12; + + //绋嶅井鍐嶆坊鍔犵┖鐧介棿闅� + var frameSpace2 = new FrameLayout(); + frameSpace2.Height = Application.GetRealHeight(8); + listView?.AddChidren(frameSpace2); + listFrame?.AddChidren(frameSpace2); + + foreach (var msg in versionInfo.UpdateContent) + { + var btnRow = new FrameRowControl(rowSpace); + btnRow.UseClickStatu = false; + btnRow.Height = Application.GetRealHeight(40); + listView?.AddChidren(btnRow); + listFrame?.AddChidren(btnRow); + + var btnMsg = btnRow.AddLeftCaption(msg, 965); + btnMsg.TextSize = 10; + btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3; + } + + //娣诲姞搴曢儴绌虹櫧闂撮殭 + var frameSpace3 = new FrameLayout(); + frameSpace3.Height = Application.GetRealHeight(63); + listView?.AddChidren(frameSpace3); + listFrame?.AddChidren(frameSpace3); + } + + #endregion + + #region 鈻� 璁惧鍗囩骇___________________________ + + /// <summary> + /// 璁惧鍗囩骇 + /// </summary> + private void DoDeviceUpdate(OTADevice oTADevice) + { + //鎵撳紑杩涘害鏉� + ProgressFormBar.Current.Start(); + //璁惧鍗囩骇 + var updateLogic = new HdlDeviceUpdateLogic(oTADevice, deviceFirmware); + //鏇存柊鐘舵�佸彉鍖栫殑浜嬩欢 + updateLogic.UpdateStatuChangedEvent += (div, msg) => + { + HdlThreadLogic.Current.RunMain(() => + { + if (div == -1) + { + //寮傚父 + this.ShowMassage(ShowMsgType.Tip, msg); + ProgressFormBar.Current.Close(); + } + else if (div == 0) + { + //涓�鑸俊鎭� + ProgressFormBar.Current.SetMsg(msg); + } + else if (div == 1) + { + //鍗囩骇瀹屾垚 + ProgressFormBar.Current.Close(); + this.ShowMassage(ShowMsgType.Tip, msg); + + HdlThreadLogic.Current.RunMain(() => + { + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(); + }); + } + else if (div == 2) + { + //涓诲姩缁堟鍗囩骇 + ProgressFormBar.Current.Close(); + } + }); + }; + //杩涘害鍊兼敼鍙樹簨浠� + updateLogic.ProgressEvent += (value) => + { + ProgressFormBar.Current.SetValue(value, 100); + }; + //璁惧鍗囩骇寮�濮� + updateLogic.StartUpdateReady(); + //缁堟鍗囩骇 + ProgressFormBar.Current.MsgClickEvent += () => + { + //鍐嶆璋冪敤,鍐呴儴鏉′欢杈炬垚鏃�,鍙互閫夋嫨缁堟鍗囩骇 + updateLogic.StartUpdateReady(); + }; + //鍏抽棴浜嬩欢 + ProgressFormBar.Current.CloseEvent += () => + { + //鍗囩骇瀵硅薄 + if (FirmwareUpdateResourse.dicUpdateList.ContainsKey(deviceMac) == true + && FirmwareUpdateResourse.dicUpdateList[deviceMac].IsFinishUpdate == true) + { + //濡傛灉璁惧宸茬粡鍗囩骇瀹屾垚锛岀晫闈㈠叧闂椂锛屽垯绉婚櫎鍐呭瓨 + FirmwareUpdateResourse.dicUpdateList[deviceMac].Dispose(); + FirmwareUpdateResourse.dicUpdateList.Remove(deviceMac); + } + }; + } + + #endregion + } +} -- Gitblit v1.8.0