From 944b87b6bcccb095cd73f13f4410fb20faf48f74 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期三, 25 十二月 2019 11:21:06 +0800 Subject: [PATCH] 2019.12.25 --- ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs | 185 +++++++++++++++------------------------------- 1 files changed, 60 insertions(+), 125 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs index 7662561..15f6ba8 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs @@ -88,19 +88,7 @@ if (listway.Count == 0) { //杩樻病鏈夌粦瀹氱綉鍏冲摝 - var btnPic = new PicViewControl(683, 392); - btnPic.UnSelectedImagePath = "Item/NoFunction.png"; - btnPic.Y = (int)(bodyFrameLayout.Height * 0.382) - Application.GetRealHeight(392 / 2); - btnPic.Gravity = Gravity.CenterHorizontal; - bodyFrameLayout.AddChidren(btnPic); - - var btnView = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(50), false); - btnView.Y = btnPic.Bottom + Application.GetRealHeight(32); - btnView.TextID = R.MyInternationalizationString.uHadNotBindGatewayMsg; - btnView.TextAlignment = TextAlignment.Center; - btnView.TextSize = 12; - btnView.TextColor = UserCenterColor.Current.TextGrayColor1; - bodyFrameLayout.AddChidren(btnView); + this.ShowNotDataImage(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uHadNotBindGatewayMsg)); return; } @@ -114,8 +102,6 @@ //璋冩暣鍒楄〃鎺т欢鐨勯珮搴� this.listview.AdjustRealHeight(Application.GetRealHeight(23)); - //璁剧疆鎺ュ彈鍦ㄧ嚎鐘舵�佹帹閫� - this.AddGatewayOnlinePush(); //寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼ this.StartGatewayOnlieCheckThread(listway); } @@ -142,15 +128,16 @@ { gatewayRow.frameTable.AddBottomLine(); } - //鎻愮ず鏈夋柊鐗堟湰 - var btnNew = new RowNewVersionTipView(); + //鎻愮ず鏂扮増鏈� + var btnNew = new InformationTipView(gatewayRow.btnIcon); btnNew.Visible = false; gatewayRow.frameTable.AddChidren(btnNew, ChidrenBindMode.BindEventOnly); gatewayRow.AddTag("btnNew", btnNew); //鍗曞嚮浜嬩欢 gatewayRow.frameTable.ButtonClickEvent += (sender, e) => { - + var form = new GatewayInfoEditorForm(); + form.AddForm(gateway); }; //鍒囨崲 @@ -176,8 +163,11 @@ } this.ShowMassage(ShowMsgType.Confirm, msg, () => { - //鎵ц鍒囨崲缃戝叧鎿嶄綔 - this.DoSwitchGateway(strWayId, gatewayRow.IsOnline); + HdlThreadLogic.Current.RunThread(() => + { + //鎵ц鍒囨崲缃戝叧鎿嶄綔 + this.DoSwitchGateway(strWayId); + }); }); }; @@ -213,16 +203,29 @@ } this.ShowMassage(ShowMsgType.Confirm, msg, () => { - this.DeleteGateway(strWayId, gatewayRow); + HdlThreadLogic.Current.RunThread(() => + { + this.DeleteGateway(strWayId, gatewayRow); + }); }); }; this.dicRowContr[strWayId] = gatewayRow; //璁剧疆涓�涓�夋嫨缃戝叧鐨勯粯璁ゅ�� - if (string.IsNullOrEmpty(GatewayResourse.AppOldSelectGatewayId) == true && gatewayRow.IsOnline == true) + if (string.IsNullOrEmpty(GatewayResourse.AppOldSelectGatewayId) == true) { - this.SaveGatewayIdToLocation(strWayId); + HdlGatewayLogic.Current.SaveGatewayIdToLocation(strWayId); } + + //褰撳墠缃戝叧鐨勮鏍� + //if (strWayId == GatewayResourse.AppOldSelectGatewayId) + //{ + // var btnNow = new IconViewControl(52); + // btnNow.Y = Application.GetMinReal(23) + gatewayRow.frameTable.chidrenYaxis; + // btnNow.UnSelectedImagePath = "Item/NowAcctionTip.png"; + // btnNow.X = gatewayRow.btnName.X + gatewayRow.btnName.GetRealWidthByText(15); + // gatewayRow.frameTable.AddChidren(btnNow, ChidrenBindMode.BindEventOnly); + //} } #endregion @@ -236,8 +239,12 @@ /// <param name="row"></param> private async void DeleteGateway(string strWayId, GatewayRowControl row) { + //鎵撳紑杩涘害鏉� + this.ShowProgressBar(); //鍒犻櫎浜戠缃戝叧 bool result = await HdlGatewayLogic.Current.DeleteGateway(strWayId); + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(); if (result == false) { return; @@ -247,15 +254,13 @@ { //濡傛灉瑙i櫎缁戝畾鐨勭綉鍏虫槸褰撳墠鎵�閫夋嫨鐨勭綉鍏崇殑璇濓紝鍒欏叧闂澶囩鐞嗙晫闈� this.closeDeviceManagForm = true; - this.SaveGatewayIdToLocation(string.Empty); + HdlGatewayLogic.Current.SaveGatewayIdToLocation(string.Empty); } - - //绉婚櫎 - if (this.dicRowContr.ContainsKey(strWayId) == true) + HdlThreadLogic.Current.RunMain(() => { - this.dicRowContr.Remove(strWayId); - } - row?.RemoveFromParent(); + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(); + }); } #endregion @@ -267,108 +272,32 @@ /// </summary> /// <param name="gatewayId"></param> /// <param name="online"></param> - private async void DoSwitchGateway(string gatewayId,bool online) + private async void DoSwitchGateway(string gatewayId) { - if (online == true) + var result = await HdlGatewayLogic.Current.DoSwitchGateway(gatewayId); + if (result == false) { - //閲嶆柊鑾峰彇鍦ㄧ嚎缃戝叧鐨勪俊鎭� - var result = await this.GetOnlineGatewayInfo(gatewayId); - if (result == false) - { - return; - } + return; } - //鍒囨崲缃戝叧,淇濆瓨缂撳瓨 - this.SaveGatewayIdToLocation(gatewayId); //濡傛灉閫夋嫨浜嗗埛鏂扮殑缃戝叧锛屽垯涓嶅叧闂鐞嗙晫闈� this.closeDeviceManagForm = false; - if (UserCenterResourse.DicActionForm.ContainsKey("DeviceListMainForm") == false) + HdlThreadLogic.Current.RunMain(() => { - //鍒锋柊涓荤敾闈� - var form = new Device.DeviceListMainForm(); - this.AddFromAndRemoveNowForm(form); - } - else - { - //鍏抽棴鐣岄潰 - this.CloseForm(); - //鍒锋柊涓荤敾闈�(涓嶉噸鏂拌幏鍙栬澶囩姸鎬�) - this.LoadFormMethodByName("DeviceListMainForm", "InitMiddleFrame", false); - } - } - - /// <summary> - /// 鑾峰彇鍦ㄧ嚎缃戝叧淇℃伅 - /// </summary> - /// <param name="gatewayId"></param> - /// <returns></returns> - private async Task<bool> GetOnlineGatewayInfo(string gatewayId) - { - //鏄剧ず杩涘害鏉� - this.ShowProgressBar(); - //鑾峰彇缃戝叧 - var gateway = HdlGatewayLogic.Current.GetLocalGateway(gatewayId); - - //妫�娴嬪箍鎾埌鐨勮繖涓綉鍏虫槸鍚︽嫢鏈変綇瀹匢D - ZbGateway realWay = null; - bool getGatewayInfo = true; - if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, gatewayId) == true) - { - //閲嶆柊璁剧疆浣忓畢ID(杩欎釜搴旇鏄笉缁忚繃APP,鐩存帴鎶婄綉鍏虫仮澶嶄簡鍑哄巶璁剧疆) - if (HdlGatewayLogic.Current.HomeIdIsEmpty(realWay.getGatewayBaseInfo.HomeId) == true) + if (UserCenterResourse.DicActionForm.ContainsKey("DeviceListMainForm") == false) { - int result2 = await HdlGatewayLogic.Current.ReBindNewGateway(realWay); - if (result2 == 0) - { - //鍑虹幇鏈煡閿欒,璇风◢鍚庡啀璇� - this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndResetAgain)); - //鍏抽棴杩涘害鏉� - this.CloseProgressBar(); - } - else if (result2 == -1) - { - //鍏抽棴杩涘害鏉� - this.CloseProgressBar(); - return false; - } - //閲嶆柊缁戝畾缃戝叧閲岄潰宸茬粡閲嶆柊鑾峰彇浜嗙綉鍏充俊鎭� - getGatewayInfo = false; + //鍒锋柊涓荤敾闈� + var form = new Device.DeviceListMainForm(); + this.AddFromAndRemoveNowForm(form); } - } - - if (getGatewayInfo == true) - { - //鑾峰彇缃戝叧淇℃伅 - var info = await HdlGatewayLogic.Current.GetGatewayNewInfoAsync(gateway); - if (info == null) + else { - //鍏抽棴杩涘害鏉� - this.CloseProgressBar(); - return false; + //鍏抽棴鐣岄潰 + this.CloseForm(); + //鍒锋柊涓荤敾闈�(涓嶉噸鏂拌幏鍙栬澶囩姸鎬�) + this.LoadFormMethodByName("DeviceListMainForm", "InitMiddleFrame", false); } - } - - //鑾峰彇鍏ㄩ儴璁惧 - bool result = await Common.LocalDevice.Current.SetDeviceToMemmoryByGateway(gateway); - //鍏抽棴杩涘害鏉� - this.CloseProgressBar(); - if (result == false) - { - return false; - } - return true; - } - - /// <summary> - /// 淇濆瓨閫夋嫨鐨勭綉鍏矷D鍒版湰鍦� - /// </summary> - /// <param name="gatewayId"></param> - private void SaveGatewayIdToLocation(string gatewayId) - { - GatewayResourse.AppOldSelectGatewayId = gatewayId; - byte[] data = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(GatewayResourse.AppOldSelectGatewayId)); - Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AppOldSelectGatewayFile, data); + }); } #endregion @@ -472,7 +401,7 @@ { if (this.dicRowContr.ContainsKey(gwid) == true && this.dicRowContr[gwid] != null) { - var btnNew = (RowNewVersionTipView)this.dicRowContr[gwid].GetTagByKey("btnNew"); + var btnNew = (InformationTipView)this.dicRowContr[gwid].GetTagByKey("btnNew"); if (btnNew != null) { btnNew.Visible = true; @@ -490,11 +419,11 @@ /// <summary> /// 鐢婚潰鍏抽棴 /// </summary> - public override void CloseForm() + public override void CloseFormBefore() { - base.CloseForm(); + base.CloseFormBefore(); - if (string.IsNullOrEmpty(GatewayResourse.AppOldSelectGatewayId) == true && this.closeDeviceManagForm == true) + if (this.closeDeviceManagForm == true) { //鍏抽棴鐣岄潰 HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId(); @@ -511,6 +440,12 @@ /// </summary> public override int FormActionAgainEvent() { + //杩涘埌杩欎釜鐣岄潰,鐞嗚涓婂墠鍥炵殑缃戝叧id鏄湁鐨�,濡傛灉涓虹┖浜�,搴旇鏄綋鍓嶇殑缃戝叧琚В缁戜簡 + if (GatewayResourse.AppOldSelectGatewayId == string.Empty) + { + //鍏抽棴璁惧鍒楄〃 + this.closeDeviceManagForm = true; + } //鍒濆鍖栦腑閮ㄦ帶浠� this.InitMiddleFrame(); return 1; -- Gitblit v1.8.0