From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码

---
 ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayReplaceBackUpListForm.cs |  302 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 302 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayReplaceBackUpListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayReplaceBackUpListForm.cs
new file mode 100644
index 0000000..b640529
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayReplaceBackUpListForm.cs
@@ -0,0 +1,302 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+
+namespace Shared.Phone.UserCenter.GatewayManage
+{
+    /// <summary>
+    /// 鏇挎崲缃戝叧鏃�,閫夋嫨缃戝叧澶囦唤鐨勫垪琛ㄧ晫闈�
+    /// </summary>
+    public class GatewayReplaceBackUpListForm : EditorCommonForm
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 鍒楄〃鎺т欢
+        /// </summary>
+        private VerticalListControl listView = null;
+        /// <summary>
+        /// 鐪熷疄鐗╃悊缃戝叧(鏂扮綉鍏�)
+        /// </summary>
+        private ZbGateway realGateway = null;
+        /// <summary>
+        /// 琚浛鎹㈢殑鐩爣缃戝叧
+        /// </summary>
+        private string targetGwId = string.Empty;
+        /// <summary>
+        /// 褰撳墠閫夋嫨鐨勫浠�
+        /// </summary>
+        private BackupListNameInfo nowSelectInfo = null;
+        /// <summary>
+        /// 褰撳墠閫夋嫨鐨勬帶浠�
+        /// </summary>
+        private MostRightIconControl nowbtnSelect = null;
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
+        /// <summary>
+        /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
+        /// </summary>
+        /// <param name="i_zbGateway">鐪熷疄鐗╃悊缃戝叧(鏂扮綉鍏�)</param>
+        /// <param name="i_zbGateway">琚浛鎹㈢殑鐩爣缃戝叧</param>
+        public void ShowForm(ZbGateway i_realGateway, string i_targetGwId)
+        {
+            this.realGateway = i_realGateway;
+            this.targetGwId = i_targetGwId;
+
+            //璁剧疆鏍囬淇℃伅
+            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uSelectUseBackup));
+
+            //鍒濆鍖栦腑閮ㄦ帶浠�
+            this.InitMiddleFrame();
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栦腑閮ㄦ帶浠�
+        /// </summary>
+        private void InitMiddleFrame()
+        {
+            //娓呯┖bodyFrame
+            this.ClearBodyFrame();
+
+            var frameBack = new FrameLayout();
+            frameBack.Height = Application.GetRealHeight(11);
+            frameBack.BackgroundColor = UserCenterColor.Current.White;
+            bodyFrameLayout.AddChidren(frameBack);
+
+            listView = new VerticalListControl(12);
+            listView.Y = frameBack.Bottom;
+            listView.Height = bodyFrameLayout.Height - frameBack.Height;
+            listView.BackgroundColor = UserCenterColor.Current.White;
+            bodyFrameLayout.AddChidren(listView);
+
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                //浠庝簯绔幏鍙栨暟鎹�
+                this.SetBackupInfoToForm();
+            });
+        }
+
+        #endregion
+
+        #region 鈻� 浠庝簯绔幏鍙栨暟鎹甠____________________
+
+        /// <summary>
+        /// 浠庝簯绔幏鍙栨暟鎹�
+        /// </summary>
+        private void SetBackupInfoToForm()
+        {
+            //杩涘害鏉�
+            this.ShowProgressBar();
+
+            //鑾峰彇鑷姩澶囦唤鐨勬暟鎹�
+            var pageAuto = HdlBackupLogic.Current.GetBackupListNameFromDB(3, this.targetGwId);
+            if (pageAuto == null)
+            {
+                //鍏抽棴杩涘害鏉�
+                this.CloseProgressBar(ShowReLoadMode.YES);
+                return;
+            }
+
+            //浠庝簯绔幏鍙栨暟鎹� 
+            var pageData = HdlBackupLogic.Current.GetBackupListNameFromDB(2, this.targetGwId);
+            if (pageData == null)
+            {
+                //鍏抽棴杩涘害鏉�
+                this.CloseProgressBar(ShowReLoadMode.YES);
+                return;
+            }
+            //鍏抽棴杩涘害鏉�
+            this.CloseProgressBar();
+
+            if (pageAuto.Count == 0 && pageData.Count == 0)
+            {
+                //鐩爣缃戝叧妫�娴嬩笉鍒板浠芥暟鎹�,鏃犳硶鎵ц鏇挎崲鎿嶄綔
+                HdlMessageLogic.Current.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uTaegetGatewayNotHadBackupAndDoNotReplace));
+                return;
+            }
+
+            HdlThreadLogic.Current.RunMain(() =>
+            {
+                listView.RemoveAll();
+                listView.RecoverHeight();
+
+                if (pageAuto.Count > 0)
+                {
+                    pageAuto[0].IsAutoBack = 1;
+                    //娣诲姞鑷姩澶囦唤琛�
+                    this.AddRowlayout(pageAuto[0], pageData.Count > 0, true);
+                }
+
+                for (int i = 0; i < pageData.Count; i++)
+                {
+                    //娣诲姞澶囦唤琛�
+                    this.AddRowlayout(pageData[i], i != pageData.Count - 1, false);
+                }
+
+                if (pageData.Count > 0 || pageAuto.Count > 0)
+                {
+                    //鏇挎崲
+                    var btnDownload = new BottomClickButton();
+                    btnDownload.TextID = R.MyInternationalizationString.uReplace;
+                    bodyFrameLayout.AddChidren(btnDownload);
+                    btnDownload.ButtonClickEvent += (sender, e) =>
+                    {
+                        if (this.nowSelectInfo == null)
+                        {
+                            return;
+                        }
+                        //鏄惁浣跨敤澶囦唤:{0}?
+                        string msg = Language.StringByID(R.MyInternationalizationString.uSelectUseBackupConfirmMsg).Replace("{0}", this.nowbtnSelect.MainKey);
+                        this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+                        {
+                            //鎵ц缃戝叧鏇挎崲鎿嶄綔
+                            this.DoReplaceGateway();
+                        }, null, 3);
+                    };
+                    //璋冩暣鐪熷疄楂樺害
+                    listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(23));
+                }
+            });
+        }
+
+        #endregion
+
+        #region 鈻� 娣诲姞澶囦唤琛宊________________________
+
+        /// <summary>
+        /// 娣诲姞澶囦唤琛�
+        /// </summary>
+        /// <param name="fileInfo"></param>
+        /// <param name="addLine"></param>
+        /// <param name="isAuto"></param>
+        private void AddRowlayout(BackupListNameInfo fileInfo, bool addLine, bool isAuto)
+        {
+            var rowLayout = new RowLayoutControl(listView.rowSpace / 2);
+            listView.AddChidren(rowLayout);
+
+            //澶囦唤鍚嶅瓧
+            var txtText = rowLayout.frameTable.AddTopView(fileInfo.BackupName, 700);
+            if (isAuto == true)
+            {
+                txtText.TextID = R.MyInternationalizationString.uAutoBackup;
+            }
+
+            //鏃堕棿 2019-11-11T11:31:01
+            var btnTime = rowLayout.frameTable.AddBottomView("", 600);
+            if (fileInfo.CreatedOnUtc.Length >= 19)
+            {
+                btnTime.Text = UserCenterLogic.ConvertUtcTimeToLocalTime(fileInfo.CreatedOnUtc).ToString("yyyy.MM.dd HH:mm:ss");
+            }
+            //搴曠嚎
+            if (addLine == true)
+            {
+                rowLayout.frameTable.AddBottomLine();
+            }
+
+            //閫夋嫨
+            var btnSelect = rowLayout.frameTable.AddMostRightEmptyIcon(58, 58);
+            btnSelect.UnSelectedImagePath = "Item/ItemUnSelected.png";
+            btnSelect.SelectedImagePath = "Item/ItemSelected.png";
+            rowLayout.frameTable.ButtonClickEvent += (sender, e) =>
+            {
+                btnSelect.IsSelected = !btnSelect.IsSelected;
+                if (btnSelect.IsSelected == true)
+                {
+                    this.nowSelectInfo = fileInfo;
+                    if (this.nowbtnSelect != null)
+                    {
+                        nowbtnSelect.IsSelected = false;
+                    }
+                    nowbtnSelect = btnSelect;
+                    nowbtnSelect.MainKey = txtText.Text;
+                }
+                else
+                {
+                    this.nowSelectInfo = null;
+                    this.nowbtnSelect = null;
+                }
+            };
+        }
+
+        #endregion
+
+        #region 鈻� 鎵ц缃戝叧鏇挎崲鎿嶄綔___________________
+
+        /// <summary>
+        /// 鎵ц缃戝叧鏇挎崲鎿嶄綔
+        /// </summary>
+        private void DoReplaceGateway()
+        {
+            //鎵ц鏇存崲缃戝叧
+            HdlGatewayLogic.Current.DoReplaceGateway(this.realGateway, this.targetGwId, this.nowSelectInfo, (div) =>
+            {
+                if (div == 1)
+                {
+                    if (GatewayResourse.AppOldSelectGatewayId == this.targetGwId)
+                    {
+                        //濡傛灉琚浛鎹㈢殑缃戝叧鏄澶囧垪琛ㄧ晫闈㈡鍦ㄦ樉绀虹殑缃戝叧鐨勮瘽,闇�瑕佺疆绌�
+                        GatewayResourse.AppOldSelectGatewayId = string.Empty;
+                    }
+                    HdlThreadLogic.Current.RunMain(() =>
+                    {
+                         //鏄剧ず鎴愬姛鐨勭晫闈�
+                         this.ShowSuccessMsg();
+                    });
+                }
+            });
+        }
+
+        /// <summary>
+        /// 鏄剧ず鎴愬姛鐨勭晫闈�
+        /// </summary>
+        private void ShowSuccessMsg()
+        {
+            var frameBack = new FrameLayout();
+            frameBack.BackgroundColor = 0x80000000;
+            this.AddChidren(frameBack);
+
+            var frameMsg = new FrameLayout();
+            frameMsg.BackgroundColor = UserCenterColor.Current.White;
+            frameMsg.Width = Application.GetRealWidth(622);
+            frameMsg.Height = Application.GetRealHeight(317);
+            frameMsg.Radius = (uint)Application.GetRealHeight(17);
+            frameMsg.Gravity = Gravity.CenterHorizontal;
+            frameMsg.Y = Application.GetRealHeight(792);
+            frameBack.AddChidren(frameMsg);
+
+            //鎻愮ず
+            var btnTitle = new NormalViewControl(492, 65, true);
+            btnTitle.Y = Application.GetRealHeight(68);
+            btnTitle.Gravity = Gravity.CenterHorizontal;
+            btnTitle.TextID = R.MyInternationalizationString.NormalTip;
+            btnTitle.TextAlignment = TextAlignment.Center;
+            btnTitle.TextColor = 0xFF333443;
+            frameMsg.AddChidren(btnTitle);
+
+            //鏇挎崲缃戝叧鎴愬姛
+            var btnSuccess = new NormalViewControl(frameMsg.Width, Application.GetRealHeight(60), false);
+            btnSuccess.Y = Application.GetRealHeight(166);
+            btnSuccess.TextAlignment = TextAlignment.Center;
+            btnSuccess.TextColor = UserCenterColor.Current.TextGrayColor1;
+            btnSuccess.TextID = R.MyInternationalizationString.uReplacegatewaySuccess;
+            frameMsg.AddChidren(btnSuccess);
+
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                System.Threading.Thread.Sleep(2000);
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    this.CloseForm();
+                    //鎶婄綉鍏虫浛鎹竴瑙堢晫闈篃鍏充簡
+                    this.CloseFormByFormName("GatewayReplaceListForm");
+                });
+            });
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0