From edfb48fa10b0518311ee46bef4aded0859069d16 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期二, 18 七月 2023 17:51:52 +0800
Subject: [PATCH] 2023年07月18日17:50:46

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/RGBColorView.cs       |  249 +++++++++++++++++++++++++++++++
 HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs                  |    6 
 HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs          |   49 +++++
 HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs       |    6 
 HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/AddOutputInputView.cs |   13 +
 HDL_ON/HDL_ON.projitems                                                 |    1 
 HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs          |  115 +++++++++++++
 7 files changed, 427 insertions(+), 12 deletions(-)

diff --git a/HDL_ON/HDL_ON.projitems b/HDL_ON/HDL_ON.projitems
index 2943751..54b81c4 100644
--- a/HDL_ON/HDL_ON.projitems
+++ b/HDL_ON/HDL_ON.projitems
@@ -551,6 +551,7 @@
     <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\VideoDoorLock\VideoDoorLockPage.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\VideoDoorLock\VideoDoorLockListPage.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Light\GroupControlPage.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\3-Intelligence\Automation\LogicView\RGBColorView.cs" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="$(MSBuildThisFileDirectory)Entity\Device\" />
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
index bd46f2d..eb5a27b 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
@@ -1405,7 +1405,7 @@
                 string value = dic["value"];
                 if (dictionaryA["key"] == key && dictionaryA["comparator"] == comparatorValue)
                 {
-                    if (this.checkSpk())
+                    if (this.CheckSpk())
                     {
                         //鏈変簺璁惧闇�瑕佸鍔犺繖涓垽鏂�
                         if (dictionaryA["value"] == value)
@@ -1429,7 +1429,7 @@
         /// 妫�鏌ユ槸鍚︽敮鎸�
         /// </summary>
         /// <returns></returns>
-        private bool checkSpk()
+        private bool CheckSpk()
         {
             if (this.function.spk == SPK.VideoDoorLock ||
                this.function.spk == SPK.doorgate
@@ -1439,7 +1439,7 @@
             }
             return false;
 
-        }
+        } 
         /// <summary>
         /// 鍒ゆ柇dictionaryB鏄惁瀹屾暣鍖呭惈鍙︿竴涓猟ictionaryA
         /// </summary>
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
index 430bd42..52570e4 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
@@ -1071,9 +1071,28 @@
                                                 stateStr += "," +GetKeyValue("cct", dicList) + "k";
                                             }
                                         }
+                                        if (device.spk == SPK.LightRGB)
+                                        {
+                                            string rgb = GetKeyValue("rgb", dicList);
+                                            if (!string.IsNullOrEmpty(rgb) && rgb.Length > 6)
+                                            {
+                                                targetView.btnStateColor.Visible = true;
+                                                targetView.btnStateColor.BackgroundColor = new LogicView.RGBColorView().GetBackgroundColor(rgb);
+                                            }
+                                        }
+                                        if (device.spk == SPK.LightRGBW)
+                                        {
+                                            string rgb = GetKeyValue("rgbw", dicList);
+                                            if (!string.IsNullOrEmpty(rgb) && rgb.Length > 6)
+                                            {
+                                                targetView.btnStateColor.Visible = true;
+                                                targetView.btnStateColor.BackgroundColor = new LogicView.RGBColorView().GetBackgroundColor(rgb);
+                                            }
+                                        }
 
                                     }
                                     break;
+                               
                                 case SPK.CurtainSwitch:
                                     {
                                         foreach (var dic in dicList)
@@ -1170,8 +1189,12 @@
 
                                         if (set_temp != "")
                                         {
-                                            string unit = device.GetAttribute("temperature_type") == null ? "掳" : device.GetAttribute("temperature_type").state;
-                                            stateStr += set_temp + unit+",";
+                                            string unit = device.GetAttribute("temperature_type") == null ? "鈩�" : device.GetAttribute("temperature_type").state;
+                                            if (string.IsNullOrEmpty(unit))
+                                            {
+                                                unit = "鈩�";
+                                            }
+                                            stateStr += set_temp + unit + ",";
                                         }
 
                                         if (mode != "")
@@ -1268,7 +1291,11 @@
                                         }
                                         if (set_temp != "")
                                         {
-                                            string unit = device.GetAttribute("temperature_type") == null ? "掳" : device.GetAttribute("temperature_type").state;
+                                            string unit = device.GetAttribute("temperature_type") == null ? "鈩�" : device.GetAttribute("temperature_type").state;
+                                            if (string.IsNullOrEmpty(unit))
+                                            {
+                                                unit = "鈩�";
+                                            }
                                             stateStr += set_temp + unit + ",";
                                         }
                                         if (mode != "")
@@ -1614,6 +1641,22 @@
                                         button3.Text = value + "k";
                                     }
                                     break;
+                                case "rgb":
+                                case "rgbw":
+                                    {
+                                        if (button3 == null)
+                                        {
+                                            //鎬曡皟璇曡蒋浠朵贡涓婁笢瑗垮鑷存姏寮傚父
+                                            break;
+                                        }
+                                        if (!string.IsNullOrEmpty(value) && value.Length > 6)
+                                        {
+                                            button3.BackgroundColor = new LogicView.RGBColorView().GetBackgroundColor(value);
+                                            button3.Tag = value;
+                                        }
+                                    }
+                                    break;
+
                             }
 
                         }
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
index 4cd73dc..8815827 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
@@ -187,7 +187,7 @@
             var list2 = this.GetVideoDeviceList();
             list.AddRange(list1);
             list.AddRange(list2);
-            //GetTestDevice(ref list, true);
+            GetTestDevice(ref list, true);
             return list;
         }
         /// <summary>
@@ -1197,7 +1197,9 @@
                       // new Entity.Function { sid = "1234567899", name = "闂ㄧ浼犳劅鍣�", spk = Entity.SPK.SensorDoorWindow },
                       //  new Entity.Function { sid = "12345678991234", name = "HDL鏈烘鎵�", spk = Entity.SPK.MechanicalArm },
                       //    new Entity.Function { sid = "123456789912345", name = "娴锋浖鏈烘鎵�", spk = Entity.SPK.MechanicalArm },
-                      //        new Entity.Function { sid = "12345678991234566", name = "娴锋浖鏈烘鎵�", spk = Entity.SPK.MechanicalArm },
+                              new Entity.Function { sid = "123456789912345668", name = "AC", spk = Entity.SPK.AcIr },
+                                 new Entity.Function { sid = "12345678991234567", name = "RGB", spk = Entity.SPK.LightRGB },
+                                  new Entity.Function { sid = "123456789912345678", name = "RGBW", spk = Entity.SPK.LightRGBW },
             };
                 foreach (var function in functions)
                 {
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/AddOutputInputView.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/AddOutputInputView.cs
index 96dc683..a1c9ea6 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/AddOutputInputView.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/AddOutputInputView.cs
@@ -62,6 +62,17 @@
             X = Application.GetRealWidth(165-10),
             TextAlignment = TextAlignment.CenterRight,
         };
+        /// <summary>
+        /// 锛堟潯浠舵垨鑰呯洰鏍囷級鑹茬洏涓撶敤
+        /// </summary>
+        public Button btnStateColor = new Button
+        {
+            Width = Application.GetRealWidth(10),
+            Height = Application.GetRealWidth(10),
+            Radius = (uint)Application.GetRealHeight(5),
+            X = Application.GetRealWidth(315 - 10),
+            Visible=false,
+        };
 
         /// <summary>
         /// 锛堟潯浠舵垨鑰呯洰鏍囷級鍥炬爣
@@ -122,12 +133,14 @@
             verticalScrolView.AddChidren(frameLayout);
             frameLayout.AddChidren(rowLayout);
             btnIcon.Gravity = Gravity.CenterVertical;
+            btnStateColor.Gravity = Gravity.CenterVertical;
             btnText.Gravity = Gravity.CenterVertical;
             btnText.TextAlignment = TextAlignment.CenterLeft;
             btnNextIcon.Gravity = Gravity.CenterVertical;
             rowLayout.AddChidren(btnIcon);
             rowLayout.AddChidren(btnText);
             rowLayout.AddChidren(btnState);
+            rowLayout.AddChidren(btnStateColor);
             rowLayout.AddChidren(btnNextIcon);
             rowLayout.AddRightView(btnDelay);
             rowLayout.AddRightView(btnDel);
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/RGBColorView.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/RGBColorView.cs
new file mode 100644
index 0000000..3b04843
--- /dev/null
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/RGBColorView.cs
@@ -0,0 +1,249 @@
+锘縰sing System;
+using HDL_ON.Entity;
+using HDL_ON.UI.CSS;
+using Shared;
+
+namespace HDL_ON.UI.UI2.Intelligence.Automation.LogicView
+{
+    public class RGBColorView
+    {
+        public RGBColorView()
+        {
+        }
+        ///聽<summary>
+        聽聽聽聽聽聽聽聽///聽鍔犺浇rgb閫夋嫨寮圭獥
+        聽聽聽聽聽聽聽聽///聽</summary>
+        聽聽聽聽聽聽聽聽///聽<param聽name="function"></param>
+        聽聽聽聽聽聽聽聽///聽<param聽name="btn"></param>
+        public void LoadRGBDialog(string stateRGBValue, Action<string> action)
+        {
+            string rgbString = "";
+
+            Light tempLight = new Light();
+
+            if (string.IsNullOrEmpty(stateRGBValue))
+            {
+                stateRGBValue = "255,255,255";
+            }
+
+            Dialog dialog = new Dialog()
+            {
+                Height = Application.GetRealHeight(647),
+            };
+
+            var bodyView = new FrameLayout();
+            dialog.AddChidren(bodyView);
+
+            var contentView = new FrameLayout()
+            {
+                Gravity = Gravity.BottomCenter,
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+                Width = Application.GetRealWidth(343),
+                Height = Application.GetRealHeight(300),
+                Radius = (uint)Application.GetRealWidth(12),
+            };
+            bodyView.AddChidren(contentView);
+
+聽聽聽聽聽聽聽聽聽聽聽聽#region聽鏍囬鍖�
+聽聽聽聽聽聽聽聽聽聽聽聽var titleView = new FrameLayout()
+            {
+                Width = Application.GetRealWidth(343),
+                Height = Application.GetRealHeight(52),
+            };
+            contentView.AddChidren(titleView);
+
+            var btnTitle = new Button()
+            {
+                Height = Application.GetRealHeight(52),
+                Gravity = Gravity.Center,
+                TextSize = CSS_FontSize.SubheadingFontSize,
+                TextColor = CSS_Color.MainColor,
+                Text = "RGB",
+                TextAlignment = TextAlignment.Center,
+            };
+            titleView.AddChidren(btnTitle);
+            titleView.AddChidren(new Button() { Height = 1, BackgroundColor = CSS_Color.DividingLineColor, Y = Application.GetRealHeight(51) });
+
+聽聽聽聽聽聽聽聽聽聽聽聽#endregion
+
+聽聽聽聽聽聽聽聽聽聽聽聽int attrViewHight = Application.GetRealHeight(245);
+聽聽聽聽聽聽聽聽聽聽聽聽//灞炴�ц缃尯鍩�
+聽聽聽聽聽聽聽聽聽聽聽聽var attrView = new FrameLayout()
+            {
+                Y = Application.GetRealHeight(52),
+                Width = Application.GetRealWidth(343),
+                Height = attrViewHight
+            };
+            contentView.AddChidren(attrView);
+            attrView.AddChidren(new Button() { Height = Application.GetRealHeight(18) });
+
+聽聽聽聽聽聽聽聽聽聽聽聽#region聽RGB
+聽聽聽聽聽聽聽聽聽聽聽聽var rgbView = new FrameLayout()
+            {
+                Height = Application.GetRealHeight(248)
+            };
+            attrView.AddChidren(rgbView);
+
+            var btnCurColor = new Button()
+            {
+                X = Application.GetRealWidth(16),
+                Y = Application.GetRealHeight(10),
+                Width = Application.GetMinRealAverage(24),
+                Height = Application.GetMinRealAverage(24),
+                Radius = (uint)Application.GetMinRealAverage(8),
+                BorderColor = CSS_Color.PromptingColor2,
+                BorderWidth = 1,
+                BackgroundColor = (uint)(0xFF000000 + tempLight.GetRGBcolor(stateRGBValue))
+            };
+            rgbView.AddChidren(btnCurColor);
+
+聽聽聽聽聽聽聽聽聽聽聽聽//鑹茬洏鐨勬甯冩帶浠�(闄愬埗閭d釜鐧借壊婊戝姩鐞冧娇鐢�)
+聽聽聽聽聽聽聽聽聽聽聽聽var framePickerBack = new FrameLayout();
+            framePickerBack.Gravity = Gravity.CenterHorizontal;
+            framePickerBack.Y = Application.GetRealHeight(20);
+            framePickerBack.Width = Application.GetMinRealAverage(198);
+            framePickerBack.Height = Application.GetMinRealAverage(198);
+            rgbView.AddChidren(framePickerBack);
+
+            var colorPicker = new ColorPicker()
+            {
+                ColorImagePath = "FunctionIcon/Light/ColorWheel.png",
+            };
+            framePickerBack.AddChidren(colorPicker);
+
+
+            //鐧界偣鎺т欢
+            var btnWhiteRound = new Button();
+            btnWhiteRound.Width = Application.GetRealWidth(24);
+            btnWhiteRound.Height = Application.GetRealWidth(24);
+            btnWhiteRound.UnSelectedImagePath = "FunctionIcon/Light/ColorWheelTip.png";
+            btnWhiteRound.Visible = false;
+            framePickerBack.AddChidren(btnWhiteRound);
+
+
+聽聽聽聽聽聽聽聽聽聽聽聽//褰撳墠鐐瑰嚮鐨勩�愮偣銆戞槸鍚︽纭�
+聽聽聽聽聽聽聽聽聽聽聽聽bool pointIsRight = false;
+聽聽聽聽聽聽聽聽聽聽聽聽//鍦嗙殑鍗婂緞(鑰冭檻杈圭晫,闇�瑕佽缃畠鐨勫崐寰勬瘮杈冨皬涓�鐐�)
+聽聽聽聽聽聽聽聽聽聽聽聽int circleR = colorPicker.Width / 2 - Application.GetRealWidth(12);
+
+
+            colorPicker.ColorChaged += (sender2, e2) =>
+            {
+                rgbString = (e2[0] + "," + e2[1] + "," + e2[2]).ToString();
+聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//trait.value聽=聽rgbString;
+聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽btnCurColor.BackgroundColor = (uint)(0xFF000000 + tempLight.GetRGBcolor(rgbString));
+            };
+            colorPicker.MouseDownEventHandler += (sender, e) =>
+            {
+                pointIsRight = this.CheckPoint(circleR, colorPicker.Width / 2, colorPicker.Height / 2, (int)e.X, (int)e.Y);
+                if (pointIsRight == false)
+                {
+聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//鐐圭殑鍖哄煙涓嶆槸鍦嗙洏鍐�
+聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽return;
+                }
+聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//鏄剧ず鐧界偣
+聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽btnWhiteRound.X = (int)e.X - btnWhiteRound.Width / 2;
+                btnWhiteRound.Y = (int)e.Y - btnWhiteRound.Height / 2;
+                if (btnWhiteRound.Visible == false)
+                {
+                    btnWhiteRound.Visible = true;
+                }
+            };
+
+            colorPicker.MouseMoveEventHandler += (sender, e) =>
+            {
+聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//褰撻紶鏍囩偣涓嬩簨浠跺鐞�
+聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽colorPicker.MouseDownEventHandler(sender, e);
+            };
+
+
+聽聽聽聽聽聽聽聽聽聽聽聽#endregion
+
+聽聽聽聽聽聽聽聽聽聽聽聽#region聽
+聽聽聽聽聽聽聽聽聽聽聽聽var btnCancel = new Button()
+            {
+                X = Application.GetRealWidth(20),
+                Width = Application.GetRealWidth(100),
+                Height = Application.GetRealHeight(44),
+                TextAlignment = TextAlignment.CenterLeft,
+                TextSize = CSS_FontSize.TextFontSize,
+                TextColor = CSS_Color.TextualColor,
+                TextID = StringId.Cancel,
+            };
+            titleView.AddChidren(btnCancel);
+            btnCancel.MouseUpEventHandler = (sender, e) =>
+            {
+                dialog.Close();
+            };
+
+            var btnComplete = new Button()
+            {
+                X = Application.GetRealWidth(223),
+                Width = Application.GetRealWidth(100),
+                Height = Application.GetRealHeight(46),
+                TextColor = CSS_Color.MainColor,
+                TextAlignment = TextAlignment.CenterRight,
+                TextSize = CSS_FontSize.TextFontSize,
+                TextID = StringId.Complete
+            };
+            titleView.AddChidren(btnComplete);
+
+聽聽聽聽聽聽聽聽聽聽聽聽//渚嬶細鍙充笅鍦嗚聽澶у皬涓�50
+聽聽聽聽聽聽聽聽聽聽聽聽int mRectCornerID = HDLUtils.RectCornerBottomRight;
+            btnComplete.SetCornerWithSameRadius((uint)Application.GetRealWidth(14), mRectCornerID);
+            btnComplete.MouseUpEventHandler = (sender, e) =>
+            {
+                dialog.Close();
+                action?.Invoke(rgbString);
+                //trait.value = rgbString;
+
+
+            };
+
+聽聽聽聽聽聽聽聽聽聽聽聽#endregion
+
+
+聽聽聽聽聽聽聽聽聽聽聽聽dialog.Show();
+
+        }
+
+        /// <summary>
+        /// 妫�娴嬬偣鍑荤偣
+        /// </summary>
+        /// <param name="circleR">鍦嗙殑鍗婂緞</param>
+        /// <param name="circleX">鍦嗗績X杞�</param>
+        /// <param name="circleY">鍦嗗績Y杞�</param>
+        /// <param name="pointX">鐐瑰嚮鐐圭殑X杞�</param>
+        /// <param name="pointY">鐐瑰嚮鐐圭殑Y杞�</param>
+        /// <returns></returns>
+        private bool CheckPoint(int circleR, int circleX, int circleY, int pointX, int pointY)
+        {
+            int dwidth = circleX - pointX;
+            if (dwidth < 0) { dwidth *= -1; }
+
+            int dHeight = circleY - pointY;
+            if (dHeight < 0) { dHeight *= -1; }
+
+            //鏍规嵁涓夎鍑芥暟,姹備笁瑙掑舰鐨勬枩杈归暱
+            int dlength = dwidth * dwidth + dHeight * dHeight;
+            //鍗婂緞闀垮害(涓嶅紑鏂�,鎵�浠ユ槸鎸夊钩鏂圭畻)
+            circleR *= circleR;
+            if (dlength < circleR)
+            {
+                //濡傛灉缁勬垚鐨勪笁瑙掑舰骞舵病鏈夐暱杩囧崐寰�,鍒欎唬琛ㄨ繕鍦ㄥ渾鍐�(涓嶅厑璁哥偣杈圭晫)
+                return true;
+            }
+            return false;
+        }
+        /// <summary>
+        /// 鑾峰彇鎺т欢鑳屾櫙鍊�
+        /// button.BackgroundColor =(uint)(0xFF000000 + new Light().GetRGBcolor(rgbValueStr))
+        /// </summary>
+        /// <param name="rgbString">rgb鍊�</param>
+        /// <returns></returns>
+        public uint GetBackgroundColor(string rgbString)
+        {
+            return (uint)(0xFF000000 + new Light().GetRGBcolor(rgbString));
+        }
+    }
+}
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs
index 2104754..e828e1a 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs
@@ -2,6 +2,7 @@
 using Shared;
 using System.Collections.Generic;
 using HDL_ON.Entity;
+using HDL_ON.UI.CSS;
 
 namespace HDL_ON.UI.UI2.Intelligence.Automation
 {
@@ -113,8 +114,8 @@
                     break;
                 //鐏厜寮�鍏� 浜害
                 case SPK.LightDimming:
-                case SPK.LightRGB:
-                case SPK.LightRGBW:
+                //case SPK.LightRGB:
+                //case SPK.LightRGBW:
                     {
                         #region 鐣岄潰
                         ///寮�鍏�
@@ -146,6 +147,60 @@
                         {
                             //鏄剧ず缂栬緫涔嬪墠鐨勮澶囩姸鎬�
                             GetEditDeviceState(device, index, lightSwitchView.btnState, brightnessView.btnState, null, null);
+                        }
+                        #endregion
+                    }
+                    break;
+                case SPK.LightRGB:
+                case SPK.LightRGBW:
+                    {
+                        #region 鐣岄潰
+                        ///寮�鍏�
+                        LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView();
+                        lightSwitchView.btnText.TextID = StringId.switchLogic;
+                        fLayout.AddChidren(lightSwitchView.FLayoutView());
+                        ///浜害
+                        LogicView.FunTypeView brightnessView = new LogicView.FunTypeView();
+                        brightnessView.frameLayout.Y = lightSwitchView.frameLayout.Bottom;
+                        brightnessView.btnText.TextID = StringId.brightnesLogic;
+                        fLayout.AddChidren(brightnessView.FLayoutView());
+                        brightnessView.btnState.Text = "5%";//浜у搧缁忕悊鏅撹緣瑕佹眰鏀圭殑 2021-11-06
+                        ///RGB鑹茬洏
+                        LogicView.FunTypeView rgbView = new LogicView.FunTypeView();
+                        rgbView.frameLayout.Y = brightnessView.frameLayout.Bottom;
+                        //rgbView.btnText.TextID = StringId.brightnesLogic;
+                        rgbView.btnText.Text= "RGB鑹茬洏";
+                        rgbView.btnState.Tag = "";
+                        rgbView.btnState.Width = Application.GetRealWidth(16);
+                        rgbView.btnState.Height = Application.GetRealWidth(16);
+                        rgbView.btnState.Radius = (uint)Application.GetRealWidth(8);
+                        rgbView.btnState.X = Application.GetRealWidth(375 - 48 - 16);
+                        fLayout.AddChidren(rgbView.FLayoutView());
+                        ///璁惧寤舵椂iewv
+                        DelayView(fLayout, rgbView.frameLayout.Bottom);
+                        #endregion
+                        #region 鐐瑰嚮浜嬩欢
+                        ///寮�鍏崇偣鍑讳簨浠�
+                        lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            SwitchViewMethod(device, lightSwitchView.btnState, 2);
+                        };
+                        ///浜害鐐瑰嚮浜嬩欢
+                        brightnessView.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            BrightnessMethod(device, brightnessView.btnState, brightnessView.btnText.Text);
+
+                        };
+                        ///RGB鑹茬洏鐐瑰嚮浜嬩欢
+                        rgbView.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            RgbColorDiskMethod(device, rgbView.btnState, rgbView.btnText.Text);
+
+                        };
+                        if (edit)
+                        {
+                            //鏄剧ず缂栬緫涔嬪墠鐨勮澶囩姸鎬�
+                            GetEditDeviceState(device, index, lightSwitchView.btnState, brightnessView.btnState, rgbView.btnState, null);
                         }
                         #endregion
                     }
@@ -333,7 +388,12 @@
                         };
                         int min = device.GetAttribute("set_temp") == null ? 16 : device.GetAttribute("set_temp").min;
                         int max = device.GetAttribute("set_temp") == null ? 32 : device.GetAttribute("set_temp").max;
-                        string unit = device.GetAttribute("temperature_type") == null ? "掳" : device.GetAttribute("temperature_type").state;
+                        string unit = device.GetAttribute("temperature_type") == null ? "鈩�" : device.GetAttribute("temperature_type").state;
+                        if (string.IsNullOrEmpty(unit))
+                        {
+                            //璋冭瘯杞欢鏈夌┖鑳戒笂浼犱负绌�
+                            unit = "鈩�";
+                        }
                         ///娓╁害鐐瑰嚮浜嬩欢
                         temperatureView.btnClick.MouseUpEventHandler += (sender, e) =>
                         {
@@ -439,7 +499,11 @@
                         {
                             int min = device.GetAttribute("set_temp") == null ? 16 : device.GetAttribute("set_temp").min;
                             int max = device.GetAttribute("set_temp") == null ? 32 : device.GetAttribute("set_temp").max;
-                            string unit = device.GetAttribute("temperature_type") == null ? "掳" : device.GetAttribute("temperature_type").state;
+                            string unit = device.GetAttribute("temperature_type") == null ? "鈩�" : device.GetAttribute("temperature_type").state;
+                            if (string.IsNullOrEmpty(unit)) {
+                                //璋冭瘯杞欢鏈夌┖鑳戒笂浼犱负绌�
+                                unit = "鈩�";
+                            }
                             string tempValue = temperatureView.btnState.Text;
                             LogicView.TemperatureView tempView = new LogicView.TemperatureView();
                             tempView.FLayoutView(this, tempValue, (stateStr) =>
@@ -951,6 +1015,47 @@
             #endregion
 
         }
+
+        /// <summary>
+        /// RGB鑹茬洏涓撶敤
+        /// </summary>
+        /// <param name="device">璁惧</param>
+        /// <param name="button">鐘舵�佹帶浠�</param>
+        /// <param name="titleName">鏍囬</param>
+        private void RgbColorDiskMethod(Entity.Function device, Button button, string titleName)
+        {
+            LogicView.RGBColorView rgbColorView = new LogicView.RGBColorView();
+            rgbColorView.LoadRGBDialog(button.Tag.ToString(), (rgbValueStr) =>
+            {
+                button.BackgroundColor = rgbColorView.GetBackgroundColor(rgbValueStr);
+                //鐣岄潰鏄剧ず閫変腑鍊�
+                button.Tag = rgbValueStr;
+                //button.Text = rgbValueStr;
+                selectedState = device.spk + rgbValueStr.ToString();
+                //璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�;
+                string keyVlaue = "";
+                switch (device.spk)
+                {
+                    case SPK.LightRGB:
+                        {
+                            keyVlaue = "rgb";
+                        }
+                        break;
+                    case SPK.LightRGBW:
+                        {
+                            keyVlaue = "rgbw";
+                        }
+                        break;
+                }
+                //鏁版嵁灏佽
+                AddDictionary(keyVlaue, rgbValueStr);
+            });
+
+        }
+
+     
+
+
         /// <summary>
         /// 鏄剧ず缂栬緫涔嬪墠鐨勮澶囩姸鎬�
         /// </summary>
@@ -1054,5 +1159,7 @@
 
         }
 
+       
+
     }
 }

--
Gitblit v1.8.0