| | |
| | | { |
| | | public class Method |
| | | { |
| | | |
| | | /// <summary> |
| | | /// 程序主入口 |
| | | /// 红外宝程序主入口 |
| | | /// </summary> |
| | | /// <param name="frame"></param> |
| | | /// <param name="function"></param> |
| | | public void MainView(FrameLayout frame, Entity.Function function,Action action) |
| | | public void MainView(FrameLayout frame, Entity.Function function, Action action) |
| | | { |
| | | Pir pirDevice = new Pir(); |
| | | if (function != null) |
| | |
| | | pirDevice.deviceId = function.deviceId; |
| | | pirDevice.sid = function.sid; |
| | | pirDevice.online = function.online; |
| | | pirDevice.versions = function.versions; |
| | | } |
| | | Pir.currPir = pirDevice; |
| | | GetControlList(frame, () => |
| | |
| | | MainPage.BasePageView.AddChidren(page); |
| | | page.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | page.BackAction += () => { |
| | | PirMain.BackAction += () => |
| | | { |
| | | action?.Invoke(); |
| | | PirMain.BackAction = null; |
| | | }; |
| | | }); |
| | | }, Pir.currPir); |
| | |
| | | { |
| | | if (device != null) |
| | | { |
| | | |
| | | control.deviceId = device.deviceId; |
| | | //遥控器添加到列表; |
| | | if (null == Pir.currPir.FunctioList.Find((c) => c.deviceId == device.deviceId)) |
| | | { |
| | | Pir.currPir.FunctioList.Add(device); |
| | | } |
| | | frame.RemoveFromParent();//添加成功关闭弹窗 |
| | | action(control); |
| | | } |
| | |
| | | var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Pir>(str); |
| | | if (pirJosn != null) |
| | | { |
| | |
|
| | | /* 项目“HDL-ON_iOS”的未合并的更改
|
| | | 在此之前:
|
| | | if (null == Pir.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId))
|
| | | 在此之后:
|
| | | if (null == list.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId))
|
| | | */
|
| | | |
| | | if (null == PirDevice.Pir.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId)) |
| | | { |
| | | |
| | |
|
| | | /* 项目“HDL-ON_iOS”的未合并的更改
|
| | | 在此之前:
|
| | | Pir.pirDeviceList.Add(pirJosn);
|
| | | 在此之后:
|
| | | list.pirDeviceList.Add(pirJosn);
|
| | | */
|
| | | {
|
| | | PirDevice.Pir.pirDeviceList.Add(pirJosn); |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | loading.Hide(); |
| | | Method method = new Method(); |
| | | method.ErrorShow(null,"读取红外宝列表失败"); |
| | | method.ErrorShow(null, "读取红外宝列表失败"); |
| | | } |
| | | } |
| | | catch { } |
| | |
| | | var pirDevice = Pir.pirDeviceList[i]; |
| | | try |
| | | { |
| | | var responsePackNew = PirSend.ControlList(pirDevice); |
| | | var responsePackNew = PirSend.ControlList(pirDevice.deviceId); |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | { |
| | | var jArray = JArray.Parse(responsePackNew.Data.ToString()); |
| | |
| | | /// 获取单个红外宝遥控器列表 |
| | | /// </summary> |
| | | /// <param name="action">回调函数</param> |
| | | public static void GetControlList(FrameLayout frame ,Action action, Pir pirDevice) |
| | | public static void GetControlList(FrameLayout frame, Action action, Pir pirDevice) |
| | | { |
| | | Loading loading = new Loading(); |
| | | frame.AddChidren(loading); |
| | | loading.Start(); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | |
| | | try |
| | | { |
| | | var responsePackNew = PirSend.ControlList(pirDevice); |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | { |
| | | var jArray = JArray.Parse(responsePackNew.Data.ToString()); |
| | | for (int a = 0; a < jArray.Count; a++) |
| | | { |
| | | var jay = jArray[a]; |
| | | //数据返序列化为Logic对象 |
| | | var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay); |
| | | var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(str); |
| | | if (pirJosn != null) |
| | | { |
| | | if (null == pirDevice.FunctioList.Find((c) => c.sid == pirJosn.sid)) |
| | | { |
| | | pirDevice.FunctioList.Add(pirJosn); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch { } |
| | | |
| | | |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | action(); |
| | | }); |
| | | } |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | ThreadSend(new Control { deviceId = pirDevice.deviceId }, (responsePackNew) => |
| | | { |
| | | var jArray = JArray.Parse(responsePackNew.Data.ToString()); |
| | | for (int a = 0; a < jArray.Count; a++) |
| | | { |
| | | var jay = jArray[a]; |
| | | //数据返序列化为Logic对象 |
| | | var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay); |
| | | var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(str); |
| | | if (pirJosn != null) |
| | | { |
| | | if (null == pirDevice.FunctioList.Find((c) => c.deviceId == pirJosn.deviceId)) |
| | | { |
| | | pirDevice.FunctioList.Add(pirJosn); |
| | | } |
| | | } |
| | | } |
| | | action(); |
| | | }, "获取遥控器列表", "frame", frame, null); |
| | | |
| | | } |
| | | /// <summary> |
| | |
| | | /// <param name="action">回调函数</param> |
| | | public void GetControl(FrameLayout frame, Control control, Action<Entity.Function> action) |
| | | { |
| | | Entity.Function function = null; |
| | | //加载log |
| | | Loading loading = new Loading(); |
| | | frame.AddChidren(loading); |
| | | loading.Start(); |
| | | new System.Threading.Thread(() => |
| | | ThreadSend(control, (responsePackNew) => |
| | | { |
| | | try |
| | | { |
| | | // 获取设备详情通过(spk,sid) |
| | | var responsePackNew = PirSend.GetinfoBySid(control); |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | { |
| | | //var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data.ToString()); |
| | | function = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(responsePackNew.Data.ToString()); |
| | | } |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | action(function); |
| | | }); |
| | | } |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | var function = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(responsePackNew.Data.ToString()); |
| | | action(function); |
| | | }, "获取设备详情", "frame", frame, null); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 发送命令线程 |
| | | /// </summary> |
| | |
| | | /// <param name="view">判断log父控件</param> |
| | | /// <param name="frame">log父控件</param> |
| | | /// <param name="dialog">log父控件</param> |
| | | public static void ThreadSend(Control control, Action<ResponsePackNew> action, string str,string view, FrameLayout frame, Dialog dialog) |
| | | /// <param name="attributesStatus">学习按键</param> |
| | | public static void ThreadSend(Control control, Action<ResponsePackNew> action, string str, string view, FrameLayout frame, Dialog dialog, Entity.AttributesStatus attributesStatus=null) |
| | | { |
| | | |
| | | |
| | | //加载log |
| | | Loading loading = new Loading(); |
| | | if (view == "dialog") |
| | |
| | | |
| | | responsePackNew = PirSend.DeviceRename(control.deviceId, control.name); |
| | | } |
| | | else if (str == "删除按键") { |
| | | // responsePackNew = PirSend.CodeRemove(control.deviceId, control.name); |
| | | else if (str == "删除按键") |
| | | { |
| | | if (attributesStatus != null) |
| | | { |
| | | responsePackNew = PirSend.CodeRemove(attributesStatus, control.deviceId); |
| | | } |
| | | } |
| | | else if (str == "获取设备详情") |
| | | { |
| | | // 获取设备详情通过(spk,sid) |
| | | responsePackNew = PirSend.GetinfoBySid(control); |
| | | } |
| | | else if (str == "获取遥控器列表") |
| | | { |
| | | responsePackNew = PirSend.ControlList(control.deviceId); |
| | | } |
| | | else if (str == "库码测试") |
| | | { |
| | | responsePackNew = PirSend.CodeTest(control); |
| | | } |
| | | } |
| | | catch { } |
| | |
| | | else |
| | | { |
| | | Method method = new Method(); |
| | | method.ErrorShow(responsePackNew, ""); |
| | | //自定义错误提示文本 |
| | | string eorroText = ""; |
| | | if (str == "删除") |
| | | { |
| | | } |
| | | else if (str == "修改名称") |
| | | { |
| | | |
| | | } |
| | | else if (str == "删除按键") |
| | | { |
| | | } |
| | | else if (str == "获取设备详情") |
| | | { |
| | | } |
| | | else if (str == "获取遥控器列表") |
| | | { |
| | | } |
| | | else if (str == "库码测试") |
| | | { |
| | | } |
| | | method.ErrorShow(responsePackNew, eorroText); |
| | | } |
| | | |
| | | }); |
| | |
| | | str = buttondata; |
| | | } |
| | | |
| | | if (!string.IsNullOrEmpty(controldata)) |
| | | if (!string.IsNullOrEmpty(str)) |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | else if (text == "读取红外宝列表失败") |
| | | { |
| | | str = "读取红外宝列表失败"; //Language.StringByID(StringId.delFail); |
| | | str = Language.StringByID(StringId.huoqushujushibao); |
| | | } |
| | | else if (text == "添加失败") |
| | | { |
| | | str = Language.StringByID(StringId.tianjiashibai); |
| | | } |
| | | else |
| | | { |
| | |
| | | break; |
| | | case "10807": |
| | | { |
| | | str = "红外宝下遥控器超过最大(10个)数量限制";// Language.StringByID(StringId.gatewayNotOnline); |
| | | str = Language.StringByID(StringId.bunengchaoguo10); |
| | | |
| | | |
| | | } |
| | | break; |
| | | case "2": |
| | | { |
| | | str = "系统维护中~请稍后再试~"; |
| | | str = Language.StringByID(StringId.xitongweihuzhong); |
| | | } |
| | | break; |
| | | default: |
| | | { |
| | | str ="获取数据失败" ;// Language.StringByID(StringId.saveFail); |
| | | str = Language.StringByID(StringId.huoqushujushibao); |
| | | } |
| | | break; |
| | | |
| | |
| | | case 3: { } break; |
| | | } |
| | | } |
| | | /// <summary> |
| | | ///指定刷新界面 |
| | | /// </summary> |
| | | /// <param name="strView">判断字符</param> |
| | | public static void RefreshView(string strView) |
| | | { |
| | | //标记是不是已经刷新完成 |
| | | bool if_bool = false; |
| | | for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--) |
| | | { |
| | | var view = MainPage.BasePageView.GetChildren(i); |
| | | if (strView == "PirMain") |
| | | { |
| | | if (view.GetType() == typeof(PirMain)) |
| | | { |
| | | //强制转换对象 |
| | | var f = (PirMain)view; |
| | | //移除所有子控件 |
| | | f.RemoveAll(); |
| | | //重新加载UI |
| | | f.Show(); |
| | | //退出for循环 |
| | | //break; |
| | | if_bool = true; |
| | | } |
| | | } |
| | | if (if_bool) |
| | | { |
| | | //退出for循环 |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 指定删除界面 |
| | | /// </summary> |
| | | /// <param name="strView">判断字符</param> |
| | | public static void RemoveView(string strView) |
| | | { |
| | | |
| | | for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--) |
| | | { |
| | | var view = MainPage.BasePageView.GetChildren(i); |
| | | if (strView == "PirMain") |
| | | { |
| | | if (view.GetType() == typeof(PirMain)) |
| | | { |
| | | //移除界面 |
| | | view.RemoveFromParent(); |
| | | } |
| | | |
| | | } |
| | | else if (strView == "AddControl") |
| | | { |
| | | |
| | | if (view.GetType() == typeof(AddControl)) |
| | | { |
| | | //找到移除 |
| | | view.RemoveFromParent(); |
| | | } |
| | | } |
| | | else if (strView == "AddControlComplete") |
| | | { |
| | | |
| | | if (view.GetType() == typeof(AddControlComplete)) |
| | | { |
| | | //找到移除 |
| | | view.RemoveFromParent(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | [Serializable] |