From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期一, 14 十二月 2020 09:59:01 +0800
Subject: [PATCH] 请合并代码,完成晾衣架最终功能。

---
 ZigbeeApp/Shared/Phone/UserCenter/Safety/AlarmTargetAddSceneForm.cs |  173 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 173 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Safety/AlarmTargetAddSceneForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Safety/AlarmTargetAddSceneForm.cs
new file mode 100755
index 0000000..f4d01db
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Safety/AlarmTargetAddSceneForm.cs
@@ -0,0 +1,173 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+
+namespace Shared.Phone.UserCenter.Safety
+{
+    /// <summary>
+    /// 娣诲姞鎶ヨ鐩爣(鍦烘櫙)鐨勫垪琛ㄧ晫闈�
+    /// </summary>
+    public class AlarmTargetAddSceneForm : EditorCommonForm
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 鍒楄〃鎺т欢
+        /// </summary>
+        private VerticalListControl listView = null;
+        /// <summary>
+        /// 闃插尯ID(杩欎釜涓滆タ浼间箮鏄敮涓�鐨�)
+        /// </summary>
+        private int zoonID = 0;
+        /// <summary>
+        /// 閫夋嫨鐨勫満鏅�
+        /// </summary>
+        private Dictionary<int, Common.SceneUI> dicSelectScene = new Dictionary<int, Common.SceneUI>();
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
+        /// <summary>
+        /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
+        /// </summary>
+        /// <param name="i_zoonID">闃插尯ID</param>
+        /// <param name="i_listScene">鐜板瓨鐨勫満鏅�</param>
+        public void ShowForm(int i_zoonID, List<Common.SceneUI> i_listScene)
+        {
+            this.zoonID = i_zoonID;
+
+            //璁剧疆澶撮儴淇℃伅
+            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uScence));
+
+            //鍒濆鍖栦腑閮ㄤ俊鎭�
+            this.InitMiddleFrame(i_listScene);
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栦腑閮ㄤ俊鎭�
+        /// </summary>
+        /// <param name="listScene">鐜板瓨鐨勫満鏅�</param>
+        private void InitMiddleFrame(List<Common.SceneUI> listScene)
+        {
+            //娓呯┖bodyFrame
+            this.ClearBodyFrame();
+
+            this.listView = new VerticalListControl(29);
+            listView.Y = Application.GetRealHeight(-6);
+            listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
+            listView.BackgroundColor = UserCenterColor.Current.White;
+            bodyFrameLayout.AddChidren(listView);
+
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                //鑾峰彇鏈湴瀹夐槻鐨勫満鏅�
+                Dictionary<int, string> dicScene = HdlSafeguardLogic.Current.GetLocalSceneByZoneID(this.zoonID);
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    int count = listScene.Count - 1;
+                    for (int i = 0; i < listScene.Count; i++)
+                    {
+                        //濡傛灉瀹夐槻閲岄潰宸茬粡娣诲姞鏈夛紝鍒欎笉鍐嶆樉绀�
+                        if (dicScene.ContainsKey(listScene[i].Id) == true)
+                        {
+                            continue;
+                        }
+                        //娣诲姞琛�
+                        this.AddRowControl(listScene[i], i != count);
+                    }
+                    //璋冩暣鐪熷疄楂樺害
+                    listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(23));
+                });
+            });
+
+            //瀹屾垚
+            var btnfinish = new BottomClickButton();
+            btnfinish.TextID = R.MyInternationalizationString.uFinish;
+            bodyFrameLayout.AddChidren(btnfinish);
+            btnfinish.ButtonClickEvent += (sender, e) =>
+            {
+                if (this.dicSelectScene.Count == 0)
+                {
+                    //鍏抽棴鐣岄潰
+                    this.CloseForm();
+                    return;
+                }
+                //淇濆瓨鍦烘櫙鍒板畨闃�
+                this.SaveSceneToSafety();
+            };
+        }
+
+        #endregion
+
+        #region 鈻� 娣诲姞琛宊____________________________
+
+        /// <summary>
+        /// 娣诲姞琛�
+        /// </summary>
+        /// <param name="scene"></param>
+        /// <param name="addLine"></param>
+        private void AddRowControl(Common.SceneUI scene, bool addLine)
+        {
+            var rowContr = new FrameRowControl(listView.rowSpace / 2);
+            listView.AddChidren(rowContr);
+
+            //鍥炬爣
+            var btnIcon = rowContr.AddLeftIcon(81);
+            btnIcon.UnSelectedImagePath = "Scene/SceneIcon.png";
+            //鍦烘櫙鍚�
+            var btnName = rowContr.AddLeftCaption(scene.Name, 700);
+            btnName.TextSize = 15;
+            //閫夋嫨
+            var btnSelect = rowContr.AddMostRightEmptyIcon(58, 58);
+            btnSelect.Visible = false;
+            btnSelect.UnSelectedImagePath = "Item/ItemSelected.png";
+            if (addLine == true)
+            {
+                //搴曠嚎
+                rowContr.AddBottomLine();
+            }
+
+            rowContr.ButtonClickEvent += (sender, e) =>
+            {
+                btnSelect.Visible = !btnSelect.Visible;
+                if (btnSelect.Visible == true)
+                {
+                    dicSelectScene[scene.Id] = scene;
+                }
+                else
+                {
+                    dicSelectScene.Remove(scene.Id);
+                }
+            };
+        }
+
+        #endregion
+
+        #region 鈻� 淇濆瓨鍦烘櫙___________________________
+
+        /// <summary>
+        /// 淇濆瓨鍦烘櫙鍒板畨闃�
+        /// </summary>
+        private async void SaveSceneToSafety()
+        {
+            var listAction = new List<Safeguard.AlarmActionObj>();
+            foreach (var scene in this.dicSelectScene.Values)
+            {
+                var actionObj = new Safeguard.AlarmActionObj();
+                actionObj.Type = 1;
+                actionObj.ScenesId = scene.Id;
+                listAction.Add(actionObj);
+            }
+            //娣诲姞鎶ヨ鐩爣鍒板畨闃�
+            bool success = await HdlSafeguardLogic.Current.AddAlarmTagetToSafety(this.zoonID, listAction);
+            if (success == true)
+            {
+                //鍏抽棴鑷韩
+                this.CloseForm();
+            }
+        }
+        #endregion
+    }
+}

--
Gitblit v1.8.0