From 5eec2e8c16bdcb163b388de486ee375e891df445 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期四, 25 二月 2021 17:54:15 +0800
Subject: [PATCH] 2021-2-25-1

---
 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs |  151 ++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 126 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 b8e067e..4835344 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs
@@ -5,22 +5,31 @@
 using System.Text;
 namespace HDL_ON.UI.UI2.PersonalCenter.PirDevice
 {
-    public class AddControl:FrameLayout
+    public class AddControl : FrameLayout
     {
         public AddControl()
         {
+            Tag = "AddControl";
         }
-
-        public void Show() {
+        public void Show()
+        {
 
             #region 鐣岄潰甯冨眬
+
             this.BackgroundColor = CSS.CSS_Color.viewMiddle;
             PirDevice.View.TopView topView = new View.TopView();
             topView.topNameBtn.TextID = StringId.zhinengyaokongqi;
             topView.topIconBtn.Visible = true;
             topView.topIconBtn.UnSelectedImagePath = "PirIcon/del.png";
             this.AddChidren(topView.FLayoutView());
-            topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); };
+            topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
+            {
+                //杩斿洖娓呯┖鍒楄〃
+                Pir.BuottonList.Clear();
+                this.RemoveFromParent();
+
+            };
+
             #region 娣诲姞鎸夐挳
             FrameLayout addLayout = new FrameLayout
             {
@@ -47,25 +56,26 @@
             #endregion
             FrameLayout frameLayout = new FrameLayout
             {
-                Y = Application.GetRealHeight(64+84),
-                Height = Application.GetRealHeight(667-64-84),
+                Y = Application.GetRealHeight(64 + 84),
+                Height = Application.GetRealHeight(667 - 64 - 84),
                 Width = Application.GetRealWidth(TextSize.view375),
             };
             this.AddChidren(frameLayout);
 
-            #region 淇濆瓨甯冨眬
+            #region 淇濆瓨
             FrameLayout saveLayout = new FrameLayout
             {
-                Y = Application.GetRealHeight(667-104),
+                Y = Application.GetRealHeight(667 - 104),
                 Height = Application.GetRealHeight(104),
                 Width = Application.GetRealWidth(TextSize.view375),
-                BackgroundColor= CSS.CSS_Color.viewLine,
+                BackgroundColor = CSS.CSS_Color.viewLine,
             };
             this.AddChidren(saveLayout);
+            saveLayout.SetCornerWithSameRadius(Application.GetRealHeight(24), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
 
             Button paixuBtn = new Button
             {
-                Width = Application.GetRealWidth(375-16*2),
+                Width = Application.GetRealWidth(375 - 16 * 2),
                 Height = Application.GetRealHeight(20),
                 Y = Application.GetRealHeight(12),
                 X = Application.GetRealWidth(16),
@@ -79,7 +89,7 @@
             {
                 Width = Application.GetRealWidth(220),
                 Height = Application.GetRealHeight(44),
-                Y = paixuBtn.Bottom+ Application.GetRealHeight(12),
+                Y = paixuBtn.Bottom + Application.GetRealHeight(12),
                 X = Application.GetRealWidth(78),
                 TextID = StringId.save,
                 TextSize = TextSize.text16,
@@ -94,26 +104,93 @@
 
             VerticalScrolViewLayout vv = new VerticalScrolViewLayout();
             frameLayout.AddChidren(vv);
+            RefreshView(vv, false);
+            #endregion
 
-            int sum = Pir.BuottonList.Count/3+1;
-            int h = sum * (16 + 44)+104;
+            #region  鐣岄潰鐐瑰嚮浜嬩欢
+            //鍒犻櫎鐐瑰嚮浜嬩欢
+            topView.clickSetBtn.MouseUpEventHandler += (sender, e) =>
+            {
+                topView.clickSetBtn.IsSelected = !topView.clickSetBtn.IsSelected;
+                if (topView.clickSetBtn.IsSelected)
+                {
+                    topView.topIconBtn.UnSelectedImagePath = "";
+                    topView.topIconBtn.Text = Language.StringByID(StringId.wancheng);
+                    topView.topIconBtn.TextSize = TextSize.text14;
+                    topView.topIconBtn.TextColor = CSS.CSS_Color.textColor;
+                    RefreshView(vv, true);
+                }
+                else
+                {
+                    topView.topIconBtn.UnSelectedImagePath = "PirIcon/del.png";
+                    topView.topIconBtn.Text = "";
+                    RefreshView(vv, false);
+                }
+
+
+
+            };
+            //娣诲姞鎸夐挳鐐瑰嚮浜嬩欢
+            addBtn.MouseUpEventHandler += (sender, e) =>
+            {
+                AddButton addButton = new AddButton();
+                MainPage.BasePageView.AddChidren(addButton);
+                addButton.Show();
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+            };
+            //淇濆瓨鐐瑰嚮浜嬩欢
+            saveBtn.MouseUpEventHandler += (sender, e) =>
+            {
+                //淇濆瓨閬ユ帶鍣ㄦ竻闄や箣鍓嶆寜閽垪琛ㄧ殑鏁版嵁
+                Pir.BuottonList.Clear();
+                //鍙兘涔嬪墠宸茬粡瀛樺湪璇ョ晫闈�
+                MainPage.BasePageView.RemoveViewByTag("Pir");
+                AddControlComplete addControlComplete = new AddControlComplete();
+                MainPage.BasePageView.AddChidren(addControlComplete);
+                addControlComplete.Show();
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+            };
+            #endregion
+        }
+        /// <summary>
+        /// 鍔犺浇鎸夐挳鎺т欢View鐨勬柟娉�
+        /// </summary>
+        /// <param name="vv">涓婁笅婊戝姩鎺т欢</param>
+        /// <param name="if_bool">琛ㄧず鏄惁鏄剧ず鍒犻櫎鍥炬爣</param>
+        void RefreshView(VerticalScrolViewLayout vv, bool if_bool)
+        {
+            vv.RemoveAll();
+            //瀹氫箟涓�涓彉閲忚褰曡鏁�
+            int sum = 0;
+            if (Pir.BuottonList.Count % 3 == 0)
+            {
+                sum = Pir.BuottonList.Count / 3;
+            }
+            else
+            {
+                sum = Pir.BuottonList.Count / 3 + 1;
+            }
+            //璁$畻鍔犺浇鍑烘潵鐨勬暟鎹渶瑕佺殑楂樺害
+            int h = 16 + sum * (16 + 44) + 104 + 76;
             int line = 0;
+            //鎸夐挳鐨勭埗鎺т欢
+            var FLayout = new FrameLayout
+            {
+                Height = Application.GetRealWidth(h),
+            };
+            vv.AddChidren(FLayout);
             for (int i = 1, j = 0; i <= Pir.BuottonList.Count; i++, j++)
             {
-                var nameObj = Pir.BuottonList[i-1];
-                var FLayout = new FrameLayout
-                {
-                    Height = Application.GetRealWidth(h),
-                };
-                vv.AddChidren(FLayout);
-              
+                var nameObj = Pir.BuottonList[i - 1];
+                //鎸夐挳
                 var buttonNameBtn = new Button
                 {
-                    Y =  Application.GetRealHeight(line*(16 + 44)),
-                    X=Application.GetRealWidth(16+(16+104)*j),
+
+                    Y = Application.GetRealHeight(16 + line * (16 + 44)),
+                    X = Application.GetRealWidth(16 + (16 + 104) * j),
                     Width = Application.GetRealWidth(104),
                     Height = Application.GetRealHeight(44),
-                    Text= nameObj.value,
+                    Text = nameObj.value,
                     TextSize = TextSize.text16,
                     TextColor = CSS.CSS_Color.textColor,
                     TextAlignment = TextAlignment.Center,
@@ -122,7 +199,31 @@
                     BorderColor = CSS.CSS_Color.textCancelColor,
                 };
                 FLayout.AddChidren(buttonNameBtn);
-              
+                //鍒犻櫎鍥炬爣
+                var delIconBtn = new Button
+                {
+                    UnSelectedImagePath = "PirIcon/delbuton.png",
+                    Y = Application.GetRealHeight(12 + line * (16 + 44)),
+                    X = Application.GetRealWidth((16 + 92) + (104 + 16) * j),
+                    Width = Application.GetRealWidth(16),
+                    Height = Application.GetRealWidth(16),
+                    Tag = nameObj.value,
+                };
+                if (if_bool)
+                {
+                    FLayout.AddChidren(delIconBtn);
+                }
+                //鍒犻櫎鍥炬爣鐨勭偣鍑讳簨浠�
+                delIconBtn.MouseUpEventHandler += (sender, e) =>
+                {
+                    var name = delIconBtn.Tag.ToString();
+                    var buttonObj = Pir.BuottonList.Find((c) => c.value == name);
+                    if (buttonObj != null)
+                    {
+                        Pir.BuottonList.Remove(buttonObj);
+                    }
+                    RefreshView(vv, true);
+                };
                 if (i % 3 == 0)
                 {
                     //婊′竴琛岄噸缃甹=0鍊�;
@@ -131,7 +232,7 @@
                 }
 
             }
-            #endregion
+
         }
     }
 }

--
Gitblit v1.8.0