From 1b565ce5fc003551b2db3a624f81221ac1df46b9 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 18 十一月 2019 13:04:39 +0800 Subject: [PATCH] 同步 了全部的代码 --- ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs | 87 ++++++++++++++++++++++++------------------- 1 files changed, 49 insertions(+), 38 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs index 5cde688..aa69336 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs @@ -31,7 +31,11 @@ /// <summary> /// 涓婚闂寸殑瓒呮椂鏃堕棿 -100:涓柇绾跨▼(鍗曚綅锛氱) /// </summary> - private int topTimeOut = 60; + private int topTimeOut = 120; + /// <summary> + /// 瓒呮椂鏈�澶ф椂闂� + /// </summary> + private int topMaxTime = 120; /// <summary> /// 鐢婚潰ID,鏍囪瀹冪敱鍝釜鐣岄潰璋冪敤骞舵墦寮�鐨� /// </summary> @@ -40,6 +44,10 @@ /// 缃戝叧ID /// </summary> private string gatewayId = string.Empty; + /// <summary> + /// 鐪熷疄缃戝叧 + /// </summary> + private ZbGateway realGateway = null; /// <summary> /// 杩涘害鏉� /// </summary> @@ -69,6 +77,7 @@ base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddDevice)); this.gatewayId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway); + HdlGatewayLogic.Current.GetRealGateway(ref this.realGateway, this.gatewayId); //鍒濆鍖栦腑閮ㄦ帶浠� this.InitMiddleFrame(); @@ -130,7 +139,7 @@ btnProgressView.Text = "0%"; frameProgress.AddChidren(btnProgressView); - new System.Threading.Thread(() => + HdlThreadLogic.Current.RunThread(() => { //钃濇墠鍒氳鏈夋椂鍊欑綉鍏充細鏀朵笉鍒板叆缃戠殑鍛戒护,鎵�浠ュ彂涓夋 for (int i = 0; i < 3; i++) @@ -140,16 +149,13 @@ return; } //璁╃綉鍏冲厑璁稿叆缃� - GatewayResourse.NowSelectGateway.AddNewDeviceToGateway(255); + this.realGateway.AddNewDeviceToGateway(255); System.Threading.Thread.Sleep(1000); } - }) - { IsBackground = true }.Start(); + }); //娣诲姞鐩戣璁惧鏂颁笂鎶ョ殑浜嬩欢 - GatewayResourse.NowSelectGateway.GwResDataAction += this.AdjustGatewayResultData; - //寮�鍚繛鎺ョ殑鍋囨兂鍔ㄧ敾鏁堟灉绾跨▼ - this.StartConcetionAnimeteThread(); + this.realGateway.GwResDataAction += this.AdjustGatewayResultData; } #endregion @@ -168,7 +174,7 @@ if (result == -1) { //鍋滄鎺ユ敹 - GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData; + this.realGateway.GwResDataAction -= this.AdjustGatewayResultData; Application.RunOnMainThread(() => { @@ -205,7 +211,7 @@ //缁欐柊璁惧璁剧疆涓婚敭灞炴�� Common.LocalDevice.Current.SetNewDeviceMainKeys(device, jobject); - device.CurrentGateWayId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway); + device.CurrentGateWayId = HdlGatewayLogic.Current.GetGatewayId(this.realGateway); //灏咲eviceInfo鐨勫睘鎬ц缃埌涓诲睘鎬т腑 Common.LocalDevice.Current.SetDeviceInfoToMain(device, device); @@ -251,7 +257,7 @@ } this.isDeviceThreadStart = true; - new System.Threading.Thread(() => + HdlThreadLogic.Current.RunThread(() => { while (this.waitDeviceTimeOut >= 0) { @@ -260,7 +266,7 @@ this.waitDeviceTimeOut--; } //鍋滄鎺ユ敹 - GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData; + this.realGateway.GwResDataAction -= this.AdjustGatewayResultData; System.Threading.Thread.Sleep(500); //鐩墠灏卞紕涓�涓� @@ -279,8 +285,7 @@ break; } }); - }) - { IsBackground = true }.Start(); + }); } /// <summary> @@ -331,7 +336,7 @@ btnRound.Y = Application.GetMinRealAverage(475); bodyFrameLayout.AddChidren(btnRound); - new System.Threading.Thread(() => + HdlThreadLogic.Current.RunThread(() => { int index = 1; while (this.Parent != null) @@ -350,8 +355,7 @@ } }); } - }) - { IsBackground = true }.Start(); + }); } #endregion @@ -368,7 +372,7 @@ { if (topic == gatewayId + "/Device/DeviceAnnounce_Respon") { - this.topTimeOut = 60; + this.topTimeOut = topMaxTime; //缃戝叧鍛婄煡瀹㈡埛绔湁璁惧澹版槑 this.SetDeviceProgressValue(1); return 2; @@ -381,10 +385,11 @@ if (info.Result != 0) { //鍑虹幇鏈煡閿欒,璇烽噸鏂板叆缃� - this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork)); - return -1; + //this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork)); + HdlLogLogic.Current.WriteLog(-1, resultData); + return 2; } - this.topTimeOut = 60; + this.topTimeOut = topMaxTime; //璁剧疆杩涘害鍊� this.SetDeviceProgressValue(2); return 2; @@ -397,10 +402,11 @@ if (info.Result != 0) { //鍑虹幇鏈煡閿欒,璇烽噸鏂板叆缃� - this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork)); - return -1; + //this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork)); + HdlLogLogic.Current.WriteLog(-1, resultData); + return 2; } - this.topTimeOut = 60; + this.topTimeOut = topMaxTime; //璁剧疆杩涘害鍊� this.SetDeviceProgressValue(3); return 2; @@ -414,9 +420,10 @@ { //鍑虹幇鏈煡閿欒,璇烽噸鏂板叆缃� this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork)); - return -1; + //HdlLogLogic.Current.WriteLog(-1, resultData); + return 2; } - this.topTimeOut = 60; + this.topTimeOut = topMaxTime; //璁剧疆杩涘害鍊� this.SetDeviceProgressValue(4); return 2; @@ -429,10 +436,11 @@ if (info.Result != 0) { //鍑虹幇鏈煡閿欒,璇烽噸鏂板叆缃� - this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork)); - return -1; + //this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork)); + HdlLogLogic.Current.WriteLog(-1, resultData); + return 2; } - this.topTimeOut = 60; + this.topTimeOut = topMaxTime; //璁剧疆杩涘害鍊� this.SetDeviceProgressValue(5); return 2; @@ -457,12 +465,17 @@ //杩涘害鏉� decimal result = value / 6; int width = (int)(result * Application.GetRealWidth(559)); + if (btnProgressBar.Width >= width) + { + //鏈変簺璁惧浼氫笂鎶ヤ袱娆�,杩欓噷涓嶈兘璁╁畠鐨勮繘搴︽潯寰�鍥炶蛋 + return; + } btnProgressBar.Width = width; //鏂囨湰鏄剧ず btnProgressView.Text = ((int)(result * 100)) + "%"; //鏂囨湰鏄剧ず鐨勯偅涓浘鐗囨绉诲姩 - frameProgress.X = ControlCommonResourse.XXLeft + btnProgressBar.Right - frameProgress.Width / 2; + frameProgress.X = Application.GetRealWidth(262) + btnProgressBar.Right - frameProgress.Width / 2; }); } @@ -476,7 +489,7 @@ return; } this.isTopicTimeOutThreadStart = true; - new System.Threading.Thread(() => + HdlThreadLogic.Current.RunThread(() => { while (this.Parent != null && this.topTimeOut >= 0) { @@ -494,8 +507,7 @@ this.CloseForm(); }); } - }) - { IsBackground = true }.Start(); + }); } #endregion @@ -509,15 +521,14 @@ { base.CloseForm(); //鍋滄鎺ユ敹 - GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData; + this.realGateway.GwResDataAction -= this.AdjustGatewayResultData; - new System.Threading.Thread(() => + HdlThreadLogic.Current.RunThread(() => { System.Threading.Thread.Sleep(1200); //鍏抽棴鍏ョ綉妯″紡 - GatewayResourse.NowSelectGateway.AddNewDeviceToGateway(0); - }) - { IsBackground = true }.Start(); + this.realGateway.AddNewDeviceToGateway(0); + }); } #endregion -- Gitblit v1.8.0