From dc6493db59dcb0893eac50b72122f94c24056b3f Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 12 十月 2020 14:35:39 +0800 Subject: [PATCH] 新版本 --- ZigbeeApp/Shared/Phone/UserCenter/Device/Direction/AddDeviceTypeListForm.cs | 135 +++++++++++++++++++++++--------------------- 1 files changed, 70 insertions(+), 65 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Direction/AddDeviceTypeListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Direction/AddDeviceTypeListForm.cs index 602e1b1..1661741 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Direction/AddDeviceTypeListForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Direction/AddDeviceTypeListForm.cs @@ -20,10 +20,6 @@ /// 褰撳墠缃戝叧瀵硅薄 /// </summary> private ZbGateway zbGateway = null; - /// <summary> - /// mini缃戝叧鏄惁鑳藉娣诲姞璁惧 - /// </summary> - private bool MiniGatewayCanAddDevice = true; #endregion @@ -37,17 +33,10 @@ //璁惧畾鏍囬 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uDeviceType)); + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(); + this.zbGateway = HdlGatewayLogic.Current.GetLocalGateway(GatewayResourse.AppOldSelectGatewayId); - if (zbGateway != null && zbGateway.LinuxImageType == 11) - { - //鍒濆鍖朚ini缃戝叧鐨勭晫闈� - this.InitControlByMiniGateway(); - } - else - { - //鍒濆鍖栦腑閮ㄦ帶浠� - this.InitMiddleFrame(); - } } /// <summary> @@ -221,14 +210,25 @@ var rowThrid = this.AddMenuRow(objectText, unSelectPic, string.Empty, false); rowThrid.ButtonClickEvent += (sender, e) => { - if (this.MiniGatewayCanAddDevice == false) + rowThrid.CanClick = false; + HdlThreadLogic.Current.RunThread(() => { - //Mini缃戝叧鏈�澶у彧鑳芥坊鍔�16涓澶� - this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uMiniGatewayMaxDeviceCountMsg)); - return; - } - var form = new Device.DeviceSearchForm(); - form.AddForm(string.Empty); + //妫�娴嬬綉鍏� + var errorMsg = this.CheckGateway(); + HdlThreadLogic.Current.RunMain(() => + { + rowThrid.CanClick = true; + if (errorMsg != null) + { + this.ShowMassage(ShowMsgType.Tip, errorMsg); + } + else + { + var form = new Device.DeviceSearchForm(); + form.AddForm(string.Empty); + } + }); + }); }; //璋冩暣鍒楄〃鎺т欢鐨勯珮搴� @@ -237,52 +237,46 @@ #endregion - #region 鈻� mini缃戝叧___________________________ + #region 鈻� 妫�娴嬬綉鍏砡__________________________ /// <summary> - /// 鍒濆鍖朚ini缃戝叧鐨勭晫闈� + /// 妫�娴嬬綉鍏�(杩斿洖閿欒淇℃伅,null浠h〃娌¢棶棰�) /// </summary> - private void InitControlByMiniGateway() + private string CheckGateway() { - //mini澶滅伅鍙兘闄愬埗鍔犲叆16鍜岃澶� - this.ShowProgressBar(); + if (zbGateway != null && zbGateway.LinuxImageType == 11) + { + //mini澶滅伅鍙兘闄愬埗鍔犲叆16鍜岃澶� + this.ShowProgressBar(); - HdlThreadLogic.Current.RunThread(() => - { int statu = 0; //閲嶆柊鑾峰彇璁惧鍒楄〃 - var listDevice = Common.LocalDevice.Current.GetDeviceListFromGateway(zbGateway, ref statu, true, ShowErrorMode.NO); - this.CloseProgressBar(); - - HdlThreadLogic.Current.RunMain(() => + var listDevice = Common.LocalDevice.Current.GetDeviceListFromGateway(zbGateway.GwId, ref statu, true, ShowErrorMode.NO); + if (statu != 1) { - if (statu != 1) - { - listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(zbGateway.GwId); - } - //妫�娴媘ini缃戝叧鐨勮澶囨暟 - this.CheckMiniGatewayDeviceCount(listDevice); - //鍒濆鍖栫晫闈� - this.InitMiddleFrame(); - }); - }); - } - - /// <summary> - /// 妫�娴媘ini缃戝叧鐨勮澶囨暟 - /// </summary> - /// <param name="listDevice"></param> - private void CheckMiniGatewayDeviceCount(List<CommonDevice> listDevice) - { - var listMac = new HashSet<string>(); - foreach (var device in listDevice) - { - if (listMac.Contains(device.DeviceAddr) == false) - { - listMac.Add(device.DeviceAddr); + //濡傛灉 + listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(zbGateway.GwId); } - } - MiniGatewayCanAddDevice = listMac.Count < 16; + //妫�娴媘ini缃戝叧鐨勮澶囨暟 + var listMac = new HashSet<string>(); + foreach (var device in listDevice) + { + if (listMac.Contains(device.DeviceAddr) == false) + { + listMac.Add(device.DeviceAddr); + } + } + this.CloseProgressBar(); + + bool canAdd = listMac.Count < 16; + if (canAdd == false) + { + //Mini缃戝叧鏈�澶у彧鑳芥坊鍔�16涓澶� + return Language.StringByID(R.MyInternationalizationString.uMiniGatewayMaxDeviceCountMsg); + } + } + + return null; } #endregion @@ -316,14 +310,25 @@ { rowLayout.ButtonClickEvent += (sender, e) => { - if (this.MiniGatewayCanAddDevice == false) + rowLayout.CanClick = false; + HdlThreadLogic.Current.RunThread(() => { - //Mini缃戝叧鏈�澶у彧鑳芥坊鍔�16涓澶� - this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uMiniGatewayMaxDeviceCountMsg)); - return; - } - //鍙嶅皠鐩爣鐣岄潰 - this.LoadFormByFullName("Shared.Phone.UserCenter.DeviceDirection." + formName); + //妫�娴嬬綉鍏� + var errorMsg = this.CheckGateway(); + HdlThreadLogic.Current.RunMain(() => + { + rowLayout.CanClick = true; + if (errorMsg != null) + { + this.ShowMassage(ShowMsgType.Tip, errorMsg); + } + else + { + //鍙嶅皠鐩爣鐣岄潰 + this.LoadFormByFullName("Shared.Phone.UserCenter.DeviceDirection." + formName); + } + }); + }); }; } -- Gitblit v1.8.0