From 2109463fab2eb1caed189e4f258e0e763c5cea7b Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期四, 07 十一月 2019 11:58:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev-tzy' into dev-wjc

---
 ZigbeeApp/Shared/Phone/UserCenter/Gateway/Update/GatewayFirmwareUpdateForm.cs |  218 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 218 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Update/GatewayFirmwareUpdateForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Update/GatewayFirmwareUpdateForm.cs
new file mode 100755
index 0000000..2649cd1
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Update/GatewayFirmwareUpdateForm.cs
@@ -0,0 +1,218 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+
+namespace Shared.Phone.UserCenter.GatewayUpdate
+{
+    /// <summary>
+    /// 鍥轰欢鍗囩骇鐢婚潰
+    /// </summary>
+    public class GatewayFirmwareUpdateForm : DialogCommonForm
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 瑕佸崌绾х殑缃戝叧
+        /// </summary>
+        private ZbGateway upDatezbGateway = null;
+        /// <summary>
+        /// 铏氭嫙璁惧鐨勫浐浠朵俊鎭�
+        /// </summary>
+        private FirmwareVersionInfo virtualFirmware = null;
+        /// <summary>
+        /// 鍗忚皟鍣ㄦ柊鐗堟湰鐨勫浐浠朵俊鎭�
+        /// </summary>
+        private FirmwareVersionInfo coordinatorFirmware = null;
+        /// <summary>
+        /// 缃戝叧鏂扮増鏈殑鍥轰欢淇℃伅
+        /// </summary>
+        private FirmwareVersionInfo gatewayFirmware = null;
+        /// <summary>
+        /// 铏氭嫙椹卞姩鍙�
+        /// </summary>
+        private List<ZbGatewayData.DriveCodeObj> listVode = null;
+        /// <summary>
+        /// 璁惧鎴愬姛鍗囩骇瀹屾垚鐨勫洖璋冨嚱鏁�
+        /// </summary>
+        public Action FinishUpdateEvent = null;
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
+        /// <summary>
+        /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
+        /// </summary>
+        /// <param name="i_zbGateway">缃戝叧</param>
+        /// <param name="i_virtualFirmware">铏氭嫙璁惧鐨勫浐浠朵俊鎭�</param>
+        /// <param name="i_coordinatorFirmware">鍗忚皟鍣ㄦ柊鐗堟湰鐨勫浐浠朵俊鎭�</param>
+        /// <param name="i_gatewayFirmware">缃戝叧鏂扮増鏈殑鍥轰欢淇℃伅</param>
+        /// <param name="i_listVode">铏氭嫙椹卞姩</param>
+        public void ShowForm(ZbGateway i_zbGateway, FirmwareVersionInfo i_virtualFirmware, FirmwareVersionInfo i_coordinatorFirmware, 
+            FirmwareVersionInfo i_gatewayFirmware, List<ZbGatewayData.DriveCodeObj> i_listVode)
+        {
+            this.upDatezbGateway = i_zbGateway;
+            this.virtualFirmware = i_virtualFirmware;
+            this.coordinatorFirmware = i_coordinatorFirmware;
+            this.gatewayFirmware = i_gatewayFirmware;
+            this.listVode = i_listVode;
+
+            //鍒濆鍖栦腑閮ㄤ俊鎭�
+            this.InitMiddleFrame();
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栦腑閮ㄤ俊鎭�
+        /// </summary>
+        private void InitMiddleFrame()
+        {
+            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);
+
+            //杩涘害鏉�
+            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.GatewayUpdateMethod(btnText, btnProgressView, frameProgress, btnProgressBar, btnProRow.Width);
+        }
+
+        #endregion
+
+        #region 鈻� 璁惧鍗囩骇___________________________
+
+        /// <summary>
+        /// 缃戝叧鍗囩骇
+        /// </summary>
+        /// <param name="btnText">鏍囬鎺т欢</param>
+        /// <param name="btnProgressView">杩涘害鍊兼枃鏈殑鏄剧ず鎺т欢</param>
+        /// <param name="frameProgress">杩涘害鍊艰兘澶熺Щ鍔ㄧ殑閭d釜妗嗘帶浠�</param>
+        /// <param name="btnProgressBar">杩涘害鏉�</param>
+        /// <param name="ProRowWidth">杩涘害鏉″鍣ㄧ殑鏈�澶у搴�</param>
+        private void GatewayUpdateMethod(NormalViewControl btnText, NormalViewControl btnProgressView,
+            FrameLayout frameProgress, FrameLayout btnProgressBar, int ProRowWidth)
+        {
+            //璁惧鍗囩骇
+            var updateLogic = new HdlGatewayUpdateLogic(this.upDatezbGateway, virtualFirmware, coordinatorFirmware, gatewayFirmware);
+            //鏇存柊鐘舵�佸彉鍖栫殑浜嬩欢
+            updateLogic.UpdateStatuChangedEvent += (div, msg) =>
+            {
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    if (div == -1)
+                    {
+                        //寮傚父
+                        this.ShowMassage(ShowMsgType.Tip, msg);
+                        this.CloseForm();
+                    }
+                    else if (div == 0)
+                    {
+                        //涓�鑸俊鎭�
+                        btnText.Text = msg;
+                    }
+                    else if (div == 1)
+                    {
+                        //鍗囩骇瀹屾垚
+                        btnText.Text = msg;
+                        this.ShowMassage(ShowMsgType.Tip, msg);
+                        //璋冪敤鍥炶皟鍑芥暟
+                        this.FinishUpdateEvent?.Invoke();
+                        this.CloseForm();
+                    }
+                });
+            };
+            //杩涘害鍊兼敼鍙樹簨浠�
+            updateLogic.ProgressEvent += (value) =>
+            {
+                Application.RunOnMainThread(() =>
+                {
+                    //杩涘害鏉�
+                    int width = (int)(value * ProRowWidth);
+                    btnProgressBar.Width = width;
+
+                    //鏂囨湰鏄剧ず
+                    int persent = (int)(value * 100);
+                    btnProgressView.Text = persent + "%";
+                    //鏂囨湰鏄剧ず鐨勯偅涓浘鐗囨绉诲姩
+                    frameProgress.X = ControlCommonResourse.XXLeft + btnProgressBar.Right - frameProgress.Width / 2;
+                });
+
+            };
+            //缃戝叧鍗囩骇寮�濮�
+            updateLogic.StartUpdateReady();
+        }
+
+        #endregion
+
+        #region 鈻� 鐣岄潰鍏抽棴___________________________
+
+        /// <summary>
+        /// 鐢婚潰鍏抽棴
+        /// </summary>
+        public override void CloseForm()
+        {
+            //瀹夊崜鍙互鐐瑰嚮绯荤粺鐨勮繑鍥為敭
+            UserView.HomePage.Instance.ScrollEnabled = true;
+            Shared.Common.CommonPage.BackKeyCanClick = true;
+
+            //鍗囩骇瀵硅薄
+            string gwId = HdlGatewayLogic.Current.GetGatewayId(upDatezbGateway);
+            if (FirmwareUpdateResourse.dicGatewayUpdateList.ContainsKey(gwId) == true
+                && FirmwareUpdateResourse.dicGatewayUpdateList[gwId].IsFinishUpdate == true)
+            {
+                //濡傛灉缃戝叧宸茬粡鍗囩骇瀹屾垚锛岀晫闈㈠叧闂椂锛屽垯绉婚櫎鍐呭瓨
+                FirmwareUpdateResourse.dicGatewayUpdateList[gwId].Dispose();
+                FirmwareUpdateResourse.dicGatewayUpdateList.Remove(gwId);
+            }
+            this.FinishUpdateEvent = null;
+
+            base.CloseForm();
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0