From 3f6685c77beeb12baf840733fb890860f4c26e7c Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 25 七月 2024 17:25:59 +0800
Subject: [PATCH] 2024年07月25日17:24:45

---
 HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs | 1292 +++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 1,010 insertions(+), 282 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs b/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs
index 6f695e2..6232dd0 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs
@@ -3,6 +3,7 @@
 using HDL_ON.UI.CSS;
 using Shared;
 using System.Collections.Generic;
+using System.Linq;
 
 namespace HDL_ON.UI
 {
@@ -13,21 +14,38 @@
         Button btnOnText;
         Button btnBrightnessText;
 
+        List<FrameLayout> functionRowList = new List<FrameLayout>();
+
+
         Scene scene;
 
         Action refreshAction;
         SceneFunction sceneFunction;
 
-        public SceneFunctionInfoEditPage(Scene s, SceneFunction fc,Action action)
+        bool isColorful = false;
+        SceneFunction rgbColorful;
+        bool isOnStatus = false;
+
+
+        public SceneFunctionInfoEditPage(Scene s, SceneFunction fc, Action action)
         {
+            
             bodyView = this;
             scene = s;
-            sceneFunction = fc.localFunction.ConvertSceneFunction();
-            foreach(var ll in sceneFunction.status)
+            sceneFunction = fc.localFunction.ConvertSceneFunction(); 
+            foreach (var ll in sceneFunction.status)
             {
-                ll.value = fc.status.Find((obj) => obj.key == ll.key).value;
+                try
+                {
+                    var temp = fc.status.Find((obj) => obj.key == ll.key);
+                    if (temp != null)
+                    {
+                        ll.value = temp.value;
+                        //ll.UintString = temp.UintString;
+                    }
+                }
+                catch { }
             }
-            //sceneFunction = fc;
             refreshAction = action;
         }
 
@@ -35,18 +53,42 @@
         {
             bodyView.BackgroundColor = CSS_Color.BackgroundColor;
 
-            new TopViewDiv(bodyView, sceneFunction.localFunction.name).LoadTopView();
+            var topView = new TopViewDiv(bodyView, sceneFunction.localFunction.name);
+            topView.maginY = 10;
+            topView.LoadTopView();
 
             contentView = new VerticalScrolViewLayout()
             {
-                Y = Application.GetRealHeight(64),
-                Height = Application.GetRealHeight(520),
+                Y = Application.GetRealHeight(64 + 10),
+                Height = Application.GetRealHeight(510),
                 ScrollEnabled = false,
             };
             bodyView.AddChidren(contentView);
 
-            LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff));
+            var onOffStatus = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff);
+            if (onOffStatus != null)
+            {
+                if (onOffStatus.value == "on")
+                {
+                    isOnStatus = true;
+                }
+                LoadFunctionRow(onOffStatus);
+            }
+            else
+            {
+                isOnStatus = true;
+            }
 
+            if (sceneFunction.localFunction.spk == SPK.LightRGB || sceneFunction.localFunction.spk == SPK.GroupControl)
+            {
+                var colorfulStatus = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Colorful);
+                if (colorfulStatus != null)
+                {
+                    isColorful = true;
+                    LoadColorfulRow(colorfulStatus);
+                    isColorful = colorfulStatus.value == "on";
+                }
+            }
             foreach (var attr in sceneFunction.status)
             {
                 switch (attr.key)
@@ -55,7 +97,6 @@
                         LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.SetTemp));
                         break;
                     case FunctionAttributeKey.Mode:
-
                         LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Mode));
                         break;
                     case FunctionAttributeKey.FanSpeed:
@@ -82,44 +123,26 @@
                     case "security"://澶у崕鎽勫儚甯冮槻鎾ら槻
                         LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == "security"));
                         break;
+                    case FunctionAttributeKey.SetVolume:
+                        LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.SetVolume));
+                        break;
+                    case FunctionAttributeKey.Signal:
+                        LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Signal));
+                        break;
+                    case FunctionAttributeKey.SongName:
+                        LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.SongName));
+                        break;
+                    case FunctionAttributeKey.Volume:
+                        LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Volume));
+                        break;
                 }
             }
-
-            //鍔犺浇寮�鍏砇ow
-            //LoadFunctionRow(sceneFunction.localFunction.trait_on_off);
-            //switch (sceneFunction.localFunction.functionType)
-            //{
-            //    case SPK.AcStandard:
-            //        LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp"));
-            //        LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode"));
-            //        LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "fan"));
-            //        break;
-            //    case SPK.FloorHeatStandard:
-            //        LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp"));
-            //        LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode"));
-            //        break;
-            //    case SPK.CurtainSwitch:
-            //        //鏃犳搷浣�
-            //        break;
-            //    case SPK.CurtainTrietex:
-            //    case SPK.CurtainRoller:
-            //        LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent"));
-            //        break;
-            //    case SPK.LightSwitch:
-            //        //鏃犳搷浣�
-            //        break;
-            //    case SPK.LightDimming:
-            //    case SPK.LightRGB:
-            //        LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness"));
-            //        break;
-            //}
 
             if (DB_ResidenceData.Instance.GatewayType != 0)
             {
                 //鍔犺浇寤舵椂Row
                 LoadDelayRow();
             }
-
             var bottomView = new FrameLayout()
             {
                 Y = Application.GetRealHeight(591),
@@ -140,59 +163,220 @@
                 BackgroundColor = CSS_Color.MainColor,
                 TextSize = CSS_FontSize.SubheadingFontSize,
                 IsBold = true,
-                Radius = (uint) Application.GetRealWidth(22),
+                Radius = (uint)Application.GetRealWidth(22),
                 TextID = StringId.Complete
             };
             bottomView.AddChidren(btnConfrim);
 
             btnConfrim.MouseUpEventHandler = (sender, e) =>
             {
-                var temp = scene.functions.Find((obj) => obj.sid == sceneFunction.sid);
-                //if (sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness) != null)
-                //{
-                //    try
-                //    {
-                //        //涓�绔彛涓嶆敮鎸佸紑鍏冲�间笌浜害鍊间竴璧峰鐞嗭紝闇�瑕佸皢寮�鍏冲�肩Щ闄ゆ帀
-                //        sceneFunction.status.Remove(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff));
-                //    }
-                //    catch { }
-                //}
-                
-                if (temp != null)
+                if (sceneFunction.localFunction.spk == SPK.GroupControl)
                 {
-                    temp.delay = sceneFunction.delay;
-                    foreach(var attr in sceneFunction.status)
+                    var colorBegin = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.ColorfulBegin);
+                    if (colorBegin != null)
                     {
-                        var keva = temp.status.Find((obj) => obj.key == attr.key);
-                        if (keva != null)
-                        {
-                            keva.value = attr.value;
-                        }
+                        sceneFunction.status.Remove(colorBegin);
+                    }
+                    var colorEnd = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.ColorfulEnd);
+                    if (colorEnd != null)
+                    {
+                        sceneFunction.status.Remove(colorEnd);
                     }
                 }
                 else
                 {
-                    scene.functions.Add(sceneFunction);
-                }
-                if (!string.IsNullOrEmpty(scene.userSceneId))
-                {
-                    var result = scene.UpdateScene();
-                    if (result == DAL.Server.StateCode.SUCCESS)
+                    if (isOnStatus)
                     {
-                        refreshAction();
-                        this.RemoveFromParent();
+                        if (isColorful)
+                        {
+                            sceneFunction.status.Clear();
+                            sceneFunction.status.Add(new SceneFunctionStatus() { key = FunctionAttributeKey.OnOff, value = "on" });
+                            sceneFunction.status.Add(new SceneFunctionStatus() { key = FunctionAttributeKey.Colorful, value = "on" });
+                        }
+                        else
+                        {
+                            if (sceneFunction.localFunction.spk == SPK.ElectricalTvHisense)
+                            {
+                                for(int i = 0;i< sceneFunction.status.Count;i++)
+                                {
+                                    var tvState = sceneFunction.status[i];
+                                    if (tvState.key == FunctionAttributeKey.OnOff)
+                                    {
+                                        tvState.key = "wol";
+                                        tvState.value = "on";
+                                    }
+                                    else
+                                    {
+                                        if(string.IsNullOrEmpty( tvState.value))
+                                        {
+                                            sceneFunction.status.RemoveAt(i);
+                                            i--;
+                                        }
+                                    }
+                                }
+                            }
+                            else
+                            {
+                                var isHasColorful = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Colorful);
+                                if (isHasColorful != null)
+                                {
+                                    sceneFunction.status.Remove(isHasColorful);
+                                }
+                            }
+                        }
                     }
                     else
                     {
-                        DAL.Server.IMessageCommon.Current.ShowErrorInfoAlter(result);
+                        if (sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff) != null)
+                        {
+                            sceneFunction.status.Clear();
+                            sceneFunction.status.Add(new SceneFunctionStatus() { key = FunctionAttributeKey.OnOff, value = "off" });
+                            sceneFunction.status.Add(new SceneFunctionStatus() { key = FunctionAttributeKey.Delay, value = sceneFunction.delay });
+                        }
                     }
                 }
-                else
+                var temp = scene.functions.Find((obj) => obj.sid == sceneFunction.sid);
+
+                try
                 {
-                    refreshAction();
-                    this.RemoveFromParent();
+                    if (temp != null)
+                    {
+                        scene.functions.Remove(temp);
+                    }
+                        scene.functions.Insert(0, sceneFunction);
+
+
+                    if (sceneFunction.localFunction.spk == SPK.MusicStandard)
+                    {
+                        for (var i = 0; i < sceneFunction.status.Count;)
+                        {
+                            var ddd = sceneFunction.status[i];
+                            if (string.IsNullOrEmpty(ddd.value))
+                            {
+                                sceneFunction.status.Remove(ddd);
+                                continue;
+                            }
+                            i++;
+                        }
+
+                        if (sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.PlaylistName) == null)
+                        {
+                            if (isOnStatus)
+                            {
+                                var songNameStatus = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.SongName);
+                                {
+                                    if (songNameStatus != null)
+                                    {
+                                        if (string.IsNullOrEmpty(songNameStatus.value))
+                                        {
+                                            sceneFunction.status.Add(new SceneFunctionStatus() { key = FunctionAttributeKey.PlaylistName, value = "hdl_special" });
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    if (!string.IsNullOrEmpty(scene.userSceneId))
+                    {
+                        var result = scene.UpdateScene();
+                        if (result == DAL.Server.StateCode.SUCCESS)
+                        {
+                            refreshAction();
+                            this.RemoveFromParent();
+                        }
+                        else
+                        {
+                            DAL.Server.IMessageCommon.Current.ShowErrorInfoAlter(result);
+                        }
+                    }
+                    else
+                    {
+                        try
+                        {
+                            refreshAction();
+                            this.RemoveFromParent();
+                        }
+                        catch
+                        {
+                            MainPage.Log($"xxxxxx123");
+                        }
+                    }
+                }
+                catch
+                {
+                    MainPage.Log($"xxxxxx1234");
                 }
             };
+
+
+            UpdataFunctionRow();
+        }
+
+        void UpdataFunctionRow()
+        {
+            try
+            {
+                contentView.RemoveAll();
+            }
+            catch (Exception ex)
+            {
+                MainPage.Log(ex.Message);
+            }
+            for (var i = 0; i < functionRowList.Count; i++)
+            {
+                try
+                {
+                    var view = functionRowList[i];
+                    if (view != null)
+                    {
+                        if (view.GetType() == typeof(FrameLayout))
+                        {
+                            if (view.Tag != null)
+                            {
+                                if (view.Tag.ToString() == FunctionAttributeKey.OnOff || view.Tag.ToString() == "delay")
+                                {
+                                    contentView.AddChidren(view);
+                                }
+                                else
+                                {
+                                    if (isOnStatus)
+                                    {
+                                        if (view.Tag.ToString() != FunctionAttributeKey.OnOff)
+                                        {
+                                            if (isColorful && sceneFunction.localFunction.spk == SPK.LightRGB)
+                                            {
+                                                if (view.Tag.ToString() != FunctionAttributeKey.Colorful)
+                                                {
+                                                    view.RemoveFromParent();
+                                                }
+                                                else
+                                                {
+                                                    contentView.AddChidren(view);
+                                                }
+                                            }
+                                            else
+                                            {
+                                                contentView.AddChidren(view);
+                                            }
+                                        }
+                                    }
+                                    else
+                                    {
+                                        if (view.Tag.ToString() != FunctionAttributeKey.OnOff && view.Tag.ToString() != "delay")
+                                        {
+                                            view.RemoveFromParent();
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log($"UpdataFuntionRow error:{ex.Message}");
+                }
+            }
         }
 
 
@@ -201,6 +385,273 @@
         /// </summary>
         void LoadFunctionRow(SceneFunctionStatus sceneStatus)
         {
+            try
+            {
+                if (sceneStatus == null)
+                    return;
+                #region Row code
+                var row = new FrameLayout()
+                {
+                    Height = Application.GetRealHeight(50),
+                    BackgroundColor = CSS_Color.MainBackgroundColor,
+                    Tag = sceneStatus.key,
+                };
+                contentView.AddChidren(row);
+                var view = functionRowList.Find((obj) => obj.Tag.ToString() == sceneStatus.key);
+                if (view == null)
+                {
+                    functionRowList.Add(row);
+                }
+
+
+                if (sceneStatus.key != FunctionAttributeKey.OnOff)
+                {
+                    row.AddChidren(new Button() { X = Application.GetRealWidth(16), Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor });
+                }
+                else
+                {
+                    if (sceneStatus.value == "stop")
+                    {
+                        sceneStatus.value = "on";
+                    }
+                }
+                Button btnRight = new Button()
+                {
+                    X = Application.GetRealWidth(339),
+                    Gravity = Gravity.CenterVertical,
+                    Width = Application.GetMinRealAverage(16),
+                    Height = Application.GetMinRealAverage(16),
+                    UnSelectedImagePath = "Public/Right.png",
+                };
+                row.AddChidren(btnRight);
+
+
+                var showCode = "";
+
+                if (sceneStatus.key == FunctionAttributeKey.Mode)
+                {
+                    if (DB_ResidenceData.Instance.GatewayType == 0)
+                    {
+                        if (SPK.AcSpkList().Contains(sceneFunction.localFunction.spk))
+                        {
+                            //0 鍒跺喎1鍒剁儹锛�2閫氶锛�3鑷姩锛�4闄ゆ箍
+                            switch (sceneStatus.value)
+                            {
+                                case "0":
+                                    showCode = "cool";
+                                    break;
+                                case "1":
+                                    showCode = "heat";
+                                    break;
+                                case "2":
+                                    showCode = "fan";
+                                    break;
+                                case "3":
+                                    showCode = "auto";
+                                    break;
+                                case "4":
+                                    showCode = "dry";
+                                    break;
+                            }
+                        }
+                        else if (SPK.FhSpkList().Contains(sceneFunction.localFunction.spk))
+                        {
+                            //1:鏅��,2:鐧藉ぉ,3:澶滄櫄,4:绂诲紑,5:鏃堕棿
+                            switch (sceneStatus.value)
+                            {
+                                case "5":
+                                    showCode = "timer";
+                                    break;
+                                case "1":
+                                    showCode = "normal";
+                                    break;
+                                case "2":
+                                    showCode = "day";
+                                    break;
+                                case "3":
+                                    showCode = "night";
+                                    break;
+                                case "4":
+                                    showCode = "away";
+                                    break;
+                            }
+                        }
+                    }
+                }
+
+                var btnFunctionText = new Button()
+                {
+                    Width = Application.GetRealWidth(330),
+                    TextAlignment = TextAlignment.CenterRight,
+                    TextColor = CSS_Color.PromptingColor1,
+                    TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                    Text = sceneStatus.GetValueText(showCode) + sceneStatus.GetUintString()
+                };
+                row.AddChidren(btnFunctionText);
+                if (sceneStatus.key == FunctionAttributeKey.RGB)
+                {
+                    btnFunctionText.Width = Application.GetRealWidth(28);
+                    btnFunctionText.Height = Application.GetRealWidth(28);
+                    btnFunctionText.X = Application.GetRealWidth(330 - 28);
+                    btnFunctionText.Gravity = Gravity.CenterVertical;
+                    btnFunctionText.Radius = (uint)Application.GetRealWidth(8);
+                    btnFunctionText.Text = "";
+                    btnFunctionText.BackgroundColor = (uint)(0xFF000000 + new Light().GetRGBcolor(sceneStatus.value));
+                }
+
+
+
+                if (sceneStatus.key == FunctionAttributeKey.OnOff)
+                {
+                    btnOnText = btnFunctionText;
+                }
+                else if (sceneStatus.key == FunctionAttributeKey.Brightness || sceneStatus.key == FunctionAttributeKey.Percent)
+                {
+                    int outT = 0;
+                    int.TryParse(sceneStatus.value, out outT);
+                    if (outT < 0)
+                        sceneStatus.value = "0";
+                    btnBrightnessText = btnFunctionText;
+                }
+
+                var btnFunctionName = new Button()
+                {
+                    X = Application.GetRealWidth(16),
+                    TextAlignment = TextAlignment.CenterLeft,
+                    TextColor = CSS_Color.FirstLevelTitleColor,
+                    TextSize = CSS_FontSize.SubheadingFontSize,
+                    Text = sceneStatus.GetNameText()
+                };
+                row.AddChidren(btnFunctionName);
+                btnFunctionName.MouseUpEventHandler = (sender, e) =>
+                {
+                    switch (sceneStatus.key)
+                    {
+                        case FunctionAttributeKey.Security:
+                            LoadEditDialog_Security(sceneStatus, btnFunctionText);
+                            break;
+                        case FunctionAttributeKey.OnOff:
+                            LoadEditDialog_OnOff(sceneStatus, btnFunctionText);
+                            break;
+                        case FunctionAttributeKey.Brightness:
+                            LoadEditDialog_Percent(sceneStatus, btnFunctionText);
+                            break;
+                        case FunctionAttributeKey.Mode:
+                            var statusList = new List<string>();
+                            var tr = sceneFunction.localFunction.attributes.Find((obj) => obj.key == FunctionAttributeKey.Mode);
+                            foreach (var t in tr.value)
+                            {
+                                statusList.Add(t);
+                            }
+                            LoadEditDialog_FunctionPar(sceneStatus, btnFunctionText, statusList);
+                            break;
+                        case FunctionAttributeKey.FanSpeed:
+                            var fanStatusList = new List<string>();
+                            var tr1 = sceneFunction.localFunction.attributes.Find((obj) => obj.key == FunctionAttributeKey.FanSpeed);
+                            foreach (var t in tr1.value)
+                            {
+                                fanStatusList.Add(t);
+                            }
+                            LoadEditDialog_FunctionPar(sceneStatus, btnFunctionText, fanStatusList);
+                            break;
+                        case FunctionAttributeKey.SetTemp:
+                            LoadEditDialog_Temp(sceneStatus, btnFunctionText);
+                            break;
+                        case FunctionAttributeKey.FadeTime:
+
+                            break;
+                        case "angle":
+                            //鍛堢幇鐨勫脊绐�
+                            LoadEditDialog_Angle(sceneStatus, btnFunctionText);
+
+                            break;
+                        case "cct":
+                            LoadEditDialog_CCT(sceneStatus, btnFunctionText);
+                            break;
+                        case FunctionAttributeKey.RGB:
+                            btnFunctionText.Width = Application.GetRealWidth(28);
+                            btnFunctionText.Height = Application.GetRealWidth(28);
+                            btnFunctionText.X = Application.GetRealWidth(330 - 28);
+                            btnFunctionText.Gravity = Gravity.CenterVertical;
+                            btnFunctionText.Radius = (uint)Application.GetRealWidth(8);
+                            btnFunctionText.Text = "";
+
+                            LoadEditDialog_RGB_V2(sceneStatus, btnFunctionText);
+                            break;
+                        case FunctionAttributeKey.Percent:
+                            LoadEditDialog_Percent(sceneStatus, btnFunctionText);
+                            break;
+                        case FunctionAttributeKey.SetVolume:
+                            BrightnessView(btnFunctionText.Text, btnFunctionName.Text, (volume, uintStr) =>
+                            {
+                                btnFunctionText.Text = volume;
+                                sceneStatus.value = volume;
+                            });
+                            break;
+                        case FunctionAttributeKey.Signal:
+                            var p = new UI2.Intelligence.Automation.PublicInterface();
+                            var dic = p.GetHisenseSignalSourceDic();
+                            ListView(dic.Keys.ToList(), btnFunctionText.Text, btnFunctionName.Text, (valueStr) =>
+                            {
+                                btnFunctionText.Text = valueStr;
+                                sceneStatus.value = p.GetValue(dic, valueStr);
+                            });
+                            break;
+                        case FunctionAttributeKey.Volume:
+                            BrightnessView(btnFunctionText.Text, btnFunctionName.Text, (volume, uintStr) =>
+                            {
+                                btnFunctionText.Text = volume;
+                                sceneStatus.value = volume;
+                            });
+                            break;
+                        case FunctionAttributeKey.SongName:
+                            MusicListView(btnFunctionText.Text, (playListName, song) =>
+                            {
+                                btnFunctionText.Text = song.name;
+                                sceneStatus.value = song.name;
+                                //杩藉姞灞炴��
+                                var oldList = new List<SceneFunctionStatus>();
+                                for (int i = 0; i < sceneFunction.status.Count; i++)
+                                {
+                                    var status = sceneFunction.status[i];
+                                    if (status.key == FunctionAttributeKey.PlaylistName)
+                                    {
+                                        //鎺у埗闇�瑕侊紙鐣岄潰涓嶉渶瑕佹樉绀猴級
+                                        sceneFunction.status.RemoveAt(i);
+                                        sceneFunction.status.Insert(i, new SceneFunctionStatus { key = FunctionAttributeKey.PlaylistName, value = playListName });
+                                    }
+                                    else if (status.key == FunctionAttributeKey.Url)
+                                    {
+                                        //瀛樺湪url灏变竴璧峰彂杩囧幓
+                                        if (!string.IsNullOrEmpty(song.url))
+                                        {
+                                            //鎺у埗闇�瑕侊紙鐣岄潰涓嶉渶瑕佹樉绀猴級
+                                            sceneFunction.status.RemoveAt(i);
+                                            sceneFunction.status.Insert(i, new SceneFunctionStatus { key = FunctionAttributeKey.Url, value = song.url });
+                                        }
+                                    }
+
+                                }
+
+                            });
+                            break;
+
+                    }
+                };
+
+                #endregion
+            }
+            catch (Exception ex)
+            {
+                MainPage.Log($"鍦烘櫙鍔犺浇璁惧灞炴�у紓甯革細{ex.Message}");
+            }
+        }
+
+        /// <summary>
+        /// 鍔犺浇鍔熻兘Row
+        /// </summary>
+        void LoadColorfulRow(SceneFunctionStatus sceneStatus)
+        {
             if (sceneStatus == null)
                 return;
             #region Row code
@@ -208,21 +659,17 @@
             {
                 Height = Application.GetRealHeight(50),
                 BackgroundColor = CSS_Color.MainBackgroundColor,
+                Tag = sceneStatus.key
             };
             contentView.AddChidren(row);
-
-
-            if (sceneStatus.key != FunctionAttributeKey.OnOff)
+            var view = functionRowList.Find((obj) => obj.Tag.ToString() == sceneStatus.key);
+            if (view == null)
             {
-                row.AddChidren(new Button() { X = Application.GetRealWidth(16), Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor });
+                functionRowList.Add(row);
             }
-            else
-            {
-                if(sceneStatus.value == "stop")
-                {
-                    sceneStatus.value = "on";
-                }
-            }
+
+            row.AddChidren(new Button() { X = Application.GetRealWidth(16), Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor });
+
             Button btnRight = new Button()
             {
                 X = Application.GetRealWidth(339),
@@ -236,91 +683,15 @@
 
             var showCode = "";
 
-            if (sceneStatus.key == FunctionAttributeKey.Mode)
-            {
-                if (DB_ResidenceData.Instance.GatewayType == 0)
-                {
-                    if (SPK.AcSpkList().Contains(sceneFunction.localFunction.spk))
-                    {
-                        //0 鍒跺喎1鍒剁儹锛�2閫氶锛�3鑷姩锛�4闄ゆ箍
-                        switch (sceneStatus.value)
-                        {
-                            case "0":
-                                showCode = "cool";
-                                break;
-                            case "1":
-                                showCode = "heat";
-                                break;
-                            case "2":
-                                showCode = "fan";
-                                break;
-                            case "3":
-                                showCode = "auto";
-                                break;
-                            case "4":
-                                showCode = "dry";
-                                break;
-                        }
-                    }
-                    else if (SPK.FhSpkList().Contains(sceneFunction.localFunction.spk))
-                    {
-                        //1:鏅��,2:鐧藉ぉ,3:澶滄櫄,4:绂诲紑,5:鏃堕棿
-                        switch (sceneStatus.value)
-                        {
-                            case "5":
-                                showCode = "timer";
-                                break;
-                            case "1":
-                                showCode = "normal";
-                                break;
-                            case "2":
-                                showCode = "day";
-                                break;
-                            case "3":
-                                showCode = "night";
-                                break;
-                            case "4":
-                                showCode = "away";
-                                break;
-                        }
-                    }
-                }
-            }
-
             var btnFunctionText = new Button()
             {
                 Width = Application.GetRealWidth(330),
                 TextAlignment = TextAlignment.CenterRight,
                 TextColor = CSS_Color.PromptingColor1,
                 TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
-                Text = sceneStatus.GetValueText(showCode) + sceneStatus.GetUintString()
+                Text = sceneStatus.GetValueText(showCode)
             };
             row.AddChidren(btnFunctionText);
-            if (sceneStatus.key == FunctionAttributeKey.RGB)
-            {
-                btnFunctionText.Width = Application.GetRealWidth(28);
-                btnFunctionText.Height = Application.GetRealWidth(28);
-                btnFunctionText.X = Application.GetRealWidth(330 - 28);
-                btnFunctionText.Gravity = Gravity.CenterVertical;
-                btnFunctionText.Radius = (uint)Application.GetRealWidth(8);
-                btnFunctionText.Text = "";
-                btnFunctionText.BackgroundColor = (uint)(0xFF000000 + new Light().GetRGBcolor(sceneStatus.value));
-            }
-
-
-
-            if (sceneStatus.key == FunctionAttributeKey.OnOff)
-            {
-                btnOnText = btnFunctionText;
-            }
-            else if (sceneStatus.key == FunctionAttributeKey.Brightness || sceneStatus.key == FunctionAttributeKey.Percent)
-            {
-                int outT = 0;
-                int.TryParse(sceneStatus.value, out outT);
-                if (outT < 0)
-                    sceneStatus.value = "0";
-                btnBrightnessText = btnFunctionText;
-            }
 
             var btnFunctionName = new Button()
             {
@@ -328,73 +699,16 @@
                 TextAlignment = TextAlignment.CenterLeft,
                 TextColor = CSS_Color.FirstLevelTitleColor,
                 TextSize = CSS_FontSize.SubheadingFontSize,
-                Text = sceneStatus.GetNameText()
+                TextID = StringId.ColorfulFunction
             };
             row.AddChidren(btnFunctionName);
             btnFunctionName.MouseUpEventHandler = (sender, e) =>
             {
-                switch (sceneStatus.key)
-                {
-                    case FunctionAttributeKey.Security:
-                        LoadEditDialog_Security(sceneStatus, btnFunctionText);
-                        break;
-                    case FunctionAttributeKey.OnOff:
-                        LoadEditDialog_OnOff(sceneStatus, btnFunctionText);
-                        break;
-                    case FunctionAttributeKey.Brightness:
-                        LoadEditDialog_Percent(sceneStatus, btnFunctionText);
-                        break;
-                    case FunctionAttributeKey.Mode:
-                        var statusList = new List<string>();
-                        var tr = sceneFunction.localFunction.attributes.Find((obj) => obj.key == FunctionAttributeKey.Mode);
-                        foreach(var t in tr.value)
-                        {
-                            statusList.Add(t);
-                        }
-                        LoadEditDialog_FunctionPar(sceneStatus, btnFunctionText,statusList);
-                        break;
-                    case FunctionAttributeKey.FanSpeed:
-                        var fanStatusList = new List<string>();
-                        var tr1 = sceneFunction.localFunction.attributes.Find((obj) => obj.key == FunctionAttributeKey.FanSpeed);
-                        foreach (var t in tr1.value)
-                        {
-                            fanStatusList.Add(t);
-                        }
-                        LoadEditDialog_FunctionPar(sceneStatus, btnFunctionText, fanStatusList);
-                        break;
-                    case FunctionAttributeKey.SetTemp:
-                        LoadEditDialog_Temp(sceneStatus, btnFunctionText);
-                        break;
-                    case FunctionAttributeKey.FadeTime:
-
-                        break;
-                    case "angle":
-                        //鍛堢幇鐨勫脊绐�
-                        LoadEditDialog_Angle(sceneStatus, btnFunctionText);
-
-                        break;
-                    case "cct":
-                        LoadEditDialog_CCT(sceneStatus, btnFunctionText);
-                        break;
-                    case FunctionAttributeKey.RGB:
-                        btnFunctionText.Width = Application.GetRealWidth(28);
-                        btnFunctionText.Height = Application.GetRealWidth(28);
-                        btnFunctionText.X = Application.GetRealWidth(330 - 28);
-                        btnFunctionText.Gravity = Gravity.CenterVertical;
-                        btnFunctionText.Radius = (uint)Application.GetRealWidth(8);
-                        btnFunctionText.Text = "";
-
-                        LoadEditDialog_RGB(sceneStatus, btnFunctionText);
-                        break;
-                    case FunctionAttributeKey.Percent:
-                        LoadEditDialog_Percent(sceneStatus, btnFunctionText);
-                        break;
-                }
+                LoadEditDialog_OnOff(sceneStatus, btnFunctionText);
             };
 
             #endregion
         }
-
 
         #region 鍔犺浇鍔熻兘鍦烘櫙鏁版嵁璋冭妭鐣岄潰
         /// <summary>
@@ -406,9 +720,15 @@
             FrameLayout delayRow = new FrameLayout()
             {
                 Height = Application.GetRealWidth(50),
-                BackgroundColor = CSS_Color.MainBackgroundColor
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+                Tag = "delay"
             };
             contentView.AddChidren(delayRow);
+            var view = functionRowList.Find((obj) => obj.Tag.ToString() == "delay");
+            if (view == null)
+            {
+                functionRowList.Add(delayRow);
+            }
             delayRow.AddChidren(new Button() { X = Application.GetRealWidth(16), Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor });
 
             Button btnDelayRight = new Button()
@@ -442,8 +762,10 @@
             delayRow.AddChidren(btnSceneDelayTitle);
 
 
-            btnSceneDelayTitle.MouseUpEventHandler = (sender, e) => {
-                Action<string> action = (obj) => {
+            btnSceneDelayTitle.MouseUpEventHandler = (sender, e) =>
+            {
+                Action<string> action = (obj) =>
+                {
                     sceneFunction.delay = obj;
                     btnDelayInfo.Text = new Scene() { delay = sceneFunction.delay }.GetDelayText();
                 };
@@ -539,51 +861,128 @@
 
             dialog.Show();
 
-            pView.MouseUpEventHandler = (sender, e) => {
+            pView.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
             };
 
-            btnCancel.MouseUpEventHandler = (sender, e) => {
+            btnCancel.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
             };
-            btnOn.MouseUpEventHandler = (sender, e) => {
+            btnOn.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
                 trait.value = "on";
-                sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = "on";
-                btn.Text = trait.GetValueText() + trait.GetUintString();
-
-                var temp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness);
-                if (temp == null)
+                isOnStatus = true;
+                try
                 {
-                    temp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Percent);
+                    sceneFunction.status.Find((obj) => obj.key == trait.key).value = "on";
                 }
-                if (temp != null)
+                catch (Exception ex)
                 {
-                    if (temp.value == "0")
+                    MainPage.Log($"鍦烘櫙閰嶇疆寮傚父锛歿ex.Message}");
+                }
+
+                try
+                {
+                    btn.Text = trait.GetValueText() + trait.GetUintString();
+                    if (trait.key == FunctionAttributeKey.OnOff)
                     {
-                        temp.value = "100";
+                        var temp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness);
+                        if (temp == null)
+                        {
+                            temp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Percent);
+                        }
+                        if (temp != null)
+                        {
+                            if (temp.value == "0")
+                            {
+                                temp.value = "100";
+                            }
+                            if (btnBrightnessText != null)
+                            {
+                                btnBrightnessText.Text = temp.GetValueText() + "%";
+                            }
+                        }
                     }
-                    btnBrightnessText.Text = temp.GetValueText() + "%";
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log($"鍦烘櫙閰嶇疆寮傚父2锛歿ex.Message}");
+                }
+                try
+                {
+                    if (trait.key == FunctionAttributeKey.Colorful)
+                    {
+                        isColorful = true;
+                    }
+                    else if (trait.key == FunctionAttributeKey.OnOff)
+                    {
+                        isOnStatus = true;
+                    }
+                    UpdataFunctionRow();
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log($"鍦烘櫙閰嶇疆寮傚父3锛歿ex.Message}");
                 }
             };
-            btnOff.MouseUpEventHandler = (sender,e) =>{
+            btnOff.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
                 trait.value = "off";
-                sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = "off";
-                btn.Text= trait.GetValueText() + trait.GetUintString();
-
-                var temp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness);
-                if(temp == null)
+                try
                 {
-                    temp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Percent);
+                    sceneFunction.status.Find((obj) => obj.key == trait.key).value = "off";
                 }
-                if (temp != null)
+                catch (Exception ex)
                 {
-                    if (temp.value != "0")
+                    MainPage.Log($"鍦烘櫙閰嶇疆寮傚父锛歿ex.Message}");
+                }
+
+                try
+                {
+                    btn.Text = trait.GetValueText() + trait.GetUintString();
+                    if (trait.key == FunctionAttributeKey.OnOff)
                     {
-                        temp.value = "0";
+                        isOnStatus = false;
+                        var temp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness);
+                        if (temp == null)
+                        {
+                            temp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Percent);
+                        }
+                        if (temp != null)
+                        {
+                            if (temp.value != "0")
+                            {
+                                temp.value = "0";
+                            }
+                            if (btnBrightnessText != null)
+                                btnBrightnessText.Text = temp.GetValueText() + "%";
+                        }
                     }
-                    btnBrightnessText.Text = temp.GetValueText() + "%";
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log($"鍦烘櫙閰嶇疆寮傚父2锛歿ex.Message}");
+                }
+
+                try
+                {
+                    if (trait.key == FunctionAttributeKey.Colorful)
+                    {
+                        isColorful = false;
+                    }
+                    else if (trait.key == FunctionAttributeKey.OnOff)
+                    {
+                        isOnStatus = false;
+                    }
+                    UpdataFunctionRow();
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log($"鍦烘櫙閰嶇疆寮傚父3锛歿ex.Message}");
                 }
             };
 
@@ -667,21 +1066,25 @@
 
             dialog.Show();
 
-            pView.MouseUpEventHandler = (sender, e) => {
+            pView.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
             };
 
-            btnCancel.MouseUpEventHandler = (sender, e) => {
+            btnCancel.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
             };
-            btnOn.MouseUpEventHandler = (sender, e) => {
+            btnOn.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
                 trait.value = "true";
                 sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Security).value = "true";
                 btn.Text = trait.GetValueText() + trait.GetUintString();
 
             };
-            btnOff.MouseUpEventHandler = (sender, e) => {
+            btnOff.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
                 trait.value = "false";
                 sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Security).value = "false";
@@ -704,7 +1107,7 @@
             trait.value = temp.ToString();
 
             List<string> pickerItems = new List<string>();
-            if(trait == null)
+            if (trait == null)
             {
                 return;
             }
@@ -719,7 +1122,7 @@
 
             var optionBaseView = new FrameLayout()
             {
-                Y = Application.GetRealHeight(456-60),
+                Y = Application.GetRealHeight(456 - 60),
                 Gravity = Gravity.CenterHorizontal,
                 Width = Application.GetRealWidth(343),
                 Height = Application.GetRealHeight(260),
@@ -739,7 +1142,7 @@
                 Radius = (uint)Application.GetRealWidth(12),
             };
             optionBaseView.AddChidren(topView);
-            topView.AddChidren(new Button() {Y = Application.GetRealHeight(39), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor });
+            topView.AddChidren(new Button() { Y = Application.GetRealHeight(39), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor });
 
             var btnCancel = new Button()
             {
@@ -781,25 +1184,30 @@
             if (pickerItems.Contains(trait.value + trait.GetUintString()))
             {
                 selectItem = trait.value.ToString() + trait.GetUintString();
+                uIPickerView.setCurrentItems(pickerItems.IndexOf(selectItem), 0, 0);
             }
 
             dialog.Show();
 
-            pView.MouseUpEventHandler = (sender, e) => {
+            pView.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
             };
 
-            btnCancel.MouseUpEventHandler = (sender, e) => {
+            btnCancel.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
             };
-            uIPickerView.OnSelectChangeEvent = (int1, int2, int3) => {
+            uIPickerView.OnSelectChangeEvent = (int1, int2, int3) =>
+            {
                 selectItem = pickerItems[int1];
             };
-            btnConfrim.MouseUpEventHandler = (sender, e) => {
+            btnConfrim.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
                 btn.Text = selectItem;
                 //sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.value.ToString() ;
-                trait.value = selectItem.Replace(trait.GetUintString(),"");
+                trait.value = selectItem.Replace(trait.GetUintString(), "");
             };
 
         }
@@ -809,7 +1217,7 @@
         /// </summary>
         /// <param name="function"></param>
         /// <param name="btn"></param>
-        void LoadEditDialog_Angle (SceneFunctionStatus trait, Button btn)
+        void LoadEditDialog_Angle(SceneFunctionStatus trait, Button btn)
         {
             double temp = trait.min;
             double.TryParse(trait.value, out temp);
@@ -888,7 +1296,7 @@
             }
             uIPickerView.setNPicker(pickerItems, null, null);
             optionBaseView.AddChidren(uIPickerView);
-            uIPickerView.setCurrentItems(pickerItems.IndexOf(trait.value.ToString()+ "掳"), 0, 0);
+            uIPickerView.setCurrentItems(pickerItems.IndexOf(trait.value.ToString() + "掳"), 0, 0);
 
             string selectItem = pickerItems[pickerItems.IndexOf(trait.value.ToString() + "掳")];
             if (pickerItems.Contains(trait.value + trait.GetUintString()))
@@ -898,17 +1306,21 @@
             //uIPickerView.setCurrentItems
             dialog.Show();
 
-            pView.MouseUpEventHandler = (sender, e) => {
+            pView.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
             };
 
-            btnCancel.MouseUpEventHandler = (sender, e) => {
+            btnCancel.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
             };
-            uIPickerView.OnSelectChangeEvent = (int1, int2, int3) => {
+            uIPickerView.OnSelectChangeEvent = (int1, int2, int3) =>
+            {
                 selectItem = pickerItems[int1];
             };
-            btnConfrim.MouseUpEventHandler = (sender, e) => {
+            btnConfrim.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
                 btn.Text = selectItem;
                 //sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.value.ToString() ;
@@ -1082,7 +1494,33 @@
         /// <param name="btn"></param>
         void LoadEditDialog_CCT(SceneFunctionStatus trait, Button btn)
         {
+            if (trait.min == 0)
+            {
+                switch (trait.key)
+                {
+                    case FunctionAttributeKey.SetTemp:
+                        trait.min = 16;
+                        break;
+                    case FunctionAttributeKey.CCT:
+                        trait.min = 2700;
+                        break;
+                }
+            }
+            if (trait.max == 0)
+            {
+                switch (trait.key)
+                {
+                    case FunctionAttributeKey.SetTemp:
+                        trait.max = 30;
+                        break;
+                    case FunctionAttributeKey.CCT:
+                        trait.max = 6500;
+                        break;
+                }
+            }
+
             double temp = trait.min;
+
             double.TryParse(trait.value, out temp);
             trait.value = temp.ToString();
 
@@ -1167,17 +1605,21 @@
 
             dialog.Show();
 
-            pView.MouseUpEventHandler = (sender, e) => {
+            pView.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
             };
 
-            btnCancel.MouseUpEventHandler = (sender, e) => {
+            btnCancel.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
             };
-            uIPickerView.OnSelectChangeEvent = (int1, int2, int3) => {
+            uIPickerView.OnSelectChangeEvent = (int1, int2, int3) =>
+            {
                 selectItem = pickerItems[int1];
             };
-            btnConfrim.MouseUpEventHandler = (sender, e) => {
+            btnConfrim.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
                 btn.Text = selectItem;
                 //sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.value.ToString() ;
@@ -1240,7 +1682,7 @@
 
             #endregion
 
-            int attrViewHight = Application.GetRealHeight(18 + 22+ 248);
+            int attrViewHight = Application.GetRealHeight(18 + 22 + 248);
             //灞炴�ц缃尯鍩�
             var attrView = new FrameLayout()
             {
@@ -1251,7 +1693,7 @@
             contentView.AddChidren(attrView);
             attrView.AddChidren(new Button() { Height = Application.GetRealHeight(18) });
 
-            
+
 
             #region RGB
             var rgbView = new FrameLayout()
@@ -1308,7 +1750,8 @@
             int circleR = colorPicker.Width / 2 - Application.GetRealWidth(12);
 
 
-            colorPicker.ColorChaged += (sender2, e2) => {
+            colorPicker.ColorChaged += (sender2, e2) =>
+            {
                 rgbString = (e2[0] + "," + e2[1] + "," + e2[2]).ToString();
                 //trait.value = rgbString;
                 btnCurColor.BackgroundColor = (uint)(0xFF000000 + tempLight.GetRGBcolor(rgbString));
@@ -1361,7 +1804,8 @@
                 TextID = StringId.Cancel,
             };
             bottomView.AddChidren(btnCancel);
-            btnCancel.MouseUpEventHandler = (sender, e) => {
+            btnCancel.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
             };
 
@@ -1381,7 +1825,204 @@
             //渚嬶細鍙充笅鍦嗚 澶у皬涓�50
             int mRectCornerID = HDLUtils.RectCornerBottomRight;
             btnComplete.SetCornerWithSameRadius((uint)Application.GetRealWidth(14), mRectCornerID);
-            btnComplete.MouseUpEventHandler = (sender, e) => {
+            btnComplete.MouseUpEventHandler = (sender, e) =>
+            {
+                dialog.Close();
+                trait.value = rgbString;
+                btn.BackgroundColor = (uint)(0xFF000000 + tempLight.GetRGBcolor(rgbString));
+            };
+
+            #endregion
+
+
+            dialog.Show();
+
+        }
+
+
+        /// <summary>
+        /// 鍔犺浇rgb閫夋嫨寮圭獥
+        /// </summary>
+        /// <param name="function"></param>
+        /// <param name="btn"></param>
+        void LoadEditDialog_RGB_V2(SceneFunctionStatus trait, Button btn)
+        {
+            string rgbString = trait.value;
+
+            Light tempLight = new Light();
+
+            if (trait == null)
+            {
+                return;
+            }
+
+            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(trait.value))
+            };
+            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();
                 trait.value = rgbString;
                 btn.BackgroundColor = (uint)(0xFF000000 + tempLight.GetRGBcolor(rgbString));
@@ -1576,14 +2217,14 @@
         /// <summary>
         /// 鍔犺浇鍔熻兘灞炴�ф暟鎹�夋嫨寮圭獥
         /// </summary>
-        void LoadEditDialog_FunctionPar(SceneFunctionStatus trait, Button btn,List<string> statusList)
+        void LoadEditDialog_FunctionPar(SceneFunctionStatus trait, Button btn, List<string> statusList)
         {
             Button lastButton = new Button();
-            var lastData = "";
-            var lastText = "";
+            var lastData = trait.value;
+            var lastText = btn.Text;
             Dialog dialog = new Dialog();
 
-            if(DB_ResidenceData.Instance.GatewayType == 0)
+            if (DB_ResidenceData.Instance.GatewayType == 0)
             {
                 if (SPK.AcSpkList().Contains(sceneFunction.localFunction.spk))
                 {
@@ -1752,7 +2393,8 @@
                 };
                 row.AddChidren(btnPropertyTitle);
 
-                btnPropertyTitle.MouseUpEventHandler = (sender, e) => {
+                btnPropertyTitle.MouseUpEventHandler = (sender, e) =>
+                {
                     btnChoose.IsSelected = true;
                     if (lastButton != null)
                     {
@@ -1769,14 +2411,17 @@
 
             dialog.Show();
 
-            pView.MouseUpEventHandler = (sender, e) => {
+            pView.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
             };
 
-            btnCancel.MouseUpEventHandler = (sender, e) => {
+            btnCancel.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
             };
-            btnConfrim.MouseUpEventHandler = (sender, e) => {
+            btnConfrim.MouseUpEventHandler = (sender, e) =>
+            {
                 dialog.Close();
                 trait.value = lastData;
                 //sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.curValue.ToString() ;
@@ -1785,7 +2430,90 @@
 
         }
 
-        #endregion
 
+        /// <summary>
+        /// 鐧惧垎姣�
+        /// </summary>
+        /// <param name="oldStateValue">鏃х姸鎬佸��</param>
+        /// <param name="titleName">鏍囬</param>
+        ///  <param name="action">鍥炶皟</param>
+        void BrightnessView(string oldStateValue, string titleName, Action<string, string> action)
+        {
+            #region 鐣岄潰
+            var brightness = new UI2.Intelligence.Automation.LogicView.BrightnessView();
+            brightness.FLayoutView(this, titleName, oldStateValue, action);
+            #endregion
+
+        }
+        /// <summary>
+        /// 鍒楄〃鐣岄潰
+        /// </summary>
+        /// <param name="list">鐣岄潰鏄剧ず鏁版嵁婧�</param>
+        /// <param name="oldStateValue">鏃х姸鎬佸��</param>
+        /// <param name="titleName">鏍囬</param>
+        ///  <param name="action">鍥炶皟</param>
+        void ListView(List<string> list, string oldStateValue, string titleName, Action<string> action)
+        {
+            var pif = new UI2.Intelligence.Automation.PublicInterface();
+            pif.SingleSelectionShow(this, list, titleName, oldStateValue, action);
+        }
+
+        /// <summary>
+        /// 闊充箰鍒楄〃鐣岄潰
+        /// </summary>
+        /// <param name="oldStateValue">鏃х姸鎬佸��</param>
+        ///  <param name="action">鍥炶皟</param>
+        void MusicListView(string oldStateValue, Action<string, Music.SongInfo> action)
+        {
+            Loading loading = new Loading();
+            this.AddChidren(loading);
+            loading.Start();
+            System.Threading.Tasks.Task.Run(() =>
+            {
+                try
+                {
+                    var palyList = Music.SendMethod.Current.GetSingleSongList(new Function { sid = sceneFunction.sid }, "hdl_special", "");
+                    List<string> songNameList = new List<string>();
+                    for (int i = 0; i < palyList.songs.Count; i++)
+                    {
+                        var song = palyList.songs[i];
+                        songNameList.Add(song.name);
+                    }
+                    Application.RunOnMainThread(() =>
+                    {
+                        loading.Hide();
+                        var publicInterface = new UI2.Intelligence.Automation.PublicInterface();
+                        publicInterface.FrameOrVv(this, songNameList, new List<string> { oldStateValue }, palyList.group, (index) =>
+                        {
+                            if (index > palyList.songs.Count)
+                            {
+                                index = 0;
+                            }
+                            var song = palyList.songs[index];
+                            action?.Invoke(palyList.group, song);
+
+                            //鐣岄潰鏄剧ず閫変腑鍊�
+                            //funTypeView.btnState.Text = songSelecetd.name;
+                            ////鏁版嵁灏佽
+                            //AddDictionary("playlist_name", palyList.group);//鍒楄〃鍚�
+                            //AddDictionary("song_name", songSelecetd.name);//姝屾洸鍚�
+                            //if (!string.IsNullOrEmpty(songSelecetd.url))
+                            //{
+                            //    //瀛樺湪url灏变竴璧峰彂閫佽繃鍘�
+                            //    AddDictionary("url", songSelecetd.url);
+                            //}
+
+                        }, false);
+
+                    });
+                }
+                catch { }
+
+            });
+        }
+        #endregion
     }
 }
+
+ 
+ 
\ No newline at end of file

--
Gitblit v1.8.0