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/GatewayReplaceListForm.cs | 203 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 203 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayReplaceListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayReplaceListForm.cs new file mode 100644 index 0000000..dc85bb3 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayReplaceListForm.cs @@ -0,0 +1,203 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.GatewayManage +{ + /// <summary> + /// 缃戝叧鏇挎崲鐣岄潰 + /// </summary> + public class GatewayReplaceForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 褰撳墠缃戝叧瀵硅薄 + /// </summary> + private ZbGateway nowZbGateway = null; + /// <summary> + /// 鍒楄〃鎺т欢 + /// </summary> + private VerticalListControl listView = null; + /// <summary> + /// 纭鎸夐挳 + /// </summary> + private BottomClickButton btnConfirm = null; + /// <summary> + /// 褰撳墠閫夋嫨鐨勭姸鎬佹帶浠� MainKey鏄綉鍏矷D + /// </summary> + private MostRightIconControl btnSelectIcon = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + /// <param name="i_zbGateway">褰撳墠缃戝叧瀵硅薄</param> + public void ShowForm(ZbGateway i_zbGateway) + { + this.nowZbGateway = i_zbGateway; + + //璁剧疆鏍囬淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uReplaceGateway)); + + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄦ帶浠� + /// </summary> + private void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + //纭畾鎸夐挳 + this.btnConfirm = new BottomClickButton(); + btnConfirm.TextID = R.MyInternationalizationString.uConfirm1; + btnConfirm.oldBackgroundColor = UserCenterColor.Current.ClickButtonDefultColor; + bodyFrameLayout.AddChidren(btnConfirm); + btnConfirm.CanClick = false; + btnConfirm.ButtonClickEvent += (sender, e) => + { + //鎵ц缃戝叧鏇挎崲鎿嶄綔 + this.DoReplaceGateway(); + }; + + //璇烽�夋嫨琚浛鎹㈢殑缃戝叧 + var btnMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(50), false); + btnMsg.Y = btnConfirm.Yaxis - Application.GetRealHeight(50 + 35); + btnMsg.TextSize = 12; + btnMsg.TextColor = UserCenterColor.Current.TextGrayColor1; + btnMsg.TextAlignment = TextAlignment.Center; + btnMsg.TextID = R.MyInternationalizationString.uPleaseSelectGatewayToBeReplaced; + bodyFrameLayout.AddChidren(btnMsg); + + this.listView = new VerticalListControl(29); + listView.Height = btnMsg.Y - Application.GetRealHeight(23); + listView.BackgroundColor = UserCenterColor.Current.White; + bodyFrameLayout.AddChidren(listView); + + HdlThreadLogic.Current.RunMainInThread(() => + { + //璁惧畾涓儴淇℃伅 + this.SetMiddleFrameInfo(); + }); + } + + /// <summary> + /// 璁惧畾涓儴淇℃伅 + /// </summary> + private void SetMiddleFrameInfo() + { + //鑾峰彇鏈湴鍏ㄩ儴缃戝叧瀵硅薄 + List<ZbGateway> listway = HdlGatewayLogic.Current.GetAllLocalGateway(); + var listShowWay = new List<ZbGateway>(); + for (int i = 0; i < listway.Count; i++) + { + //鍙湁绫诲瀷鐩稿悓鐨勭綉鍏�,鎵嶈兘鏄剧ず + if (listway[i].GwId != this.nowZbGateway.GwId && listway[i].LinuxImageType == this.nowZbGateway.LinuxImageType) + { + listShowWay.Add(listway[i]); + } + } + for (int i = 0; i < listShowWay.Count; i++) + { + //娣诲姞琛� + this.AddRowLayout( listShowWay[i], i != listShowWay.Count - 1); + } + + //璋冩暣鍒楄〃鎺т欢鐨勯珮搴� + this.listView.AdjustRealHeight(Application.GetRealHeight(23)); + } + + #endregion + + #region 鈻� 娣诲姞缃戝叧琛宊________________________ + + /// <summary> + /// 娣诲姞琛� + /// </summary> + /// <param name="localWay">鏈湴缃戝叧</param> + /// <param name="addLine">鏄惁娣诲姞搴曠嚎</param> + private void AddRowLayout(ZbGateway localWay, bool addLine) + { + var frameRow = new FrameRowControl(this.listView.rowSpace / 2); + this.listView.AddChidren(frameRow); + + //鍥炬爣 + var btnIcon = frameRow.AddLeftIcon(); + HdlGatewayLogic.Current.SetGatewayIcon(btnIcon, localWay); + + //鏄剧ず鏂囨湰 + var wayName = HdlGatewayLogic.Current.GetGatewayName(localWay); + if (wayName == string.Empty) + { + //鏃犳硶璇嗗埆鐨勭綉鍏宠澶� + wayName = Language.StringByID(R.MyInternationalizationString.uUnDistinguishTheGatewayDevice); + } + frameRow.AddTopView(wayName, 700); + + //鎴块棿 + var room = HdlRoomLogic.Current.GetRoomByGateway(localWay.GwId); + var roomName = HdlRoomLogic.Current.GetRoomName(room); + frameRow.AddBottomView(roomName, 700); + + //閫夋嫨鐘舵�� + var btnSelect = frameRow.AddMostRightEmptyIcon(58, 58); + btnSelect.MainKey = localWay.GwId; + btnSelect.Visible = false; + btnSelect.UnSelectedImagePath = "Item/ItemSelected.png"; + + if (addLine == true) + { + //搴曠嚎 + frameRow.AddBottomLine(); + } + frameRow.ButtonClickEvent += (sender, e) => + { + if (this.btnSelectIcon != null) { this.btnSelectIcon.Visible = false; } + + btnSelect.Visible = true; + this.btnSelectIcon = btnSelect; + this.btnSelectIcon.MainKey = localWay.GwId; + this.btnConfirm.CanClick = true; + }; + } + + #endregion + + #region 鈻� 鎵ц缃戝叧鏇挎崲鎿嶄綔___________________ + + /// <summary> + /// 鎵ц缃戝叧鏇挎崲鎿嶄綔 + /// </summary> + private void DoReplaceGateway() + { + if (this.btnSelectIcon == null) { return; } + + ZbGateway realGateway = null; + if (HdlGatewayLogic.Current.GetRealGateway(ref realGateway, this.nowZbGateway.GwId) == false) + { + //閿欒:缃戝叧瀵硅薄涓㈠け + HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg)); + return; + } + + var targetGw = HdlGatewayLogic.Current.GetLocalGateway(this.btnSelectIcon.MainKey); + //纭鏇挎崲鎺夌綉鍏�:{0}? + string msg = Language.StringByID(R.MyInternationalizationString.uReplaceGatewayConfirmMsg).Replace("{0}", HdlGatewayLogic.Current.GetGatewayName(targetGw)); + this.ShowMassage(ShowMsgType.Confirm, msg, () => + { + var form = new GatewayReplaceBackUpListForm(); + form.AddForm(realGateway, this.btnSelectIcon.MainKey); + }); + } + + #endregion + } +} -- Gitblit v1.8.0