From dcf60777c9346ff058f06298d03173f0c53d1902 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期三, 16 十二月 2020 20:42:15 +0800
Subject: [PATCH] 20201216-4

---
 HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs                    |   18 ++
 HDL_ON/Entity/Function/Light.cs                              |  188 +++++++++-----------------
 HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs         |   23 +-
 HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs            |   10 -
 HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs         |    4 
 HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs      |    8 
 HDL_ON/DAL/DriverLayer/Control_Udp.cs                        |   24 ++-
 HDL_ON/Entity/FunctionList.cs                                |   46 +++--
 HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPageBLL.cs |    4 
 HDL_ON/Entity/Function/Function.cs                           |    8 
 HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPage.cs    |    3 
 HDL_ON/UI/UI2/3-Intelligence/Scene/NewSceneMenuListPage.cs   |   10 
 HDL_ON/UI/UI0-Public/PublicAssmebly.cs                       |    1 
 HDL_ON/DAL/DriverLayer/Packet.cs                             |    4 
 HDL_ON/UI/UI2/FuntionControlView/AC/ACPageBLL.cs             |    2 
 .vs/HDL_APP_Project/xs/UserPrefs.xml                         |   57 ++++++--
 HDL_ON/DAL/DriverLayer/Control.cs                            |    5 
 17 files changed, 207 insertions(+), 208 deletions(-)

diff --git a/.vs/HDL_APP_Project/xs/UserPrefs.xml b/.vs/HDL_APP_Project/xs/UserPrefs.xml
index cc09a66..b54fba8 100644
--- a/.vs/HDL_APP_Project/xs/UserPrefs.xml
+++ b/.vs/HDL_APP_Project/xs/UserPrefs.xml
@@ -1,24 +1,51 @@
 锘�<Properties StartupConfiguration="{D998E133-F0DD-4760-BE3C-461632F54DA4}|Default">
-  <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.47f89eb181110cd1c1050db004cedf20a2ec9c7f" />
-  <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/Common/HDLCommon.cs">
+  <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.6242be7109c740c6cb8999a8904b6e0ea8d45192" />
+  <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/Entity/Function/Light.cs">
     <Files>
-      <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/AddRoom/AddRoomPage.cs" Line="490" Column="28" />
-      <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditPage.cs" Line="159" Column="10" />
-      <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditPageBLL.cs" Line="33" Column="18" />
-      <File FileName="HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs" Line="33" Column="21" />
-      <File FileName="HDL_ON/Entity/Room.cs" Line="466" Column="23" />
-      <File FileName="HDL_ON/UI/UI2/FuntionControlView/Music/View/PlayView.cs" Line="221" Column="17" />
-      <File FileName="HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs" Line="88" Column="14" />
-      <File FileName="HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs" Line="340" Column="68" />
-      <File FileName="HDL_ON/Common/HDLCommon.cs" Line="294" Column="7" />
+      <File FileName="HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs" Line="69" Column="31" />
+      <File FileName="HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPage.cs" Line="40" Column="36" />
+      <File FileName="HDL_ON/Entity/Function/Function.cs" Line="256" Column="21" />
+      <File FileName="HDL_ON/Entity/Function/Light.cs" Line="94" Column="95" />
     </Files>
     <Pads>
       <Pad Id="ProjectPad">
         <State name="__root__">
           <Node name="HDL_APP_Project" expanded="True">
             <Node name="HDL_ON" expanded="True">
-              <Node name="Common" expanded="True">
-                <Node name="HDLCommon.cs" selected="True" />
+              <Node name="Common" expanded="True" />
+              <Node name="DAL" expanded="True">
+                <Node name="DriverLayer" expanded="True" />
+                <Node name="Mqtt" expanded="True" />
+                <Node name="Server" expanded="True" />
+              </Node>
+              <Node name="Entity" expanded="True">
+                <Node name="Function" expanded="True">
+                  <Node name="Light.cs" selected="True" />
+                </Node>
+              </Node>
+              <Node name="UI" expanded="True">
+                <Node name="UI0-Public" expanded="True" />
+                <Node name="UI2" expanded="True">
+                  <Node name="2-Classification" expanded="True" />
+                  <Node name="3-Intelligence" expanded="True">
+                    <Node name="Scene" expanded="True" />
+                  </Node>
+                  <Node name="4-PersonalCenter" expanded="True">
+                    <Node name="RoomListManage" expanded="True">
+                      <Node name="AddRoom" expanded="True" />
+                    </Node>
+                    <Node name="UnlockSetting" expanded="True" />
+                  </Node>
+                  <Node name="FuntionControlView" expanded="True">
+                    <Node name="AC" expanded="True" />
+                    <Node name="Electrical" expanded="True" />
+                    <Node name="FoolHeating" expanded="True" />
+                    <Node name="Light" expanded="True" />
+                    <Node name="Music" expanded="True">
+                      <Node name="View" expanded="True" />
+                    </Node>
+                  </Node>
+                </Node>
               </Node>
             </Node>
           </Node>
@@ -38,7 +65,9 @@
     <BreakpointStore>
       <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/Entity/Function/Scene.cs" relfile="HDL_ON/Entity/Function/Scene.cs" line="323" column="1" />
       <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs" relfile="HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs" line="505" column="1" />
-      <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs" relfile="HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs" line="76" column="1" />
+      <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs" relfile="HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs" line="86" column="1" />
+      <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/3-Intelligence/Scene/SceneAddPage.cs" relfile="HDL_ON/UI/UI2/3-Intelligence/Scene/SceneAddPage.cs" line="465" column="1" />
+      <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/3-Intelligence/Scene/SceneAddPage.cs" relfile="HDL_ON/UI/UI2/3-Intelligence/Scene/SceneAddPage.cs" line="458" column="1" />
     </BreakpointStore>
   </MonoDevelop.Ide.DebuggingService.Breakpoints>
   <MultiItemStartupConfigurations />
diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index 4c86695..82757c7 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -482,6 +482,11 @@
         public void UpdataFunctionStatus(string revString)
         {
             MainPage.Log($"A鍗忚鏇存柊鐘舵��:{revString}");
+            if(Control.Ins.myUdp!= null)
+            {
+                //閲嶇疆閲嶅惎udp鍒ゆ柇璋冩暣
+                Ins.myUdp.controlLostCount = 0;
+            }
             var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(revString);
             if (temp != null)
             {
diff --git a/HDL_ON/DAL/DriverLayer/Control_Udp.cs b/HDL_ON/DAL/DriverLayer/Control_Udp.cs
index e4e770b..fd41020 100644
--- a/HDL_ON/DAL/DriverLayer/Control_Udp.cs
+++ b/HDL_ON/DAL/DriverLayer/Control_Udp.cs
@@ -331,8 +331,8 @@
                                 var bytes = new byte[] { function.bus_Data.loopId,
                                             b,
                                             254, 0,Convert.ToByte(light.fadeTime) ,3,
-                                            (byte)light.redColor,(byte)light.greenColor,
-                                            (byte)light.blueColor,
+                                            (byte)light.RedColor,(byte)light.GreenColor,
+                                            (byte)light.BlueColor,
                                             0,0};
                                 ControlBytesSend(Command.SetLogicLoopColor, subnetId, deviceId, bytes, 1);
                                 break;
@@ -714,7 +714,7 @@
 
             try
             {
-                //MainPage.Log("鍙戦�佹暟鎹�:" + SendFlag);
+                MainPage.Log("鍙戦�佹暟鎹�:" + SendFlag);
                 UdpSocket._BusSocket.AsyncBeginSend(Packet);
                 Packet.HaveSendCount--;
 
@@ -787,6 +787,10 @@
 
         }
 
+        //private void signAlinkPacket()
+        //{
+        //}
+
         /// <summary>
         /// 鍙戦�佹暟鎹�
         /// </summary>
@@ -845,15 +849,19 @@
         /// </summary>
         public void SendLocalHdlLinkData(byte[] sendBytes)
         {
+            if (controlLostCount > 3)
+            {
+                UdpSocket._BusSocket.Stop();
+                UdpSocket._BusSocket.Start(8585);
+                controlLostCount = 0;
+            }
             Packet = new Packet(sendBytes, new System.Net.IPEndPoint(System.Net.IPAddress.Parse(Control.Ins.reportIp), 8585));
-            Packet.HaveSendCount = 4;//ps锛氭病鏈夐噸鍙戯紝鍚庢湡鏈夋椂闂村彲浠ュ鍔犻噸鍙戝垽鏂�
+            Packet.HaveSendCount = 2;//ps锛氭病鏈夐噸鍙戯紝鍚庢湡鏈夋椂闂村彲浠ュ鍔犻噸鍙戝垽鏂�
+            
             System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(managerSendCount));
             thread.IsBackground = true;
             thread.Start(Packet);
-            //wait();涓嶉渶瑕佺瓑寰�
-            //MainPage.Log($"鍙戦�丠dl-Link鏁版嵁锛孖P:{Control.Ins.reportIp}:8585");
+            controlLostCount++;
         }
-
-
     }
 }
diff --git a/HDL_ON/DAL/DriverLayer/Packet.cs b/HDL_ON/DAL/DriverLayer/Packet.cs
index b094ea1..c0a5517 100644
--- a/HDL_ON/DAL/DriverLayer/Packet.cs
+++ b/HDL_ON/DAL/DriverLayer/Packet.cs
@@ -232,9 +232,7 @@
                                         rgb.brightness = receiveBytes[1];
                                         rgb.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[1] + "%";
                                     }
-                                    rgb.redColor = receiveBytes[6];
-                                    rgb.greenColor = receiveBytes[7];
-                                    rgb.blueColor = receiveBytes[8];
+                                    rgb.SetRGBcolor(new byte[] { receiveBytes[6], receiveBytes[7], receiveBytes[8] });
 
                                     HomePage.UpdataFunctionStates(rgb);
                                     RoomPage.UpdataStates(rgb);
diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs
index 3a4a28e..d6d1e9b 100644
--- a/HDL_ON/Entity/Function/Function.cs
+++ b/HDL_ON/Entity/Function/Function.cs
@@ -295,8 +295,8 @@
                 {
                     sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.curValue.ToString() });
                 }
-                sFunc.sid = this.sid;
             }
+            sFunc.sid = this.sid;
             return sFunc;
         }
 
@@ -464,7 +464,11 @@
         /// <summary>
         /// 棰滆壊
         /// </summary>
-        public const string Color = "color";
+        public const string RGB = "rgb";
+        /// <summary>
+        /// 娓愬彉鏃堕棿
+        /// </summary>
+        public const string FadeTime = "fade_time";
         /// <summary>
         /// 妯″紡
         /// </summary>
diff --git a/HDL_ON/Entity/Function/Light.cs b/HDL_ON/Entity/Function/Light.cs
index 48453e6..c6c9738 100644
--- a/HDL_ON/Entity/Function/Light.cs
+++ b/HDL_ON/Entity/Function/Light.cs
@@ -91,13 +91,13 @@
             {
                 if (trait_fadeTime == null)
                 {
-                    trait_fadeTime = attributes.Find((obj) => obj.key == "fade_time");
+                    trait_fadeTime = attributes.Find((obj) => obj.key == FunctionAttributeKey.FadeTime);
                     //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂��
                     if (trait_fadeTime == null)
                     {
                         trait_fadeTime = new FunctionAttributes()
                         {
-                            key = "fade_time",
+                            key = FunctionAttributeKey.FadeTime,
                             value = new List<string> { "up", "down" },
                             max = 10,
                             min = 0,
@@ -136,130 +136,78 @@
                 }
             }
         }
+        /// <summary>
+        /// 鑾峰彇rgb棰滆壊
+        /// </summary>
+        /// <returns></returns>
+        public int GetRGBcolor()
+        {
+            if (trait_color == null)
+            {
+                trait_color = attributes.Find((obj) => obj.key == FunctionAttributeKey.RGB);
+                //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂��
+                if (trait_color == null)
+                {
+                    trait_color = new FunctionAttributes()
+                    {
+                        key = "color",
+                        value = new List<string> { "255,255,255" },
+                        curValue = "255,255,255"
+                    };
+                }
+                if (trait_color.curValue.ToString() == "{}")
+                    trait_color.curValue = "255,255,255";
+                int.TryParse(trait_color.curValue.ToString().Split(",")[0], out redColor);
+                int.TryParse(trait_color.curValue.ToString().Split(",")[1], out greenColor);
+                int.TryParse(trait_color.curValue.ToString().Split(",")[2], out blueColor);
+            }
+
+            int recolor = redColor * 256 * 256 + greenColor * 256 + blueColor;
+
+            return recolor;
+        }
+        /// <summary>
+        /// 鑾峰彇rgb 鎺у埗瀛楃涓�
+        /// </summary>
+        /// <returns></returns>
+        public string GetRGBcolorString()
+        {
+            return redColor + "," + greenColor + "," + blueColor;
+        }
+
+        /// <summary>
+        /// 璁剧疆rgb棰滆壊
+        /// </summary>
+        public void SetRGBcolor(byte[] color)
+        {
+            redColor = color[0];
+            greenColor = color[1];
+            blueColor = color[2];
+        }
 
         [Newtonsoft.Json.JsonIgnore]
         public FunctionAttributes trait_color;
-        /// <summary>
-        /// RGB棰滆壊
-        /// 255255255
-        /// </summary>
-        [Newtonsoft.Json.JsonIgnore]
-        public int color
+        int redColor = 255;
+        int greenColor = 255;
+        int blueColor = 255;
+
+        public int RedColor {
+            get
+            {
+                return redColor;
+            }
+        }
+        public int GreenColor {
+            get
+            {
+                return greenColor;
+            }
+        }
+        public int BlueColor
         {
             get
             {
-                if (trait_color == null)
-                {
-                    trait_color = attributes.Find((obj) => obj.key == "color");
-                    //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂��
-                    if (trait_color == null)
-                    {
-                        trait_color = new FunctionAttributes()
-                        {
-                            key = "color",
-                            value = new List<string> { "FFFFFF" },
-                            max = 0xFFFFFF,
-                            min = 0x00000F,
-                            curValue = 0x00000F
-                        };
-                    }
-                    if (trait_color.curValue.ToString() == "{}")
-                        trait_color.curValue = 0x00000F;
-                }
-                return Convert.ToInt32(trait_color.curValue);
-            }
-            set
-            {
-                try
-                {
-                    trait_color.curValue = value;
-                }
-                catch
-                {
-                    MainPage.Log("color 鏁版嵁鍒锋柊澶辫触.");
-                }
-            }
-        }
-        [Newtonsoft.Json.JsonIgnore]
-        public int redColor
-        {
-            get {
-                try
-                {
-                    return color >> 16;
-                }
-                catch (Exception ex)
-                {
-                    MainPage.Log($"Get red color error : {ex.Message}");
-                    return 0;
-                }
-            }
-            set
-            {
-                try
-                {
-                    var rc = value << 16;
-                    color = rc + (color & 0xFFFF);
-                }
-                catch (Exception ex)
-                {
-                    MainPage.Log($"set red color error : {ex.Message}");
-                }
-            }
-        }
-        [Newtonsoft.Json.JsonIgnore]
-        public int greenColor
-        {
-            get
-            {
-                try
-                {
-                    return (color & 0xFFFF) >> 8;
-                }
-                catch (Exception ex)
-                {
-                    MainPage.Log($"Get green color error : {ex.Message}");
-                    return 0;
-                }
-            }
-            set
-            {
-                try
-                {
-                    var gc = value << 8;
-                    color = gc + (color & 0xFF00FF);
-                }
-                catch (Exception ex)
-                {
-                    MainPage.Log($"set green color error : {ex.Message}");
-                }
-            }
-        }
-        [Newtonsoft.Json.JsonIgnore]
-        public int blueColor
-        {
-            get
-            {
-                try
-                {
-                    return color & 0xFF;
-                }
-                catch (Exception ex)
-                {
-                    MainPage.Log($"Get blue color error : {ex.Message}");
-                    return 0;
-                }
-            }
-            set
-            {
-                try
-                {
-                    color = value + (color & 0xFFFF00);
-                }
-                catch (Exception ex)
-                {
-                    MainPage.Log($"set blue color error : {ex.Message}");
-                }
+                return blueColor;
             }
         }
     }
diff --git a/HDL_ON/Entity/FunctionList.cs b/HDL_ON/Entity/FunctionList.cs
index 6d6b3f2..7026912 100644
--- a/HDL_ON/Entity/FunctionList.cs
+++ b/HDL_ON/Entity/FunctionList.cs
@@ -382,28 +382,36 @@
                     var deviceList = Newtonsoft.Json.JsonConvert.DeserializeObject<DevcieApiPack>(pack.Data.ToString());
                     if (deviceList != null)
                     {
-                        for (int i =0;i < List.GetDeviceFunctionList().Count;)
+                        if (List.GetDeviceFunctionList().Count > 0)
                         {
-                            var localFunction = List.GetDeviceFunctionList()[i];
-                            var newFunction = deviceList.list.Find((obj) => obj.deviceId == localFunction.deviceId);
-                            if (newFunction == null)//濡傛灉浜戠鏈�鏂版暟鎹病鏈夎鏉℃暟鎹紝鍒欐湰鍦伴渶瑕佸垹鎺夎鏁版嵁璁板綍
+                            for (int i = 0; i < List.GetDeviceFunctionList().Count;)
                             {
-                                List.DeleteFunction(localFunction);
-                            }
-                            else
-                            {
-                                i++;
-                                if (localFunction.modifyTime != newFunction.modifyTime)
+                                var localFunction = List.GetDeviceFunctionList()[i];
+                                if (localFunction.functionCategory == FunctionCategory.Music)
                                 {
-                                    MainPage.Log($"local:{localFunction.modifyTime}\r\n server:{newFunction.modifyTime}");
-                                    localFunction.name = newFunction.name;
-                                    localFunction.collect = newFunction.collect;
-                                    localFunction.modifyTime = newFunction.modifyTime;
-                                    localFunction.roomIds = newFunction.roomIds;
-                                    localFunction.bus_Data = newFunction.bus_Data;
-                                    localFunction.SaveFunctionData(false);
+                                    i++;
+                                    continue;
                                 }
-                                deviceList.list.Remove(newFunction);//鎿嶄綔瀹岀殑鏁版嵁娓呯悊鎺夛紝鍓╀笅鐨勫氨鏄柊澧炵殑鍔熻兘
+                                var newFunction = deviceList.list.Find((obj) => obj.deviceId == localFunction.deviceId);
+                                if (newFunction == null)//濡傛灉浜戠鏈�鏂版暟鎹病鏈夎鏉℃暟鎹紝鍒欐湰鍦伴渶瑕佸垹鎺夎鏁版嵁璁板綍
+                                {
+                                    List.DeleteFunction(localFunction);
+                                }
+                                else
+                                {
+                                    i++;
+                                    if (localFunction.modifyTime != newFunction.modifyTime)
+                                    {
+                                        MainPage.Log($"local:{localFunction.modifyTime}\r\n server:{newFunction.modifyTime}");
+                                        localFunction.name = newFunction.name;
+                                        localFunction.collect = newFunction.collect;
+                                        localFunction.modifyTime = newFunction.modifyTime;
+                                        localFunction.roomIds = newFunction.roomIds;
+                                        localFunction.bus_Data = newFunction.bus_Data;
+                                        localFunction.SaveFunctionData(false);
+                                    }
+                                    deviceList.list.Remove(newFunction);//鎿嶄綔瀹岀殑鏁版嵁娓呯悊鎺夛紝鍓╀笅鐨勫氨鏄柊澧炵殑鍔熻兘
+                                }
                             }
                         }
                         //澶勭悊鍓╀笅鐨勬柊澧炲姛鑳�
@@ -636,7 +644,7 @@
                 case FunctionAttributeKey.Brightness:
                     text = Language.StringByID(StringId.Brightness);
                     break;
-                case FunctionAttributeKey.Color:
+                case FunctionAttributeKey.RGB:
                     text = Language.StringByID(StringId.ColorValue);
                     break;
                 case FunctionAttributeKey.Mode:
diff --git a/HDL_ON/UI/UI0-Public/PublicAssmebly.cs b/HDL_ON/UI/UI0-Public/PublicAssmebly.cs
index 25523fb..471a499 100644
--- a/HDL_ON/UI/UI0-Public/PublicAssmebly.cs
+++ b/HDL_ON/UI/UI0-Public/PublicAssmebly.cs
@@ -362,6 +362,7 @@
                 TextSize = CSS_FontSize.TextFontSize,
                 TextColor = isWhite ? CSS_Color.FirstLevelTitleColor : CSS_Color.MainBackgroundColor,
                 Text = msg,
+                IsMoreLines = true,
             };
             frame.AddChidren(btnTipMsg);
 
diff --git a/HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs b/HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs
index a0961e8..21e1102 100644
--- a/HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs
+++ b/HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs
@@ -19,10 +19,20 @@
                 switch (function.functionType)
                 {
                     case FunctionType.Relay:
-                        var relayView = new RelayPage(function as Light);
-                        MainPage.BasePageView.AddChidren(relayView);
-                        relayView.LoadPage(btnCollectionIcon, btnName, btnFromFloor);
-                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                        if (function.spk == SPK.ElectricSocket)
+                        {
+                            var s1View = new SocketPage(function as SwitchSocket);
+                            MainPage.BasePageView.AddChidren(s1View);
+                            s1View.LoadPage(btnCollectionIcon, btnName, btnFromFloor);
+                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                        }
+                        else
+                        {
+                            var relayView = new RelayPage(function as Light);
+                            MainPage.BasePageView.AddChidren(relayView);
+                            relayView.LoadPage(btnCollectionIcon, btnName, btnFromFloor);
+                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                        }
                         break;
                     case FunctionType.RGB:
                         var rgbView = new RGBPage(function as Light);
diff --git a/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs b/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs
index 1e9ab60..855b89c 100644
--- a/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs
+++ b/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs
@@ -747,7 +747,7 @@
                 {
                     Button btnFunctionCount = new Button()
                     {
-                        X = Application.GetRealWidth(16) + Application.GetRealWidth(7 * functionCount.ToString().Length),
+                        X = Application.GetRealWidth(17) + Application.GetRealWidth(7 * functionCount.ToString().Length),
                         Y = btnName.Bottom,
                         Width = Application.GetRealWidth(120),
                         Height = Application.GetRealHeight(24),
@@ -761,7 +761,7 @@
                     {
                         X = Application.GetRealWidth(16),
                         Y = btnName.Bottom,
-                        Width = Application.GetRealWidth(12 * functionCount.ToString().Length),
+                        Width = Application.GetRealWidth(14 * functionCount.ToString().Length),
                         Height = Application.GetRealHeight(24),
                         TextColor = CSS_Color.MainColor,
                         TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Scene/NewSceneMenuListPage.cs b/HDL_ON/UI/UI2/3-Intelligence/Scene/NewSceneMenuListPage.cs
index 412fcd3..fa5a3fe 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Scene/NewSceneMenuListPage.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Scene/NewSceneMenuListPage.cs
@@ -158,11 +158,11 @@
         {
             btnAddSceneBg.MouseUpEventHandler = (sender, e) =>
             {
-                if(!DB_ResidenceData.Instance.HomeGateway.gatewayStatus)
-                {
-                    new PublicAssmebly().TipMsgAutoClose(Language.StringByID(StringId.GatewayOfflineCannotCreateScene), true);
-                    return;
-                }
+                //if(!DB_ResidenceData.Instance.HomeGateway.gatewayStatus)
+                //{
+                //    new PublicAssmebly().TipMsgAutoClose(Language.StringByID(StringId.GatewayOfflineCannotCreateScene), true);
+                //    return;
+                //}
 
                 if (DB_ResidenceData.Instance.CheckWhetherGatewayIdIsNull())
                 {
diff --git a/HDL_ON/UI/UI2/FuntionControlView/AC/ACPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/AC/ACPageBLL.cs
index 0a7a4af..d29fcf9 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/AC/ACPageBLL.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/AC/ACPageBLL.cs
@@ -25,7 +25,7 @@
                     }
                     updataTime = DateTime.Now;
                     bodyView.arcBar.ProgressBarColor = bodyView.aC.trait_on_off.curValue.ToString() == "on" ? CSS_Color.MainColor : CSS_Color.PromptingColor2;
-                    bodyView.btnTemp.Text = uAc.trait_temp.curValue.ToString().Substring(0, 2);
+                    bodyView.btnTemp.Text = uAc.trait_temp.curValue.ToString();
                     bodyView.btnIndoorTemp.Text = Language.StringByID(StringId.IndoorTemp) + Convert.ToInt32(Convert.ToDouble(uAc.trait_IndoorTemp.curValue)) + "掳C";
                     bodyView.btnMode.UnSelectedImagePath = uAc.curModeImage;
                     bodyView.btnWindSpeed.UnSelectedImagePath = uAc.curFanImage;
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPage.cs
index ff756e4..2af08c2 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPage.cs
@@ -126,10 +126,9 @@
             };
             controlView.AddChidren(btnSwitch);
 
-
             LoadEventList();
 
-            new TopViewDiv(bodyView, Language.StringByID(StringId.Fan)).LoadTopView_FunctionTop(socketFunction, actionRefresh);
+            new TopViewDiv(bodyView, Language.StringByID(StringId.Socket)).LoadTopView_FunctionTop(socketFunction, actionRefresh);
             new System.Threading.Thread(() =>
             {
                 DriverLayer.Control.Ins.SendReadCommand(socketFunction);
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPageBLL.cs
index b8af979..058be7c 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPageBLL.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPageBLL.cs
@@ -60,7 +60,7 @@
         {
             btnSwitchIcon.MouseUpEventHandler += (sender, e) =>
             {
-                btnSwitchIcon.IsSelected = !btnSwitchIcon.IsSelected;
+                btnSwitchIcon.IsSelected = btnSwitch.IsSelected = !btnSwitchIcon.IsSelected;
 
                 new System.Threading.Thread(() =>
                 {
@@ -74,7 +74,7 @@
             };
             btnSwitch.MouseUpEventHandler += (sender, e) =>
             {
-                btnSwitch.IsSelected = !btnSwitch.IsSelected;
+                btnSwitch.IsSelected = btnSwitchIcon.IsSelected = !btnSwitch.IsSelected;
 
                 new System.Threading.Thread(() =>
                 {
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs
index 18bd9d9..fb0b739 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs
@@ -95,7 +95,7 @@
                 light.brightness = dimmerBar.Progress;
                 //Control.Send(CommandType_A.write, light);
                 System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                d.Add("brightness", light.brightness.ToString());
+                d.Add(FunctionAttributeKey.Brightness, light.brightness.ToString());
                 Control.Ins.SendWriteCommand(light, d);
                 light.fadeTime = barFadeTime.Progress;
             };
@@ -113,7 +113,7 @@
                 {
                     //Control.Send(CommandType_A.write, this.light);
                     System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                    d.Add("brightness", light.brightness.ToString());
+                    d.Add(FunctionAttributeKey.Brightness, light.brightness.ToString());
                     Control.Ins.SendWriteCommand(light, d);
                 }
                 else
@@ -124,7 +124,7 @@
                         new System.Threading.Thread(() =>
                         {
                             System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                            d.Add("brightness", light.brightness.ToString());
+                            d.Add(FunctionAttributeKey.Brightness, light.brightness.ToString());
                             Control.Ins.SendWriteCommand(light, d);
                         })
                         { IsBackground = true }.Start();
@@ -157,7 +157,7 @@
                 {
                     light.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
                     System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                    d.Add("on_off", light.trait_on_off.curValue.ToString());
+                    d.Add(FunctionAttributeKey.OnOff, light.trait_on_off.curValue.ToString());
                     Control.Ins.SendWriteCommand(light, d);
                 })
                 { IsBackground = true }.Start();
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs
index 0878e07..0162525 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs
@@ -110,10 +110,6 @@
             };
             controlView.AddChidren(btnFromFoorAndRoom);
 
-            if(light.redColor==0&&light.greenColor == 0&& light.blueColor == 0)
-            {
-            }
-
             btnCurColor = new Button()
             {
                 X = Application.GetRealWidth(16),
@@ -123,13 +119,9 @@
                 Radius = (uint)Application.GetMinRealAverage(8),
                 BorderColor = CSS_Color.PromptingColor2,
                 BorderWidth = 1,
-                BackgroundColor = (uint)(0xFF000000 + light.redColor * 256 * 256 + light.greenColor * 256 + light.blueColor)
+                BackgroundColor = (uint)(0xFF000000 + light.GetRGBcolor())
             };
 
-            if (light.redColor == 0 && light.greenColor == 0 && light.blueColor == 0)
-            {
-                btnCurColor.BackgroundColor = 0x00000000;
-            }
             controlView.AddChidren(btnCurColor);
 
             btnCollection = new Button()
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs
index 586b001..aeec41e 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs
@@ -25,7 +25,7 @@
                         }
                         bodyView.dimmerBar.ProgressBarColor = uFunction.trait_on_off.curValue.ToString() == "on" ? CSS.CSS_Color.AuxiliaryColor1 : CSS.CSS_Color.PromptingColor2;
                         bodyView.btnSwitch.IsSelected = uFunction.trait_on_off.curValue.ToString() == "on";
-                        bodyView.btnCurColor.BackgroundColor = (uint)(0xFF000000 + bodyView.light.redColor * 256 * 256 + bodyView.light.greenColor * 256 + bodyView.light.blueColor);
+                        bodyView.btnCurColor.BackgroundColor = (uint)(0xFF000000 + bodyView.light.GetRGBcolor());
                     }
                 }
                 catch (Exception ex)
@@ -61,14 +61,12 @@
             colorPicker.ColorChaged += (sender2, e2) => {
                 if ((DateTime.Now - colorChangeTime).TotalMilliseconds > 200)
                 {
-                    light.redColor = e2[0];
-                    light.greenColor = e2[1];
-                    light.blueColor = e2[2];
+                    light.SetRGBcolor(e2);
                     colorChangeTime = DateTime.Now;
-                    btnCurColor.BackgroundColor = (uint)(0xFF000000 + light.redColor * 256 * 256 + light.greenColor * 256 + light.blueColor);
+                    btnCurColor.BackgroundColor = (uint)(0xFF000000 + light.GetRGBcolor());
                     //Control.Send(CommandType_A.write, this.light);
                     System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                    d.Add("color", (light.redColor * 256 * 256 + light.greenColor * 256 + light.blueColor).ToString());
+                    d.Add(FunctionAttributeKey.RGB, light.GetRGBcolorString());
                     Control.Ins.SendWriteCommand(light, d);
                 }
             };
@@ -103,7 +101,7 @@
                 onDimmerBar = false;
                 light.brightness = dimmerBar.Progress;
                 System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                d.Add("brightness", light.brightness.ToString());
+                d.Add(FunctionAttributeKey.Brightness, light.brightness.ToString());
                 Control.Ins.SendWriteCommand(light, d);
                 light.fadeTime = barFadeTime.Progress;
                 //Control.Send(CommandType_A.write, light);
@@ -122,7 +120,7 @@
                 {
                     //Control.Send(CommandType_A.write, this.light);
                     System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                    d.Add("brightness", light.brightness.ToString());
+                    d.Add(FunctionAttributeKey.Brightness, light.brightness.ToString());
                     Control.Ins.SendWriteCommand(light, d);
                 }
                 else
@@ -134,7 +132,7 @@
                         {
                             //Control.Send(CommandType_A.write, light);
                             System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                            d.Add("brightness", light.brightness.ToString());
+                            d.Add(FunctionAttributeKey.Brightness, light.brightness.ToString());
                             Control.Ins.SendWriteCommand(light, d);
                         })
                         { IsBackground = true }.Start();
@@ -171,7 +169,7 @@
                 {
                     light.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
                     System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                    d.Add("on_off", light.trait_on_off.curValue.ToString());
+                    d.Add(FunctionAttributeKey.OnOff, light.trait_on_off.curValue.ToString());
                     Control.Ins.SendWriteCommand(light, d);
                 })
                 { IsBackground = true }.Start();
@@ -184,13 +182,12 @@
         {
             btnRestoredPoint.MouseUpEventHandler = (sender, e) =>
             {
-                light.color = 0xFFFFFF;
+                light.SetRGBcolor(new byte[] { 255, 255, 255 });
                 btnCurColor.BackgroundColor = 0xFFFFFFFF;
                 System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                d.Add("color", "FFFFFF");
+                d.Add(FunctionAttributeKey.RGB, light.GetRGBcolorString());
                 Control.Ins.SendWriteCommand(light, d);
             };
         }
-
     }
 }

--
Gitblit v1.8.0