From 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期二, 21 七月 2020 09:46:53 +0800 Subject: [PATCH] 请合并最新多功能面板代码 --- ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WirelessApSearchForm.cs | 427 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 427 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WirelessApSearchForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WirelessApSearchForm.cs new file mode 100755 index 0000000..6e36d1d --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WirelessApSearchForm.cs @@ -0,0 +1,427 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.GatewayAdd +{ + /// <summary> + /// 鏃犵嚎缃戝叧AP妯″紡鐨勬悳绱㈢晫闈� + /// </summary> + public class WirelessApSearchForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鎼滅储鍒扮殑缃戝叧鍒楄〃 + /// </summary> + private List<ZbGateway> listZbGateway = new List<ZbGateway>(); + /// <summary> + /// 鎼滅储鍒扮殑缃戝叧绫诲埆 0:绗竴娆$粦瀹� 1:宸茬粡缁戝畾 2:闇�瑕佹崲缁� + /// </summary> + private Dictionary<string, int> dicZbGatewayDiv = new Dictionary<string, int>(); + /// <summary> + /// 鑾峰彇寰楀埌浜嗘柊缃戝叧 + /// </summary> + private bool newGatewayGetting = false; + /// <summary> + /// 缃戝叧鎼滅储涓� + /// </summary> + private bool isGatewaySearching = true; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + //璁剧疆鏍囬淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddWirelessGateway)); + + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitDefultMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄦ帶浠� + /// </summary> + private void InitDefultMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + //缃戝叧濡傛灉姝e父杩炴帴璺敱鍣▄0}绯荤粺鎸囩ず鐏細1绉掗棯鐑� + string[] ArryMsg = Language.StringByID(R.MyInternationalizationString.uAddApWirelessGatewayMsg4).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries); + int yy = Application.GetRealHeight(1066); + foreach (var msg in ArryMsg) + { + var btnMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false); + btnMsg.Text = msg; + btnMsg.Y = yy; + btnMsg.TextAlignment = TextAlignment.Center; + btnMsg.TextColor = UserCenterColor.Current.TextGrayColor1; + bodyFrameLayout.AddChidren(btnMsg); + yy = btnMsg.Bottom; + } + + //鍒濆鍖栬繛鎺ョ殑鍋囨兂鍔ㄧ敾鏁堟灉 + this.InitConcetionAnimete(); + //寮�鍚綉鍏虫娴嬬殑绾跨▼ + this.StartCheckGatewayThread(); + } + + /// <summary> + /// 鍒濆鍖栧け璐ユā寮忕殑涓儴鎺т欢 + /// </summary> + private void InitFailMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + //鍥炬爣 + var picGwImage = new FrameLayout(); + picGwImage.Width = this.GetPictrueRealSize(861); + picGwImage.Height = this.GetPictrueRealSize(245); + picGwImage.Y = Application.GetRealWidth(223); + picGwImage.Gravity = Gravity.CenterHorizontal; + picGwImage.BackgroundImagePath = "Gateway/WirelessApGatewaySearching.png"; + bodyFrameLayout.AddChidren(picGwImage); + var btnFailIcon = new PicViewControl(66, 66); + btnFailIcon.UnSelectedImagePath = "Item/FailIcon.png"; + btnFailIcon.Gravity = Gravity.CenterHorizontal; + btnFailIcon.Y = this.GetPictrueRealSize(110); + picGwImage.AddChidren(btnFailIcon); + //鎼滅储澶辫触 + var btnFailView = new NormalViewControl(300, 60, true); + btnFailView.TextAlignment = TextAlignment.Center; + btnFailView.Y = picGwImage.Bottom - Application.GetRealHeight(15); + btnFailView.Gravity = Gravity.CenterHorizontal; + btnFailView.TextColor = UserCenterColor.Current.TextGrayColor3; + btnFailView.TextID = R.MyInternationalizationString.uSearchFail; + bodyFrameLayout.AddChidren(btnFailView); + + //瑙e喅鏂规硶锛屽彲閫夋嫨鎵ц浠ヤ笅浠绘剰涓�绉嶆柟寮忥細 + var btnMsg1 = new NormalViewControl(930, 60, true); + btnMsg1.X = Application.GetRealWidth(75); + btnMsg1.Y = picGwImage.Bottom + Application.GetRealHeight(112); + btnMsg1.TextID = R.MyInternationalizationString.uSearchGatewayFailMsg1; + bodyFrameLayout.AddChidren(btnMsg1); + //1.鐭寜HID/WCFG鎸夐敭锛岀郴缁熸寚绀虹伅蹇棯3绉掞紝缃戝叧杩涘叆鎹㈢粦妯″紡锛屽己鍒剁綉鍏崇粦瀹氬埌褰撳墠APP + var btnMsg2 = new NormalViewControl(930, 100, true); + btnMsg2.X = Application.GetRealWidth(75); + btnMsg2.Y = btnMsg1.Bottom + Application.GetRealHeight(35); + btnMsg2.Text = Language.StringByID(R.MyInternationalizationString.uSearchGatewayFailMsg2).Replace("{0}", "\r\n"); + btnMsg2.TextSize = 12; + btnMsg2.TextColor = UserCenterColor.Current.TextGrayColor1; + btnMsg2.IsMoreLines = true; + bodyFrameLayout.AddChidren(btnMsg2); + //2.闀挎寜缃戝叧ZB/RST鎸夐敭20绉掍互涓婏紝鐩村埌鎵�鏈夋寚绀虹伅鍚屾椂鐏紝鍗虫仮澶嶅嚭鍘傝缃苟閲嶅惎 + var btnMsg3 = new NormalViewControl(930, 100, true); + btnMsg3.X = Application.GetRealWidth(75); + btnMsg3.Y = btnMsg2.Bottom + Application.GetRealHeight(12); + btnMsg3.Text = Language.StringByID(R.MyInternationalizationString.uSearchGatewayFailMsg3).Replace("{0}", "\r\n"); + btnMsg3.TextSize = 12; + btnMsg3.TextColor = UserCenterColor.Current.TextGrayColor1; + btnMsg3.IsMoreLines = true; + bodyFrameLayout.AddChidren(btnMsg3); + //3.璇烽噸璇曪紝閲嶆柊娣诲姞缃戝叧銆� + var btnMsg4 = new NormalViewControl(930, 50, true); + btnMsg4.X = Application.GetRealWidth(75); + btnMsg4.Y = btnMsg3.Bottom + Application.GetRealHeight(12); + btnMsg4.Text = Language.StringByID(R.MyInternationalizationString.uSearchGatewayFailMsg4); + btnMsg4.TextSize = 12; + btnMsg4.TextColor = UserCenterColor.Current.TextGrayColor1; + bodyFrameLayout.AddChidren(btnMsg4); + //4.杩斿洖缃戝叧绠$悊銆� + var btnMsg5 = new NormalViewControl(930, 50, true); + btnMsg5.X = Application.GetRealWidth(75); + btnMsg5.Y = btnMsg4.Bottom + Application.GetRealHeight(12); + btnMsg5.Text = Language.StringByID(R.MyInternationalizationString.uSearchGatewayFailMsg5); + btnMsg5.TextSize = 12; + btnMsg5.TextColor = UserCenterColor.Current.TextGrayColor1; + bodyFrameLayout.AddChidren(btnMsg5); + + //閲嶈瘯 + var frameback = new FrameLayoutStatuControl(); + frameback.UseClickStatu = false; + frameback.Y = Application.GetRealHeight(1259); + frameback.Gravity = Gravity.CenterHorizontal; + frameback.Width = Application.GetRealWidth(746); + frameback.Height = Application.GetRealHeight(184); + frameback.BackgroundImagePath = "Item/BottomButtonGround.png"; + bodyFrameLayout.AddChidren(frameback); + var btnReDo = new NormalViewControl(300, 65, true); + btnReDo.IsBold = true; + btnReDo.TextColor = UserCenterColor.Current.White; + btnReDo.TextSize = 16; + btnReDo.Y = Application.GetRealHeight(49); + btnReDo.Gravity = Gravity.CenterHorizontal; + btnReDo.TextAlignment = TextAlignment.Center; + btnReDo.TextID = R.MyInternationalizationString.uReDoAgain; + frameback.AddChidren(btnReDo, ChidrenBindMode.BindEvent); + frameback.ButtonClickEvent += (sender, e) => + { + //鍒濆鍖栧垵濮嬩腑閮ㄦ帶浠� + this.InitDefultMiddleFrame(); + }; + + //杩斿洖缃戝叧绠$悊 + var btnGoBack = new BottomClickButton(688); + btnGoBack.Y = Application.GetRealHeight(1495); + btnGoBack.TextID = R.MyInternationalizationString.uGobackGatewayManage; + if (UserCenterResourse.DicActionForm.ContainsKey("GatewayListForm") == false) + { + //杩斿洖涓婚〉 + btnGoBack.TextID = R.MyInternationalizationString.uGobackToHomePage; + } + bodyFrameLayout.AddChidren(btnGoBack); + btnGoBack.ButtonClickEvent += (sender, e) => + { + this.CloseForm(); + //鍏抽棴鎸囧畾鐣岄潰 + this.CloseFormByFormName("NewGateWayMenuSelectForm"); + }; + } + + #endregion + + #region 鈻� 鍋囨兂鍔ㄧ敾___________________________ + + /// <summary> + /// 鍒濆鍖栬繛鎺ョ殑鍋囨兂鍔ㄧ敾鏁堟灉 + /// </summary> + private void InitConcetionAnimete() + { + //鍥炬爣 + var btnGwImage = new FrameLayout(); + btnGwImage.Width = this.GetPictrueRealSize(861); + btnGwImage.Height = this.GetPictrueRealSize(245); + btnGwImage.Y = Application.GetRealHeight(360); + btnGwImage.Gravity = Gravity.CenterHorizontal; + btnGwImage.BackgroundImagePath = "Gateway/WirelessApGatewaySearching.png"; + bodyFrameLayout.AddChidren(btnGwImage); + + //姝e湪鎼滅储缃戝叧鈥� + var btnMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false); + btnMsg.TextID = R.MyInternationalizationString.uGatewaySearching; + btnMsg.Y = Application.GetRealHeight(821); + btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3; + btnMsg.TextAlignment = TextAlignment.Center; + bodyFrameLayout.AddChidren(btnMsg); + + //棣栨牸鐨刋杞� + int firstPoint = this.GetPictrueRealSize(275); + //涓�鏍肩殑瀹藉害 + int width = this.GetPictrueRealSize(22); + //闂磋窛澶у皬 + int space = this.GetPictrueRealSize(12); + + //鐢熸垚鏍煎瓙鍧愭爣 + var listPoint = new List<int>(); + for (int i = 0; i < 9; i++) + { + listPoint.Add(firstPoint + (width + space) * i); + } + + //寮�鍚繛鎺ョ殑鍋囨兂鍔ㄧ敾鏁堟灉绾跨▼ + var btnRound = new PicViewControl(width, width, false); + btnRound.Radius = (uint)width / 2; + btnRound.BackgroundColor = UserCenterColor.Current.ConcetionRoundColor; + btnRound.Y = this.GetPictrueRealSize(135); + btnRound.X = listPoint[0]; + btnGwImage.AddChidren(btnRound); + + string strMsg = btnMsg.Text; + HdlThreadLogic.Current.RunThread(() => + { + int index = 1; + //璁℃椂鏃堕棿 + int timeCount = 0; + //瓒呮椂鏃堕棿 + int timeOut = 240; + while (btnGwImage.Parent != null) + { + timeCount++; + if (timeCount == 10) + { + //5绉掑悗娓呯┖缃戝叧鍒楄〃 + HdlGatewayLogic.Current.ClearAllRealGateway(); + ZigBee.Common.Application.IsSearchingGateway = true; + } + if (timeCount % 2 == 0) + { + timeOut--; + } + if (this.newGatewayGetting == true || timeOut <= 0) + { + //鑾峰彇寰楀埌鏂扮綉鍏�,鍒欎腑鏂嚎绋� + break; + } + + Application.RunOnMainThread(() => + { + btnRound.X = listPoint[index]; + index++; + if (index == listPoint.Count) + { + index = 0; + } + //姝e湪鎼滅储缃戝叧鈥Xs + btnMsg.Text = strMsg + timeOut + "s"; + }); + + System.Threading.Thread.Sleep(500); + } + //鎼滅储缁撴潫 + this.isGatewaySearching = false; + + if (timeOut <= 0) + { + HdlThreadLogic.Current.RunMain(() => + { + //鍒濆鍖栧け璐ユā寮忕殑涓儴鎺т欢 + this.InitFailMiddleFrame(); + }); + } + else if (newGatewayGetting == true) + { + HdlThreadLogic.Current.RunMain(() => + { + if (this.Parent != null) + { + var form = new GatewayManage.GatewaySearchListForm(); + this.AddFromAndRemoveNowForm(form, listZbGateway, dicZbGatewayDiv); + } + }); + } + }); + } + + #endregion + + #region 鈻� 缃戝叧妫�娴媉__________________________ + + /// <summary> + /// 寮�鍚綉鍏虫娴嬬殑绾跨▼ + /// </summary> + private void StartCheckGatewayThread() + { + this.isGatewaySearching = true; + HdlThreadLogic.Current.RunThread(async () => + { + int count = 0; + while (this.Parent != null && this.isGatewaySearching == true) + { + //姣�2绉掓娴嬫悳绱㈠埌鐨勭綉鍏� + System.Threading.Thread.Sleep(500); + count++; + if (count < 4) + { + //涓昏涓轰簡蹇竴鐐硅兘澶熶腑鏂繖涓嚎绋� + continue; + } + count = 0; + + await this.CheckZbGatewayAndSetRow(); + + if (this.newGatewayGetting == true) + { + //鑾峰彇寰楀埌鏂扮綉鍏�,鍒欎腑鏂嚎绋� + break; + } + } + }); + } + + /// <summary> + /// 妫�娴嬫悳绱㈠埌鐨勭綉鍏� + /// </summary> + private async Task<bool> CheckZbGatewayAndSetRow() + { + for (int i = 0; i < ZbGateway.GateWayList.Count; i++) + { + var way = ZbGateway.GateWayList[i]; + var wayId = way.GwId; + if (dicZbGatewayDiv.ContainsKey(wayId) == true) + { + //宸茬粡澶勭悊浜� + continue; + } + + //缃戝叧缁戝畾妯″紡 + GatewayBindMode mode = GatewayBindMode.BindAgain; + //濡傛灉鏄涓�娆$粦瀹�,鎴栬�呮槸浠ュ墠宸茬粡缁戝畾杩囦簡鐨� + if (HdlGatewayLogic.Current.HomeIdIsEmpty(way) == true + || way.HomeId == Common.Config.Instance.HomeId) + { + if (way.HomeId != Common.Config.Instance.HomeId) + { + //绗竴娆$粦瀹�,涔熷氨鏄綉鍏充綇瀹匢D涓虹┖ + mode = GatewayBindMode.First; + } + else + { + //宸茬粡缁戝畾杩囦簡 + mode = GatewayBindMode.Binded; + } + //娣诲姞鎼滅储鍒扮殑缃戝叧鍒扮紦瀛�(鎵ц缃戝叧淇濆瓨鎿嶄綔) + var result = await HdlGatewayLogic.Current.AddNewGateway(way, ShowErrorMode.NO); + if (result == false) + { + continue; + } + } + //鏀堕泦缃戝叧瀵硅薄 + this.listZbGateway.Add(way); + + //鍏ㄩ儴澶勭悊OK鍚庯紝鎵嶈兘璁剧疆flage + if (mode == GatewayBindMode.First) + { + //绗竴娆$粦瀹� + this.dicZbGatewayDiv[wayId] = 0; + //鑾峰彇鍒颁簡鏂扮綉鍏� + this.newGatewayGetting = true; + } + else if (mode == GatewayBindMode.Binded) + { + //宸茬粡缁戝畾杩� + this.dicZbGatewayDiv[wayId] = 1; + } + else + { + //闇�瑕侀噸鏂扮粦瀹� + this.dicZbGatewayDiv[wayId] = 2; + //鑾峰彇鍒颁簡鏂扮綉鍏� + this.newGatewayGetting = true; + } + + if (mode == GatewayBindMode.First || mode == GatewayBindMode.Binded) + { + //鎴戣寰楄繖閲岄渶瑕佽幏鍙栦竴涓嬫柊缃戝叧鐨勮澶囧垪琛� + Common.LocalDevice.Current.SetDeviceToMemmoryByGateway(way); + } + } + return true; + } + + #endregion + + #region 鈻� 鐣岄潰鍏抽棴___________________________ + + /// <summary> + /// 鐣岄潰鍏抽棴 + /// </summary> + public override void CloseFormBefore() + { + ZigBee.Common.Application.IsSearchingGateway = false; + + base.CloseFormBefore(); + } + + #endregion + } +} -- Gitblit v1.8.0