From f1c3921b08bb22ac6f5db22d620e01d7e8e5c49f Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期一, 30 十二月 2019 13:32:33 +0800
Subject: [PATCH] 2019-12-30-1

---
 ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs |  220 ++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 136 insertions(+), 84 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs
index 47ea583..ebac787 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs
@@ -1,14 +1,14 @@
-锘縰sing System;
+锘縰sing System;
 using System.Collections.Generic;
 using System.Threading.Tasks;
 using ZigBee.Device;
 
-namespace Shared.Phone.UserCenter.Safety
-{
-    /// <summary>
-    /// 瀹夐槻绠$悊鐨勪富鐣岄潰鈽�
-    /// </summary>
-    public class SafetyManagementMainForm : EditorCommonForm
+namespace Shared.Phone.UserCenter.Safety
+{
+    /// <summary>
+    /// 瀹夐槻绠$悊鐨勪富鐣岄潰鈽�
+    /// </summary>
+    public class SafetyManagementMainForm : EditorCommonForm
     {
         #region 鈻� 鍙橀噺澹版槑___________________________
 
@@ -52,11 +52,9 @@
         {
             //娓呯┖bodyFrame
             this.ClearBodyFrame();
-            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
-            {
-                //鍒濆鍖栧彸涓婅鍥炬爣
-                this.InitTopRightIcon();
-            }
+
+            //鍒濆鍖栧彸涓婅鍥炬爣
+            this.InitTopRightIcon();
 
             //鍒濆鍖栧叏閮ㄥ唴瀛樹俊鎭�
             this.InitAllMemoryData();
@@ -168,28 +166,98 @@
         /// </summary>
         private void InitTopRightIcon()
         {
-            var btnIcon = new MostRightIconControl(69, 69);
-            btnIcon.UnSelectedImagePath = "Item/More.png";
-            topFrameLayout.AddChidren(btnIcon);
-            btnIcon.InitControl();
-            btnIcon.ButtonClickEvent += (sender, e) =>
+            //蹇嵎鏂瑰紡
+            var btnShortCut = new MostRightIconControl(69, 69);
+            btnShortCut.UnSelectedImagePath = "Safeguard/SafetyShortcut.png";
+            btnShortCut.SelectedImagePath = "Safeguard/SafetyShortcutSelected.png";
+
+            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
             {
-                //鑿滃崟鎺т欢
-                var frameMenu = new TopRightMenuControl(2);
-                //闃插尯鍒楄〃
-                string menu1 = Language.StringByID(R.MyInternationalizationString.uGarrisonAreaList);
-                frameMenu.AddRowMenu(menu1, "Item/GarrisonList.png", "Item/GarrisonListSelected.png", () =>
+                //蹇嵎鏂瑰紡鍚戝乏绉诲姩
+                btnShortCut.X = Application.GetRealWidth(855);
+
+                var btnIcon = new MostRightIconControl(69, 69);
+                btnIcon.UnSelectedImagePath = "Item/More.png";
+                topFrameLayout.AddChidren(btnIcon);
+                btnIcon.InitControl();
+                btnIcon.ButtonClickEvent += (sender, e) =>
                 {
-                    var form = new GarrisonAreaListMenuForm();
-                    form.AddForm();
-                });
-                //瀵嗙爜璁剧疆
-                string menu2 = Language.StringByID(R.MyInternationalizationString.uPasswordSettion);
-                frameMenu.AddRowMenu(menu2, "Item/PswSettion.png", "Item/PswSettionSelected.png", () =>
+                    //鑿滃崟鎺т欢
+                    var frameMenu = new TopRightMenuControl(2);
+                    //闃插尯鍒楄〃
+                    string menu1 = Language.StringByID(R.MyInternationalizationString.uGarrisonAreaList);
+                    frameMenu.AddRowMenu(menu1, "Item/GarrisonList.png", "Item/GarrisonListSelected.png", () =>
+                    {
+                        HdlCheckLogic.Current.CheckSecondarySecurity(() =>
+                        { 
+                            //楠岃瘉鎴愬姛
+                            var form = new GarrisonAreaListMenuForm();
+                            form.AddForm(); 
+                        }, 
+                        () =>
+                        {
+                            //璇峰墠寰�涓汉涓績{0}璁剧疆浜屾瀹夊叏楠岃瘉鏂瑰紡
+                            string msg = Language.StringByID(R.MyInternationalizationString.uGotoCenterAndSetSecondAuthentication).Replace("{0}", "\r\n");
+                            this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+                            {
+                                var form = new UserMain.SecondAuthenticationForm();
+                                form.AddForm();
+                            });
+                        });
+                    });
+                    //瀵嗙爜璁剧疆
+                    string menu2 = Language.StringByID(R.MyInternationalizationString.uPasswordSettion);
+                    frameMenu.AddRowMenu(menu2, "Item/PswSettion.png", "Item/PswSettionSelected.png", () =>
+                    {
+                        HdlCheckLogic.Current.CheckSecondarySecurity(() =>
+                        {
+                            //楠岃瘉鎴愬姛
+                            var form = new PasswordMenuForm();
+                            form.AddForm();
+                        },
+                        () =>
+                        {
+                            //璇峰墠寰�涓汉涓績{0}璁剧疆浜屾瀹夊叏楠岃瘉鏂瑰紡
+                            string msg = Language.StringByID(R.MyInternationalizationString.uGotoCenterAndSetSecondAuthentication).Replace("{0}", "\r\n");
+                            this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+                            {
+                                var form = new UserMain.SecondAuthenticationForm();
+                                form.AddForm();
+                            });
+                        });
+                    });
+                };
+            }
+
+            topFrameLayout.AddChidren(btnShortCut);
+            btnShortCut.InitControl();
+            if (UserCenterResourse.Option.SafetyShortcut == true)
+            {
+                //浣跨敤蹇嵎鏂瑰紡
+                btnShortCut.IsSelected = true;
+            }
+            btnShortCut.ButtonClickEvent += (sender, e) =>
+            {
+                if (btnShortCut.IsSelected == true)
                 {
-                    var form = new SafetyPasswordMenuForm();
-                    form.AddForm();
-                });
+                    //纭畾鍙栨秷涓婚〉鐨勩�屽畨闃层�嶆嵎寰勶紵
+                    this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uCancelSafetyShortcutMsg), () =>
+                    {
+                        UserCenterResourse.Option.SafetyShortcut = false;
+                        UserCenterResourse.Option.Save();
+                        btnShortCut.IsSelected = false;
+                    });
+                }
+                else
+                {
+                    //纭畾鍒涘缓銆屽畨闃层�嶆嵎寰勫埌涓婚〉锛�
+                    this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uCreatSafetyShortcutMsg), () =>
+                    {
+                        UserCenterResourse.Option.SafetyShortcut = true;
+                        UserCenterResourse.Option.Save();
+                        btnShortCut.IsSelected = true;
+                    });
+                }
             };
         }
 
@@ -278,12 +346,12 @@
         /// <summary>
         /// 鐢婚潰鍏抽棴
         /// </summary>
-        public override void CloseForm()
+        public override void CloseFormBefore()
         {
             //绉婚櫎鍏ㄩ儴鐩戝惉浜嬩欢
             this.RemoveAllListenEvent();
 
-            base.CloseForm();
+            base.CloseFormBefore();
         }
 
         /// <summary>
@@ -291,8 +359,8 @@
         /// </summary>
         private void RemoveAllListenEvent()
         {
-            HdlDeviceAttributeLogic.Current.RemoveEvent("SafetyManagementMainFormAlarm");
-            HdlDeviceAttributeLogic.Current.RemoveEvent("SafetyManagementMainFormReceivePushOnline");
+            HdlGatewayReceiveLogic.Current.RemoveEvent("SafetyManagementMainFormAlarm");
+            HdlGatewayReceiveLogic.Current.RemoveEvent("SafetyManagementMainFormReceivePushOnline");
         }
 
         #endregion
@@ -332,9 +400,9 @@
                 var dicDevice = HdlSafeguardLogic.Current.GetAllSensorDeviceInfo();
                 var listDevice = new List<CommonDevice>();
 
-                foreach (var zoneId in dicDevice.Keys)
+                HdlThreadLogic.Current.RunMain(() =>
                 {
-                    Application.RunOnMainThread(() =>
+                    foreach (var zoneId in dicDevice.Keys)
                     {
                         foreach (var Info in dicDevice[zoneId])
                         {
@@ -352,17 +420,12 @@
                                 listDevice.Add(tempDevice);
                             }
                         }
-                        //鏈�鍚庝竴涓槻鍖虹殑鏃跺�欙紝寮�鍚悇绉嶇洃瑙嗙嚎绋�
-                        if (zoneId == dicDevice.Count)
-                        {
-                            //寮�鍚紶鎰熷櫒鎶ヨ鐩戣
-                            this.StartCheckDeviceAlarm();
-
-                            //寮�鍚澶囧湪绾跨洃娴�
-                            this.StartCheckDeviceOnline(listDevice);
-                        }
-                    });
-                }
+                    }
+                    //寮�鍚紶鎰熷櫒鎶ヨ鐩戣
+                    this.StartCheckDeviceAlarm();
+                    //寮�鍚澶囧湪绾跨洃娴�
+                    this.StartCheckDeviceOnline(listDevice);
+                });
             });
         }
 
@@ -384,6 +447,8 @@
             var frameDevice = new SafetySensorStatuControl();
             listView.AddChidrenFrame(frameDevice);
             frameDevice.InitControl(device);
+            //娣诲姞闃村奖鐗规晥
+            frameDevice.SetViewShadow(true);
 
             string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
             this.dicSensorStatuView[mainkeys] = frameDevice;
@@ -399,15 +464,13 @@
         private void StartCheckDeviceAlarm()
         {
             //鏍规嵁鎺ュ彛鎺ㄩ�侊紝璁剧疆鎶ヨ淇℃伅
-            HdlDeviceAttributeLogic.Current.AddAttributeEvent("SafetyManagementMainFormAlarm", "IASInfoReport", (device) =>
+            HdlGatewayReceiveLogic.Current.AddAttributeEvent("SafetyManagementMainFormAlarm", ReceiveComandDiv.A浼犳劅鍣ㄤ笂鎶�, (device) =>
             {
                 if (HdlSafeguardLogic.Current.IsSensorDeviceExist(device) == false)
                 {
                     //濡傛灉杩欎釜璁惧涓嶅瓨鍦ㄤ簬瀹夐槻锛屽垯涓嶅鐞�
                     return;
                 }
-                //娣诲姞瀹夐槻璁惧涓婃姤鐨勮鎺т欢
-                this.AddSafeguardLogPushRow(device);
 
                 //浼犳劅鍣ㄧ姸鎬�
                 string mainkey = Common.LocalDevice.Current.GetDeviceMainKeys(device);
@@ -456,7 +519,7 @@
             oldGetOnlineTime = DateTime.Now;
 
             //浠庤澶囧垪琛ㄤ腑鑾峰彇鍦ㄧ嚎鐘舵��
-            HdlThreadLogic.Current.RunThread(async () =>
+            HdlThreadLogic.Current.RunThread(() =>
             {
                 //棣栧厛鑾峰彇杩欎簺浼犳劅鍣ㄦ墍鍦ㄧ殑缃戝叧
                 var listWay = new List<ZbGateway>();
@@ -477,7 +540,7 @@
                         //鐣岄潰鍏抽棴
                         return;
                     }
-                    await Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, false, this.ReceiveDeviceStatuPush, ShowErrorMode.NO);
+                    Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, false, this.ReceiveDeviceStatuPush, ShowErrorMode.NO);
                 }
             });
         }
@@ -554,7 +617,7 @@
             this.dicSensorStatuView.Clear();
 
             frameLayoutDraw.RemoveAll();
-            var listView = new VerticalFrameControl(35);
+            var listView = new VerticalFrameControl(0);
             listView.Height = frameLayoutDraw.Height;
             frameLayoutDraw.AddChidren(listView);
 
@@ -603,6 +666,7 @@
                     }
                     //鎵ц鍒濆鍖�
                     TodaySafeguardFrame = new SafeguardLogControl();
+                    TodaySafeguardFrame.Y = Application.GetRealHeight(10);
                     listView.AddChidrenFrame(TodaySafeguardFrame);
                     TodaySafeguardFrame.InitControl(nowDayKey, nowDayData);
 
@@ -637,38 +701,14 @@
         /// <summary>
         /// 娣诲姞瀹夐槻璁惧涓婃姤鐨勮鎺т欢(瀹夐槻鎺ㄩ�佷細璋冪敤杩欎釜涓滆タ)
         /// </summary>
-        /// <param name="device">璁惧瀵硅薄锛屼负null鏃舵槸甯冮槻</param>
+        /// <param name="device">璁惧瀵硅薄</param>
         public void AddSafeguardLogPushRow(CommonDevice device)
         {
-            if (device == null && HdlSafeguardLogic.Current.listAlarmInfo.Count > 0)
-            {
-                //濡傛灉鏄畨闃叉帹閫佺殑璇濓紝澶翠笂闈㈢殑閭d笁涓渾鍦堢殑鍥炬爣瑕佹敼鍙�
-                Application.RunOnMainThread(() =>
-                {
-                    var infoTemp = HdlSafeguardLogic.Current.listAlarmInfo[0];
-                    if (infoTemp.AlarmType == SafeguardAlarmType.AtHome)
-                    {
-                        garrisonControl?.SetIconStatuByGarrisonMode(GarrisonMode.AtHome);
-                        this.ShowMassage(ShowMsgType.Tip, infoTemp.AlarmMsg);
-                    }
-                    else if (infoTemp.AlarmType == SafeguardAlarmType.RemoveHome)
-                    {
-                        garrisonControl?.SetIconStatuByGarrisonMode(GarrisonMode.RemoveHome);
-                        this.ShowMassage(ShowMsgType.Tip, infoTemp.AlarmMsg);
-                    }
-                    else if (infoTemp.AlarmType == SafeguardAlarmType.RemoveGarrison)
-                    {
-                        garrisonControl?.SetIconStatuByGarrisonMode(GarrisonMode.RemoveGarrison);
-                        this.ShowMassage(ShowMsgType.Tip, infoTemp.AlarmMsg);
-                    }
-                });
-                return;
-            }
-            if (this.TabSelectIndex != 1 || HdlSafeguardLogic.Current.listAlarmInfo.Count == 0)
+            if (this.TabSelectIndex != 1 || HdlAlarmsLogic.Current.listSafetyAlarmInfo.Count == 0)
             {
                 return;
             }
-            var info = HdlSafeguardLogic.Current.listAlarmInfo[0];
+            var info = HdlAlarmsLogic.Current.listSafetyAlarmInfo[0];
             if (device != null)
             {
                 string mainkey1 = Common.LocalDevice.Current.GetDeviceMainKeys(info.DeviceAddr, info.DeviceEpoint);
@@ -704,6 +744,18 @@
             });
         }
 
+        /// <summary>
+        /// 闃插尯鎺ㄩ��
+        /// </summary>
+        /// <param name="garrison"></param>
+        public void GarrisonModePush(GarrisonMode garrison)
+        {
+            HdlThreadLogic.Current.RunMain(() =>
+            {
+                garrisonControl?.SetIconStatuByGarrisonMode(garrison);
+            });
+        }
+
         #endregion
 
         #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________
@@ -729,6 +781,6 @@
             return 1;
         }
 
-        #endregion
-    }
-}
+        #endregion
+    }
+}

--
Gitblit v1.8.0