From d72ca686a3e262693f8a6e45e747e8e8da43335b Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期二, 06 七月 2021 09:39:03 +0800
Subject: [PATCH] 2021-07-06 1.更新

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs |  284 +++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 227 insertions(+), 57 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
index e46520b..cd334f8 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
@@ -1,6 +1,8 @@
-锘縰sing System;
+using System;
 using Shared;
 using System.Collections.Generic;
+using HDL_ON.Entity;
+
 namespace HDL_ON.UI.UI2.Intelligence.Automation
 {
     public class ConditionDeviceFunList : FrameLayout
@@ -36,65 +38,140 @@
             };
             this.AddChidren(fLayout);
             #endregion
-            switch (device.functionType)
+            switch (device.spk)
             {
                 //寮�鍏崇伅鍏� light.Switch
-                case FunctionType.Dimmer:
-                case FunctionType.RGB:
-                case FunctionType.RGBW:
-                case FunctionType.ColorTemperature:
-                case FunctionType.Relay:
+                case SPK.LightDimming:
+                case SPK.LightRGB:
+                case SPK.LightRGBW:
+                case SPK.LightCCT:
+                case SPK.LightSwitch:
                 //绐楀笜
-                case FunctionType.Curtain:
-                case FunctionType.RollingShutter:
-                case FunctionType.MotorCurtain:
+                case SPK.CurtainSwitch:
+                case SPK.CurtainRoller:
+                case SPK.CurtainTrietex:
                 //绌鸿皟
-                case FunctionType.AC:
+                case SPK.AcStandard:
                 //鍦扮儹
-                case FunctionType.FloorHeating:
+                case SPK.FloorHeatStandard:
                     {
-                        LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView();
-                        lightSwitchView.btnText.TextID = StringId.switchLogic;
-                        lightSwitchView.btnState.Text = "";
-                        fLayout.AddChidren(lightSwitchView.FLayoutView());
-                        lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
-                        {
-                            FrameLayout frame = new FrameLayout
-                            {
-                                BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
-                            };
-                            this.AddChidren(frame);
-                            LogicView.SwitchView switchView = new LogicView.SwitchView();
-                            switchView.FLayoutView(frame, 2, lightSwitchView.btnState.Text, (strValue) =>
-                            {
-                                int id = 0;
-                                switch (strValue)
-                                {
-                                    case "on":
-                                        {
-                                            id = StringId.onLogic;
-                                        }
-                                        break;
-                                    case "off":
-                                        {
-                                            id = StringId.offLogic;
-                                        }
-                                        break;
-                                }
-                                //鏄剧ず鏂囨湰
-                                lightSwitchView.btnState.TextID = id;
-                                selectedState = device.functionType + "_" + strValue;
-                                //璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�;
-                                string keyVlaue = "on_off";
-                                AddDictionary(keyVlaue, strValue);
 
-                            });
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.switchLogic;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.onLogic, StringId.offLogic);
                         };
                         if (edit)
                         {
-                            GetEditState(device, index, lightSwitchView.btnState, null, null, null);
+                            GetEditState(device, index, view.btnState, null, null, null);
+                        }
+                    }
+                    break;
+                case SPK.SensorWater:
+                    {
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.luoshuiandwuluoshui;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.luoshui, StringId.wuluoshui);
+                        };
+                        if (edit)
+                        {
+                            GetEditState(device, index, view.btnState, null, null, null);
                         }
 
+                    }
+                    break;
+                case SPK.SensorSmoke:
+                case SPK.SensorGas:
+                    {
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.xieluoandwuxieluo;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.xieluo, StringId.wuxieluo);
+                        };
+                        if (edit)
+                        {
+                            GetEditState(device, index, view.btnState, null, null, null);
+                        }
+
+                    }
+                    break;
+                case SPK.SensorDryContact:
+                    {
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.switchLogic;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.onLogic, StringId.offLogic);
+                        };
+                        if (edit)
+                        {
+                            GetEditState(device, index, view.btnState, null, null, null);
+                        }
+
+                    }
+                    break;
+                case SPK.SensorShanLan:
+                case SPK.SensorDuiShe:
+                case SPK.SensorPir:
+                    {
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.yourenandwuren;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.youren, StringId.wuren);
+                        };
+                        if (edit)
+                        {
+                            GetEditState(device, index, view.btnState, null, null, null);
+                        }
+                    }
+                    break;
+                case SPK.SensorDoorWindow: {
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.kaiqiandbihe;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.kaiqi , StringId.bihe);
+                        };
+                        if (edit)
+                        {
+                            GetEditState(device, index, view.btnState, null, null, null);
+                        }
+                    }
+                    break;
+                case SPK.SensoruUtrasonic:
+                    {
+                        
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.yourenandwuren;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.youren, StringId.wuren);
+                        };
+                        LogicView.FunTypeView view1 = new LogicView.FunTypeView();
+                        view1.frameLayout.Y = view.frameLayout.Bottom;
+                        view1.btnText.TextID = StringId.fangchaigongneng;
+                        fLayout.AddChidren(view1.FLayoutView());
+                        view1.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view1.btnState, StringId.zaixian, StringId.buzaixian);
+                        };
+
+                        if (edit)
+                        {
+                            GetEditState(device, index, view.btnState, view1.btnState, null, null);
+                        }
                     }
                     break;
 
@@ -147,6 +224,100 @@
 
         }
         /// <summary>
+        /// 璁惧閫夋嫨鏉′欢鐣岄潰
+        /// </summary>
+        /// <param name="device">璁惧</param>
+        /// <param name="button">閫変腑鐘舵�佹樉绀烘枃鏈珺tn鎺т欢</param>
+        /// <param name="btnText1">灞炴�х姸鎬佸�兼枃鏈�1</param>
+        /// <param name="btnText2">灞炴�х姸鎬佸�兼枃鏈�2</param>
+        private void DeviceView(Entity.Function device,Button button,int btnText1,int btnText2) { 
+            FrameLayout frame = new FrameLayout { BackgroundColor = CSS.CSS_Color.viewTrans60lucence };
+            this.AddChidren(frame);
+            LogicView.SwitchView switchView = new LogicView.SwitchView();
+            switchView.FLayoutView(frame, btnText1, btnText2, button.Text, (intValue) =>
+            {
+                //璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�;
+                string keyVlaue = "on_off";
+                string value = "";
+                switch (device.spk)
+                {
+                    //浼犳劅鍣�
+                    case SPK.SensorWater:
+                    case SPK.SensorSmoke:
+                    case SPK.SensorGas:
+                    case SPK.SensorDryContact:
+                    case SPK.SensorShanLan:
+                    case SPK.SensorDuiShe:
+                    case SPK.SensorPir:
+                    case SPK.SensorDoorWindow:
+                    case SPK.SensoruUtrasonic:
+                        {
+                            keyVlaue = "status";
+                        }
+                        break;
+
+                }
+                switch (intValue)
+                {
+                    case StringId.xieluo:
+                    case StringId.luoshui:
+                        {
+                            value = "alarm";
+                        }
+                        break;
+                    case StringId.wuxieluo:
+                    case StringId.wuluoshui:
+                        {
+                            value = "normal";
+                        }
+                        break;
+                    case StringId.onLogic:
+                        {
+                            value = "on";
+                        }
+                        break;
+                    case StringId.offLogic:
+                        {
+                            value = "off";
+                        }
+                        break;
+                    case StringId.youren: {
+                            value = "true";
+                        }
+                        break;
+                    case StringId.wuren: {
+                            value = "false";
+                        }
+                        break;
+                    case StringId.kaiqi:
+                        {
+                            value = "open";
+                        }
+                        break;
+                    case StringId.bihe:
+                        {
+                            value = "close";
+                        }
+                        break;
+                    case StringId.zaixian: {
+                            keyVlaue = "dismantle";
+                            value = "true";
+                        };break;
+                    case StringId.buzaixian:
+                        {
+                            keyVlaue = "dismantle";
+                            value = "false";
+                        }; break;
+                }
+                //鏄剧ず鏂囨湰
+                button.TextID = intValue;
+                selectedState = device.spk + "_" + value;
+                AddDictionary(keyVlaue, value);
+
+            });
+
+        }
+        /// <summary>
         /// 鏄剧ず缂栬緫涔嬪墠鐨勮澶囩姸鎬�
         /// </summary>
         /// <param name="device">缂栬緫璁惧</param>
@@ -181,21 +352,20 @@
             LogicMethod.dictionary(dic, "comparator", "=");
             LogicMethod.dictionary(dic, "data_type", "string");
             LogicMethod.dictionary(dic, "value", selectedValue);
-            AddDictionaryList(KeyValue, dic, dicSateteList);
+            AddDictionaryList(KeyValue, dic);
         }
         /// <summary>
         /// 鏇存柊鏁版嵁鍒楄〃
         /// </summary>
         /// <param name="keyValue">璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�</param> 
-        /// <param name="dictionary">閫変腑鏁版嵁</param>
-        /// <param name="dicList">瀛樺偍鏁版嵁鍒楄〃</param>
+        /// <param name="dictionary">娣诲姞閫変腑鏁版嵁</param>
         /// <returns></returns>
-        private void AddDictionaryList(string keyValue, Dictionary<string, string> dictionary, List<Dictionary<string, string>> dicList)
+        private void AddDictionaryList(string keyValue, Dictionary<string, string> dictionary) 
         {
             int indexValue = -1;
-            for (int i = 0; i < dicList.Count; i++)
+            for (int i = 0; i < dicSateteList.Count; i++)
             {
-                var dic = dicList[i];
+                var dic = dicSateteList[i];
                 if (dic.ContainsValue(keyValue))
                 {
                     //鍒ゆ柇鏄惁瀛樺湪
@@ -207,14 +377,14 @@
             if (indexValue != -1)
             {
                 //瀛樺湪绉婚櫎
-                dicList.RemoveAt(indexValue);
+                dicSateteList.RemoveAt(indexValue);
                 //閲嶆柊娣诲姞
-                dicList.Insert(indexValue, dictionary);
+                dicSateteList.Insert(indexValue, dictionary);
             }
             else
             {
                 //鏂版坊鍔�
-                dicList.Add(dictionary);
+                dicSateteList.Add(dictionary);
             }
 
         }

--
Gitblit v1.8.0