From f9181a9c8125136f597add7c30cb2ff508d54ba7 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 25 七月 2024 17:34:32 +0800
Subject: [PATCH] 2024年07月25日17:33:40

---
 HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs | 1396 ++++++++++++---------------------------------------------
 1 files changed, 305 insertions(+), 1,091 deletions(-)

diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs
index c507931..3ae8804 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs
@@ -2,6 +2,7 @@
 using System;
 using System.Collections.Generic;
 using System.Threading;
+using HDL_ON.Common;
 using HDL_ON.DAL.Server;
 using HDL_ON.DriverLayer;
 using HDL_ON.Entity;
@@ -50,17 +51,22 @@
         /// <summary>
         /// 鍥炶皟鍒锋柊
         /// </summary>
-        Action backActon;
+        Action<GroupControl> addActon;
+        Action delAction;
         /// <summary>
         /// 鏄惁鏂板缇ゆ帶
         /// </summary>
         bool isAdd = true;
+        /// <summary>
+        /// 缂栬緫鐨勭粍鎺ф暟鎹�
+        /// </summary>
+        string editDataString = "";
 
         GroupControl groupControl;
 
         GroupControlType groupControlType = new GroupControlType();
 
-        public AddGroupControlPage(GroupControl groupControl, Action action)
+        public AddGroupControlPage(GroupControl groupControl, Action<GroupControl> addAction,Action delAction)
         {
             bodyView = this;
             if(groupControl == null)
@@ -71,21 +77,93 @@
             {
                 isAdd = false;
                 this.groupControl = groupControl;
+                editDataString = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl);
             }
             groupControlLightList = new List<Function>();
-            backActon = action;
+            this.addActon = addAction;
+
+            this.delAction = delAction;
+
             lightList = FunctionList.List.GetLightList();
         }
 
         public void LoadPage()
         {
             bodyView.BackgroundColor = CSS_Color.BackgroundColor;
-            new TopViewDiv(bodyView, Language.StringByID(StringId.CombinedDimming)).LoadTopView();
+            if (isAdd)
+            {
+                var topView = new TopViewDiv(bodyView, Language.StringByID(StringId.GroupControl));
+                topView.maginY = 10;
+                topView.LoadTopView();
+            }
+            else
+            {
+                var topView = new TopViewDiv(bodyView, "");
+                topView.maginY = 10;
+                topView.LoadTopView_SettingText(()=> {
 
+                    Action action = () => {
+                        var waitPage = new Loading();
+                        this.AddChidren(waitPage);
+                        waitPage.Start("");
+                        new System.Threading.Thread(() =>
+                        {
+                            try
+                            {
+                                var pack = ApiUtlis.Ins.HttpRequest.DelGroupControl(groupControl.userDeviceGroupControlId);
+                                if (pack != null)
+                                {
+                                    Application.RunOnMainThread(() =>
+                                    {
+                                        try
+                                        {
+                                            if (pack.Code == StateCode.SUCCESS)
+                                            {
+                                                var delTemp = FunctionList.List.groupControls.Find((obj) => groupControl.sid == obj.sid);
+                                                FunctionList.List.groupControls.Remove(delTemp);
+                                                //list.Remove(groupControl);
+                                                this.RemoveFromParent();
+                                                delAction?.Invoke();
+                                            }
+                                            else
+                                            {
+                                                IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+                                            }
+                                        }
+                                        catch (Exception ex)
+                                        {
+                                            MainPage.Log($"鍒锋柊缁勬帶鏁版嵁寮傚父:{ex.Message}");
+                                        }
+                                    });
+                                }
+                            }
+                            catch (Exception ex)
+                            {
+                                MainPage.Log($"鍒犻櫎缁勬帶寮傚父:{ex.Message}");
+                            }
+                            finally
+                            {
+                                Application.RunOnMainThread(() => {
+                                    if (waitPage != null)
+                                    {
+                                        waitPage.Hide();
+                                        waitPage.RemoveFromParent();
+                                        waitPage = null;
+                                    }
+                                });
+                            }
+                        })
+                        { IsBackground = true }.Start();
+
+                    };
+                    new PublicAssmebly().TipOptionMsg(StringId.Tip, StringId.DoYouWantDelCombinedDimming, action);
+
+                }, Language.StringByID(StringId.DelGroupControl),true);
+            }
             var contentView = new FrameLayout()
             {
-                Y = Application.GetRealHeight(64),
-                Height = Application.GetRealHeight(550),
+                Y = Application.GetRealHeight(64+10),
+                Height = Application.GetRealHeight(667-64-10),
             };
             bodyView.AddChidren(contentView);
 
@@ -100,7 +178,7 @@
             Button btnGroupNameTitle = new Button()
             {
                 X = Application.GetRealWidth(16),
-                Width = Application.GetRealWidth(78),
+                Width = Application.GetRealWidth(178),
                 TextID = StringId.GroupNmae,
                 TextAlignment = TextAlignment.CenterLeft,
                 TextSize = CSS_FontSize.SubheadingFontSize,
@@ -172,10 +250,12 @@
             locationMagtView.AddChidren(btnLocationInfoRight);
             EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
             {
+                Application.HideSoftInput();
                 //淇敼鍔熻兘鎵�灞炴埧闂翠箣鍚庣殑鍥炶皟浜嬩欢
                 Action chooseRoomBackAction = () => {
                     try
                     {
+                        groupControl.uids = groupControl.roomIds;
                         btnLocationValues.Text = groupControl.GetRoomListName();
                     }
                     catch { }
@@ -247,13 +327,13 @@
                 TextColor = CSS_Color.FirstLevelTitleColor,
                 TextID = StringId.SelectedAll,
             };
-            if (groupControlLightList.Count > 0)
+            if (groupControlLightList.Count == lightList.Count)
             {
                 btnChooseAll.TextID = StringId.Cancel;
             }
             roomFloorChangeView.AddChidren(btnChooseAll);
             btnChooseAll.MouseUpEventHandler = (sender, e) => {
-                if (groupControlLightList.Count > 0)
+                if (groupControlLightList.Count == lightList.Count)
                 {
                     groupControlLightList.Clear();
                     btnChooseAll.TextID = StringId.SelectAll;
@@ -261,11 +341,33 @@
                 }
                 else
                 {
+                    groupControlLightList.Clear();
                     groupControlLightList.AddRange(lightList);
                     btnChooseAll.TextID = StringId.Cancel;
                     btnConfrim.IsSelected = true;
                 }
-                LoadLightRow(lightList);
+
+                for (int i = 0; i < functionListView.ChildrenCount; i++)
+                {
+                    var view = functionListView.GetChildren(i);
+                    if (view.GetType() == typeof(LightRow))
+                    {
+                        if (view.Tag != null && view.Tag.ToString() == "row")
+                        {
+                            for (int j = 0; j < (view as FrameLayout).ChildrenCount; j++)
+                            {
+                                var btn = (view as FrameLayout).GetChildren(j);
+                                if (btn.GetType() == typeof(Button))
+                                {
+                                    if (btn.Tag != null && btn.Tag.ToString() == "ChooseIcon")
+                                    {
+                                        (btn as Button).IsSelected = groupControlLightList.Count == lightList.Count;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
             };
 
             #endregion
@@ -273,12 +375,11 @@
             functionListView = new VerticalScrolViewLayout()
             {
                 Y = Application.GetRealHeight(220),
-                Height = Application.GetRealHeight(640 - 12 - 52 - 100 -100),
+                Height = Application.GetRealHeight(640 - 12 - 52 - 100 -100-10),
             };
             bodyView.AddChidren(functionListView);
 
 
-            LoadLightRow(lightList);
             functionListView.AddChidren(new Button()
             {
                 Height = Application.GetRealHeight(10),
@@ -308,6 +409,7 @@
                 TextSize = CSS_FontSize.SubheadingFontSize,
                 SelectedTextColor = CSS_Color.MainBackgroundColor,
                 SelectedBackgroundColor = CSS_Color.MainColor,
+                IsSelected = !isAdd
             };
             bottomView.AddChidren(btnConfrim);
             btnConfrim.MouseUpEventHandler = (sender, e) => {
@@ -321,58 +423,174 @@
                         return;
                     }
                     groupControl.name = name;
-                    groupControl.sids.Clear();
-                    foreach (var light in groupControlLightList)
+                    if (groupControlLightList.Count < 2)
                     {
-                        try
-                        {
-                            var gc = new GroupControlFunction();
-                            gc.sid = light.sid;
-                            gc.spk = light.spk;
-                            groupControl.sids.Add(gc);
-                        }
-                        catch (Exception ex)
-                        {
-                            MainPage.Log($"鏂板缇ゆ帶杞崲鏁版嵁寮傚父:{ex.Message}");
-                        }
+                        new PublicAssmebly().TipMsg(StringId.Tip, StringId.PlsSelectMoreData);
+                        return;
                     }
-                    try
+                    if (isAdd)
                     {
-                        var http = new HttpServerRequest();
-                        groupControl.type = groupControlType.type;
-                        groupControl.sid = groupControl.NewGroupControlSid();
-                        var pack = http.AddGroupControl(new List<GroupControl>() { groupControl });
-                        if (pack != null)
+                        groupControl.sids.Clear();
+                        foreach (var light in groupControlLightList)
                         {
-                            if(pack.Code == StateCode.SUCCESS)
+                            try
                             {
-                                backActon?.Invoke();
-                                this.RemoveFromParent();
+                                var gc = new GroupControlFunction();
+                                gc.sid = light.sid;
+                                gc.spk = light.spk;
+                                groupControl.sids.Add(gc);
                             }
-                            else
+                            catch (Exception ex)
                             {
-                                IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+                                MainPage.Log($"鏂板缇ゆ帶杞崲鏁版嵁寮傚父:{ex.Message}");
                             }
                         }
+                        var waitPage = new Loading();
+                        bodyView.AddChidren(waitPage);
+                        waitPage.Start("");
+                        new Thread(() =>
+                        {
+                            try
+                            {
+                                groupControl.type = groupControlType.type;
+                                groupControl.sid = groupControl.NewGroupControlSid();
+                                var pack = ApiUtlis.Ins.HttpRequest.AddGroupControl(new List<GroupControl>() { groupControl });
+                                if (pack != null)
+                                {
+                                    if (pack.Code == StateCode.SUCCESS)
+                                    {
+                                        try
+                                        {
+                                            var addTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString());
+                                            if (addTemp != null && addTemp.Count > 0)
+                                                groupControl.userDeviceGroupControlId = addTemp[0].userDeviceGroupControlId;
+                                            FunctionList.List.groupControls.Add(groupControl);
+                                        }
+                                        catch (Exception ex)
+                                        {
+                                            MainPage.Log($"娣诲姞缇ゆ帶寮傚父锛岃浆璇戣繑鍥炴暟鎹け璐�:{ex.Message}");
+                                        }
+                                        Application.RunOnMainThread(() =>
+                                        {
+                                            addActon?.Invoke(groupControl);
+                                            this.RemoveFromParent();
+                                        });
+                                    }
+                                    else
+                                    {
+                                        IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+                                    }
+                                }
+
+                            }
+                            catch (Exception ex)
+                            {
+                                MainPage.Log($"鏂板缇ゆ帶寮傚父:{ex.Message}");
+                            }
+                            finally
+                            {
+                                Application.RunOnMainThread(() => {
+                                    try
+                                    {
+                                        waitPage.Hide();
+                                        waitPage = null;
+                                    }
+                                    catch { }
+                                });
+                            }
+                        })
+                        { IsBackground = true }.Start();
                     }
-                    catch (Exception ex)
+                    else
                     {
-                        MainPage.Log($"鏂板缇ゆ帶寮傚父:{ex.Message}");
+                        var waitPage = new Loading();
+                        bodyView.AddChidren(waitPage);
+                        waitPage.Start("");
+                        new Thread(() =>
+                        {
+                            try
+                            {
+                                //var newEditDataString = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl);
+                                //var newEditDataString1 = Newtonsoft.Json.JsonConvert.SerializeObject(groupControlLightList);
+                                //var newEditDataString2 = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl.sids);
+                                ////娌℃湁鏇存柊鏁版嵁鍒欑洿鎺ラ��鍑�
+                                //if (newEditDataString == editDataString && newEditDataString1 == newEditDataString2)
+                                //{
+                                //    this.RemoveFromParent();
+                                //    return;
+                                //}
+                                groupControl.sids.Clear();
+                                foreach (var light in groupControlLightList)
+                                {
+                                    try
+                                    {
+                                        var gc = new GroupControlFunction();
+                                        gc.sid = light.sid;
+                                        gc.spk = light.spk;
+                                        groupControl.sids.Add(gc);
+                                    }
+                                    catch (Exception ex)
+                                    {
+                                        MainPage.Log($"鏂板缇ゆ帶杞崲鏁版嵁寮傚父:{ex.Message}");
+                                    }
+                                }
+
+                                var pack = ApiUtlis.Ins.HttpRequest.EditGroupControl(new List<GroupControl>() { groupControl });
+                                if (pack != null)
+                                {
+                                    if (pack.Code == StateCode.SUCCESS)
+                                    {
+                                        var temp = FunctionList.List.groupControls.Find((obj) => obj.userDeviceGroupControlId == groupControl.userDeviceGroupControlId);
+                                        if (temp != null)
+                                        {
+                                            temp = groupControl;
+                                        }
+                                        Application.RunOnMainThread(() =>
+                                        {
+                                            addActon?.Invoke(temp);
+                                            this.RemoveFromParent();
+                                        });
+                                    }
+                                    else
+                                    {
+                                        IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+                                    }
+                                }
+                            }
+                            catch (Exception ex)
+                            {
+                                MainPage.Log($"缂栬緫缇ゆ帶寮傚父:{ex.Message}");
+                            }
+                            finally
+                            {
+                                Application.RunOnMainThread(() =>
+                                {
+                                    try
+                                    {
+                                        waitPage.Hide();
+                                        waitPage = null;
+                                    }
+                                    catch { }
+                                });
+
+                            }
+                        })
+                        { IsBackground = true }.Start();
+
                     }
                 }
             };
 
             #endregion
 
-            //鍔犺浇鍔熻兘绛涢�夌粍浠�
+
             LoadDialog_ChangeFloor();
 
 
             new Thread(() => {
-                var http = new HttpServerRequest();
                 if (isAdd)
                 {
-                    var pack = http.GetGroupControlTypes("light.switch");
+                    var pack = Common.ApiUtlis.Ins.HttpRequest.GetGroupControlTypes("light.switch");
                     if (pack != null)
                     {
                         if (pack.Code == StateCode.SUCCESS)
@@ -383,7 +601,16 @@
                                 var groupControlTypes = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControlType>>(pack.Data.ToString());
                                 if (groupControlTypes != null && groupControlTypes.Count > 0)
                                 {
+                                    //groupControlType = new GroupControlType {
+                                    //      type = "LIGHT",
+                                    //        typeName ="鐏厜鎺у埗",
+                                    //        spks = new List<string> { "light.switch" },
+                                    //         spkAttrs = new List<string> { "on_off" }
+                                    //};
                                     groupControlType = groupControlTypes[0];
+                                    Application.RunOnMainThread(() => {
+                                        LoadLightRow(lightList);
+                                    });
                                 }
                             }
                             catch (Exception ex)
@@ -399,7 +626,7 @@
                 }
                 else
                 {
-                    var pack = http.GetGroupControInfo(groupControl.userDeviceGroupControlId);
+                    var pack = Common.ApiUtlis.Ins.HttpRequest.GetGroupControInfo(groupControl.userDeviceGroupControlId);
                     if (pack != null)
                     {
                         if (pack.Code == StateCode.SUCCESS)
@@ -411,6 +638,14 @@
                                 if (groupControlTemps != null && groupControlTemps.Count > 0)
                                 {
                                     groupControl = groupControlTemps[0];
+                                    Application.RunOnMainThread(() =>
+                                    {
+                                        if (groupControl.sids.Count == lightList.Count)
+                                        {
+                                            btnChooseAll.TextID = StringId.Cancel;
+                                        }
+                                        LoadLightRow(lightList);
+                                    });
                                 }
                             }
                             catch (Exception ex)
@@ -436,7 +671,7 @@
         /// <summary>
         /// 鏄剧ず鐨勮澶囩殑鎬绘暟
         /// </summary>
-        int showCount = 0;
+        int showCount = -1;
 
         /// <summary>
         /// 鍔犺浇鍔熻兘row
@@ -456,18 +691,19 @@
                     {
                         if (!isAppend)
                         {
-                            showCount = 0;
+                            showCount = -1;
                             functionListView.RemoveAll();
                         }
-                        int i = 0;
-                        foreach (var function in functions)
+                        for(var i =0;i<100;i++)
+                        //foreach (var function in functions)
                         {
-                            i++;
-                            if (i > 100)
+                            showCount++;
+                            if (showCount >= functions.Count)
                             {
                                 break;
                             }
-                            showCount++;
+                            var function = functions[showCount];
+
                             var functionDiv = new LightRow(function)
                             {
                                 Gravity = Gravity.CenterHorizontal,
@@ -475,7 +711,7 @@
                                 BorderColor = 0x00FFFFFF,
                                 BorderWidth = 1,
                                 BackgroundColor = CSS_Color.MainBackgroundColor,
-                                Tag = function.spk + function.sid
+                                Tag = "row"
                             };
                             functionDiv.AddChidren(new Button()
                             {
@@ -488,13 +724,22 @@
 
                             Action setAction = () =>
                             {
-                                if (groupControlLightList.Count > 0)
+                                if (groupControlLightList.Count > 1)
                                 {
                                     btnConfrim.IsSelected = true;
                                 }
                                 else
                                 {
                                     btnConfrim.IsSelected = false;
+                                }
+                                if (groupControlLightList.Count != functions.Count)
+                                {
+                                    btnChooseAll.TextID = StringId.SelectedAll;
+                                }
+                                else
+                                {
+                                    if(btnChooseAll.TextID != StringId.Cancel)
+                                        btnChooseAll.TextID = StringId.Cancel;
                                 }
                             };
                             if (groupControl.sids.Find((obj) => obj.sid == function.sid) != null)
@@ -514,12 +759,8 @@
                                 TextAlignment = TextAlignment.Center,
                                 TextSize = CSS_FontSize.SubheadingFontSize,
                                 TextColor = CSS_Color.FirstLevelTitleColor,
-                                Text = "鍔犺浇鏇村",
+                                TextID = StringId.LoadMore,
                             };
-                            if (Language.CurrentLanguage != "Chinese")
-                            {
-                                btnAppend.Text = "Load more";
-                            }
                             functionListView.AddChidren(btnAppend);
                             btnAppend.MouseUpEventHandler = (sender, e) =>
                             {
@@ -558,12 +799,17 @@
             string nowSelectId = null;
             btnFloor.MouseUpEventHandler += (sender, e) =>
             {
+                Application.HideSoftInput();
                 //鏄剧ず涓嬫媺鍒楄〃
                 var form = new FloorRoomSelectPopupView();
                 form.ShowDeviceFunctionView(btnFloor, this.lightList, (selectId, listFunc) =>
                 {
+                    groupControlLightList.Clear();
+                    groupControl.sids.Clear();
+                    btnChooseAll.TextID = StringId.SelectAll;
+                    btnConfrim.IsSelected = false;
                     btnChooseAll.MouseUpEventHandler = (sender2, e2) => {
-                        if (groupControlLightList.Count > 0)
+                        if (groupControlLightList.Count == listFunc.Count)
                         {
                             groupControlLightList.Clear();
                             btnChooseAll.TextID = StringId.SelectAll;
@@ -571,6 +817,7 @@
                         }
                         else
                         {
+                            groupControlLightList.Clear();
                             groupControlLightList.AddRange(listFunc);
                             btnChooseAll.TextID = StringId.Cancel;
                             btnConfrim.IsSelected = true;
@@ -580,1044 +827,11 @@
                     nowSelectId = selectId;
                     //閲嶆柊鍔犺浇鐣岄潰
                     LoadLightRow(listFunc);
-                }, nowSelectId);
+                }, nowSelectId,100);
             };
         }
 
     }
 
-
-    //public class LightRow : FrameLayout
-    //{
-    //    #region 鍖哄煙鎺т欢
-    //    static FrameLayout bodyDiv;
-    //    /// <summary>
-    //    /// 鍔熻兘/鍦烘櫙icon
-    //    /// </summary>
-    //    Button btnIcon;
-    //    /// <summary>
-    //    /// 鍔熻兘鍚嶇О/鍦烘櫙鍚嶇О
-    //    /// </summary>
-    //    Button btnName;
-    //    /// <summary>
-    //    /// 妤煎眰淇℃伅鏄剧ず鎸夐挳
-    //    /// </summary>
-    //    Button btnFromFloor;
-    //    /// <summary>
-    //    /// 閫変腑鎸夐挳
-    //    /// </summary>
-    //    Button btnSelect;
-    //    #endregion
-
-    //    #region 鍖哄煙鍙橀噺
-    //    Function function;
-    //    #endregion
-    //    public LightRow(Function func)
-    //    {
-    //        bodyDiv = this;
-    //        bodyDiv.Tag = func.sid;
-    //        function = func;
-    //    }
-
-
-    //    /// <summary>
-    //    /// 鍔犺浇鎺у埗鍗$墖鍖哄煙
-    //    /// </summary>
-    //    public void LoadDiv(List<Function> functions, Action action)
-    //    {
-    //        btnIcon = new Button()
-    //        {
-    //            X = Application.GetRealWidth(10),
-    //            Y = Application.GetRealHeight(15),
-    //            Width = Application.GetRealWidth(32),
-    //            Height = Application.GetRealWidth(32),
-    //            UnSelectedImagePath = $"FunctionIcon/Icon/{function.IconName}.png"
-    //        };
-    //        bodyDiv.AddChidren(btnIcon);
-
-    //        btnName = new Button()
-    //        {
-    //            X = Application.GetRealWidth(8 + 10 + 32),
-    //            Y = Application.GetRealHeight(10),
-    //            Width = Application.GetRealWidth(200),
-    //            Height = Application.GetRealHeight(24),
-    //            Text = function.name,
-    //            TextAlignment = TextAlignment.CenterLeft,
-    //            TextColor = CSS_Color.FirstLevelTitleColor,
-    //            TextSize = CSS_FontSize.TextFontSize,
-    //        };
-    //        bodyDiv.AddChidren(btnName);
-
-    //        btnFromFloor = new Button()
-    //        {
-    //            X = Application.GetRealWidth(8 + 10 + 32),
-    //            Y = Application.GetRealHeight(10 + 24),
-    //            Width = Application.GetRealWidth(200),
-    //            Height = Application.GetRealHeight(18),
-    //            Text = function.GetRoomListName(),
-    //            TextAlignment = TextAlignment.CenterLeft,
-    //            TextColor = CSS_Color.PromptingColor1,
-    //            TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
-    //        };
-    //        bodyDiv.AddChidren(btnFromFloor);
-
-    //        btnSelect = new Button()
-    //        {
-    //            X = Application.GetRealWidth(303),
-    //            Gravity = Gravity.CenterVertical,
-    //            Width = Application.GetRealWidth(32),
-    //            Height = Application.GetRealWidth(32),
-    //            UnSelectedImagePath = "FunctionIcon/Light/LightScene/CheckIcon.png",
-    //            SelectedImagePath = "FunctionIcon/Light/LightScene/CheckOnIcon.png",
-    //            IsSelected = functions.Find((obj) => obj.deviceId == function.deviceId) != null
-    //        };
-    //        bodyDiv.AddChidren(btnSelect);
-
-    //        btnSelect.MouseUpEventHandler = (sender, e) => {
-    //            btnSelect.IsSelected = !btnSelect.IsSelected;
-    //            if (btnSelect.IsSelected)
-    //            {
-    //                var addTemp = functions.Find((obj) => obj.deviceId == function.deviceId);
-    //                if (addTemp == null)
-    //                {
-    //                    functions.Add(function);
-    //                }
-    //            }
-    //            else
-    //            {
-    //                var removeTemp = functions.Find((obj) => obj.deviceId == function.deviceId);
-    //                if (removeTemp != null)
-    //                {
-    //                    functions.Remove(removeTemp);
-    //                }
-    //            }
-    //            ///鍒锋柊鐣岄潰
-    //            if (functions.Count == 0 || functions.Count == 1)
-    //            {
-    //                action();
-    //            }
-    //        };
-
-    //    }
-
-
-    //}
-
-    ///// <summary>
-    ///// 鐏厜鍦烘櫙缂栬緫寮圭獥
-    ///// </summary>
-    //public class LightSceneEditDialog : Dialog
-    //{
-
-
-    //    Dictionary<string, string> d = new Dictionary<string, string>();
-    //    List<Function> listSwitch = new List<Function>();
-    //    List<Function> lightDimming = new List<Function>();
-    //    List<Function> lightCCT = new List<Function>();
-    //    List<Function> lightRGB = new List<Function>();
-
-    //    /// <summary>
-    //    /// 浼犲叆鐨勭伅鍏夊垪琛�
-    //    /// 鍔犲叆鍦烘櫙鎺у埗鍔熻兘鍒楄〃
-    //    /// </summary>
-    //    List<Function> lights;
-    //    /// <summary>
-    //    /// 涓存椂鐏厜瀵硅薄
-    //    /// 澶勭悊鐏厜鏂规硶
-    //    /// </summary>
-    //    Light tempLight = new Light();
-    //    //鍙戦�佹暟鎹敹闆�
-    //    Dictionary<string, string> commandDic = new Dictionary<string, string>();
-
-    //    Scene scene;
-    //    Action<Scene> backAction;
-    //    public LightSceneEditDialog(List<Function> functions, Scene inParScene, Action<Scene> action)
-    //    {
-    //        lights = functions;
-    //        scene = inParScene;
-    //        backAction = action;
-    //    }
-
-
-    //    public void ShowDialog()
-    //    {
-    //        commandDic.Clear();
-    //        commandDic.Add(FunctionAttributeKey.OnOff, "off");
-
-    //        listSwitch = lights.FindAll((obj) => obj.spk == SPK.LightSwitch);
-    //        lightDimming = lights.FindAll((obj) => obj.spk == SPK.LightDimming);
-    //        lightCCT = lights.FindAll((obj) => obj.spk == SPK.LightCCT);
-    //        lightRGB = lights.FindAll((obj) => obj.spk == SPK.LightRGB);
-
-
-
-    //        var hadDimming = lightDimming.Count > 0;
-    //        var hadCCT = lightCCT.Count > 0;
-    //        var hadRGB = lightRGB.Count > 0;
-    //        if (hadRGB)
-    //        {
-    //            commandDic.Add(FunctionAttributeKey.RGB, lightRGB[0].GetAttrState(FunctionAttributeKey.RGB));
-    //            commandDic.Add(FunctionAttributeKey.Brightness, lightRGB[0].GetAttrState(FunctionAttributeKey.Brightness));
-    //        }
-    //        if (hadCCT)
-    //        {
-    //            commandDic.Add(FunctionAttributeKey.CCT, lightCCT[0].GetAttrState(FunctionAttributeKey.CCT));
-    //            if (!commandDic.ContainsKey(FunctionAttributeKey.Brightness))
-    //            {
-    //                commandDic.Add(FunctionAttributeKey.Brightness, lightCCT[0].GetAttrState(FunctionAttributeKey.Brightness));
-    //            }
-    //        }
-    //        if (hadDimming)
-    //        {
-    //            if (!commandDic.ContainsKey(FunctionAttributeKey.Brightness))
-    //            {
-    //                commandDic.Add(FunctionAttributeKey.Brightness, lightDimming[0].GetAttrState(FunctionAttributeKey.Brightness));
-    //            }
-    //        }
-
-    //        var bodyView = new FrameLayout();
-    //        this.AddChidren(bodyView);
-    //        bodyView.MouseUpEventHandler = (sender, e) => {
-    //            this.Close();
-    //        };
-
-    //        var contentView = new FrameLayout()
-    //        {
-    //            BackgroundColor = CSS_Color.MainBackgroundColor,
-    //            Width = Application.GetRealWidth(343),
-    //            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,
-    //            TextID = StringId.CombinedDimming,
-    //            TextAlignment = TextAlignment.Center,
-    //        };
-    //        if (btnTitle.GetTextWidth() > Application.GetRealWidth(197))//247
-    //        {
-    //            btnTitle.Width = Application.GetRealWidth(197);
-    //            btnTitle.IsMoreLines = true;
-    //        }
-    //        else
-    //        {
-    //            btnTitle.Width = btnTitle.GetTextWidth() + Application.GetRealWidth(10);
-    //            btnTitle.IsMoreLines = false;
-    //        }
-    //        titleView.AddChidren(btnTitle);
-
-    //        var btnEditIcon = new Button()
-    //        {
-    //            Width = Application.GetRealWidth(24),
-    //            Height = Application.GetRealWidth(24),
-    //            X = Application.GetRealWidth(12) + btnTitle.Right,
-    //            Gravity = Gravity.CenterVertical,
-    //            UnSelectedImagePath = "Public/Edit.png",
-    //        };
-    //        if (string.IsNullOrEmpty(scene.userSceneId))
-    //        {
-    //            titleView.AddChidren(btnEditIcon);
-    //        }
-    //        else
-    //        {
-    //            btnTitle.Text = scene.name;
-    //            btnTitle.Width = btnTitle.GetTextWidth() + Application.GetRealWidth(10);
-    //            btnTitle.Gravity = Gravity.Center;
-    //        }
-
-    //        Action<string> callBack = (str) =>
-    //        {
-    //            //鍚嶇О涓嶈兘涓虹┖
-    //            if (string.IsNullOrEmpty(str))
-    //            {
-    //                new Tip()
-    //                {
-    //                    CloseTime = 1,
-    //                    Text = Language.StringByID(StringId.NameCannotBeEmpty),
-    //                    Direction = AMPopTipDirection.None,
-    //                }.Show(bodyView);
-    //                return;
-    //            }
-    //            btnTitle.Text = str;
-    //            scene.name = str;
-
-
-    //            if (btnTitle.GetTextWidth() > Application.GetRealWidth(197))//247
-    //            {
-    //                btnTitle.Width = Application.GetRealWidth(197);
-    //            }
-    //            else
-    //            {
-    //                btnTitle.Width = btnTitle.GetTextWidth();
-    //            }
-
-    //        };
-    //        EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
-    //        {
-    //            List<string> sceneNameList = new List<string>();
-    //            foreach (var tempScene in FunctionList.List.scenes)
-    //            {
-    //                sceneNameList.Add(tempScene.name);
-    //            }
-    //            new PublicAssmebly().LoadDialog_EditParater(StringId.SceneName, scene.name, callBack, StringId.SceneNameCannotBeEmpty, StringId.SceneNameAlreadyExists, sceneNameList);
-    //        };
-    //        btnTitle.MouseUpEventHandler = eventHandler;
-    //        btnEditIcon.MouseUpEventHandler = eventHandler;
-
-    //        titleView.AddChidren(new Button() { Height = 1, BackgroundColor = CSS_Color.DividingLineColor, Y = Application.GetRealHeight(51) });
-
-    //        #endregion
-
-
-    //        //var dimmingLight = lights.Find((obj) => obj.spk == SPK.LightDimming);
-    //        //var cctLight = lights.Find((obj) => obj.spk == SPK.LightCCT);
-    //        //var rgbLight = lights.Find((obj) => obj.spk == SPK.LightRGB);
-    //        var dimmingLight = scene.functions.Find((obj) => obj.localFunction.spk == SPK.LightDimming);
-    //        var cctLight = scene.functions.Find((obj) => obj.localFunction.spk == SPK.LightCCT);
-    //        var rgbLight = scene.functions.Find((obj) => obj.localFunction.spk == SPK.LightRGB);
-
-    //        var brightnessValue = 0;
-    //        var cctValue = 27;
-    //        //if(rgbLight!= null)
-    //        //{
-    //        //    int.TryParse(rgbLight.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness).value, out brightnessValue);
-    //        //}
-    //        //if (cctLight != null)
-    //        //{
-    //        //    int.TryParse(cctLight.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness).value, out brightnessValue);
-    //        //    int.TryParse(cctLight.status.Find((obj) => obj.key == FunctionAttributeKey.CCT).value, out cctValue);
-    //        //}
-    //        //if(dimmingLight!=null)
-    //        //{
-    //        //    int.TryParse(cctLight.status.Find((obj) => obj.key == FunctionAttributeKey.CCT).value, out brightnessValue);
-    //        //}
-
-
-    //        //灞炴�ц缃尯鍩�
-    //        var attrView = new VerticalScrolViewLayout()
-    //        {
-    //            Y = Application.GetRealHeight(52),
-    //            Width = Application.GetRealWidth(343),
-    //            ScrollEnabled = false,
-    //        };
-    //        //灞炴�ц缃尯鍩熼珮搴�
-    //        int attrViewHight = Application.GetRealHeight(18 + 22);
-
-
-    //        //鍙湁缁х數鍣�
-    //        if (!hadDimming && !hadCCT && !hadRGB)
-    //        {
-    //            attrViewHight += Application.GetRealHeight(50);
-    //            attrView.Height = attrViewHight;
-    //            contentView.AddChidren(attrView);
-    //            attrView.AddChidren(new Button() { Height = Application.GetRealHeight(18) });
-
-    //            var view = new FrameLayout()
-    //            {
-    //                Width = Application.GetRealWidth(343),
-    //                Height = Application.GetRealHeight(50),
-    //            };
-    //            attrView.AddChidren(view);
-
-
-    //            var btnClose = new Button()
-    //            {
-    //                X = Application.GetRealWidth(50),
-    //                Gravity = Gravity.CenterVertical,
-    //                Width = Application.GetRealWidth(98),
-    //                Height = Application.GetRealHeight(40),
-    //                TextColor = CSS_Color.TextualColor,
-    //                SelectedBackgroundColor = CSS_Color.MainColor,
-    //                SelectedTextColor = CSS_Color.MainBackgroundColor,
-    //                BackgroundColor = CSS_Color.DividingLineColor,
-    //                TextID = StringId.OFF,
-    //                TextSize = CSS_FontSize.TextFontSize,
-    //                Radius = (uint)Application.GetRealWidth(5),
-    //                IsSelected = true,
-    //                //BorderWidth = 1,
-    //                //BorderColor = 0x00000000
-    //            };
-    //            view.AddChidren(btnClose);
-
-    //            var btnOpen = new Button()
-    //            {
-    //                X = Application.GetRealWidth(100 + 98),
-    //                Gravity = Gravity.CenterVertical,
-    //                Width = Application.GetRealWidth(98),
-    //                Height = Application.GetRealHeight(40),
-    //                TextColor = CSS_Color.TextualColor,
-    //                SelectedBackgroundColor = CSS_Color.MainColor,
-    //                SelectedTextColor = CSS_Color.MainBackgroundColor,
-    //                BackgroundColor = CSS_Color.DividingLineColor,
-    //                TextID = StringId.On,
-    //                TextSize = CSS_FontSize.TextFontSize,
-    //                Radius = (uint)Application.GetRealWidth(5),
-    //            };
-    //            view.AddChidren(btnOpen);
-
-    //            btnClose.MouseUpEventHandler = (sender, e) =>
-    //            {
-    //                btnClose.IsSelected = true;
-    //                btnOpen.IsSelected = false;
-    //                commandDic[FunctionAttributeKey.OnOff] = "off";
-    //                d.Clear();
-    //                d.Add(FunctionAttributeKey.OnOff, "off");
-    //                foreach (var light in lights)
-    //                {
-    //                    Control.Ins.SendWriteCommand(light, d);
-    //                }
-    //            };
-    //            btnOpen.MouseUpEventHandler = (sender, e) =>
-    //            {
-    //                btnClose.IsSelected = false;
-    //                btnOpen.IsSelected = true;
-    //                commandDic[FunctionAttributeKey.OnOff] = "on";
-    //                d.Clear();
-    //                d.Add(FunctionAttributeKey.OnOff, "on");
-    //                foreach (var light in lights)
-    //                {
-    //                    Control.Ins.SendWriteCommand(light, d);
-    //                }
-    //            };
-
-    //        }
-
-    //        else
-    //        {
-    //            if (hadRGB)
-    //            {
-    //                attrViewHight += Application.GetRealHeight(248);
-    //                hadDimming = true;
-    //            }
-    //            if (hadCCT)
-    //            {
-    //                attrViewHight += Application.GetRealHeight(54 + 11);
-    //                hadDimming = true;
-    //            }
-    //            if (hadDimming)
-    //            {
-    //                attrViewHight += Application.GetRealHeight(54 + 11);
-    //            }
-    //            attrView.Height = attrViewHight;
-    //            contentView.AddChidren(attrView);
-    //            attrView.AddChidren(new Button() { Height = Application.GetRealHeight(18) });
-
-
-    //            if (hadDimming)
-    //            {
-    //                LoadDimmingAttrView(attrView);
-    //            }
-    //            if (hadCCT)
-    //            {
-    //                LoadCctAttrView(attrView);
-    //            }
-    //            if (hadRGB)
-    //            {
-    //                LoadRgbAttrView(attrView);
-    //            }
-    //        }
-
-    //        contentView.Height = Application.GetRealHeight(52 + 44) + attrViewHight;
-    //        contentView.Gravity = Gravity.Center;
-
-
-
-
-    //        #region bottom View
-    //        var bottomView = new FrameLayout()
-    //        {
-    //            Y = Application.GetRealHeight(52) + attrViewHight,
-    //            Height = Application.GetRealHeight(46),
-    //        };
-    //        contentView.AddChidren(bottomView);
-    //        bottomView.AddChidren(new Button() { Height = 1, BackgroundColor = CSS_Color.DividingLineColor });
-
-    //        if (string.IsNullOrEmpty(scene.userSceneId))
-    //        {
-    //            var btnCacel = new Button()
-    //            {
-    //                Width = Application.GetRealWidth(172),
-    //                Height = Application.GetRealHeight(44),
-    //                TextAlignment = TextAlignment.Center,
-    //                TextSize = CSS_FontSize.SubheadingFontSize,
-    //                TextColor = CSS_Color.TextualColor,
-    //                TextID = StringId.Cancel,
-    //            };
-    //            bottomView.AddChidren(btnCacel);
-
-    //            var btnSave = new Button()
-    //            {
-    //                X = Application.GetRealWidth(172),
-    //                Width = Application.GetRealWidth(172),
-    //                Height = Application.GetRealHeight(46),
-    //                BackgroundColor = CSS_Color.MainColor,
-    //                TextColor = CSS_Color.MainBackgroundColor,
-    //                TextAlignment = TextAlignment.Center,
-    //                TextSize = CSS_FontSize.SubheadingFontSize,
-    //                TextID = StringId.Save
-    //            };
-    //            bottomView.AddChidren(btnSave);
-
-    //            //渚嬶細鍙充笅鍦嗚 澶у皬涓�50
-    //            int mRectCornerID = HDLUtils.RectCornerBottomRight;
-    //            btnSave.SetCornerWithSameRadius((uint)Application.GetRealWidth(14), mRectCornerID);
-
-    //            btnCacel.MouseUpEventHandler = (sender, e) =>
-    //            {
-    //                this.Close();
-
-    //                //var waitPage = new Loading();
-    //                //MainPage.BaseView.AddChidren(waitPage);
-    //                //waitPage.Start(Language.StringByID(StringId.PleaseWait));
-    //                //new Thread(() =>
-    //                //{
-    //                //    try
-    //                //    {
-    //                //        foreach (var light in lights)
-    //                //        {
-    //                //            Dictionary<string, string> sendDate = new Dictionary<string, string>();
-    //                //            //璧嬪�煎満鏅姛鑳芥暟鎹�
-    //                //            foreach (var attr in light.GetAttributes())
-    //                //            {
-    //                //                if (commandDic.ContainsKey(attr))
-    //                //                {
-    //                //                    try
-    //                //                    {
-    //                //                        sendDate.Add(attr, commandDic[attr]);
-    //                //                    }
-    //                //                    catch { }
-    //                //                }
-
-    //                //            }
-    //                //                Control.Ins.SendWriteCommand(light, sendDate);
-    //                //            Thread.Sleep(50);
-    //                //        }
-    //                //    }
-    //                //    catch
-    //                //    { }
-    //                //    finally
-    //                //    {
-    //                //        Application.RunOnMainThread(() =>
-    //                //        {
-    //                //            waitPage.Hide();
-    //                //            new PublicAssmebly().TipMsgAutoClose("缁勫悎鎺у埗宸叉墽琛�", true);
-    //                //            if (waitPage != null)
-    //                //            {
-    //                //                //backAction(null);
-    //                //                waitPage.RemoveFromParent();
-    //                //            }
-    //                //        });
-    //                //    }
-    //                //})
-    //                //{ IsBackground = true }.Start();
-    //            };
-
-    //            btnSave.MouseUpEventHandler = (sender, e) =>
-    //            {
-    //                if (string.IsNullOrEmpty(scene.name))
-    //                {
-    //                    new Tip()
-    //                    {
-    //                        CloseTime = 1,
-    //                        Text = Language.StringByID(StringId.NameCannotBeEmpty),
-    //                        Direction = AMPopTipDirection.None,
-    //                    }.Show(bodyView);
-    //                    return;
-    //                }
-    //                foreach (var tempRoom in FunctionList.List.scenes)
-    //                {
-    //                    if (scene.name == tempRoom.name)
-    //                    {
-    //                        new PublicAssmebly().TipMsg(StringId.Tip, StringId.NameAlreadyExists);
-    //                        return;
-    //                    }
-    //                }
-    //                var waitPage = new Loading();
-    //                MainPage.BaseView.AddChidren(waitPage);
-    //                waitPage.Start(Language.StringByID(StringId.PleaseWait));
-    //                new Thread(() =>
-    //                {
-    //                    try
-    //                    {
-    //                        var serverScene = new Scene();
-    //                        for (int i = 0; i < lights.Count; i++)
-    //                        {
-    //                            var light = lights[i];
-    //                            //璧嬪�煎満鏅姛鑳芥暟鎹�
-    //                            foreach (var attr in light.GetAttributes())
-    //                            {
-    //                                if (commandDic.ContainsKey(attr))
-    //                                {
-    //                                    try
-    //                                    {
-    //                                        light.SetAttrState(attr, commandDic[attr]);
-    //                                    }
-    //                                    catch { }
-    //                                }
-    //                            }
-    //                            //杞崲鍦烘櫙鐨勫姛鑳藉璞�
-    //                            var sceneFunction = light.ConvertSceneFunction();
-    //                            //鏌ヨ鏈夋病鏈夊瓨鍦�
-    //                            var temp = scene.functions.Find((obj) => obj.sid == sceneFunction.sid);
-    //                            //璧嬪��
-    //                            if (temp != null)
-    //                            {
-    //                                temp = sceneFunction;
-    //                            }
-    //                            else
-    //                            {
-    //                                scene.functions.Add(sceneFunction);
-    //                            }
-    //                        }
-    //                        var result = FunctionList.List.AddScene(scene, out serverScene);
-    //                        Application.RunOnMainThread(() =>
-    //                        {
-    //                            if (result == StateCode.SUCCESS)
-    //                            {
-    //                                scene.userSceneId = serverScene.userSceneId;
-    //                                FunctionList.List.scenes.Add(scene);
-    //                                backAction?.Invoke(scene);
-    //                                this.Close();
-    //                            }
-    //                            else
-    //                            {
-    //                                if (result == "124005")
-    //                                    IMessageCommon.Current.ShowErrorInfoAlter(Language.StringByID(StringId.GatewayOffline));
-    //                                else
-    //                                    IMessageCommon.Current.ShowErrorInfoAlter(result);
-    //                            }
-    //                        });
-    //                    }
-    //                    catch { }
-    //                    finally
-    //                    {
-    //                        Application.RunOnMainThread(() =>
-    //                        {
-    //                            waitPage.Hide();
-    //                            waitPage.RemoveFromParent();
-    //                        });
-    //                    }
-    //                })
-    //                { IsBackground = true, Priority = ThreadPriority.AboveNormal }.Start();
-    //            };
-    //        }
-    //        else
-    //        {
-    //            var btnCacel = new Button()
-    //            {
-    //                Height = Application.GetRealHeight(44),
-    //                TextAlignment = TextAlignment.Center,
-    //                TextSize = CSS_FontSize.SubheadingFontSize,
-    //                TextColor = CSS_Color.TextualColor,
-    //                TextID = StringId.Close,
-    //            };
-    //            bottomView.AddChidren(btnCacel);
-
-
-    //            //渚嬶細鍙充笅鍦嗚 澶у皬涓�50
-    //            //int mRectCornerID = HDLUtils.RectCornerBottomRight;
-    //            //btnSave.SetCornerWithSameRadius((uint)Application.GetRealWidth(14), mRectCornerID);
-
-    //            btnCacel.MouseUpEventHandler = (sender, e) =>
-    //            {
-    //                this.Close();
-    //            };
-
-    //        }
-
-
-
-
-
-    //        #endregion
-
-
-    //        this.Show();
-
-    //    }
-
-    //    /// <summary>
-    //    /// 鍔犺浇璋冨厜灞炴�ц缃帶浠�
-    //    /// </summary>
-    //    /// <param name="attrView"></param>
-    //    void LoadDimmingAttrView(VerticalScrolViewLayout attrView)
-    //    {
-    //        string briValue = "";
-    //        commandDic.TryGetValue(FunctionAttributeKey.Brightness, out briValue);
-
-    //        var dimmingView = new FrameLayout()
-    //        {
-    //            Height = Application.GetRealHeight(54 + 11)
-    //        };
-    //        attrView.AddChidren(dimmingView);
-
-    //        #region 浜害璋冭妭
-    //        var btnBrightnessText = new Button()
-    //        {
-    //            X = Application.GetRealWidth(35),
-    //            Y = Application.GetRealHeight(1),
-    //            Width = Application.GetRealWidth(224),
-    //            Height = Application.GetRealHeight(25),
-    //            TextAlignment = TextAlignment.CenterLeft,
-    //            TextColor = CSS_Color.FirstLevelTitleColor,
-    //            TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
-    //            TextID = StringId.Brightness,
-    //        };
-    //        btnBrightnessText.Text = Language.StringByID(StringId.Brightness) + " " + commandDic[FunctionAttributeKey.Brightness] + "%";
-    //        dimmingView.AddChidren(btnBrightnessText);
-
-
-    //        var btnMinValuesText = new Button()
-    //        {
-    //            X = Application.GetRealWidth(35),
-    //            Y = btnBrightnessText.Bottom,
-    //            Width = Application.GetRealWidth(40),
-    //            Height = Application.GetRealHeight(21),
-    //            Text = "0%",
-    //            TextAlignment = TextAlignment.CenterLeft,
-    //            TextColor = CSS_Color.PromptingColor1,
-    //            TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
-    //        };
-    //        dimmingView.AddChidren(btnMinValuesText);
-
-    //        var dimmerBar = new DiyImageSeekBar()
-    //        {
-    //            X = Application.GetRealWidth(45 + 10),
-    //            Y = Application.GetRealHeight(11),
-    //            Width = Application.GetRealWidth(220),
-    //            Height = Application.GetRealHeight(54),
-    //            SeekBarViewHeight = Application.GetRealHeight(8),
-    //            ThumbImagePath = "Public/ThumbImage.png",
-    //            ThumbImageHeight = Application.GetRealHeight(54),
-    //            ProgressTextColor = CSS_Color.FirstLevelTitleColor,
-    //            ProgressTextSize = CSS_FontSize.PromptFontSize_FirstLevel,
-    //            ProgressBarColor = CSS_Color.AuxiliaryColor1,
-    //            MaxValue = 100,
-    //            Progress = Convert.ToInt32(commandDic[FunctionAttributeKey.Brightness]),
-    //            SeekBarPadding = Application.GetRealWidth(20),
-    //            IsProgressTextShow = false,
-    //            ProgressChangeDelayTime = 0,
-    //        };
-    //        dimmingView.AddChidren(dimmerBar);
-    //        dimmerBar.OnProgressChangedEvent = (sender, e) => {
-    //            btnBrightnessText.Text = Language.StringByID(StringId.Brightness) + " " + e + "%";
-    //        };
-    //        dimmerBar.OnStopTrackingTouchEvent = (sender, e) => {
-    //            commandDic[FunctionAttributeKey.Brightness] = dimmerBar.Progress.ToString();
-    //            btnBrightnessText.Text = Language.StringByID(StringId.Brightness) + " " + e + "%";
-
-    //            foreach (var light in lights)
-    //            {
-    //                if (light.spk == SPK.LightSwitch)
-    //                {
-    //                    d.Clear();
-    //                    d.Add(FunctionAttributeKey.OnOff, e > 0 ? "on" : "off");
-    //                    Control.Ins.SendWriteCommand(light, d);
-    //                }
-    //                else
-    //                {
-    //                    d.Clear();
-    //                    d.Add(FunctionAttributeKey.Brightness, e.ToString());
-    //                    Control.Ins.SendWriteCommand(light, d);
-    //                }
-    //            }
-    //        };
-
-
-    //        var btnMaxValuesText = new Button()
-    //        {
-    //            X = dimmerBar.Right,
-    //            Y = btnBrightnessText.Bottom,
-    //            Width = Application.GetRealWidth(55),
-    //            Height = Application.GetRealHeight(21),
-    //            Text = "100%",
-    //            TextAlignment = TextAlignment.CenterLeft,
-    //            TextColor = CSS_Color.PromptingColor1,
-    //            TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
-    //        };
-    //        dimmingView.AddChidren(btnMaxValuesText);
-    //        #endregion
-
-    //    }
-
-    //    /// <summary>
-    //    /// 鍔犺浇cct灞炴�ц缃帶浠�
-    //    /// </summary>
-    //    /// <param name="attrView"></param>
-    //    void LoadCctAttrView(VerticalScrolViewLayout attrView)
-    //    {
-    //        #region 鑹叉俯
-
-    //        string valueStr = "2700";
-    //        commandDic.TryGetValue(FunctionAttributeKey.CCT, out valueStr);
-    //        int value = Convert.ToInt32(valueStr) / 100;
-
-    //        var cctView = new FrameLayout()
-    //        {
-    //            Height = Application.GetRealHeight(54 + 11)
-    //        };
-    //        attrView.AddChidren(cctView);
-
-
-    //        //鑹叉俯
-    //        var btnTempClolor = new Button();
-    //        btnTempClolor.X = Application.GetRealWidth(35);
-    //        btnTempClolor.Y = Application.GetRealHeight(1);
-    //        btnTempClolor.Width = Application.GetRealWidth(224);
-    //        btnTempClolor.Height = Application.GetRealHeight(21);
-    //        btnTempClolor.TextAlignment = TextAlignment.CenterLeft;
-    //        btnTempClolor.TextColor = CSS_Color.FirstLevelTitleColor;
-    //        btnTempClolor.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
-    //        btnTempClolor.TextID = StringId.ColorTemperature;
-    //        cctView.AddChidren(btnTempClolor);
-
-    //        //2700K
-    //        var btnTempClolorMin = new Button()
-    //        {
-    //            X = Application.GetRealWidth(35),
-    //            Y = btnTempClolor.Bottom,
-    //            Width = Application.GetRealWidth(40),
-    //            Height = Application.GetRealHeight(21),
-    //        };
-    //        btnTempClolorMin.Width = Application.GetRealWidth(54);
-    //        btnTempClolorMin.Height = Application.GetRealHeight(21);
-    //        btnTempClolorMin.Text = "2700K";
-    //        btnTempClolorMin.TextAlignment = TextAlignment.CenterLeft;
-    //        btnTempClolorMin.TextColor = CSS_Color.PromptingColor1;
-    //        btnTempClolorMin.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
-    //        cctView.AddChidren(btnTempClolorMin);
-
-    //        //婊戝姩鏉$殑鑳屾櫙鍥剧墖
-    //        var btnColorTemplatrueBack = new Button()
-    //        {
-    //            X = Application.GetRealWidth(55 + 22 + 15),
-    //            Y = Application.GetRealHeight(11),
-    //            Width = Application.GetRealWidth(180),
-    //            Height = Application.GetRealHeight(54),
-    //        };
-    //        btnColorTemplatrueBack.UnSelectedImagePath = "FunctionIcon/Light/ColorTemperatureBar.png";
-    //        btnColorTemplatrueBack.Height = Application.GetRealHeight(8);
-    //        btnColorTemplatrueBack.Gravity = Gravity.CenterHorizontal;
-    //        cctView.AddChidren(btnColorTemplatrueBack);
-    //        //婊戝姩鏉℃帶浠�
-    //        var barColorTemplatrue = new CCTSeekBarControl()
-    //        {
-    //            X = Application.GetRealWidth(55 + 22),
-    //            Y = Application.GetRealHeight(11),
-    //            Width = Application.GetRealWidth(220),
-    //            Height = Application.GetRealHeight(54),
-    //        };
-    //        barColorTemplatrue.MinValue = 27;
-    //        barColorTemplatrue.MaxValue = 65;
-    //        barColorTemplatrue.ProgressBarColor = 0x00000000;//鍏ㄩ儴閫忔槑
-    //        barColorTemplatrue.ProgressBarUnEnableColor = 0x00000000;
-    //        barColorTemplatrue.SeekBarBackgroundColor = 0x00000000;
-    //        cctView.AddChidren(barColorTemplatrue);
-    //        barColorTemplatrue.Y = btnTempClolorMin.Y - (barColorTemplatrue.Height - btnTempClolorMin.Height) / 2;
-    //        barColorTemplatrue.Progress = value;
-    //        //璁剧疆鍒濆鍊�
-    //        btnTempClolor.Text = Language.StringByID(StringId.ColorTemperature) + " " + (barColorTemplatrue.Progress * 100 + "K");
-    //        barColorTemplatrue.OnProgressChangedEvent = (sender, e) =>
-    //        {
-    //            btnTempClolor.Text = Language.StringByID(StringId.ColorTemperature) + " " + (barColorTemplatrue.Progress * 100 + "K");
-    //        };
-    //        barColorTemplatrue.OnStopTrackingTouchEvent = (sender, e) =>
-    //        {
-    //            commandDic[FunctionAttributeKey.CCT] = (barColorTemplatrue.Progress * 100).ToString();
-
-    //            d.Clear();
-    //            d.Add(FunctionAttributeKey.CCT, (barColorTemplatrue.Progress * 100).ToString());
-    //            foreach (var light in lightCCT)
-    //            {
-    //                if (light.spk == SPK.LightCCT)
-    //                {
-    //                    Control.Ins.SendWriteCommand(light, d);
-    //                }
-    //            }
-    //        };
-    //        //鍙樻洿鑳屾櫙鍥剧殑Y杞村潗鏍�
-    //        btnColorTemplatrueBack.Y = barColorTemplatrue.Y + (barColorTemplatrue.Height - btnColorTemplatrueBack.Height) / 2;
-
-    //        //6500K
-    //        var btnTempClolorMax = new Button();
-    //        btnTempClolorMax.Y = btnTempClolorMin.Y;
-    //        btnTempClolorMax.X = barColorTemplatrue.Right - Application.GetRealWidth(30);
-    //        btnTempClolorMax.Width = Application.GetRealWidth(54);
-    //        btnTempClolorMax.Height = Application.GetRealHeight(21);
-    //        btnTempClolorMax.Text = "6500K";
-    //        btnTempClolorMax.TextAlignment = TextAlignment.CenterRight;
-    //        btnTempClolorMax.TextColor = CSS_Color.PromptingColor1;
-    //        btnTempClolorMax.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
-    //        cctView.AddChidren(btnTempClolorMax);
-
-    //        #endregion
-
-
-    //    }
-
-    //    /// <summary>
-    //    /// 鍔犺浇rgb灞炴�ц缃帶浠�
-    //    /// </summary>
-    //    /// <param name="attrView"></param>
-    //    void LoadRgbAttrView(VerticalScrolViewLayout attrView)
-    //    {
-
-    //        #region RGB
-
-    //        string value = "255,255,255";
-    //        commandDic.TryGetValue(FunctionAttributeKey.RGB, out value);
-
-    //        var rgbView = new FrameLayout()
-    //        {
-    //            Height = Application.GetRealHeight(248)
-    //        };
-    //        attrView.AddChidren(rgbView);
-
-
-    //        var btnCurColor = new Button()
-    //        {
-    //            X = Application.GetRealWidth(24),
-    //            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(commandDic[FunctionAttributeKey.RGB]))
-    //        };
-    //        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.MouseUpEventHandler = (sender2, e) => {
-    //            d.Clear();
-    //            d.Add(FunctionAttributeKey.RGB, commandDic[FunctionAttributeKey.RGB]);
-    //            foreach (var light in lightCCT)
-    //            {
-    //                if (light.spk == SPK.LightCCT)
-    //                {
-    //                    Control.Ins.SendWriteCommand(light, d);
-    //                }
-    //            }
-    //        };
-    //        colorPicker.ColorChaged += (sender2, e2) => {
-    //            string rgbString = (e2[0] + "," + e2[1] + "," + e2[2]).ToString();
-    //            commandDic[FunctionAttributeKey.RGB] = rgbString;
-    //            btnCurColor.BackgroundColor = (uint)(0xFF000000 + tempLight.GetRGBcolor(rgbString));
-    //            foreach (var rgbTemp in lightRGB)
-    //            {
-    //                rgbTemp.SetAttrState(FunctionAttributeKey.RGB, 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.MouseUpEventHandler = (sender, e) => {
-    //            foreach (var rgbTemp in lightRGB)
-    //            {
-    //                Dictionary<string, string> d = new Dictionary<string, string>();
-    //                d.Add(FunctionAttributeKey.RGB, tempLight.GetRGBcolorString(rgbTemp));
-    //                Control.Ins.SendWriteCommand(rgbTemp, d, false, 0);
-    //            }
-    //        };
-
-    //        colorPicker.MouseMoveEventHandler += (sender, e) =>
-    //        {
-    //            //褰撻紶鏍囩偣涓嬩簨浠跺鐞�
-    //            colorPicker.MouseDownEventHandler(sender, e);
-    //        };
-
-
-    //        #endregion
-
-    //    }
-
-
-    //    /// <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;
-    //    }
-
-    //}
 
 }
\ No newline at end of file

--
Gitblit v1.8.0