From 4cc04639fbadde3a7f3b9875353df0d90fc09043 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期六, 18 一月 2020 14:33:40 +0800
Subject: [PATCH] 节前备份

---
 HDL_ON/UI/UI2/1-HomePage/UI/HomePage.cs |   98 +++++++++++++++++++++++++++++++------------------
 1 files changed, 62 insertions(+), 36 deletions(-)

diff --git a/HDL_ON/UI/UI2/1-HomePage/UI/HomePage.cs b/HDL_ON/UI/UI2/1-HomePage/UI/HomePage.cs
index 00e53f1..5c214dc 100644
--- a/HDL_ON/UI/UI2/1-HomePage/UI/HomePage.cs
+++ b/HDL_ON/UI/UI2/1-HomePage/UI/HomePage.cs
@@ -1,16 +1,14 @@
-锘縰sing System;
-using System.Collections.Generic;
+锘縰sing System.Collections.Generic;
 using HDL_ON.Entity;
-using Newtonsoft.Json.Linq;
 using Shared;
 
 namespace HDL_ON.UI
 {
-    public class HomePage : FrameLayout
+    public partial class HomePage : FrameLayout
     {
 
         #region 鎺т欢鍒楄〃
-        FrameLayout bodyView;
+        static FrameLayout bodyView;
         /// <summary>
         /// 椤堕儴淇℃伅鍖哄煙
         /// </summary>
@@ -35,6 +33,18 @@
         /// 褰撳墠pm2.5鐘舵��
         /// </summary>
         Button btnPm25Values;
+        /// <summary>
+        /// 鐏厜鍖哄煙闆嗗悎
+        /// </summary>
+        static Dictionary<string, FrameLayout> LightViews;
+        /// <summary>
+        /// 绌鸿皟鍖哄煙闆嗗悎
+        /// </summary>
+        static Dictionary<string, FrameLayout> AcViews;
+        /// <summary>
+        /// 绐楀笜鍖哄煙闆嗗悎
+        /// </summary>
+        static Dictionary<string, FrameLayout> CurtainViews;
         #endregion
 
         public HomePage()
@@ -156,10 +166,15 @@
                 Gravity = Gravity.CenterHorizontal,
                 Width = Application.GetRealWidth(343),
                 Height = Application.GetRealHeight(28),
+            };
+            topView.AddChidren(msgView);
+
+            var btngb = new Button()
+            {
                 BackgroundColor = CSS.CSS_Color.MainColor,//0x3F4484F4,//
                 Alpha = 0.4f,
             };
-            topView.AddChidren(msgView);
+            msgView.AddChidren(btngb);
 
             Button btnMsgIcon;
             btnMsgIcon = new Button()
@@ -219,7 +234,7 @@
             btnChangeFunction = new Button()
             {
                 Width = Application.GetRealWidth(114),
-                TextID = InternationalizationString.Functions,
+                TextID = StringId.Functions,
                 SelectedTextColor = CSS.CSS_Color.MainColor,
                 TextColor = CSS.CSS_Color.PromptingColor1,
                 //TextSize = CSS.CSS_FontSize.TextFontSize,
@@ -234,7 +249,7 @@
             {
                 X = btnChangeFunction.Right,
                 Gravity = Gravity.CenterVertical,
-                Width = Application.GetRealWidth(2),
+                Width = Application.GetRealWidth(1),
                 Height = Application.GetRealHeight(14),
                 BackgroundColor = CSS.CSS_Color.PromptingColor1,
             };
@@ -245,7 +260,7 @@
             {
                 X = btnLine.Right,
                 Width = Application.GetRealWidth(114),
-                TextID = InternationalizationString.Scenes,
+                TextID = StringId.Scenes,
                 SelectedTextColor = CSS.CSS_Color.MainColor,
                 TextColor = CSS.CSS_Color.PromptingColor1,
                 TextSize = CSS.CSS_FontSize.TextFontSize,
@@ -262,14 +277,14 @@
             contextView = new VerticalScrolViewLayout()
             {
                 Y = changeView.Bottom + Application.GetRealHeight(10),
-                Height = Application.GetRealHeight(340 + 30), //20涓鸿秴鍑洪儴鍒�
+                Height = Application.GetRealHeight(310 + 30), //20涓鸿秴鍑洪儴鍒�
             };
             bodyView.AddChidren(contextView);
 
-            var lightViews = new Dictionary<string, FrameLayout>();
-            var acViews = new Dictionary<string, FrameLayout>();
-            var curtainViews = new Dictionary<string, FrameLayout>();
-            FrameLayout rowView = new FrameLayout();
+            LightViews = new Dictionary<string, FrameLayout>();
+            AcViews = new Dictionary<string, FrameLayout>();
+            CurtainViews = new Dictionary<string, FrameLayout>();
+            var rowView = new FrameLayout();
 
             foreach (var function in DB_ResidenceData.residenceData.functions)
             {
@@ -281,12 +296,17 @@
                     };
                     contextView.AddChidren(rowView);
                 }
-
+                var functionView_X = Application.GetRealWidth((182 + 7) * (index % 2));
+                if (index % 2 == 0)
+                {
+                    functionView_X += 7;
+                }
                 var functionView = new FrameLayout()
                 {
-                    X = Application.GetRealWidth((182 + 7) * (index % 2)),
+                    X = functionView_X,
                     Width = Application.GetRealWidth(182),
                     Height = Application.GetRealHeight(140),
+                    Tag = function.sid
                 };
                 rowView.AddChidren(functionView);
                 var btnbg = new Button()
@@ -299,17 +319,17 @@
                 {
                     case FunctionType.Light:
                         #region 鐏厜 Light
-                        lightViews.Add(function.sid, functionView);
+                        LightViews.Add(function.sid, functionView);
                         #endregion
                         break;
                     case FunctionType.Curtain:
                         #region 绐楀笜
-                        curtainViews.Add(function.sid, functionView);
+                        CurtainViews.Add(function.sid, functionView);
                         #endregion
                         break;
                     case FunctionType.AC:
                         #region 绌鸿皟 AC
-                        acViews.Add(function.sid, functionView);
+                        AcViews.Add(function.sid, functionView);
                         #endregion
                         break;
 
@@ -317,11 +337,8 @@
                 LoadControlView(functionView, function);
             }
 
-
             contextView.AddChidren(new Button { Height = Application.GetRealHeight(30) });
             #endregion
-
-
         }
         /// <summary>
         /// 鍔犺浇鎺у埗鍗$墖
@@ -343,9 +360,9 @@
             {
                 X = Application.GetRealWidth(21),
                 Y = Application.GetRealHeight(10) + btnIcon.Bottom,
-                Text = function.Name,
+                Text = function.name,
                 IsBold = true,
-                TextColor = CSS.CSS_Color.PromptingColor1,
+                TextColor = CSS.CSS_Color.FirstLevelTitleColor,
                 TextSize = CSS.CSS_FontSize.TextFontSize,
                 Height = Application.GetRealHeight(24),
                 Width = Application.GetRealWidth(140),
@@ -380,10 +397,11 @@
                 Y = btnZone.Bottom,
                 Height = Application.GetRealHeight(18),
                 Width = Application.GetRealWidth(113),
-                TextColor = CSS.CSS_Color.PromptingColor1,
                 SelectedTextColor = CSS.CSS_Color.MainBackgroundColor,
+                TextColor = 0x00000000,
                 TextSize = CSS.CSS_FontSize.PromptFontSize_SecondaryLevel,
                 TextAlignment = TextAlignment.CenterLeft,
+                Tag = "state",
                 Text = function.lastState
             };
             view.AddChidren(btnState);
@@ -396,7 +414,7 @@
                 Width = Application.GetMinRealAverage(24),
                 Height = Application.GetMinRealAverage(24),
                 UnSelectedImagePath = "Collection/CollectionIcon.png",
-                SelectedImagePath = "Collection/CollectionOnIcon.png",
+                SelectedImagePath = "Collection/CollectionIcon.png",
             };
             view.AddChidren(btnCollection);
 
@@ -405,13 +423,12 @@
             {
                 X = Application.GetRealWidth(122),
                 Y = Application.GetRealHeight(92),
-                Width = Application.GetRealWidth(48),
-                Height = Application.GetRealHeight(36),
+                Width = Application.GetMinRealAverage(48),
+                Height = Application.GetMinRealAverage(36),
                 UnSelectedImagePath = "Collection/Switch.png",
                 SelectedImagePath = "Collection/SwitchOn.png",
             };
             view.AddChidren(btnSwitch);
-
 
             switch (function.funcType)
             {
@@ -421,15 +438,25 @@
                     btnIcon.SelectedImagePath = "Public/FunctionIcon/LightOnIcon.png";
 
                     btnSwitch.MouseUpEventHandler += (sender, e) => {
-                        var jsonString = new JObject { { "Namespace", "HDL" }, { "Command", "write" }, { "Type", "device" } };
-                        var data = new JObject { { "Switch", 1 }, { "Dimmer", 100 }, { "sid", "0001002019101209000025670400010001" } };
-                        jsonString.Add("objects", data);
-                        Control.Send(jsonString, function, 3);
+                        var curState = !btnSwitch.IsSelected;
+                        for (int i = 0; i < view.ChildrenCount; i++)
+                        {
+                            if (view.GetChildren(i).GetType() == typeof(Button))
+                            {
+                                var btn = view.GetChildren(i) as Button;
+                                btn.IsSelected = curState;
+                            }
+                        }
+                        new System.Threading.Thread(() =>
+                        {
+                            var light = function as Light;
+                            light.state = btnSwitch.IsSelected ? 1 : 0;
+                            Control.Send("write", function, 3);
+                        })
+                        { IsBackground = true }.Start();
                     };
-
                     #endregion
                     break;
-
                 case FunctionType.Curtain:
                     #region 绐楀笜
                     btnIcon.UnSelectedImagePath = "Public/FunctionIcon/CurtainIcon.png";
@@ -451,6 +478,5 @@
             }
 
         }
-
     }
 }

--
Gitblit v1.8.0