From a715181089be0d31cd737a5367ffd02690b9d77f Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 12 十一月 2020 13:36:01 +0800
Subject: [PATCH] 20201112

---
 HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalSciencePage.cs |  403 ++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 225 insertions(+), 178 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalSciencePage.cs b/HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalSciencePage.cs
index 2aad4ab..069664f 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalSciencePage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalSciencePage.cs
@@ -3,6 +3,7 @@
 using HDL_ON.Entity;
 using HDL_ON.UI.CSS;
 using System.Collections.Generic;
+using HDL_ON.DriverLayer;
 
 namespace HDL_ON.UI
 {
@@ -19,6 +20,14 @@
         /// 鎴块棿閫夋嫨涓嬫媺鍥炬爣
         /// </summary>
         Button btnFoorDownIcon;
+        /// <summary>
+        /// 鎴块棿閫夋嫨瑙﹀彂鍖哄煙
+        /// </summary>
+        Button btnRoomClickRow;
+        /// <summary>
+        /// 浼犳劅鍣ㄥ垪琛ㄥ尯鍩�
+        /// </summary>
+        FrameLayout sensorListView;
 
         /// <summary>
         /// 澶╂皵鍚嶇О鏂囨湰
@@ -39,17 +48,6 @@
 
         #endregion
         #region 鍖哄煙鍙橀噺
-        List<System.Threading.Thread> threads = new List<System.Threading.Thread>();
-
-
-        uint level1Color = 0xFF2172FF;
-        uint level2Color = 0xCC4484F4;
-        uint level3Color = 0x664484F4;
-        uint level4Color = 0xFFADE764;
-        uint level5Color = 0xFFFFDD55;
-        uint level6Color = 0xFFFF9D54;
-        uint level7Color = 0xFFFF3D3D;
-
         Room room;
 
         #endregion
@@ -58,16 +56,6 @@
         public EnvironmentalSciencePage()
         {
             bodyView = this;
-        }
-
-        public override void RemoveFromParent()
-        {
-            foreach(var thread in threads)
-            {
-                thread.Abort();
-            }
-            threads.Clear();
-            base.RemoveFromParent();
         }
 
         /// <summary>
@@ -95,7 +83,7 @@
             {
                 X = Application.GetRealWidth(24),
                 Y = Application.GetRealHeight(16),
-                Width = Application.GetRealWidth(55),
+                Width = Application.GetRealWidth(60),
                 Height = Application.GetRealHeight(48),
                 TextSize = 42,
                 IsBold = true,
@@ -163,7 +151,6 @@
                 Text = "10掳C",
             };
             topWeatherView.AddChidren(btnTempUpperLimitText);
-
             
             var btnTempLowerLimit = new Button()
             {
@@ -218,7 +205,7 @@
                 Y = Application.GetRealHeight(90),
                 Width = Application.GetRealWidth(24),
                 Height = Application.GetRealWidth(24),
-                UnSelectedImagePath = "Public/DeviceInfoIcon/HumidityIcon.png",
+                UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/HumidityIcon.png",
             };
             topWeatherView.AddChidren(btnHumidityIcon);
 
@@ -241,7 +228,7 @@
                 Y = Application.GetRealHeight(90),
                 Width = Application.GetRealWidth(24),
                 Height = Application.GetRealWidth(24),
-                UnSelectedImagePath = "Public/DeviceInfoIcon/Pm25Icon.png",
+                UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/Pm25Icon.png",
             };
             topWeatherView.AddChidren(btnPm25Icon);
 
@@ -297,11 +284,11 @@
             bodyView.AddChidren(contentView);
 
             #region 鎴块棿椤堕儴鍒囨崲鏄剧ず鍖哄煙
-            room = new Room();
-            if (DB_ResidenceData.residenceData.rooms.Count > 0)
-            {
-                room = DB_ResidenceData.residenceData.rooms[0];
-            }
+            room = new Room() { name = Language.StringByID(StringId.All), sid = ""};
+            //if (DB_ResidenceData.rooms.Count > 0)
+            //{
+            //    room = DB_ResidenceData.rooms[0];
+            //}
             btnFoorDownIcon = new Button()
             {
                 Width = Application.GetMinRealAverage(16),
@@ -324,9 +311,16 @@
                 Text = room.name,
             };
             contentView.AddChidren(btnRoom);
+
+            btnRoomClickRow = new Button()
+            {
+                Height = Application.GetRealHeight(40),
+            };
+            contentView.AddChidren(btnRoomClickRow);
+
             #endregion
 
-            FrameLayout sensorListView = new FrameLayout()
+            sensorListView = new FrameLayout()
             {
                 Gravity = Gravity.CenterHorizontal,
                 Y = Application.GetRealHeight(50),
@@ -338,123 +332,10 @@
             };
             contentView.AddChidren(sensorListView);
 
-            int index = 0;
-            foreach(var sensor in  DB_ResidenceData.residenceData.functionList.sensorsEnvironmentalScience)
-            {
-                if(sensor.functionType == FunctionType.Noise|| sensor.functionType == FunctionType.WindPower)
-                {
-                    continue;
-                }
-                if(sensor.roomIdList.Contains(room.sid))
-                {
-                    FrameLayout sensorView = new FrameLayout()
-                    {
-                        Width = Application.GetRealWidth(148),
-                        Height = Application.GetRealWidth(80),
-                        Radius = (uint)Application.GetRealWidth(8),
-                        BorderColor = 0x00000000,
-                        BorderWidth = 0,
-                        BackgroundColor = CSS_Color.MainBackgroundColor,
-                        Y = Application.GetRealWidth(92 * (index / 2))
-                    };
-                    if (index % 2 != 0)
-                    {
-                        sensorView.X = Application.GetRealWidth(160);
-                    }
-                    sensorListView.AddChidren(sensorView);
+            LoadSenesorList();
 
-                    var arcBar = new ArcSeekBar()
-                    {
-                        ProgressBarUnitSring = "掳C",
-                        X = Application.GetRealWidth(7),
-                        Gravity = Gravity.CenterVertical,
-                        Width = Application.GetRealWidth(48),
-                        Height = Application.GetRealWidth(48),
-                        OpenAngle = 1,
-                        ThumbColor = 0x00000000,
-                        ThumbModeFill = true,
-                        ProgressBarColor = sensor.levelColorList[sensor.curLevel - 1],
-                        ThumbRadius = 1,
-                        ArcWidthWithDefaultStyle = Application.GetRealWidth(3),
-                        MinValue = 0,
-                        MaxValue = 96,
-                        Progress = (96 / sensor.levelColorList.Count) * sensor.curLevel,
-                        //ProgressBarUnitSring = "",
-                        IsClickable = false,
-                        ProgressTextColor = 0x00000000,
-                        ArcColor = CSS_Color.BackgroundColor,
-                        //BackgroundColor = 0x33FF0000,
-                    };
-                    sensorView.AddChidren(arcBar);
+            LoadEventList();
 
-                    var btnSensorTitle = new Button()
-                    {
-                        X = Application.GetRealWidth(7),
-                        Gravity = Gravity.CenterVertical,
-                        Width = Application.GetRealWidth(48),
-                        Height = Application.GetRealWidth(48),
-                        TextAlignment = TextAlignment.Center,
-                        TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
-                        TextColor = CSS_Color.FirstLevelTitleColor,
-                        TextID = sensor.functionTypeNameId
-                    };
-                    sensorView.AddChidren(btnSensorTitle);
-                    btnSensorTitle.MouseUpEventHandler = (sender, e) => {
-                        var esp = new EnvironmentalSensorPage(sensor);
-                        MainPage.BasePageView.AddChidren(esp);
-                        esp.LoadPage();
-                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
-                    };
-
-                    if (sensor.functionType != FunctionType.Noise && sensor.functionType != FunctionType.WindPower)
-                    {
-                        var btnInfoIcon = new Button()
-                        {
-                            X = Application.GetRealWidth(120),
-                            Width = Application.GetRealWidth(28),
-                            Height = Application.GetRealWidth(28),
-                            UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/TipInfoIcon.png",
-                        };
-                        sensorView.AddChidren(btnInfoIcon);
-                        btnInfoIcon.MouseUpEventHandler = (sender, e) =>
-                        {
-                            LoadInfo( sensor);
-                        };
-                    }
-
-                    var btnSensorValues = new Button()
-                    {
-                        X = Application.GetRealWidth(72),
-                        Y = Application.GetRealWidth(17),
-                        Width = Application.GetRealWidth(70),
-                        Height = Application.GetRealWidth(30),
-                        TextAlignment = TextAlignment.CenterLeft,
-                        TextColor = CSS_Color.FirstLevelTitleColor,
-                        TextSize = CSS_FontSize.EmphasisFontSize_Secondary,
-                        IsBold = true,
-                        Text = sensor.values.ToString(),
-                    };
-                    sensorView.AddChidren(btnSensorValues);
-
-                    var btnLevel = new Button()
-                    {
-                        X = Application.GetRealWidth(70),
-                        Y = btnSensorValues.Bottom,
-                        Width = Application.GetRealWidth(50),
-                        Height = Application.GetRealWidth(18),
-                        TextAlignment = TextAlignment.CenterLeft,
-                        TextColor = sensor.levelColorList[sensor.curLevel - 1],
-                        TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
-                        TextID = sensor.levelTextList[sensor.curLevel - 1]
-                    };
-                    sensorView.AddChidren(btnLevel);
-
-
-
-
-                    index++;
-                }
-            }
 
             #endregion
 
@@ -466,17 +347,144 @@
         }
 
         /// <summary>
+        /// 鍔犺浇浼犳劅鍣ㄥ垪琛�
+        /// </summary>
+        void LoadSenesorList()
+        {
+            sensorListView.RemoveAll();
+            int index = 0;
+            foreach (var sensor in DB_ResidenceData.functionList.sensorsEnvironmentalScience)
+            {
+                LoadSensorDiv(sensor, index);
+                index++;
+            }
+        }
+
+        /// <summary>
+        /// 鍔犺浇浼犳劅鍣ㄥ垪琛�
+        /// </summary>
+        void LoadSensorDiv(Sensor sensor,int index)
+        {
+            if (room.sid == "" ||  sensor.roomIdList.Contains(room.sid))
+            {
+                var sensorTag = sensor.sid;
+                if (sensor.bus_Data != null)
+                {
+                    sensorTag = ((int)sensor.functionType % 256) + "_" + sensor.bus_Data.SubnetID + "_" + sensor.bus_Data.DeviceID + "_" + sensor.bus_Data.LoopID;
+                }
+                FrameLayout sensorView = new FrameLayout()
+                {
+                    Width = Application.GetRealWidth(148),
+                    Height = Application.GetRealWidth(80),
+                    Radius = (uint)Application.GetRealWidth(8),
+                    BorderColor = 0x00000000,
+                    BorderWidth = 0,
+                    BackgroundColor = CSS_Color.MainBackgroundColor,
+                    Y = Application.GetRealWidth(92 * (index / 2)),
+                    Tag = sensorTag
+                };
+                if (index % 2 != 0)
+                {
+                    sensorView.X = Application.GetRealWidth(160);
+                }
+                sensorListView.AddChidren(sensorView);
+
+                var arcBar = new DiyArcSeekBar()
+                {
+                    X = Application.GetRealWidth(7),
+                    Gravity = Gravity.CenterVertical,
+                    Width = Application.GetRealWidth(48),
+                    Height = Application.GetRealWidth(48),
+                    OpenAngle = 10,
+                    ProgressBarColor = sensor.levelColorList[sensor.curLevel - 1],
+                    MinValue = 0,
+                    MaxValue = 96,
+                    Progress = (96 / sensor.levelColorList.Count) * sensor.curLevel,
+                    IsClickable = false,
+                    ArcColor = CSS_Color.BackgroundColor,
+                    ArcWidth = Application.GetRealWidth(4),
+                    IsThumbImgBtnShow = false,
+                    SeekBarPadding = Application.GetRealWidth(2),
+                };
+                sensorView.AddChidren(arcBar);
+
+                var btnSensorTitle = new Button()
+                {
+                    X = Application.GetRealWidth(7),
+                    Gravity = Gravity.CenterVertical,
+                    Width = Application.GetRealWidth(48),
+                    Height = Application.GetRealWidth(48),
+                    TextAlignment = TextAlignment.Center,
+                    TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
+                    TextColor = CSS_Color.FirstLevelTitleColor,
+                    TextID = sensor.functionTypeNameId,
+                    Tag = "SensorTitle"
+                };
+                sensorView.AddChidren(btnSensorTitle);
+                btnSensorTitle.MouseUpEventHandler = (sender, e) => {
+                    var esp = new EnvironmentalSensorPage(sensor);
+                    MainPage.BasePageView.AddChidren(esp);
+                    esp.LoadPage();
+                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                };
+
+                var btnInfoIcon = new Button()
+                {
+                    X = Application.GetRealWidth(120),
+                    Width = Application.GetRealWidth(28),
+                    Height = Application.GetRealWidth(28),
+                    UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/TipInfoIcon.png",
+                };
+                sensorView.AddChidren(btnInfoIcon);
+                btnInfoIcon.MouseUpEventHandler = (sender, e) =>
+                {
+                    LoadInfo(sensor);
+                };
+
+                var btnSensorValues = new Button()
+                {
+                    X = Application.GetRealWidth(72),
+                    Y = Application.GetRealWidth(17),
+                    Width = Application.GetRealWidth(70),
+                    Height = Application.GetRealWidth(30),
+                    TextAlignment = TextAlignment.CenterLeft,
+                    TextColor = CSS_Color.FirstLevelTitleColor,
+                    TextSize = CSS_FontSize.EmphasisFontSize_Secondary,
+                    IsBold = true,
+                    Text = sensor.values.ToString(),
+                    Tag = "SensorValues"
+                };
+                sensorView.AddChidren(btnSensorValues);
+
+                var btnLevel = new Button()
+                {
+                    X = Application.GetRealWidth(70),
+                    Y = btnSensorValues.Bottom,
+                    Width = Application.GetRealWidth(50),
+                    Height = Application.GetRealWidth(18),
+                    TextAlignment = TextAlignment.CenterLeft,
+                    TextColor = sensor.levelColorList[sensor.curLevel - 1],
+                    TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
+                    TextID = sensor.levelTextList[sensor.curLevel - 1],
+                    Tag = "SensorLevel"
+                };
+                sensorView.AddChidren(btnLevel);
+
+                Control.ins.SendReadCommand(sensor);
+            }
+        }
+
+        /// <summary>
         /// 鍔犺浇浼犳劅鍣ㄧ瓑绾х浉鍏充俊鎭�
         /// </summary>
-        /// <param name="btnInfo"></param>
-        /// <param name="sensor"></param>
         void LoadInfo(Sensor sensor)
         {
             Dialog dialog = new Dialog();
 
             FrameLayout dialogBodyView = new FrameLayout();
             dialog.AddChidren(dialogBodyView);
-            dialogBodyView.MouseUpEventHandler = (sender, e) => {
+            dialogBodyView.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
             };
 
@@ -489,7 +497,8 @@
                 Radius = (uint)Application.GetRealWidth(12),
                 BackgroundColor = CSS_Color.MainBackgroundColor,
                 Animate = Animate.DownToUp,
-                ScrollEnabled = false
+                ScrollEnabled = false,
+                AnimateSpeed = 0.3f,
             };
             dialogBodyView.AddChidren(infoView);
 
@@ -503,22 +512,13 @@
             };
             infoView.AddChidren(btnTitle);
 
-            switch(sensor.functionType)
+            switch (sensor.functionType)
             {
-                case FunctionType.PM10:
-                    btnTitle.Text = "PM1.0(ug/m虏)";
-                    break;
                 case FunctionType.PM25:
                     btnTitle.Text = "PM2.5(ug/m虏)";
                     break;
-                case FunctionType.WindPower:
-
-                    break;
-                case FunctionType.Noise:
-
-                    break;
                 case FunctionType.Temp:
-                    btnTitle.Text = Language.StringByID(StringId.Temp )+ "(掳C)";
+                    btnTitle.Text = Language.StringByID(StringId.Temp) + "(掳C)";
                     break;
                 case FunctionType.TVOC:
                     btnTitle.Text = "TVOC(PPM)";
@@ -529,8 +529,6 @@
                 case FunctionType.Humidity:
                     btnTitle.Text = Language.StringByID(StringId.Humidity) + "(%)";
                     break;
-                   
-                   
             }
 
             FrameLayout subTitleView = new FrameLayout()
@@ -549,7 +547,6 @@
                 IsBold = true,
                 TextID = StringId.IntervalValue,
             });
-
 
             subTitleView.AddChidren(new Button()
             {
@@ -572,7 +569,7 @@
                 IsBold = true,
                 TextID = StringId.ColorValue,
             });
-            for (int index = 0; index    < sensor.levelTextList.Count;index++)
+            for (int index = 0; index < sensor.levelTextList.Count; index++)
             {
                 infoView.AddChidren(new Button()
                 {
@@ -581,7 +578,6 @@
                     Height = Application.GetRealWidth(1),
                     BackgroundColor = CSS_Color.DividingLineColor,
                 });
-
 
                 FrameLayout subInfoView = new FrameLayout()
                 {
@@ -600,7 +596,6 @@
                     Text = sensor.intervalValue[index]
                 });
 
-
                 subInfoView.AddChidren(new Button()
                 {
                     Gravity = Gravity.CenterHorizontal,
@@ -609,7 +604,7 @@
                     TextColor = CSS_Color.FirstLevelTitleColor,
                     TextSize = CSS_FontSize.TextFontSize,
                     IsBold = true,
-                    TextID =sensor.levelTextList[index]
+                    TextID = sensor.levelTextList[index]
                 });
 
                 subInfoView.AddChidren(new Button()
@@ -621,17 +616,13 @@
                     Radius = (uint)Application.GetRealWidth(4),
                     BackgroundColor = sensor.levelColorList[index]
                 });
-
             }
 
 
 
 
             dialog.Show();
-
         }
-
-
 
         /// <summary>
         /// 鎴块棿鍒楄〃鐐瑰嚮浜嬩欢
@@ -651,8 +642,8 @@
                     X = Application.GetRealWidth(10),
                     Y = Application.GetRealHeight(266),
                     Width = Application.GetRealWidth(160),
-                    Height = Application.GetRealHeight(203),
-                    BackgroundImagePath = "PersonalCenter/HomeListbg.png",
+                    Height = Application.GetRealHeight(110),
+                    BackgroundImagePath = "PersonalCenter/HomeList1bg.png",
                 };
                 dialogBody.AddChidren(dispalyView);
 
@@ -661,12 +652,67 @@
                     X = Application.GetRealWidth(8),
                     Y = Application.GetRealHeight(15),
                     Width = Application.GetRealWidth(150),
-                    Height = Application.GetRealHeight(45 * 4),
+                    Height = Application.GetRealHeight(45 * 2),
+                    ScrollEnabled = false
                 };
                 dispalyView.AddChidren(contentView);
 
+                if (DB_ResidenceData.rooms.Count < 2)
+                {
+                }
+                else if (DB_ResidenceData.rooms.Count < 3)
+                {
+                    dispalyView = new FrameLayout()
+                    {
+                        X = Application.GetRealWidth(10),
+                        Y = Application.GetRealHeight(266),
+                        Width = Application.GetRealWidth(160),
+                        Height = Application.GetRealHeight(155),
+                        BackgroundImagePath = "PersonalCenter/HomeList2bg.png",
+                    };
+                    dialogBody.AddChidren(dispalyView);
 
-                foreach (var roomTemp in DB_ResidenceData.residenceData.rooms)
+                    contentView.Height = Application.GetRealHeight(45 * 3);
+                    dispalyView.AddChidren(contentView);
+                }
+                else if (DB_ResidenceData.rooms.Count < 4)
+                {
+                    dispalyView = new FrameLayout()
+                    {
+                        X = Application.GetRealWidth(10),
+                        Y = Application.GetRealHeight(266),
+                        Width = Application.GetRealWidth(160),
+                        Height = Application.GetRealHeight(200),
+                        BackgroundImagePath = "PersonalCenter/HomeList3bg.png",
+                    };
+                    dialogBody.AddChidren(dispalyView);
+
+                    contentView.Height = Application.GetRealHeight(45 * 4);
+                    dispalyView.AddChidren(contentView);
+                }
+                else
+                {
+                    dispalyView = new FrameLayout()
+                    {
+                        X = Application.GetRealWidth(10),
+                        Y = Application.GetRealHeight(266),
+                        Width = Application.GetRealWidth(160),
+                        Height = Application.GetRealHeight(245),
+                        BackgroundImagePath = "PersonalCenter/HomeList4bg.png",
+                    };
+                    dialogBody.AddChidren(dispalyView);
+
+                    contentView.Height = Application.GetRealHeight(45 * 5);
+                    contentView.ScrollEnabled = true;
+                    dispalyView.AddChidren(contentView);
+                }
+
+
+                var showListRoom = new List<Room>();
+                showListRoom.Add(new Room() { name = Language.StringByID(StringId.All),sid = "" });
+                showListRoom.AddRange(DB_ResidenceData.rooms);
+
+                foreach (var roomTemp in showListRoom) 
                 {
                     string roomName = roomTemp.name;
                     var btnRoomName = new Button()
@@ -690,14 +736,15 @@
                         dialog.Close();
                         btnRoom.Text = roomName;
                         room = roomTemp;
+                        LoadSenesorList();
                     };
                 }
 
                 dialog.Show();
             };
 
-            btnRoom.MouseUpEventHandler = eventHandler;
-            btnFoorDownIcon.MouseUpEventHandler = eventHandler;
+            btnRoomClickRow.MouseUpEventHandler = eventHandler;
+            //btnFoorDownIcon.MouseUpEventHandler = eventHandler;
         }
 
 

--
Gitblit v1.8.0