From 9b44e30275621a48335fbea7b32b5065a2859c9c Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 16 三月 2021 16:54:33 +0800
Subject: [PATCH] Merge branch 'WJC' into temp-wxr

---
 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs |   89 ++++++++++++++++++++++++++++++++------------
 1 files changed, 64 insertions(+), 25 deletions(-)

diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs
index 4835344..47a0357 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs
@@ -9,9 +9,9 @@
     {
         public AddControl()
         {
-            Tag = "AddControl";
+            Tag = "PirView";
         }
-        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();
 
             };
@@ -104,7 +103,7 @@
 
             VerticalScrolViewLayout vv = new VerticalScrolViewLayout();
             frameLayout.AddChidren(vv);
-            RefreshView(vv, false);
+            RefreshView(vv, false, control);
             #endregion
 
             #region  鐣岄潰鐐瑰嚮浜嬩欢
@@ -118,13 +117,13 @@
                     topView.topIconBtn.Text = Language.StringByID(StringId.wancheng);
                     topView.topIconBtn.TextSize = TextSize.text14;
                     topView.topIconBtn.TextColor = CSS.CSS_Color.textColor;
-                    RefreshView(vv, true);
+                    RefreshView(vv, true, control);
                 }
                 else
                 {
                     topView.topIconBtn.UnSelectedImagePath = "PirIcon/del.png";
                     topView.topIconBtn.Text = "";
-                    RefreshView(vv, false);
+                    RefreshView(vv, false, control);
                 }
 
 
@@ -135,19 +134,26 @@
             {
                 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();
+                    }
+                }
                 AddControlComplete addControlComplete = new AddControlComplete();
                 MainPage.BasePageView.AddChidren(addControlComplete);
-                addControlComplete.Show();
+                addControlComplete.Show(control,false);
                 MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
             };
             #endregion
@@ -157,18 +163,18 @@
         /// </summary>
         /// <param name="vv">涓婁笅婊戝姩鎺т欢</param>
         /// <param name="if_bool">琛ㄧず鏄惁鏄剧ず鍒犻櫎鍥炬爣</param>
-        void RefreshView(VerticalScrolViewLayout vv, bool if_bool)
+        void RefreshView(VerticalScrolViewLayout vv, bool if_bool, Control control)
         {
             vv.RemoveAll();
             //瀹氫箟涓�涓彉閲忚褰曡鏁�
             int sum = 0;
-            if (Pir.BuottonList.Count % 3 == 0)
+            if (control.status.Count % 3 == 0)
             {
-                sum = Pir.BuottonList.Count / 3;
+                sum = control.status.Count / 3;
             }
             else
             {
-                sum = Pir.BuottonList.Count / 3 + 1;
+                sum = control.status.Count / 3 + 1;
             }
             //璁$畻鍔犺浇鍑烘潵鐨勬暟鎹渶瑕佺殑楂樺害
             int h = 16 + sum * (16 + 44) + 104 + 76;
@@ -179,9 +185,9 @@
                 Height = Application.GetRealWidth(h),
             };
             vv.AddChidren(FLayout);
-            for (int i = 1, j = 0; i <= Pir.BuottonList.Count; i++, j++)
+            for (int i = 1, j = 0; i <= control.status.Count; i++, j++)
             {
-                var nameObj = Pir.BuottonList[i - 1];
+                var nameObj = control.status[i - 1];
                 //鎸夐挳
                 var buttonNameBtn = new Button
                 {
@@ -207,7 +213,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 +222,46 @@
                 //鍒犻櫎鍥炬爣鐨勭偣鍑讳簨浠�
                 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 Entity.AttributesStatus;
+                    //鍔犺浇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, control.deviceId);
+                        }
+                        catch { }
+                        finally
+                        {
+                            Application.RunOnMainThread(() =>
+                            {
+                                loading.Hide();
+                                if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
+                                {
+                                    var buttonObj = control.status.Find((c) => c.value == obj.value);
+                                    if (buttonObj != null)
+                                    {
+                                        control.status.Remove(buttonObj);
+                                    }
+                                    RefreshView(vv, true, control);
+                                }
+                                else {
+                                    Method method = new Method();
+                                    method.ErrorShow(responsePackNew,"");
+                                }
+
+                            });
+                        }
+
+                    })
+                    { IsBackground = true }.Start();
+
+
                 };
                 if (i % 3 == 0)
                 {

--
Gitblit v1.8.0