陈嘉乐
2021-03-25 1cba5ec1959f9012c66f96254afb3206904ff671
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
@@ -8,13 +8,13 @@
{
    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)
@@ -37,6 +37,7 @@
                    PirMain.BackAction += () =>
                    {
                        action?.Invoke();
                        PirMain.BackAction = null;
                    };
                });
            }, Pir.currPir);
@@ -142,7 +143,13 @@
                            {
                                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);
                                }
@@ -246,7 +253,7 @@
                            {
                                loading.Hide();
                                Method method = new Method();
                                method.ErrorShow(null,"读取红外宝列表失败");
                                method.ErrorShow(null, "读取红外宝列表失败");
                            }
                        }
                        catch { }
@@ -365,9 +372,10 @@
        /// <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")
@@ -395,7 +403,10 @@
                    }
                    else if (str == "删除按键")
                    {
                        // responsePackNew = PirSend.CodeRemove(control.deviceId, control.name);
                        if (attributesStatus != null)
                        {
                            responsePackNew = PirSend.CodeRemove(attributesStatus, control.deviceId);
                        }
                    }
                    else if (str == "获取设备详情")
                    {
@@ -405,6 +416,10 @@
                    else if (str == "获取遥控器列表")
                    {
                        responsePackNew = PirSend.ControlList(control.deviceId);
                    }
                    else if (str == "库码测试")
                    {
                        responsePackNew = PirSend.CodeTest(control);
                    }
                }
                catch { }
@@ -420,7 +435,28 @@
                        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);
                        }
                    });
@@ -504,6 +540,10 @@
            {
                str = Language.StringByID(StringId.huoqushujushibao);
            }
            else if (text == "添加失败")
            {
                str = Language.StringByID(StringId.tianjiashibai);
            }
            else
            {
                if (responsePackNew != null)
@@ -550,6 +590,79 @@
                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]