From 2450c12c825ad4d78d1572da2fa421706db2df2f Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 18 六月 2020 16:01:14 +0800 Subject: [PATCH] 新代码 --- ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundListForm.cs | 181 ++++++++++++++++++++++++++++++--------------- 1 files changed, 120 insertions(+), 61 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundListForm.cs b/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundListForm.cs index 54f2151..5b1441d 100755 --- a/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundListForm.cs +++ b/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundListForm.cs @@ -69,7 +69,7 @@ //鐢婚潰鍏抽棴 dialogForm.CloseDialog(); }; - }; + }; } /// <summary> @@ -130,17 +130,11 @@ /// <returns></returns> private async Task getData() { - //SmartSoundInfo.Auth auth = new SmartSoundInfo.Auth(); - //auth.HomeID = Common.Config.Instance.Home.Id; - //auth.UserID = Common.Config.Instance.Guid; - //auth.Platform = ""; string url = string.Format("https://developer.hdlcontrol.com/zigbeespeakerservice/Auth?Platform&PageSetting.PageSize=100&PageSetting.PageIndex=1&UserID={0}&HomeID={1}", Common.Config.Instance.Guid,Common.Config.Instance.Home.Id); - dataString = await MyHttpWebResponse.GetWebRequest(url); - - smartSoundInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<SmartSoundInfo>(dataString); - + dataString = await MyHttpWebResponse.GetWebRequest(url); + smartSoundInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<SmartSoundInfo>(dataString); } /// <summary> @@ -150,8 +144,7 @@ /// <param name="new_remark"></param> /// <returns></returns> private async Task<string> setRemark(SmartSoundInfo.SoundInfo soundInfo, string new_remark) - { - + { if (soundInfo == null) return ""; @@ -162,7 +155,7 @@ "\"UserID\":" + "\"" + soundInfo.UserID + "\"" + "," + "\"HomeID\":" + "\"" + soundInfo.HomeID + "\"" + "}"; - string response_str = await MyHttpWebResponse.PutWebRequest(url, json, Encoding.UTF8); + string response_str = MyHttpWebResponse.PutWebRequest(url, json, Encoding.UTF8); JObject jObject = JObject.Parse(response_str); return jObject["StateCode"].ToString(); @@ -178,55 +171,66 @@ for (int i = 0; i < smartSoundInfo.ResponseData.Data.Count; i++) { - // - var smartSound = smartSoundInfo.ResponseData.Data[i]; - var row = new SoundRowLayout(); - listView.AddChidren(row); - - if (smartSound.Platform == "Baidu") + try { - row.Account = "灏忓害锛�" + smartSound.UserName; - row.ImagePath = "SmartSound/Xiaodu.png"; - row.Remark = smartSound.Remark; + // + var smartSound = smartSoundInfo.ResponseData.Data[i]; + var row = new SoundRowLayout(); + listView.AddChidren(row); + + if (smartSound.PlatfromName == "Baidu") + { + string remark = "灏忓害"; + if (smartSound.Remark != null && smartSound.Remark.Trim() != "") + remark += "(" + smartSound.Remark + ")"; + + row.ImagePath = "SmartSound/Xiaodu.png"; + row.Remark = remark; + } + + row.InitControl(); + row.btnDelect.AddTag("index", i); + row.btnRename.AddTag("index", i); + row.frameTable.AddTag("index", i); + + //閲嶅懡鍚� + row.btnRename.ButtonClickEvent += (sender, e) => + { + int index = (int)((NormalViewControl)sender).GetTagByKey("index"); + var smartSound1 = smartSoundInfo.ResponseData.Data[index]; + ShowRenameDialog(row, smartSound1); + }; + + // 瑙i櫎缁戝畾 + row.btnDelect.ButtonClickEvent += (sender, e) => + { + int index = (int)(((NormalViewControl)sender).GetTagByKey("index")); + var smartSound1 = smartSoundInfo.ResponseData.Data[index]; + ShowDelectDialog(smartSound1); + }; + + //璺宠浆鍒版帶鍒跺唴瀹圭晫闈� FrameRowControl + row.frameTable.ButtonClickEvent += (sender, e) => + { + int index = (int)row.frameTable.GetTagByKey("index"); + if (SmartSound.getInstantiate().LayerList != null) + SmartSound.getInstantiate().LayerList.Clear(); + + var smartSoundControlForm = new SmartSoundControlForm(smartSoundInfo.ResponseData.Data[index]); + smartSoundControlForm.AddForm(); + }; } - - row.InitControl(); - row.btnDelect.AddTag("index", i); - row.btnRename.AddTag("index", i); - row.frameTable.AddTag("index", i); - - //閲嶅懡鍚� - row.btnRename.ButtonClickEvent += (sender, e) => + catch (Exception e) { - int index = (int)((NormalViewControl)sender).GetTagByKey("index"); - var smartSound1 = smartSoundInfo.ResponseData.Data[index]; - ShowRenameDialog(row, smartSound1); - }; - - // 瑙i櫎缁戝畾 - row.btnDelect.ButtonClickEvent += (sender, e) => - { - int index = (int)(((NormalViewControl)sender).GetTagByKey("index")); - ShowDelectDialog(index); - }; - - //璺宠浆鍒版帶鍒跺唴瀹圭晫闈� FrameRowControl - row.frameTable.ButtonClickEvent += (sender, e) => - { - int index = (int)row.frameTable.GetTagByKey("index"); - if (SmartSound.getInstantiate().LayerList != null) - SmartSound.getInstantiate().LayerList.Clear(); - - var smartSoundControlForm = new SmartSoundControlForm(smartSoundInfo.ResponseData.Data[index]); - smartSoundControlForm.AddForm(); - }; + this.ShowMassage(ShowMsgType.Tip, e.Message); + } } } /// <summary> /// 瑙i櫎缁戝畾寮圭獥 /// </summary> - private void ShowDelectDialog(int index) + private void ShowDelectDialog(SmartSoundInfo.SoundInfo smartSound) { //鐢熸垚涓�涓脊绐楃敾闈� var dialogForm = new TextDialog("瑙i櫎缁戝畾闇�瑕佸埌绗笁鏂� APP 杩涜鎿嶄綔", "璺宠浆鑷冲皬搴�"); @@ -235,8 +239,41 @@ //鎸変笅纭鎸夐挳 dialogForm.ComfirmClickEvent += () => { - //鐢婚潰鍏抽棴 - dialogForm.CloseDialog(); + HdlThreadLogic.Current.RunThread(() => + { + this.ShowProgressBar("鍒犻櫎鏈嶅姟鍣ㄨ褰�..."); + string json = DelectSmartSound(smartSound); + if (json == "SUCCESS") + { + smartSoundInfo.ResponseData.Data.Remove(smartSound); + } + this.CloseProgressBar(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + //鐢婚潰鍏抽棴 + dialogForm.CloseDialog(); + bool bol = false; + try + { +#if Android + bol = HDLUtils.OpenAppWithPackageName("com.baidu.duer.superapp"); +#else + HDLUtils.OpenApp("xiaoduapp://"); +#endif + } + catch (Exception e) + { + string error = e.Message; + bol = false; + } + if (!bol) + { + this.ShowMassage(ShowMsgType.Tip, "鎵撳紑APP澶辫触"); + } + iniView(); + }); + }); }; } /// <summary> @@ -250,7 +287,8 @@ //娣诲姞澶囦唤 dialogForm.SetTitleText("閲嶅懡鍚�"); //璇疯緭鍏ュ浠藉悕绉� - dialogForm.SetTipText(smartSound.Remark); + dialogForm.SetTipText("璇疯緭鍏ュ悕绉�"); + dialogForm.Text = smartSound.Remark; //鎸変笅纭鎸夐挳 dialogForm.ComfirmClickEvent += (async (textValue) => @@ -264,7 +302,7 @@ if (str == "SUCCESS") { smartSound.Remark = remark; - soundRowLayout.btnRemark.Text = textValue; + soundRowLayout.btnRemark.Text = "灏忓害" + "(" + textValue + ")"; } else { @@ -276,8 +314,29 @@ #endregion + /// <summary> + /// 鍒犻櫎鏁版嵁 + /// </summary> + /// <param name="soundInfo"></param> + /// <returns></returns> + private string DelectSmartSound(SmartSoundInfo.SoundInfo soundInfo) + { + if (soundInfo == null) + return ""; - #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________ + string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/Auth"; + string json = "{" + + "\"AuthID\":" + "\"" + soundInfo.Id + "\"" + "," + + "\"UserID\":" + "\"" + soundInfo.UserID + "\"" + "," + + "\"HomeID\":" + "\"" + soundInfo.HomeID + "\"" + "}"; + + string response_str = MyHttpWebResponse.DeleteWebRequest(url, json, Encoding.UTF8); + JObject jObject = JObject.Parse(response_str); + + return jObject["StateCode"].ToString(); + } + +#region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________ /// <summary> /// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠� @@ -287,9 +346,9 @@ return 1; } - #endregion +#endregion - #region 鈻� 鍏抽棴鐣岄潰___________________________ +#region 鈻� 鍏抽棴鐣岄潰___________________________ /// <summary> /// 鐢婚潰鍏抽棴 @@ -299,7 +358,7 @@ base.CloseFormBefore(); } - #endregion - +#endregion + } } \ No newline at end of file -- Gitblit v1.8.0