From adb12dcdbb2ddaeac687c3aa9e57bb7ed459ab7e Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期三, 24 六月 2020 15:26:46 +0800 Subject: [PATCH] 2020.06.24.01 --- ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs | 190 ++++++++++++++++------------------------------- 1 files changed, 64 insertions(+), 126 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs index c399fee..d456bd7 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs @@ -15,7 +15,7 @@ /// <summary> /// 鏂颁笂鎶ョ殑璁惧 /// </summary> - private Dictionary<string, List<CommonDevice>> dicNewDevice = new Dictionary<string, List<CommonDevice>>(); + private List<CommonDevice> listNewDevice = new List<CommonDevice>(); /// <summary> /// 鏄剧ず璁惧绾跨▼鏄惁宸茬粡寮�鍚� /// </summary> @@ -49,17 +49,9 @@ /// </summary> private ZbGateway realGateway = null; /// <summary> - /// 杩涘害鏉� + /// 杩涘害鏉℃帶浠� /// </summary> - private FrameLayout btnProgressBar = null; - /// <summary> - /// 杩涘害鍊兼樉绀烘枃鏈殑鏁翠綋 - /// </summary> - private FrameLayout frameProgress = null; - /// <summary> - /// 杩涘害鍊肩殑鏄剧ず鏂囨湰 - /// </summary> - private NormalViewControl btnProgressView = null; + private ProgressRowBar btnProgressBar = null; /// <summary> /// 缃戝叧鏄惁鍏佽鍏ョ綉鐨勬爣璇� /// </summary> @@ -113,36 +105,12 @@ bodyFrameLayout.AddChidren(btnSearch); //杩涘害鏉� - var btnProRow = new FrameLayout(); - btnProRow.Gravity = Gravity.CenterHorizontal; - btnProRow.Y = Application.GetRealHeight(861); - btnProRow.Width = Application.GetRealWidth(559); - btnProRow.Height = Application.GetRealHeight(29); - btnProRow.BackgroundColor = 0xffe6e6e6; - btnProRow.Radius = (uint)Application.GetRealHeight(29) / 2; - bodyFrameLayout.AddChidren(btnProRow); - this.btnProgressBar = new FrameLayout(); - btnProgressBar.Width = 0; - btnProgressBar.Height = btnProRow.Height; - btnProgressBar.BackgroundColor = 0xfffb744a; - btnProgressBar.Radius = (uint)Application.GetRealHeight(29) / 2; - btnProRow.AddChidren(btnProgressBar); - - //杩涘害鍊兼枃鏈� - this.frameProgress = new FrameLayout(); - frameProgress.Width = Application.GetRealWidth(84); - frameProgress.Height = Application.GetRealHeight(60); - frameProgress.Y = Application.GetRealHeight(772); - bodyFrameLayout.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); - this.btnProgressView = new NormalViewControl(84, 32, true); - btnProgressView.TextSize = 10; - btnProgressView.TextAlignment = TextAlignment.Center; - btnProgressView.Text = "0%"; - frameProgress.AddChidren(btnProgressView); + this.btnProgressBar = new ProgressRowBar(559, 29); + btnProgressBar.ProgressBarGoback = false; + btnProgressBar.Gravity = Gravity.CenterHorizontal; + btnProgressBar.Y = Application.GetRealHeight(861); + bodyFrameLayout.AddChidren(btnProgressBar); + btnProgressBar.StartMode1(true); if (this.realGateway != null) { @@ -187,50 +155,42 @@ return; } - lock (this.dicNewDevice) + var jobject = Newtonsoft.Json.Linq.JObject.Parse(resultData); + CommonDevice.DeviceInfoData info = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceInfoData>(jobject["Data"].ToString()); + if (info.DriveCode != 0) { - var jobject = Newtonsoft.Json.Linq.JObject.Parse(resultData); - CommonDevice.DeviceInfoData info = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceInfoData>(jobject["Data"].ToString()); - if (info.DriveCode != 0) - { - //涓嶉渶瑕佽櫄鎷熻澶� - return; - } - //鏍规嵁璁惧Type鍒涘缓瀵瑰簲鐨勮澶囧璞� - var device = Common.LocalDevice.Current.NewDeviceObjectByDeviceId((DeviceType)jobject.Value<int>("Device_ID")); - if (device == null) - { - return; - } - device.DeviceInfo = info; - - //缁欐柊璁惧璁剧疆涓婚敭灞炴�� - Common.LocalDevice.Current.SetNewDeviceMainKeys(device, jobject); - device.CurrentGateWayId = HdlGatewayLogic.Current.GetGatewayId(this.realGateway); - //灏咲eviceInfo鐨勫睘鎬ц缃埌涓诲睘鎬т腑 - Common.LocalDevice.Current.SetDeviceInfoToMain(device, device); - - //娣诲姞璁惧鐨勭紦瀛� - device.IsOnline = 1; - Common.LocalDevice.Current.AddDeviceToMemory(ref device); - - if (this.dicNewDevice.ContainsKey(device.DeviceAddr) == false) - { - this.dicNewDevice[device.DeviceAddr] = new List<CommonDevice>(); - } - - //鍒锋柊瓒呮椂鏃堕棿 - this.waitDeviceTimeOut = 20; - - //鑾峰彇璁惧鐨勫浐瀹氬睘鎬� - HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device); - - //涓嶉渶瑕�200绔偣鐨勯偅涓澶� 2020.01.13 鍙樻洿:ota涔熷姞杩涙潵 - this.dicNewDevice[device.DeviceAddr].Add(device); - - //鏈夋柊璁惧锛屽紑鍚樉绀鸿澶囦俊鎭晫闈㈢殑绾跨▼(閲岄潰浼氱瓑寰呬笁绉掕繖鏍�) - this.StartShowDeviceAddSuccessFormThread(); + //涓嶉渶瑕佽櫄鎷熻澶� + return; } + //鏍规嵁璁惧Type鍒涘缓瀵瑰簲鐨勮澶囧璞� + var device = Common.LocalDevice.Current.NewDeviceObjectByDeviceId((DeviceType)jobject.Value<int>("Device_ID")); + if (device == null) + { + return; + } + device.DeviceInfo = info; + + //缁欐柊璁惧璁剧疆涓婚敭灞炴�� + Common.LocalDevice.Current.SetNewDeviceMainKeys(device, jobject); + device.CurrentGateWayId = this.realGateway.GwId; + //灏咲eviceInfo鐨勫睘鎬ц缃埌涓诲睘鎬т腑 + Common.LocalDevice.Current.SetDeviceInfoToMain(device, device); + + //娣诲姞璁惧鐨勭紦瀛� + device.IsOnline = 1; + Common.LocalDevice.Current.AddDeviceToMemory(ref device); + + //鍒锋柊瓒呮椂鏃堕棿 + this.waitDeviceTimeOut = 20; + + //鑾峰彇璁惧鐨勫浐瀹氬睘鎬� + HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device); + + //涓嶉渶瑕�200绔偣鐨勯偅涓澶� 2020.01.13 鍙樻洿:ota涔熷姞杩涙潵 + this.listNewDevice.Add(device); + + //鏈夋柊璁惧锛屽紑鍚樉绀鸿澶囦俊鎭晫闈㈢殑绾跨▼(閲岄潰浼氱瓑寰呬笁绉掕繖鏍�) + this.StartShowDeviceAddSuccessFormThread(); } #endregion @@ -264,22 +224,25 @@ //鐩墠灏卞紕涓�涓� Application.RunOnMainThread(() => { - foreach (var listDevice in this.dicNewDevice.Values) + var listDevice = new List<CommonDevice>(); + for (int i = 0; i < this.listNewDevice.Count; i++) { - //閲嶆柊鍙樻洿UI - foreach (var device in listDevice) + var device = this.listNewDevice[i]; + if (device.DeviceAddr != this.listNewDevice[0].DeviceAddr) { - if (device is OTADevice) - { - continue; - } - device.IconPath = string.Empty; - device.ReSave(); + continue; } - //鏄剧ず璁惧淇℃伅鐢婚潰 - this.ShowDeviceAddSuccessForm(listDevice); - break; + listDevice.Add(device); + //閲嶆柊鍙樻洿UI + if (device is OTADevice) + { + continue; + } + device.IconPath = string.Empty; + device.ReSave(); } + //鏄剧ず璁惧淇℃伅鐢婚潰 + this.ShowDeviceAddSuccessForm(listDevice); }); }); } @@ -402,7 +365,7 @@ return 0; } //缃戝叧鍛婄煡瀹㈡埛绔湁璁惧澹版槑 - this.SetDeviceProgressValue(1); + this.btnProgressBar.SetValue(1, 6); return 2; } else if (topic == gatewayId + "/Device/DeviceGetActiveEP_Respon") @@ -419,7 +382,7 @@ return 2; } //璁剧疆杩涘害鍊� - this.SetDeviceProgressValue(2); + this.btnProgressBar.SetValue(2, 6); return 2; } else if (topic == gatewayId + "/Device/DeviceGetActiveEPSimpleDesc_Respon") @@ -436,7 +399,7 @@ return 2; } //璁剧疆杩涘害鍊� - this.SetDeviceProgressValue(3); + this.btnProgressBar.SetValue(3, 6); return 2; } else if (topic == gatewayId + "/Device/DeviceGetDefaultBind_Respon") @@ -453,7 +416,7 @@ return 2; } //璁剧疆杩涘害鍊� - this.SetDeviceProgressValue(4); + this.btnProgressBar.SetValue(4, 6); return 2; } else if (topic == gatewayId + "/Device/DeviceAutoBindZBCoord_Respon") @@ -470,42 +433,17 @@ return 2; } //璁剧疆杩涘害鍊� - this.SetDeviceProgressValue(5); + this.btnProgressBar.SetValue(5, 6); return 2; } else if (topic == gatewayId + "/DeviceInComingRespon") { this.topTimeOut = topMaxTime; //缃戝叧鏈�缁堜笂鎶ヨ妭鐐硅澶囦俊鎭� - this.SetDeviceProgressValue(6); + this.btnProgressBar.SetValue(6, 6); return 1; } return 0; - } - - /// <summary> - /// 璁剧疆璁惧鐨勮繘搴﹀�� - /// </summary> - /// <param name="value"></param> - private void SetDeviceProgressValue(decimal value) - { - Application.RunOnMainThread(() => - { - //杩涘害鏉� - 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 = Application.GetRealWidth(262) + btnProgressBar.Right - frameProgress.Width / 2; - }); } /// <summary> -- Gitblit v1.8.0