| | |
| | | using System.Threading.Tasks; |
| | | using Newtonsoft.Json.Linq; |
| | | using Shared.Common; |
| | | using Shared.Phone.SmartSound.Forms; |
| | | using Shared.Phone.UserCenter.Device; |
| | | using Shared.Phone.UserCenter.SmartSound.Util; |
| | | using Shared.Phone.UserCenter.SmartSound.Widget; |
| | |
| | | private RowLayoutControl oldShowRightMuneRow = null; |
| | | |
| | | private static string dataString = ""; |
| | | private MostRightIconControl btnAddDeviceIcon = null; |
| | | |
| | | |
| | | #region ■ 初始化_____________________________ |
| | |
| | | base.SetTitleText("智能音箱"); |
| | | Dictionary<string, string> floorDictionary = Config.Instance.Home.FloorDics;//楼层列表 |
| | | |
| | | var helpBtn = new MyButton(); |
| | | helpBtn.TextColor = UserCenterColor.Current.TextOrangeColor; |
| | | helpBtn.Text = "帮助"; |
| | | helpBtn.Gravity = Gravity.CenterRight; |
| | | helpBtn.TextAlignment = TextAlignment.CenterRight; |
| | | topFrameLayout.AddChidren(helpBtn); |
| | | helpBtn.X -= Application.GetRealWidth(58); |
| | | //右上添加按钮 |
| | | if (btnAddDeviceIcon == null) |
| | | { |
| | | btnAddDeviceIcon = new MostRightIconControl(69, 69); |
| | | btnAddDeviceIcon.UnSelectedImagePath = "Item/Add.png"; |
| | | topFrameLayout.AddChidren(btnAddDeviceIcon); |
| | | btnAddDeviceIcon.InitControl(); |
| | | btnAddDeviceIcon.ButtonClickEvent += (sender, e) => |
| | | { |
| | | var helpForm = new AddSmartSound(); |
| | | helpForm.AddForm(); |
| | | }; |
| | | } |
| | | |
| | | //var helpBtn = new MyButton(); |
| | | //helpBtn.TextColor = UserCenterColor.Current.TextOrangeColor; |
| | | //helpBtn.Text = "帮助"; |
| | | //helpBtn.Gravity = Gravity.CenterRight; |
| | | //helpBtn.TextAlignment = TextAlignment.CenterRight; |
| | | //topFrameLayout.AddChidren(helpBtn); |
| | | //helpBtn.X -= Application.GetRealWidth(58); |
| | | |
| | | //初始化中部控件 |
| | | this.InitMiddleFrame(); |
| | | |
| | | helpBtn.MouseUpEventHandler += (sernder, e) => |
| | | { |
| | | //生成一个弹窗画面 |
| | | var dialogForm = new TextDialog("绑定智能音箱到第三方 APP 进行操作", "跳转至小度"); |
| | | dialogForm.SetTitleText("帮助"); |
| | | //helpBtn.MouseUpEventHandler += (sernder, e) => |
| | | //{ |
| | | // var helpForm = new AddSmartSound(); |
| | | // helpForm.AddForm(); |
| | | // /* |
| | | // //生成一个弹窗画面 |
| | | // var dialogForm = new TextDialog("绑定智能音箱到第三方 APP 进行操作", "跳转至小度APP"); |
| | | // dialogForm.SetTitleText("帮助"); |
| | | |
| | | //按下确认按钮 |
| | | dialogForm.ComfirmClickEvent += () => |
| | | { |
| | | //画面关闭 |
| | | dialogForm.CloseDialog(); |
| | | }; |
| | | }; |
| | | // //按下确认按钮 |
| | | // dialogForm.ComfirmClickEvent += () => |
| | | // { |
| | | // //画面关闭 |
| | | // dialogForm.CloseDialog(); |
| | | // OpenXiaoDuAPP(); |
| | | // };*/ |
| | | //}; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | this.CloseProgressBar(); |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | }
|
| | | |
| | | /// <summary> |
| | | /// 获取音箱列表 |
| | | /// </summary> |
| | | /// <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> |
| | |
| | | /// <param name="new_remark"></param> |
| | | /// <returns></returns> |
| | | private async Task<string> setRemark(SmartSoundInfo.SoundInfo soundInfo, string new_remark) |
| | | { |
| | | |
| | | { |
| | | if (soundInfo == null) |
| | | return ""; |
| | | |
| | |
| | | "\"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(); |
| | |
| | | |
| | | 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; |
| | | }else if (smartSound.PlatfromName == "AISpeech") |
| | | { |
| | | string remark = "思必驰"; |
| | | if (smartSound.Remark != null && smartSound.Remark.Trim() != "") |
| | | remark += "(" + smartSound.Remark + ")"; |
| | | |
| | | row.ImagePath = "SmartSound/Sibici.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); |
| | | }; |
| | | |
| | | // 解除绑定 |
| | | 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); |
| | | }; |
| | | this.ShowMassage(ShowMsgType.Tip, e.Message); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 解除绑定 |
| | | row.btnDelect.ButtonClickEvent += (sender, e) => |
| | | private void OpenXiaoDuAPP() |
| | | { |
| | | bool bol = false; |
| | | try |
| | | { |
| | | #if Android |
| | | bol = HDLUtils.OpenAppWithPackageName("com.baidu.duer.superapp"); |
| | | #else |
| | | bol=HDLUtils.OpenApp("xiaoduapp://"); |
| | | #endif |
| | | |
| | | if (!bol) |
| | | { |
| | | int index = (int)(((NormalViewControl)sender).GetTagByKey("index")); |
| | | ShowDelectDialog(index); |
| | | }; |
| | | #if Android |
| | | HDLUtils.OpenUrl("market://details?id=com.baidu.duer.superapp"); |
| | | #else |
| | | HDLUtils.OpenUrl("https://apps.apple.com/cn/app/%E5%B0%8F%E5%BA%A6/id1437733193"); |
| | | #endif |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | string error = e.Message; |
| | | bol = false; |
| | | } |
| | | } |
| | | |
| | | //跳转到控制内容界面 FrameRowControl |
| | | row.frameTable.ButtonClickEvent += (sender, e) => |
| | | /// <summary> |
| | | /// 思必驰 |
| | | /// </summary> |
| | | private void OpenSBCAPP() |
| | | { |
| | | bool bol = false; |
| | | try |
| | | { |
| | | #if Android |
| | | bol = HDLUtils.OpenAppWithPackageName("com.aispeech.companionapp"); |
| | | #else |
| | | bol=HDLUtils.OpenApp("AispeechMobile://"); |
| | | #endif |
| | | |
| | | if (!bol) |
| | | { |
| | | 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(); |
| | | }; |
| | | #if Android |
| | | HDLUtils.OpenUrl("market://details?id=com.aispeech.companionapp"); |
| | | #else |
| | | HDLUtils.OpenUrl("https://apps.apple.com/cn/app/id1460767442"); |
| | | #endif |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | string error = e.Message; |
| | | bol = false; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 解除绑定弹窗 |
| | | /// </summary> |
| | | private void ShowDelectDialog(int index) |
| | | private void ShowDelectDialog(SmartSoundInfo.SoundInfo smartSound) |
| | | { |
| | | //生成一个弹窗画面 |
| | | var dialogForm = new TextDialog("解除绑定需要到第三方 APP 进行操作", "跳转至小度"); |
| | | var dialogForm = new TextDialog("解除绑定需要到第三方 APP 进行操作", "跳转至第三方APP"); |
| | | dialogForm.SetTitleText("解除绑定"); |
| | | |
| | | //按下确认按钮 |
| | | dialogForm.ComfirmClickEvent += () => |
| | | { |
| | | //画面关闭 |
| | | dialogForm.CloseDialog(); |
| | | {
|
| | | if (smartSound.PlatfromName == "Baidu")
|
| | | {
|
| | | OpenXiaoDuAPP();
|
| | | }
|
| | | else if (smartSound.PlatfromName == "AISpeech") {
|
| | | OpenSBCAPP();
|
| | | } |
| | | }; |
| | | } |
| | | /// <summary> |
| | |
| | | //添加备份 |
| | | dialogForm.SetTitleText("重命名"); |
| | | //请输入备份名称 |
| | | dialogForm.SetTipText(smartSound.Remark); |
| | | dialogForm.SetTipText("请输入名称"); |
| | | dialogForm.Text = smartSound.Remark; |
| | | |
| | | //按下确认按钮 |
| | | dialogForm.ComfirmClickEvent += (async (textValue) => |
| | | { |
| | | |
| | | //画面关闭 |
| | | dialogForm.CloseDialog(); |
| | | |
| | |
| | | string str = await setRemark(smartSound, remark); //上传备份 |
| | | if (str == "SUCCESS") |
| | | { |
| | | smartSound.Remark = remark; |
| | | soundRowLayout.btnRemark.Text = textValue; |
| | | smartSound.Remark = remark;
|
| | | if (smartSound.PlatfromName == "Baidu")
|
| | | {
|
| | | soundRowLayout.btnRemark.Text = "小度" + "(" + textValue + ")";
|
| | | }
|
| | | else if (smartSound.PlatfromName == "AISpeech")
|
| | | {
|
| | | soundRowLayout.btnRemark.Text = "思必驰" + "(" + textValue + ")";
|
| | | }
|
| | | else |
| | | {
|
| | | soundRowLayout.btnRemark.Text = textValue;
|
| | | }
|
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | #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> |
| | | /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件 |
| | |
| | | return 1; |
| | | } |
| | | |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region ■ 关闭界面___________________________ |
| | | #region ■ 关闭界面___________________________ |
| | | |
| | | /// <summary> |
| | | /// 画面关闭 |
| | |
| | | base.CloseFormBefore(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | } |
| | | } |