wei
2021-03-03 d4811b7d34b45ff6b21b97f11da128b5572ec526
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs
@@ -9,9 +9,9 @@
    {
        public AddControl()
        {
            Tag = "AddControl";
            Tag = "Pir";
        }
        public void Show()
        public void Show(Control control)
        {
            #region 界面布局
@@ -24,8 +24,7 @@
            this.AddChidren(topView.FLayoutView());
            topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
            {
                //返回清空列表
                Pir.BuottonList.Clear();
                this.RemoveFromParent();
            };
@@ -135,19 +134,27 @@
            {
                AddButton addButton = new AddButton();
                MainPage.BasePageView.AddChidren(addButton);
                addButton.Show();
                addButton.Show(control);
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            //保存点击事件
            saveBtn.MouseUpEventHandler += (sender, e) =>
            {
                //保存遥控器清除之前按钮列表的数据
                Pir.BuottonList.Clear();
               //移除当前界面
                this.RemoveFromParent();
                //可能之前已经存在该界面
                MainPage.BasePageView.RemoveViewByTag("Pir");
                for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--)
                {
                    var view = MainPage.BasePageView.GetChildren(i);
                    if (view.GetType() == typeof(AddControlComplete))
                    {
                        view.RemoveFromParent();
                    }
                }
                //MainPage.BasePageView.RemoveViewByTag("Pir");
                AddControlComplete addControlComplete = new AddControlComplete();
                MainPage.BasePageView.AddChidren(addControlComplete);
                addControlComplete.Show();
                addControlComplete.Show(control);
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            #endregion
@@ -207,7 +214,7 @@
                    X = Application.GetRealWidth((16 + 92) + (104 + 16) * j),
                    Width = Application.GetRealWidth(16),
                    Height = Application.GetRealWidth(16),
                    Tag = nameObj.value,
                    Tag = nameObj,
                };
                if (if_bool)
                {
@@ -216,13 +223,47 @@
                //删除图标的点击事件
                delIconBtn.MouseUpEventHandler += (sender, e) =>
                {
                    var name = delIconBtn.Tag.ToString();
                    var buttonObj = Pir.BuottonList.Find((c) => c.value == name);
                    if (buttonObj != null)
                    var obj = delIconBtn.Tag as ButtonObj;
                    //加载log
                    Loading loading = new Loading();
                    this.AddChidren(loading);
                    HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
                    loading.Start();
                    new System.Threading.Thread(() =>
                    {
                        Pir.BuottonList.Remove(buttonObj);
                    }
                    RefreshView(vv, true);
                        try
                        {
                            //发送按键删除;
                            responsePackNew = PirSend.CodeRemove(obj);
                        }
                        catch { }
                        finally
                        {
                            Application.RunOnMainThread(() =>
                            {
                                loading.Hide();
                                if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                                {
                                    ///这里:监听MTTP推送下来主题,才知道是否添加成功
                                    var buttonObj = Pir.BuottonList.Find((c) => c.value == obj.value);
                                    if (buttonObj != null)
                                    {
                                        Pir.BuottonList.Remove(buttonObj);
                                    }
                                    RefreshView(vv, true);
                                }
                                else {
                                    Method method = new Method();
                                    method.ErrorShow(responsePackNew);
                                }
                            });
                        }
                    })
                    { IsBackground = true }.Start();
                };
                if (i % 3 == 0)
                {