From 5727cf0b9b54da0a191dd1e23cb5abf21320fbff Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 25 十一月 2019 10:34:17 +0800 Subject: [PATCH] IOS使用新的项目名称 --- ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFirmwareUpdateForm.cs | 330 +++++++++++++++++++++++++----------------------------- 1 files changed, 155 insertions(+), 175 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFirmwareUpdateForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFirmwareUpdateForm.cs index 80f6c2c..2cb58a4 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFirmwareUpdateForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFirmwareUpdateForm.cs @@ -9,219 +9,199 @@ /// <summary> /// 鍥轰欢鍗囩骇鐢婚潰 /// </summary> - public class DeviceFirmwareUpdateForm : UserCenterCommonForm + public class DeviceFirmwareUpdateForm : DialogCommonForm { - /// <summary> - /// 鍗囩骇鐨勮澶� - /// </summary> - private List<CommonDevice> listUpdateDevice = null; + #region 鈻� 鍙橀噺澹版槑___________________________ + /// <summary> - /// 璁惧鏂扮増鏈殑鍥轰欢淇℃伅 - /// </summary> - private FirmwareVersionInfo deviceFirmware = null; - /// <summary> - /// 褰撳墠闀滃儚鐗堟湰 + /// 璁惧鐨凪ac鍦板潃 /// </summary> - private int imageVersion = 0; + private string deviceMac = string.Empty; + /// <summary> + /// 璁惧鎴愬姛鍗囩骇瀹屾垚鐨勫洖璋冨嚱鏁� + /// </summary> + public Action FinishUpdateEvent = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ /// <summary> /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) /// </summary> - /// <param name="i_listdevice">璁惧</param> - /// <param name="i_deviceFirmware">璁惧鏂扮増鏈�</param> - /// <param name="i_imageVersion">褰撳墠闀滃儚鐗堟湰</param> - public void ShowForm(List<CommonDevice> i_listdevice, FirmwareVersionInfo i_deviceFirmware, int i_imageVersion) + /// <param name="device">ota璁惧瀵硅薄</param> + /// <param name="deviceFirmware">鍥轰欢鍗囩骇淇℃伅</param> + public void ShowForm(OTADevice device, FirmwareVersionInfo deviceFirmware) { - this.listUpdateDevice = i_listdevice; - this.imageVersion = i_imageVersion; - this.deviceFirmware = i_deviceFirmware; - - //璁剧疆鏍囬淇℃伅 - base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uFirmwareUpdate)); - - var btnIcon = new TopLayoutMostRightView(); - btnIcon.UnSelectedImagePath = "Item/More.png"; - btnIcon.SelectedImagePath = "Item/MoreSelected.png"; - topFrameLayout.AddChidren(btnIcon); - btnIcon.MouseUpEventHandler += (sender, e) => - { - //鑿滃崟鎺т欢 - var frameMenu = new TopRightMenuControl(this, 1); - //鍘嗗彶鐗堟湰 - string menu1 = Language.StringByID(R.MyInternationalizationString.uHistoryVersion); - frameMenu.AddRowMenu(menu1, (obj) => - { - var form = new DeviceHistoryFirmwareVersionForm(); - this.AddForm(form, listUpdateDevice); - form.FormCloseAction += ((firmwareInfo) => - { - //濡傛灉褰撳墠姝e湪鍗囩骇锛屽垯鍘嗗彶鐗堟湰鏃犳晥 - if (FirmwareUpdateResourse.dicDeviceUpdateList.ContainsKey(this.listUpdateDevice[0].DeviceAddr) == false) - { - //閲嶆柊鍒锋柊鐣岄潰 - this.ShowForm(listUpdateDevice, firmwareInfo, firmwareInfo.FirmwareVersion); - } - }); - }); - }; - - //鍒濆鍖栦腑閮ㄦ帶浠� - this.InitMiddleFrame(); + this.deviceMac = device.DeviceAddr; + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(device, deviceFirmware); } /// <summary> - /// 鍒濆鍖栦腑閮ㄦ帶浠� + /// 鍒濆鍖栦腑閮ㄤ俊鎭� /// </summary> - private void InitMiddleFrame() + /// <param name="device">ota璁惧瀵硅薄</param> + /// <param name="deviceFirmware">鍥轰欢鍗囩骇淇℃伅</param> + private void InitMiddleFrame(OTADevice device, FirmwareVersionInfo deviceFirmware) { - bodyFrameLayout.RemoveAll(); + var frameBack = new FrameLayout(); + frameBack.Width = Application.GetRealWidth(674); + frameBack.Height = Application.GetRealHeight(386); + frameBack.BackgroundColor = UserCenterColor.Current.White; + frameBack.Gravity = Gravity.CenterHorizontal; + frameBack.Y = Application.GetRealHeight(683); + frameBack.Radius = 6; + bodyFrameLayout.AddChidren(frameBack); + + //杩涘害鏄剧ず鏂囨湰 + var btnText = new NormalViewControl(frameBack.Width, Application.GetRealHeight(58), false); + btnText.Y = Application.GetRealHeight(248); + btnText.TextColor = UserCenterColor.Current.TextGrayColor1; + btnText.TextAlignment = TextAlignment.Center; + //btnText.Text = "鍗囩骇涓�"; + frameBack.AddChidren(btnText); - //娌℃湁鏂扮増鏈� - if (deviceFirmware == null) - { - //鏄剧ず宸茬粡鏄柊鐗堟湰 - this.ShowIsMostVewVersion(); - } - else - { - //鏄剧ず宸茬粡鏄柊鐗堟湰 - this.ShowIsHadNewVersion(); - } + //杩涘害鏉� + var btnProRow = new FrameLayout(); + btnProRow.Gravity = Gravity.CenterHorizontal; + btnProRow.Y = Application.GetRealHeight(161); + btnProRow.Width = Application.GetRealWidth(559); + btnProRow.Height = Application.GetRealHeight(29); + btnProRow.BackgroundColor = 0xfff5f5f5; + btnProRow.Radius = (uint)Application.GetRealHeight(29) / 2; + frameBack.AddChidren(btnProRow); + var btnProgressBar = new FrameLayout(); + btnProgressBar.Width = 0; + btnProgressBar.Height = btnProRow.Height; + btnProgressBar.Radius = btnProRow.Radius; + btnProgressBar.BackgroundColor = 0xfffb744a; + btnProgressBar.Radius = (uint)Application.GetRealHeight(29) / 2; + btnProRow.AddChidren(btnProgressBar); + + //杩涘害鍊兼枃鏈� + var frameProgress = new FrameLayout(); + frameProgress.Width = Application.GetRealWidth(84); + frameProgress.Height = Application.GetRealHeight(60); + frameProgress.Y = Application.GetRealHeight(86); + frameBack.AddChidren(frameProgress); + frameProgress.X = btnProRow.X + btnProgressBar.Right - frameProgress.Width / 2; + var btnProgressPic = new PicViewControl(84, 60); + btnProgressPic.UnSelectedImagePath = "Item/ProgressMsg.png"; + frameProgress.AddChidren(btnProgressPic); + var btnProgressView = new NormalViewControl(84, 32, true); + btnProgressView.TextSize = 10; + btnProgressView.TextAlignment = TextAlignment.Center; + btnProgressView.Text = "0%"; + frameProgress.AddChidren(btnProgressView); + + //璁惧鍗囩骇 + this.DeviceUpdateMethod(device, deviceFirmware, btnText, btnProgressView, frameProgress, btnProgressBar, btnProRow.Width); } - /// <summary> - /// 鏄剧ず宸茬粡鏄柊鐗堟湰 - /// </summary> - private void ShowIsMostVewVersion() - { - //濡傛灉鐐圭殑鏄巻鍙茬増鏈紝鍒欏悓姝ョ晫闈� - string mainKeys = this.listUpdateDevice[0].DeviceAddr; - if (FirmwareUpdateResourse.dicDeviceUpdateList.ContainsKey(mainKeys) == true) - { - var btnUpdateControl = FirmwareUpdateResourse.dicDeviceUpdateList[mainKeys]; - bodyFrameLayout.AddChidren(btnUpdateControl); - //鍒濆鍖栧崌绾ф帶浠� - this.InitDeviceUpdateControl(btnUpdateControl); - return; - } + #endregion - //褰撳墠绋嬪簭鐗堟湰 - var btnVersionMsg = new MsgViewControl(800, true); - btnVersionMsg.TextID = R.MyInternationalizationString.uIsMostNewVersion; - btnVersionMsg.Y = Application.GetRealHeight(100); - btnVersionMsg.TextAlignment = TextAlignment.Center; - btnVersionMsg.Gravity = Gravity.CenterHorizontal; - bodyFrameLayout.AddChidren(btnVersionMsg); - - //鐗堟湰 - var btnVersion = new MsgViewControl(800, true); - btnVersion.Text = Common.LocalDevice.Current.AppendVersion(this.imageVersion); - btnVersion.Y = btnVersionMsg.Bottom + Application.GetRealHeight(10); - btnVersion.TextAlignment = TextAlignment.Center; - btnVersion.Gravity = Gravity.CenterHorizontal; - bodyFrameLayout.AddChidren(btnVersion); - } + #region 鈻� 璁惧鍗囩骇___________________________ /// <summary> - /// 鏄剧ず瀛樺湪鏈�鏂扮増鏈� + /// 璁惧鍗囩骇 /// </summary> - private void ShowIsHadNewVersion() + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="deviceFirmware">鍥轰欢淇℃伅</param> + /// <param name="btnText">鏍囬鎺т欢</param> + /// <param name="btnProgressView">杩涘害鍊兼枃鏈殑鏄剧ず鎺т欢</param> + /// <param name="frameProgress">杩涘害鍊艰兘澶熺Щ鍔ㄧ殑閭d釜妗嗘帶浠�</param> + /// <param name="btnProgressBar">杩涘害鏉�</param> + /// <param name="ProRowWidth">杩涘害鏉″鍣ㄧ殑鏈�澶у搴�</param> + private void DeviceUpdateMethod(OTADevice device, FirmwareVersionInfo deviceFirmware, NormalViewControl btnText, + NormalViewControl btnProgressView, FrameLayout frameProgress, FrameLayout btnProgressBar, int ProRowWidth) { - //鍗囩骇鎺т欢 - string mainKeys = this.listUpdateDevice[0].DeviceAddr; - - //涓存椂鎺т欢 - var btnTemp = new ButtonCommon(); - Common.LocalDevice.Current.SetDeviceBeloneIconToControl(btnTemp, this.listUpdateDevice); - - DeviceFirmwareUpdateControl btnUpdateControl = null; - if (FirmwareUpdateResourse.dicDeviceUpdateList.ContainsKey(mainKeys) == true) + //璁惧鍗囩骇 + var updateLogic = new HdlDeviceUpdateLogic(device, deviceFirmware); + //鏇存柊鐘舵�佸彉鍖栫殑浜嬩欢 + updateLogic.UpdateStatuChangedEvent += (div, msg) => { - btnUpdateControl = FirmwareUpdateResourse.dicDeviceUpdateList[mainKeys]; - bodyFrameLayout.AddChidren(btnUpdateControl); - } - else - { - btnUpdateControl = new DeviceFirmwareUpdateControl(null, this.listUpdateDevice, this.deviceFirmware); - bodyFrameLayout.AddChidren(btnUpdateControl); - btnUpdateControl.InitChidrenControl(btnTemp.UnSelectedImagePath); - } - //鍒濆鍖栧崌绾ф帶浠� - this.InitDeviceUpdateControl(btnUpdateControl); - } - - /// <summary> - /// 鍒濆鍖栧崌绾ф帶浠� - /// </summary> - /// <param name="btnUpdateControl"></param> - private void InitDeviceUpdateControl(DeviceFirmwareUpdateControl btnUpdateControl) - { - //鍗囩骇 - BottomClickButton btnUpdate = btnUpdateControl.btnUpdateButton; - if (btnUpdate == null) - { - btnUpdate = new BottomClickButton(); - btnUpdate.UseClickStatu = false; - btnUpdate.TextID = R.MyInternationalizationString.uLevelUp; - btnUpdate.Gravity = Gravity.BottomCenter; - btnUpdate.MouseUpTime = 0; - btnUpdate.Radius = 0; - btnUpdate.Width = Application.CurrentWidth; - btnUpdate.MouseUpEvent += (sender, e) => + HdlThreadLogic.Current.RunMain(() => { - if (btnUpdateControl.UpdateStatu == UpdateStatuMode.UpdateSuccess) + if (div == -1) { - //鍗囩骇鎴愬姛鐨勬椂鍊欙紝濡傛灉鍗曞嚮姝ゆ寜閽紝鍒欏叧闂晫闈� + //寮傚父 + this.ShowMassage(ShowMsgType.Tip, msg); this.CloseForm(); - return; } - //杩涘叆鎵ц鏇存柊鎿嶄綔鍑嗗闃舵 - btnUpdateControl.StartUpdateReady(); - }; - } - btnUpdateControl.btnUpdateButton = btnUpdate; - bodyFrameLayout.AddChidren(btnUpdate); - - var listView = new VerticalScrolViewLayout(); - listView.Y = btnUpdateControl.Bottom; - listView.Height = bodyFrameLayout.Height - btnUpdateControl.Height - btnUpdate.Height; - bodyFrameLayout.AddChidren(listView); - - //鍋氭垚鏇存柊鍐呭鎺т欢 - ViewNormalControl btnTempMsg = null; - //涓存椂鎺т欢 - ButtonCommon btnTemp = null; - //鍋氭垚鏇存柊璁板綍鎺т欢 - foreach (string msg in btnUpdateControl.deviceFirmware.UpdateContent) + else if (div == 0) + { + //涓�鑸俊鎭� + btnText.Text = msg; + } + else if (div == 1) + { + //鍗囩骇瀹屾垚 + this.ShowMassage(ShowMsgType.Tip, msg); + //璋冪敤鍥炶皟鍑芥暟 + this.FinishUpdateEvent?.Invoke(); + this.CloseForm(); + } + else if (div == 2) + { + //涓诲姩缁堟鍗囩骇 + this.CloseForm(); + } + }); + }; + //杩涘害鍊兼敼鍙樹簨浠� + updateLogic.ProgressEvent += (value) => { - var btnmsg = new ViewNormalControl(listView.Width); - btnmsg.X = ControlCommonResourse.XXLeft; - if (btnTemp != null) + Application.RunOnMainThread(() => { - btnmsg.Y = btnTemp.Bottom + Application.GetRealHeight(5); - } - btnmsg.Text = msg; - listView.AddChidren(btnmsg); - btnTempMsg = btnmsg; - } + //杩涘害鏉� + decimal result = value / 100; + int width = (int)(result * ProRowWidth); + btnProgressBar.Width = width; + + //鏂囨湰鏄剧ず + btnProgressView.Text = value + "%"; + //鏂囨湰鏄剧ず鐨勯偅涓浘鐗囨绉诲姩 + frameProgress.X = ControlCommonResourse.XXLeft + btnProgressBar.Right - frameProgress.Width / 2; + }); + + }; + //璁惧鍗囩骇寮�濮� + updateLogic.StartUpdateReady(); + //缁堟鍗囩骇 + btnText.ButtonClickEvent += (sender, e) => + { + //鍐嶆璋冪敤,鍐呴儴鏉′欢杈炬垚鏃�,鍙互閫夋嫨缁堟鍗囩骇 + updateLogic.StartUpdateReady(); + }; } + + #endregion + + #region 鈻� 鐣岄潰鍏抽棴___________________________ /// <summary> /// 鐢婚潰鍏抽棴 /// </summary> - /// <param name="isCloseForm">鏄惁鍏抽棴鐣岄潰,false鐨勬椂鍊�,鍙細璋冪敤鍏抽棴鍑芥暟閲岄潰鐨勯檮鍔犲姛鑳�</param> - public override void CloseForm(bool isCloseForm = true) + public override void CloseForm() { - //鍗囩骇鎺т欢 - string mainKeys = this.listUpdateDevice[0].DeviceAddr; - if (FirmwareUpdateResourse.dicDeviceUpdateList.ContainsKey(mainKeys) == true - && FirmwareUpdateResourse.dicDeviceUpdateList[mainKeys].IsFinishUpdate == true) + //瀹夊崜鍙互鐐瑰嚮绯荤粺鐨勮繑鍥為敭 + UserView.HomePage.Instance.ScrollEnabled = true; + Shared.Common.CommonPage.BackKeyCanClick = true; + + //鍗囩骇瀵硅薄 + if (FirmwareUpdateResourse.dicDeviceUpdateList.ContainsKey(deviceMac) == true + && FirmwareUpdateResourse.dicDeviceUpdateList[deviceMac].IsFinishUpdate == true) { //濡傛灉璁惧宸茬粡鍗囩骇瀹屾垚锛岀晫闈㈠叧闂椂锛屽垯绉婚櫎鍐呭瓨 - FirmwareUpdateResourse.dicDeviceUpdateList.Remove(mainKeys); + FirmwareUpdateResourse.dicDeviceUpdateList[deviceMac].Dispose(); + FirmwareUpdateResourse.dicDeviceUpdateList.Remove(deviceMac); } + this.FinishUpdateEvent = null; - base.CloseForm(isCloseForm); + base.CloseForm(); } + + #endregion } } -- Gitblit v1.8.0