From 6d73bf6e816570291865674bef8bce8972e4de3f Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期三, 01 十二月 2021 16:32:57 +0800
Subject: [PATCH] 2021-12-01-01

---
 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs |  119 +++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 98 insertions(+), 21 deletions(-)

diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs
index 5a50897..c770e5a 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs
@@ -4,30 +4,31 @@
 using Shared;
 namespace HDL_ON.UI.UI2.PersonalCenter.PirDevice
 {
-    public class AddControlComplete:FrameLayout
+    public class AddControlComplete : FrameLayout
     {
         public AddControlComplete()
         {
-            Tag = "Pir";
+            Tag = "PirView";
         }
-        public void Show(Control control) {
+        public void Show(Control control, bool bool_library)
+        {
             #region 鐣岄潰甯冨眬
             this.BackgroundColor = CSS.CSS_Color.viewMiddle;
             PirDevice.View.TopView topView = new View.TopView();
             topView.topNameBtn.TextID = StringId.tianjiayaokongqi;
             this.AddChidren(topView.FLayoutView());
-            topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); };
+            topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); };
 
-            FrameLayout fLayout = new FrameLayout 
+            FrameLayout fLayout = new FrameLayout
             {
-                Y =Application.GetRealHeight(64),
+                Y = Application.GetRealHeight(64),
                 BackgroundColor = CSS.CSS_Color.textWhiteColor,
                 Height = Application.GetRealHeight(224),
                 Width = Application.GetRealWidth(375),
             };
             this.AddChidren(fLayout);
-            //
-            Button iconBtn = new Button 
+            //鎴愬姛鍥炬爣
+            Button iconBtn = new Button
             {
                 Y = Application.GetRealHeight(28),
                 X = Application.GetRealWidth(137),
@@ -40,7 +41,7 @@
             //娣诲姞鎴愬姛
             Button text1Btn = new Button
             {
-                Width = Application.GetRealWidth(375-32),
+                Width = Application.GetRealWidth(375 - 32),
                 Height = Application.GetRealHeight(22),
                 Y = Application.GetRealHeight(158),
                 X = Application.GetRealWidth(16),
@@ -50,7 +51,7 @@
                 TextAlignment = TextAlignment.Center,
             };
             fLayout.AddChidren(text1Btn);
-            //鍙埌鍒嗙被-鍔熻兘-鐢靛櫒鎿嶄綔浣跨敤
+            //鍙埌鍒嗙被-鍔熻兘-鎿嶄綔浣跨敤
             Button text2Btn = new Button
             {
                 Width = Application.GetRealWidth(375 - 32),
@@ -65,7 +66,7 @@
             fLayout.AddChidren(text2Btn);
             //鎵�灞炲垎绫�
             View.PatchView fenlei = new View.PatchView();
-            fenlei.frameLayout.Y = fLayout.Bottom+ Application.GetRealHeight(8);
+            fenlei.frameLayout.Y = fLayout.Bottom + Application.GetRealHeight(8);
             this.AddChidren(fenlei.FLayoutView(false));
             fenlei.btnText1.TextID = StringId.suoshufenlei;
             fenlei.btnText2.TextID = StringId.dianqi;
@@ -75,19 +76,20 @@
             this.AddChidren(namePatchView.FLayoutView());
             namePatchView.btnText1.TextID = StringId.yaokongqimingcheng;
             namePatchView.btnText2.Text = control.name;
+
             //鎵�灞炲尯鍩�
             View.PatchView quyuPatchView = new View.PatchView();
             quyuPatchView.frameLayout.Y = namePatchView.frameLayout.Bottom;
             this.AddChidren(quyuPatchView.FLayoutView());
             quyuPatchView.btnText1.TextID = StringId.suoshuquyu;
-            quyuPatchView.btnText2.TextID = StringId.dianqi;
+            quyuPatchView.btnText2.Text = Intelligence.Automation.LogicMethod.CurrLogicMethod.GetGetRoomName(GetFunction(control.deviceId));
 
             //缁х画娣诲姞
             Button addBtn = new Button
             {
                 Y = quyuPatchView.frameLayout.Bottom + Application.GetRealHeight(125),
                 X = Application.GetRealWidth(16),
-                Width = Application.GetRealWidth(375-32),
+                Width = Application.GetRealWidth(375 - 32),
                 Height = Application.GetRealHeight(20),
                 TextID = StringId.jixutianjia,
                 TextSize = TextSize.text14,
@@ -102,20 +104,95 @@
             #endregion
             #region  鐣岄潰鐐瑰嚮浜嬩欢
             //閬ユ帶鍣ㄥ悕绉扮偣鍑讳簨浠�
-            namePatchView.btnClick.MouseUpEventHandler += (sender,e) => { };
+            namePatchView.btnClick.MouseUpEventHandler += (sender, e) =>
+            {
+
+                List<string> list = new List<string>();
+                for (int i = 0; i < Pir.currPir.FunctioList.Count; i++)
+                {
+                    //娣诲姞鎵�鏈夐仴鎺у悕绉板垪琛�
+                    list.Add(Pir.currPir.FunctioList[i].name);
+                }
+                PirMethod method = new PirMethod();
+                method.EditControlName(StringId.editName, list, control.name, (name, dialog) =>
+                {
+                    //鍙戦�佹洿鏂板悕绉板懡浠�
+                    PirMethod.ThreadSend(new Control { deviceId = control.deviceId, name = name }, (responsePackNew) =>
+                    {
+                        //鍏抽棴绐楀彛
+                        dialog.Close();
+                        //鏇存柊澶囨敞
+                        namePatchView.btnText2.Text = name;
+                        //鏇存柊涓存椂璁惧鍚嶇О
+                        control.name = name;
+                        //鏇存崲鍐呭瓨璁惧鍚嶇О
+                        GetFunction(control.deviceId).name = name;
+                    }, "淇敼鍚嶇О", "dialog", null, dialog);
+                }, () => { });
+            };
             //鎵�灞炲尯鍩熺偣鍑讳簨浠�
-            quyuPatchView.btnClick.MouseUpEventHandler += (sender, e) => { };
+            quyuPatchView.btnClick.MouseUpEventHandler += (sender, e) =>
+            {
+                PirMethod method = new PirMethod();
+                method.ManagementPosition(GetFunction(control.deviceId), () =>
+                {
+                    //鏇存柊鍖哄煙
+                    quyuPatchView.btnText2.Text = Intelligence.Automation.LogicMethod.CurrLogicMethod.GetGetRoomName(GetFunction(control.deviceId));
+                });
+            };
             //缁х画娣诲姞鐐瑰嚮浜嬩欢
-            addBtn.MouseUpEventHandler += (sender, e) => {
-                Method method = new Method();
-                method.AddControl();
+            addBtn.MouseUpEventHandler += (sender, e) =>
+            {
+                if (bool_library)
+                {//缁х画娣诲姞搴撶殑閬ユ帶鍣�
+                    PirMethod.RefreshView("PirMain");//鍒锋柊鎸囩偣鐣岄潰
+                    this.RemoveFromParent();
+                }
+                else
+                {//缁х画娣诲姞鑷畾涔夌殑閬ユ帶鍣�
+                    PirMethod method = new PirMethod();
+                    method.AddControl(this, (controlDevice) =>
+                    {
+                        AddButton addButton = new AddButton();
+                        MainPage.BasePageView.AddChidren(addButton);
+                        addButton.Show(controlDevice);
+                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                    });
+                }
             };
             //瀹屾垚鐐瑰嚮浜嬩欢
-            saveView.btnClick.MouseUpEventHandler += (sender, e) => {
-                MainPage.BasePageView.RemoveViewByTag("AddControl");
-                MainPage.BasePageView.RemoveViewByTag("Pir");
+            saveView.btnClick.MouseUpEventHandler += (sender, e) =>
+            {
+                //鍒锋柊鎸囩偣鐣岄潰
+                PirMethod.RefreshView("PirMain");
+                //绉婚櫎鎵�鏈夌晫闈�
+                MainPage.BasePageView.RemoveViewByTag("PirView");
             };
             #endregion
         }
+        /// <summary>
+        /// 鏌ユ壘璁惧瀵硅薄
+        /// </summary>
+        /// <param name="deviceId">璁惧ID</param>
+        /// <returns></returns>
+        public Entity.Function GetFunction(string deviceId)
+        {
+            var fun = Pir.currPir.FunctioList.Find((c) => c.deviceId == deviceId);
+            if (fun != null)
+            {
+                return fun;
+            }
+            return new Entity.Function();
+        }
+
+        /// <summary>
+        /// 绉婚櫎鐣岄潰
+        /// </summary>
+        public override void RemoveFromParent()
+        {
+            //鍒锋柊鎸囧畾鐣岄潰
+            PirMethod.RefreshView("PirMain");
+            base.RemoveFromParent();
+        }
     }
 }

--
Gitblit v1.8.0