| | |
| | | /// </summary> |
| | | private string wifiPsw = string.Empty; |
| | | /// <summary> |
| | | /// 新设备的sid(用来匹配哪一个设备是新的) |
| | | /// </summary> |
| | | private string newDeviceSid = string.Empty; |
| | | /// <summary> |
| | | /// 超时线程是否运行 |
| | | /// </summary> |
| | | private bool timeoutThreadActivity = false; |
| | |
| | | /// <summary> |
| | | /// 显示成功界面 |
| | | /// </summary> |
| | | private void ShowSuccessView() |
| | | private void ShowSuccessView(Entity.Function newDevice) |
| | | { |
| | | //清空body |
| | | this.ClearBodyFrame(); |
| | |
| | | bodyFrameLayout.AddChidren(btnUse); |
| | | btnUse.ButtonClickEvent += (sender, e) => |
| | | { |
| | | //关掉界面 |
| | | this.CloseForm(); |
| | | HdlFormLogic.Current.CloseFormByFormName("AddThirdPartyDeviceMenuListPage"); |
| | | HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.GetPirDeviceList(this, () => |
| | | if (newDevice == null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | //关闭掉全部的界面,应该不会发生 |
| | | HdlFormLogic.Current.CloseAllOpenForm(); |
| | | return; |
| | | } |
| | | var form = HdlFormLogic.Current.GetFormByName("AddMiniRemoteControlDirection1Page") as AddMiniRemoteControlDirection1Page; |
| | | if (form.AddDeviceEvent != null) |
| | | { |
| | | //代表这个是由温总那边调用的,直接回调函数 |
| | | form.AddDeviceEvent.Invoke(newDevice); |
| | | //关闭掉这个界面 |
| | | this.CloseForm(); |
| | | //再把AddMiniRemoteControlDirection1Page界面关了 |
| | | HdlFormLogic.Current.CloseFormByFormName("AddMiniRemoteControlDirection1Page"); |
| | | } |
| | | else |
| | | { |
| | | //代表这并不是由温总的界面调用的,则关闭掉全部的界面 |
| | | HdlFormLogic.Current.CloseAllOpenForm(); |
| | | //然后再把温总的界面new起来 |
| | | HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.GetPirDeviceList(this, () => |
| | | { |
| | | var page = new UI2.PersonalCenter.PirDevice.PirMain(); |
| | | MainPage.BasePageView.AddChidren(page); |
| | | page.Show(null); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | var page = new UI2.PersonalCenter.PirDevice.PirMain(); |
| | | MainPage.BasePageView.AddChidren(page); |
| | | page.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }); |
| | | }); |
| | | }); |
| | | } |
| | | }; |
| | | } |
| | | |
| | |
| | | //数组类型 |
| | | if (linqArry.Count == 0) { return false; } |
| | | strSpk = linqArry[0]["spk"].ToString(); |
| | | this.newDeviceSid = linqArry[0]["sid"].ToString(); |
| | | } |
| | | else |
| | | { |
| | | //非数组类型 |
| | | strSpk = json["objects"]["spk"].ToString(); |
| | | this.newDeviceSid = json["objects"]["sid"].ToString(); |
| | | } |
| | | if (strSpk != Entity.SPK.IrModule) |
| | | { |
| | |
| | | /// 刷新红外宝信息 |
| | | /// </summary> |
| | | /// <param name="successEvent">成功的回调事件</param> |
| | | private void RefreshMiniRemoteControlInfo(Action successEvent) |
| | | private void RefreshMiniRemoteControlInfo(Action<Entity.Function> successEvent) |
| | | { |
| | | var pra = new Dictionary<string, object>(); |
| | | pra.Add("homeId", Entity.DB_ResidenceData.Instance.CurrentRegion.RegionID); |
| | |
| | | continue; |
| | | } |
| | | var listDevice = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.DevcieApiPack>(result.Data.ToString()); |
| | | Entity.Function newDevice = null; |
| | | foreach (var newFunction in listDevice.list) |
| | | { |
| | | //添加到缓存当中 |
| | | newFunction.SaveFunctionFile(); |
| | | Entity.FunctionList.List.IniFunctionList(newFunction.savePath, true); |
| | | if (newFunction.sid == this.newDeviceSid) |
| | | { |
| | | //这个设备是新追加的 |
| | | newDevice = newFunction; |
| | | } |
| | | } |
| | | //调用回调函数 |
| | | successEvent?.Invoke(); |
| | | successEvent?.Invoke(newDevice); |
| | | return; |
| | | } |
| | | catch |
| | |
| | | return; |
| | | } |
| | | //刷新红外宝信息 |
| | | this.RefreshMiniRemoteControlInfo(() => |
| | | this.RefreshMiniRemoteControlInfo((Entity.Function newDevice) => |
| | | { |
| | | //移除这个事件 |
| | | HdlCloudReceiveLogic.Current.RemoveCloudReceiveEvent("AddMiniRemoteControlDirection4Page"); |
| | |
| | | this.timeoutThreadActivity = false; |
| | | |
| | | //添加设备成功之后,处理一些东西 |
| | | this.DoSomethingAfterAddDeviceSuccess(); |
| | | this.DoSomethingAfterAddDeviceSuccess(newDevice); |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加设备成功之后,处理一些东西 |
| | | /// </summary> |
| | | private void DoSomethingAfterAddDeviceSuccess() |
| | | private void DoSomethingAfterAddDeviceSuccess(Entity.Function newDevice) |
| | | { |
| | | HdlThreadLogic.Current.RunThread(() => |
| | | { |
| | |
| | | HdlThreadLogic.Current.RunMain(() => |
| | | { |
| | | //显示成功界面 |
| | | this.ShowSuccessView(); |
| | | this.ShowSuccessView(newDevice); |
| | | }); |
| | | } |
| | | } |