From 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期二, 21 七月 2020 09:46:53 +0800
Subject: [PATCH] 请合并最新多功能面板代码

---
 ZigbeeApp/Shared/Phone/Device/Logic/Method.cs |  144 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 105 insertions(+), 39 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/Method.cs b/ZigbeeApp/Shared/Phone/Device/Logic/Method.cs
index 5df1e25..6fba6f9 100755
--- a/ZigbeeApp/Shared/Phone/Device/Logic/Method.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/Method.cs
@@ -108,7 +108,7 @@
             List<string> devicetypelist = new List<string>();
             devicetypelist.Clear();
 
-            var lightjosn = devicelist.Find((device) => device.Type == DeviceType.DimmableLight || device.Type == DeviceType.OnOffOutput);
+            var lightjosn = devicelist.Find((device) => device.Type == DeviceType.DimmableLight || device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.ColorTemperatureLight);
             if (lightjosn != null)
             {
                 devicetypelist.Add(Language.StringByID(MyInternationalizationString.Lights));
@@ -166,6 +166,7 @@
             {
                 DeviceTypeList.Add(DeviceType.OnOffOutput);//0x0101鍗佽繘鍒�257
                 DeviceTypeList.Add(DeviceType.DimmableLight);
+                DeviceTypeList.Add(DeviceType.ColorTemperatureLight);
             }
             else if (devicetype == Language.StringByID(MyInternationalizationString.Curtains))
             {
@@ -316,6 +317,12 @@
                         selectedpatm = "ZigeeLogic/selectedairswitch.png";
                     }
                     break;
+                case DeviceType.ColorTemperatureLight:
+                    {
+                        patm = "ZigeeLogic/nightLight.png";
+                        selectedpatm = "ZigeeLogic/nightLightSelected.png";
+                    }
+                    break;
             }
             button.UnSelectedImagePath = patm;
             button.SelectedImagePath = selectedpatm;
@@ -350,6 +357,7 @@
                         deviceTypeList.Add(DeviceType.WindowCoveringDevice);
                         deviceTypeList.Add(DeviceType.Thermostat);
                         deviceTypeList.Add(DeviceType.AirSwitch);
+                        deviceTypeList.Add(DeviceType.ColorTemperatureLight);
                         ///闂ㄩ攣鐗规畩
                        // deviceTypeList.Add(DeviceType.DoorLock);
                     }
@@ -372,6 +380,7 @@
                         deviceTypeList.Add(DeviceType.WindowCoveringDevice);
                         deviceTypeList.Add(DeviceType.Thermostat);
                         deviceTypeList.Add(DeviceType.AirSwitch);
+                        deviceTypeList.Add(DeviceType.ColorTemperatureLight);
                         ///闂ㄩ攣鐗规畩
                       // deviceTypeList.Add(DeviceType.DoorLock);
                     }
@@ -702,7 +711,11 @@
                     Common.Logic.CurrentLogic.LogicIsCustomPushText = 0;
                     pushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor;
                 }
-                Send.Zj(LogicView.IfString.Tag, Common.Logic.CurrentLogic);
+                if (!Config.Instance.Home.IsVirtually)
+                {
+                    Send.Zj(LogicView.IfString.Tag, Common.Logic.CurrentLogic);
+
+                }
             };
 
             if (Common.Logic.CurrentLogic.LogicIsCustomPushText == 0)
@@ -759,43 +772,94 @@
             bool succeed = false;
             //鍒ゆ柇鏄柊娣诲姞閫昏緫(榛樿0)杩樻槸淇敼閫昏緫
             CommonPage.Loading.Start();
-            if (CurrentLogic.LogicId == 0)
-            {
-                //鍙戦�佹坊鍔犻�昏緫鍛戒护
-                var logicifon = await Send.AddModifyLogic(CurrentLogic);
-                if (logicifon != null && logicifon.LogicId != 0)
-                {
-                    succeed = true;
-                    CurrentLogic.LogicId = logicifon.LogicId;
-                    if (LogicView.IfString._Logic == if_logic || LogicView.IfString._SoneLogic == if_logic)
-                    {
-                        //鑷姩鍖栭�昏緫鍒楄〃
-                        Common.Logic.LogicList.Add(CurrentLogic);
-                    }
-                    if (LogicView.IfString._LockLogic == if_logic)
-                    {
-                        //闂ㄩ攣鑱斿姩浜嬩欢閫昏緫鍒楄〃
-                        Common.Logic.LockLogicList.Add(CurrentLogic);
-                    }
-                    if (LogicView.IfString._SoneLogic == if_logic)
-                    {
-                        //Sone闂ㄩ攣鑱斿姩浜嬩欢閫昏緫鍒楄〃
-                        Common.Logic.SoneLogicList.Add(CurrentLogic);
 
-                    }
-                    if (tag)
-                    {
-                        Send.Zj(tag, CurrentLogic);
-                    }
+            if (Config.Instance.Home.IsVirtually)
+            {
+                if (Common.Logic.LogicList.Count == 0)
+                {
+                    CurrentLogic.LogicId = 1;
+                    Common.Logic.LogicList.Add(CurrentLogic);
                 }
+
+                if (CurrentLogic.LogicId == 0)
+                {
+                    bool d = false;
+                    for (int i = 1; i < 50; i++)
+                    {
+                       
+                        for (int j = 0; j < Common.Logic.LogicList.Count; j++)
+                        {
+                            if (i != Common.Logic.LogicList[j].LogicId)
+                            {
+                                CurrentLogic.LogicId = i;
+                                Common.Logic.LogicList.Add(CurrentLogic);
+                                d = true;
+                                break;
+                            }
+                        }
+                        if (d)
+                        {
+                            break;
+                        }
+                    }
+
+                }
+                else
+                {
+                    for (int j = 0; j < Common.Logic.LogicList.Count; j++)
+                    {
+                        if (CurrentLogic.LogicId == Common.Logic.LogicList[j].LogicId)
+                        {
+                            Common.Logic.LogicList.RemoveAt(j);
+                            Common.Logic.LogicList.Insert(j,CurrentLogic);
+                            break;
+                        }
+                    }
+
+                }
+
+                //鑷姩鍖栭�昏緫鍒楄〃
             }
             else
             {
-                //鍙戦�佷慨鏀归�昏緫鍛戒护锛�
-                //淇敼鍛戒护涓嶉渶瑕佺瓑寰呭洖澶嶏紱
-                Send.AddModifyLogic(CurrentLogic);
-                //缂栬緫榛樿鎴愬姛锛堜笉鑰冭檻缃戠粶鎯呭喌锛夛紱
-                succeed = true;
+                if (CurrentLogic.LogicId == 0)
+                {
+                    //鍙戦�佹坊鍔犻�昏緫鍛戒护
+                    var logicifon = await Send.AddModifyLogic(CurrentLogic);
+                    if (logicifon != null && logicifon.LogicId != 0)
+                    {
+                        succeed = true;
+                        CurrentLogic.LogicId = logicifon.LogicId;
+                        if (LogicView.IfString._Logic == if_logic || LogicView.IfString._SoneLogic == if_logic)
+                        {
+                            //鑷姩鍖栭�昏緫鍒楄〃
+                            Common.Logic.LogicList.Add(CurrentLogic);
+                        }
+                        if (LogicView.IfString._LockLogic == if_logic)
+                        {
+                            //闂ㄩ攣鑱斿姩浜嬩欢閫昏緫鍒楄〃
+                            Common.Logic.LockLogicList.Add(CurrentLogic);
+                        }
+                        if (LogicView.IfString._SoneLogic == if_logic)
+                        {
+                            //Sone闂ㄩ攣甯稿紑妯″紡閫昏緫鍒楄〃
+                            Common.Logic.SoneLogicList.Add(CurrentLogic);
+
+                        }
+                        if (tag)
+                        {
+                            Send.Zj(tag, CurrentLogic);
+                        }
+                    }
+                }
+                else
+                {
+                    //鍙戦�佷慨鏀归�昏緫鍛戒护锛�
+                    //淇敼鍛戒护涓嶉渶瑕佺瓑寰呭洖澶嶏紱
+                    Send.AddModifyLogic(CurrentLogic);
+                    //缂栬緫榛樿鎴愬姛锛堜笉鑰冭檻缃戠粶鎯呭喌锛夛紱
+                    succeed = true;
+                }
             }
             CommonPage.Loading.Hide();
 
@@ -827,11 +891,13 @@
             else if (LogicView.IfString._SoneLogic == if_logic)
             {
                 //璺冲埌Sone闂ㄩ攣鑱斿姩浜嬩欢鍒楄〃鐣岄潰
-                UserView.HomePage.Instance.RemoveViewByTag("SoneLogic");//绉婚櫎鎵�鏈夋爣璁癓ockListView鐣岄潰
-                var soneLogicList = new SoneLogicList();
-                UserView.HomePage.Instance.AddChidren(soneLogicList);
-                UserView.HomePage.Instance.PageIndex += 1;
-                soneLogicList.Show();
+                //UserView.HomePage.Instance.RemoveViewByTag("SoneLogic");//绉婚櫎鎵�鏈夋爣璁癓ockListView鐣岄潰
+                //var soneLogicList = new SoneLogicList();
+                //UserView.HomePage.Instance.AddChidren(soneLogicList);
+                //UserView.HomePage.Instance.PageIndex += 1;
+                //soneLogicList.Show();
+
+                SoneLogicList.soneLogicList?.RefreshView();
             }
 
         }

--
Gitblit v1.8.0