From 2e12a9190f431565e576d0b05866366d15bcc9ae Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 23 六月 2022 11:07:37 +0800
Subject: [PATCH] 修复场景闪退问题

---
 HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs |  217 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 211 insertions(+), 6 deletions(-)

diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs b/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs
index 9a7fe8d..92fea27 100644
--- a/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs
+++ b/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs
@@ -1,7 +1,6 @@
 锘縰sing System;
 using HDL_ON.Entity;
 using HDL_ON.UI.CSS;
-using HDL_ON.UI.Music;
 using Shared;
 
 namespace HDL_ON.UI
@@ -9,7 +8,7 @@
     public partial class FunctionControlZone : FrameLayout
     {
         #region 鍖哄煙鎺т欢
-        static FrameLayout bodyDiv;
+        FunctionControlZone bodyDiv;
         /// <summary>
         /// 鍔熻兘/鍦烘櫙icon
         /// </summary>
@@ -26,6 +25,11 @@
         /// 鏀惰棌鎸夐挳
         /// </summary>
         Button btnCollectionIcon;
+        /// <summary>
+        /// 绂荤嚎鏂囨湰
+        /// </summary>
+        Button btnOffline;
+
         #endregion
 
         #region 鍖哄煙鍙橀噺
@@ -50,6 +54,7 @@
 
         /// <summary>
         /// 鍔犺浇鍔熻兘绫诲瀷鎺у埗鍗$墖
+        /// Tag 鍔熻兘灞炴�ф樉绀�
         /// </summary>
         public void LoadFunctionDiv()
         {
@@ -61,8 +66,9 @@
             }
             LoadDiv();
 
-            btnIcon.UnSelectedImagePath = $"FunctionIcon/Icon/{function.IconName}.png";
 
+            btnIcon.UnSelectedImagePath = $"FunctionIcon/Icon/{function.IconName}.png";
+            
             if (SPK.CurtainSpkList().Contains(function.spk))
             {//绐楀笜娌℃湁寮�鍏虫寜閽�
                 CurtainFragment();
@@ -90,6 +96,182 @@
                         this.AddChidren(btnTipPowerLow);
                     }
                 }
+            }
+            else if (function.spk == SPK.DoorLock)
+            {
+                btnIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/DoorLock.png";
+            }
+            else if(SPK.PanelSpkList().Contains(function.spk))//鏅鸿兘闈㈡澘璁惧
+            {
+                var powerLowTipAttr = function.attributes.Find((obj) => obj.key == FunctionAttributeKey.BatteryState);
+                if (powerLowTipAttr != null)
+                {
+                    if (powerLowTipAttr.state.ToLower() == "low")
+                    {
+                        Button btnTipPowerLow = new Button()
+                        {
+                            X = Application.GetRealWidth(307),
+                            Y = Application.GetRealHeight(70),
+                            Width = Application.GetRealWidth(24),
+                            Height = Application.GetRealWidth(24),
+                            UnSelectedImagePath = "FunctionIcon/ArmSensor/PowerLowIcon.png",
+                            SelectedImagePath = "FunctionIcon/ArmSensor/PowerLowIcon.png",
+                        };
+                        this.AddChidren(btnTipPowerLow);
+                    }
+                }
+                var alarmStatusAttr = function.GetAttribute("alarm_status");
+                if(alarmStatusAttr !=null)
+                {
+                    var btnAlarmStatus = new Button()
+                    {
+                        X = Application.GetRealWidth(8 + 10 + 32),
+                        Y = Application.GetRealHeight(53),
+                        Width = Application.GetRealWidth(200),
+                        Height = Application.GetRealHeight(24),
+                        TextAlignment = TextAlignment.CenterLeft,
+                        TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
+                        Tag = "AlarmStatus"
+                    };
+                    if (alarmStatusAttr.state == "alarm")
+                    {
+                        btnAlarmStatus.TextID = StringId.InAlarm;
+                        btnAlarmStatus.TextColor = CSS_Color.WarningColor;
+                    }
+                    else
+                    {
+                        btnAlarmStatus.TextID = StringId.zhengchang;
+                        btnAlarmStatus.TextColor = CSS_Color.MainColor;
+                    }
+
+                    bodyDiv.AddChidren(btnAlarmStatus);
+                }
+
+                //var tipScrView1 = new HorizontalScrolViewLayout() {
+                //    X = Application.GetRealWidth(10),
+                //    Y =  Application.GetRealHeight(56),
+                //    Height = Application.GetRealHeight(20),
+                //    Width = Application.GetRealWidth(330),
+                //    BackgroundColor = 0x22220022,
+                //};
+                //var tipScrView2 = new HorizontalScrolViewLayout()
+                //{
+                //    X = Application.GetRealWidth(10),
+                //    Y = Application.GetRealHeight(83),
+                //    Height = Application.GetRealHeight(20),
+                //    Width = Application.GetRealWidth(330),
+                //    BackgroundColor = 0x22220022,
+                //};
+
+
+                foreach (var target in function.targetSids)
+                {
+                    //bodyDiv.AddChidren(tipScrView1);
+                    //bodyDiv.AddChidren(tipScrView2);
+                    var targetObj = FunctionList.List.Functions.Find((obj) => target == obj.sid);
+                    if(targetObj == null)
+                    {
+                        continue;
+                    }
+                    if (SPK.AcSpkList().Contains(targetObj.spk))
+                    {
+                        bodyDiv.Height = Application.GetRealHeight(126);
+
+                        AC acDevice = new AC();
+                        var btnAcMode = new Button()
+                        {
+                            X = Application.GetRealWidth(10),
+                            Y = Application.GetRealHeight(56),
+                            Width = Application.GetRealWidth(62),
+                            Height = Application.GetRealHeight(19),
+                            BackgroundColor = 0x334484F4,
+                            TextAlignment = TextAlignment.Center,
+                            TextSize = 10,
+                            TextColor = 0xFF4484F4,
+                            Text = Language.StringByID(StringId.AC) + acDevice.GetModeAttrText(targetObj.GetAttrState(FunctionAttributeKey.Mode)),
+                            Tag = target + "screen.panel.ac.mode",
+                            Radius = (uint)Application.GetRealWidth(4),
+                        };
+                        bodyDiv.AddChidren(btnAcMode);
+                        //tipScrView1.AddChidren(new Button() { Width = Application.GetRealWidth(16)});
+
+                        var btnAcTemp = new Button()
+                        {
+                            X = Application.GetRealWidth(10 + 72),
+                            Y = Application.GetRealHeight(56),
+                            Width = Application.GetRealWidth(62),
+                            Height = Application.GetRealHeight(19),
+                            BackgroundColor = 0x334484F4,
+                            TextAlignment = TextAlignment.Center,
+                            TextSize = 10,
+                            TextColor = 0xFF4484F4,
+                            Text = Language.StringByID(StringId.AC) + targetObj.GetAttrState(FunctionAttributeKey.Temperature) + "掳C",
+                            Radius = (uint)Application.GetRealWidth(4),
+                            Tag = target + "screen.panel.ac.temp"
+                        };
+                        bodyDiv.AddChidren(btnAcTemp);
+                        //tipScrView1.AddChidren(new Button() { Width = Application.GetRealWidth(6) });
+                    }
+                    else if (SPK.FhSpkList().Contains(targetObj.spk))
+                    {
+
+                        FloorHeating fhDevice = new FloorHeating();
+                        var btnFhMode = new Button()
+                        {
+                            X = Application.GetRealWidth(10 + 72*2),
+                            Y = Application.GetRealHeight(56),
+                            Radius = (uint)Application.GetRealWidth(4),
+                            Width = Application.GetRealWidth(62),
+                            Height = Application.GetRealHeight(19),
+                            BackgroundColor = 0x33ff9d54,
+                            TextAlignment = TextAlignment.Center,
+                            TextSize = 10,
+                            TextColor = 0xFFff9d54,
+                            Text = Language.StringByID(StringId.FloorHeating) + fhDevice.GetModeAttrText(targetObj.GetAttrState(FunctionAttributeKey.Mode)),
+                            Tag = target + "screen.panel.fh.mode"
+                        };
+                        bodyDiv.AddChidren(btnFhMode);
+                        //tipScrView1.AddChidren(new Button() { Width = Application.GetRealWidth(6) });
+
+                        var btnFhTemp = new Button()
+                        {
+                            X = Application.GetRealWidth(10 + 72 * 3),
+                            Y = Application.GetRealHeight(56),
+                            Radius = (uint)Application.GetRealWidth(4),
+                            Width = Application.GetRealWidth(62),
+                            Height = Application.GetRealHeight(19),
+                            BackgroundColor = 0x33ff9d54,
+                            TextAlignment = TextAlignment.Center,
+                            TextSize = 10,
+                            TextColor = 0xFFff9d54,
+                            Text = Language.StringByID(StringId.FloorHeating) + targetObj.GetAttrState(FunctionAttributeKey.Temperature) + "掳C",
+                            Tag = target + "screen.panel.fh.temp"
+                        };
+                        bodyDiv.AddChidren(btnFhTemp);
+                        //tipScrView1.AddChidren(new Button() { Width = Application.GetRealWidth(6) });
+                    }
+                    else if (SPK.AirFreshSpkList().Contains(targetObj.spk))
+                    {
+
+                        AC acDevice = new AC();
+                        var btnAirFreshFanSpeed = new Button()
+                        {
+                            X = Application.GetRealWidth(10),
+                            Y = Application.GetRealHeight(83),
+                            Width = Application.GetRealWidth(62),
+                            Height = Application.GetRealHeight(19),
+                            BackgroundColor = 0x3309bb07,
+                            TextAlignment = TextAlignment.Center,
+                            TextSize = 10,
+                            TextColor = 0xFF09bb07,
+                            Radius = (uint)Application.GetRealWidth(4),
+                            Text = Language.StringByID(StringId.AirFresh) + acDevice.GetFanAttrText(targetObj.GetAttrState(FunctionAttributeKey.FanSpeed)),
+                            Tag = target + "screen.panel.airFresh.mode"
+                        };
+                        bodyDiv.AddChidren(btnAirFreshFanSpeed);
+                    }
+                }
+
             }
             else
             {
@@ -160,6 +342,8 @@
 
             LoadEvent_DivSkipEvent();
             LoadEvent_FunctionCollection();
+
+   
         }
 
         /// <summary>
@@ -212,10 +396,28 @@
                 UnSelectedImagePath = "Collection/CollectionGrayIcon.png",
                 IsSelected = function.collect
             };
-            if ( !SPK.ArmSensorSpkList().Contains(function.spk) && !SPK.EnvironDeviceSpkList().Contains( function.spk))//!DB_ResidenceData.Instance.CurrentRegion.isOtherShare &&
+            if ( !SPK.ArmSensorSpkList().Contains(function.spk)
+                && function.spk != SPK.DoorLock
+                && !SPK.EnvironDeviceSpkList().Contains( function.spk))//!DB_ResidenceData.Instance.CurrentRegion.isOtherShare &&
             {
                 bodyDiv.AddChidren(btnCollectionIcon);
             }
+
+            //if (!function.online)
+            //{
+            //    bodyDiv.BackgroundColor = CSS_Color.PromptingColor2;
+            //    btnOffline = new Button()
+            //    {
+            //        X = Application.GetRealWidth(8 + 10 + 32),
+            //        Y = Application.GetRealHeight(28 + 24),
+            //        Height = Application.GetRealHeight(30),
+            //        TextID = StringId.DeviceOffline,
+            //        TextColor = CSS_Color.WarningColor,
+            //        TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+            //        TextAlignment = TextAlignment.CenterLeft
+            //    };
+            //    bodyDiv.AddChidren(btnOffline);
+            //}
         }
 
         /// <summary>
@@ -332,7 +534,7 @@
                 btnCurtainOpen.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainUpIcon.png";
                 btnCurtainOpen.SelectedImagePath = "FunctionIcon/Curtain/CurtainUpIconOn.png";
             }
-            LoadEvent_ControlCurtain(btnCurtainStop, btnCurtainOpen, btnCurtainClose, function);
+            LoadEvent_ControlCurtain(btnCurtainStop, btnCurtainOpen, btnCurtainClose);
             #endregion
         }
         /// <summary>
@@ -408,7 +610,7 @@
                 SelectedImagePath = "MusicIcon/nextSelected.png",
             };
             bodyDiv.AddChidren(btnNext);
-            LoadEvent_ControlMusic(btnPlay, btnNext, btnPrev, function as A31MusicModel);
+            LoadEvent_ControlMusic(btnPlay, btnNext, btnPrev, function);
             #endregion
         }
 
@@ -437,5 +639,8 @@
             };
             bodyDiv.AddChidren(btnLastStates);
         }
+
+
+
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0