From 9ab5bd54fadd8fc9c542b48c99a117a4e182669b Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期四, 14 十月 2021 16:37:56 +0800
Subject: [PATCH] 智能空开能源界面数据更新

---
 HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmCenterPage.cs |  193 ++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 155 insertions(+), 38 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmCenterPage.cs b/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmCenterPage.cs
index 0e7b6ff..03fb2c6 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmCenterPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmCenterPage.cs
@@ -1,4 +1,5 @@
 锘縰sing System;
+using System.Collections.Generic;
 using HDL_ON.DriverLayer;
 using HDL_ON.Entity;
 using HDL_ON.UI.CSS;
@@ -15,9 +16,16 @@
         /// 鑷畾涔夊竷闃插尯鍩�
         /// </summary>
         HorizontalScrolViewLayout customDeploymentView;
-
+        /// <summary>
+        /// 
+        /// </summary>
+        FrameLayout alarmIconBgView;
         //瀹夐槻鐘舵�佽儗鏅浘
         Button btnArmTipIcon;
+        /// <summary>
+        /// 瀹夐槻璀︽姤鍥炬爣
+        /// </summary>
+        Button btnInalarmIcon;
         /// <summary>
         /// 褰撳墠甯冮槻鍚嶇О
         /// </summary>
@@ -28,6 +36,23 @@
         /// </summary>
         FrameLayout disarmView;
 
+        /// <summary>
+        /// 甯冮槻鎺ュ彛
+        /// </summary>
+        SecurityAlarm InDefenseMode = null;
+        /// <summary>
+        /// 鑷畾涔夊竷闃叉帶浠跺垪琛�
+        /// </summary>
+        List<ArmDiyView> armDiyViewList = new List<ArmDiyView>();
+
+
+        Action refreshAction = null;
+
+        public ArmCenterPage(Action action)
+        {
+            refreshAction = action;
+            bodyView = this;
+        }
         public ArmCenterPage()
         {
             bodyView = this;
@@ -55,7 +80,7 @@
                 Height =Application.GetRealWidth(32),
             });
 
-            FrameLayout alarmIconBgView = new FrameLayout()
+            alarmIconBgView = new FrameLayout()
             {
                 Gravity = Gravity.CenterHorizontal,
                 Width = Application.GetRealWidth(198),
@@ -72,6 +97,25 @@
                 SelectedImagePath = "FunctionIcon/ArmCenter/InDefenseBigIcon.png",
             };
             alarmIconBgView.AddChidren(btnArmTipIcon);
+
+            btnInalarmIcon = new Button()
+            {
+                Width = Application.GetRealWidth(198),
+                Height = Application.GetRealWidth(198),
+                UnSelectedImagePath = "FunctionIcon/ArmCenter/InAlarmBigIcon.png",
+            };
+            btnInalarmIcon.MouseUpEventHandler = (sender, e) => {
+                if(InDefenseMode!= null)
+                {
+                    Action action = () =>
+                    {
+                        InDefenseMode.alarm = false;
+                        Control.Ins.ControlSecurity(InDefenseMode, "enable");
+                    };
+                    new PublicAssmebly().TipOptionMsg(StringId.Tip, StringId.ClearTheSecurityAlarmTip, action);
+
+                }
+            };
 
             btnDefenseName = new Button()
             {
@@ -105,27 +149,24 @@
                 BackgroundColor = CSS_Color.MainColor,
                 TextAlignment = TextAlignment.Center,
                 TextColor = CSS_Color.MainBackgroundColor,
-                Text = "鎾ら槻",
+                TextID = StringId.chefang,// = "鎾ら槻",
                 Radius = (uint)Application.GetRealWidth(20),
                 Gravity = Gravity.CenterHorizontal,
             };
             disarmView.AddChidren(btnDisarm);
+            
             btnDisarm.MouseUpEventHandler = (sender, e) => {
-                foreach (var temp in FunctionList.List.securities)
+                if(InDefenseMode!= null)
                 {
-                    if (temp.status == "enable")
-                    {
-                        Control.Ins.ControlSecurity(temp, "disable");
-                        break;
-                    }
+                    Control.Ins.ControlSecurity(InDefenseMode, "disable");
                 }
             };
 
-                #endregion
+            #endregion
 
-                #region 鑷畾涔夊竷闃�
-                //鑷畾涔夊竷闃叉爣棰�
-                Button btnCustomDeploymentTitle = new Button()
+            #region 鑷畾涔夊竷闃�
+            //鑷畾涔夊竷闃叉爣棰�
+            Button btnCustomDeploymentTitle = new Button()
             {
                 X = Application.GetRealWidth(24),
                 Height = Application.GetRealWidth(54),
@@ -217,11 +258,34 @@
             #endregion
 
 
+            iniCustomDeploymentView();
 
+        }
 
-            ///鍒锋柊鐣岄潰
-            LoadEvent_RefreshSecurityStatus();
-
+        /// <summary>
+        /// 鍒濆鍖栨姤璀︾姸鎬�
+        /// </summary>
+        /// <param name="inAlarm"></param>
+        public void InitAlarmStatus(bool inAlarm)
+        {
+            try
+            {
+                if (inAlarm)
+                {
+                    if (btnInalarmIcon.Parent == null)
+                    {
+                        alarmIconBgView.AddChidren(btnInalarmIcon);
+                    }
+                }
+                else
+                {
+                    if (btnInalarmIcon.Parent != null)
+                    {
+                        btnInalarmIcon.RemoveFromParent();
+                    }
+                }
+            }
+            catch { }
         }
 
         /// <summary>
@@ -230,11 +294,11 @@
         private void iniCustomDeploymentView()
         {
             customDeploymentView.RemoveAll();
-
+            armDiyViewList.Clear();
             foreach (var mode in FunctionList.List.securities)
             {
                 var armDiyView = new ArmDiyView("FunctionIcon/ArmCenter/AtHomeDefenseIcon.png", "FunctionIcon/ArmCenter/AtHomeDefenseIconOn.png",
-                mode.name);
+                mode.name,mode.sid);
                 customDeploymentView.AddChidren(armDiyView);
                 EventHandler<MouseEventArgs> event2 = (sender, e) =>
                 {
@@ -244,13 +308,18 @@
                 if (mode.status == "enable")
                 {
                     armDiyView.LightingView(true);
+                    InDefenseMode = mode;
+
+                    ///鍒锋柊鐣岄潰
+                    LoadEvent_RefreshSecurityStatus(InDefenseMode);
                 }
+                armDiyViewList.Add(armDiyView);
             }
 
             if (FunctionList.List.securities.Count < 4)
             {
                 var view = new ArmDiyView("FunctionIcon/ArmCenter/AddDefenseIcon.png", "FunctionIcon/ArmCenter/AddDefenseIcon.png",
-                  Language.StringByID(StringId.Custom));
+                  Language.StringByID(StringId.Custom),"customSid");
                 customDeploymentView.AddChidren(view);
                 EventHandler<MouseEventArgs> event1 = (sender, e) =>
                 {
@@ -339,13 +408,12 @@
             }
 
             btnOpen.MouseUpEventHandler = (sender, e) => {
-                if (alarm.status == "disable")
+                string controlStatus = alarm.status == "disable" ? "enable" : "disable";
+                new System.Threading.Thread(() =>
                 {
-                    Control.Ins.ControlSecurity(alarm, "enable");
-                }else
-                {
-                    Control.Ins.ControlSecurity(alarm, "disable");
-                }
+                    Control.Ins.ControlSecurity(alarm, controlStatus);
+                })
+                { IsBackground = true }.Start();
                 dialog.Close();  
             };
 
@@ -369,26 +437,70 @@
 
         }
 
-        public static void LoadEvent_RefreshSecurityStatus()
+        public static void LoadEvent_RefreshSecurityStatus(SecurityAlarm updataTemp)
         {
             Application.RunOnMainThread(() =>
             {
-                if (bodyView != null)
+                try
                 {
-                    bodyView.iniCustomDeploymentView();
-                    bodyView.disarmView.Height = 0;
-                    bodyView.btnArmTipIcon.IsSelected = false;
-                    bodyView.btnDefenseName.Text = "";
-                    foreach (var temp in FunctionList.List.securities)
+                    if (bodyView != null)
                     {
-                        if (temp.status == "enable")
+                        bodyView.refreshAction?.Invoke();
+
+                        //甯冮槻
+                        if (updataTemp.status == "enable")
                         {
-                            bodyView.disarmView.Height = Application.GetRealHeight(68);
-                            bodyView.btnArmTipIcon.IsSelected = true;
-                            bodyView.btnDefenseName.Text = temp.name;
-                            break;
+                            bodyView.InDefenseMode = updataTemp;
+                            foreach (var tempView in bodyView.armDiyViewList)
+                            {
+                                tempView.LightingView(false);
+                                if (tempView.sid == updataTemp.sid)
+                                {
+                                    tempView.LightingView(updataTemp.status == "enable");
+                                }
+                            }
                         }
+                        else
+                        {
+                            //鎾ら槻
+                            if(bodyView.InDefenseMode.sid == updataTemp.sid)
+                            {
+                                foreach (var tempView in bodyView.armDiyViewList)
+                                {
+                                    tempView.LightingView(false);
+                                }
+                            }
+                        }
+
+
+                        //foreach(var tempView in bodyView.armDiyViewList)
+                        //{
+                        //    tempView.LightingView(false);
+                        //    if(tempView.sid == updataTemp.sid)
+                        //    {
+                        //        tempView.LightingView(updataTemp.status == "enable");
+                        //    }
+                        //}
+
+                        //娌℃湁甯冮槻鐨勬儏鍐�
+                        if (bodyView.InDefenseMode ==null|| bodyView.InDefenseMode.status == "disable")
+                        {
+                            bodyView.disarmView.Height = 0;   
+                            bodyView.btnArmTipIcon.IsSelected = false;   
+                            bodyView.btnDefenseName.Text = "";   
+                        }
+                        else
+                        {
+                            bodyView.disarmView.Height = Application.GetRealHeight(68); 
+                            bodyView.btnArmTipIcon.IsSelected = true; 
+                            bodyView.btnDefenseName.Text = bodyView.InDefenseMode.name; 
+                        }
+                        bodyView.InitAlarmStatus(bodyView.InDefenseMode.alarm);
                     }
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log($"瀹夐槻鐣岄潰鏇存柊寮傚父锛歿ex.Message}");
                 }
             });
         }
@@ -402,14 +514,16 @@
     {
         Button btnIcon;
         Button btnText;
+        public string sid;
         /// <summary>
         /// 鑷畾涔夊竷闃茬晫闈�
         /// </summary>
         /// <param name="UnSelectedIconPath">鍥剧墖璺緞</param>
         /// <param name="SelectedIconPath">鍥剧墖璺緞</param>
         /// <param name="Text">鏄剧ず鏂囨湰</param>
-        public ArmDiyView(string UnSelectedIconPath, string SelectedIconPath, string Text)
+        public ArmDiyView(string UnSelectedIconPath, string SelectedIconPath, string Text,string inSid)
         {
+            sid = inSid;
             this.Width = Application.GetRealWidth(82);
             this.Height = Application.GetRealWidth(80);
 
@@ -453,6 +567,9 @@
 
     }
 
+    /// <summary>
+    /// 鍥哄畾甯冮槻鎺т欢
+    /// </summary>
     public class FixedArmView : FrameLayout
     {
         /// <summary>

--
Gitblit v1.8.0