wei
2021-01-11 41f9c8837b0551c68f8fd798c06951fa716b7ab8
HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs
@@ -1,4 +1,4 @@
using System;
using System;
using Shared;
using System.Collections.Generic;
using HDL_ON.Entity;
@@ -53,14 +53,57 @@
                case SPK.LightRGBW:
                case SPK.LightCCT:
                    {
                        //2表示(开,关)功能
                        SwitchBrightnessView(fLayout, device, index, edit, 2);
                        #region 界面
                        ///开关
                        LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView();
                        lightSwitchView.btnText.TextID = StringId.switchLogic;
                        fLayout.AddChidren(lightSwitchView.FLayoutView());
                        ///亮度
                        LogicView.FunTypeView brightnessView = new LogicView.FunTypeView();
                        brightnessView.frameLayout.Y = lightSwitchView.frameLayout.Bottom;
                        brightnessView.btnText.TextID = StringId.brightnesLogic;
                        fLayout.AddChidren(brightnessView.FLayoutView());
                        #endregion
                        #region 点击事件
                        ///开关点击事件
                        lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
                        {
                            SwitchViewMethod(device, lightSwitchView.btnState, 2);
                        };
                        ///亮度点击事件
                        brightnessView.btnClick.MouseUpEventHandler += (sender, e) =>
                        {
                            BrightnessMethod(device, brightnessView.btnState, brightnessView.btnText.Text);
                        };
                        if (edit)
                        {
                            //显示编辑之前的设备状态
                            GetEditState(device, index, lightSwitchView.btnState, brightnessView.btnState, null, null);
                        }
                        #endregion
                    }
                    break;
                case SPK.LightSwitch:
                    {
                        //2表示(开,关)功能
                        SwitchView(fLayout, device, index, edit, 2);
                        #region 界面
                        ///开关
                        LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView();
                        lightSwitchView.btnText.TextID = StringId.switchLogic;
                        fLayout.AddChidren(lightSwitchView.FLayoutView());
                        #endregion
                        #region 点击事件
                        ///开关点击事件
                        lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
                        {
                            SwitchViewMethod(device, lightSwitchView.btnState, 2);
                        };
                        if (edit)
                        {
                            //显示编辑之前的设备状态
                            GetEditState(device, index, lightSwitchView.btnState, null, null, null);
                        }
                        #endregion
                    }
                    break;
                //窗帘
@@ -68,8 +111,24 @@
                case SPK.CurtainTrietex:
                case SPK.CurtainRoller:
                    {
                        //3表示(开,关,暂停)功能
                        SwitchView(fLayout, device, index, edit, 3);
                        #region 界面
                        ///开关
                        LogicView.FunTypeView curtainSwitchView = new LogicView.FunTypeView();
                        curtainSwitchView.btnText.TextID = StringId.switchLogic;
                        fLayout.AddChidren(curtainSwitchView.FLayoutView());
                        #endregion
                        #region 点击事件
                        ///开关点击事件
                        curtainSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
                        {
                            SwitchViewMethod(device, curtainSwitchView.btnState, 3);
                        };
                        if (edit)
                        {
                            //显示编辑之前的设备状态
                            GetEditState(device, index, curtainSwitchView.btnState, null, null, null);
                        }
                        #endregion
                    }
                    break;
                case SPK.AcStandard:
@@ -109,19 +168,18 @@
                        {
                            ///之前的状态文本
                            string tempValue = temperatureView.btnState.Text;
                            LogicView.TemperatureView tempView= new LogicView.TemperatureView();
                            tempView.FLayoutView(this, tempValue,(stateStr)=> {
                            LogicView.TemperatureView tempView = new LogicView.TemperatureView();
                            tempView.FLayoutView(this, tempValue, (stateStr) =>
                            {
                                //界面显示选中值
                                temperatureView.btnState.Text = stateStr;
                                //设备属性值,云雀上定义好的;
                                string keyVlaue = "set_temp";
                                selectedState = device.spk + "_"+ keyVlaue;
                                string set_temp_value = stateStr.Replace("℃", "");
                                //数据封装
                                Dictionary<string, string> dic = new Dictionary<string, string>();
                                LogicMethod.dictionary(dic, "key", keyVlaue);
                                LogicMethod.dictionary(dic, "value", set_temp_value);
                                AddDictionaryData(dicSateteList, keyVlaue, dic);
                                AddDictionary(keyVlaue, set_temp_value);
                            });
@@ -135,18 +193,14 @@
                            string keyVlaue = "mode";
                            selectedState = device.spk + "_"+keyVlaue;
                            PublicInterface modeView = new PublicInterface();
                            var modeListStr=  modeView.GetViewList(keyVlaue);
                            var modeListStr = modeView.GetViewList(keyVlaue);
                            modeView.SingleSelectionShow(this, modeListStr, Language.StringByID(StringId.modeLogic), currText
                               , (stateValue) =>
                               {
                                   //界面显示选中值
                                   acModehView.btnState.Text = stateValue;
                                   //数据封装
                                   Dictionary<string, string> dic = new Dictionary<string, string>();
                                   LogicMethod.dictionary(dic, "key", keyVlaue);
                                   LogicMethod.dictionary(dic, "value", modeView.GetModeValueString(stateValue, keyVlaue));
                                   AddDictionaryData(dicSateteList, keyVlaue, dic);
                                   AddDictionary(keyVlaue, modeView.GetModeValueString(stateValue, keyVlaue));
                               });
                        };
@@ -167,10 +221,7 @@
                                   //界面显示选中值
                                   acSpeedView.btnState.Text = stateValue;
                                   //数据封装
                                   Dictionary<string, string> dic = new Dictionary<string, string>();
                                   LogicMethod.dictionary(dic, "key", keyVlaue);
                                   LogicMethod.dictionary(dic, "value", speedView.GetModeValueString(stateValue, keyVlaue));
                                   AddDictionaryData(dicSateteList, keyVlaue, dic);
                                   AddDictionary(keyVlaue, speedView.GetModeValueString(stateValue, keyVlaue));
                               });
                        };
@@ -209,6 +260,7 @@
                        ///开关点击事件
                        floorHeatingSwitchVie.btnClick.MouseUpEventHandler += (sender, e) =>
                        {
                            SwitchViewMethod(device, floorHeatingSwitchVie.btnState, 2);
                        };
                        ///温度点击事件
@@ -216,7 +268,8 @@
                        {
                            string tempValue = temperatureView.btnState.Text;
                            LogicView.TemperatureView tempView = new LogicView.TemperatureView();
                            tempView.FLayoutView(this, tempValue, (stateStr) => {
                            tempView.FLayoutView(this, tempValue, (stateStr) =>
                            {
                                //界面显示选中值
                                temperatureView.btnState.Text = stateStr;
                                //设备属性值,云雀上定义好的;
@@ -224,25 +277,21 @@
                                selectedState = device.spk + "_"+ keyVlaue;
                                string set_temp_value = stateStr.Replace("℃", "");
                                //数据封装
                                Dictionary<string, string> dic = new Dictionary<string, string>();
                                LogicMethod.dictionary(dic, "key", keyVlaue);
                                LogicMethod.dictionary(dic, "value", set_temp_value);
                                AddDictionaryData(dicSateteList, keyVlaue, dic);
                                AddDictionary(keyVlaue, set_temp_value);
                            });
                        };
                        ///模式点击事件
                        floorHeatingModehView.btnClick.MouseUpEventHandler += (sender, e) =>
                        {
                            ///之前的状态文本
                            string currText= floorHeatingModehView.btnState.Text;
                            string currText = floorHeatingModehView.btnState.Text;
                            //设备属性值,云雀上定义好的;
                            string keyVlaue = "mode";
                            selectedState = device.spk + "_"+ keyVlaue;
                            PublicInterface modeView = new PublicInterface();
                            var modeListStr = modeView.GetViewList("floorheatingmode");
                            modeView.SingleSelectionShow(this, modeListStr, Language.StringByID(StringId.modeLogic), currText
@@ -251,10 +300,7 @@
                                   //界面显示选中值
                                   floorHeatingModehView.btnState.Text = stateValue;
                                   //数据封装
                                   Dictionary<string, string> dic = new Dictionary<string, string>();
                                   LogicMethod.dictionary(dic, "key", keyVlaue);
                                   LogicMethod.dictionary(dic, "value", modeView.GetModeValueString(stateValue, "floorheatingmode"));
                                   AddDictionaryData(dicSateteList, keyVlaue, dic);
                                   AddDictionary(keyVlaue, modeView.GetModeValueString(stateValue, "floorheatingmode"));
                               });
                        };
@@ -273,8 +319,6 @@
            #region  保存点击事件
            saveView.btnClick.MouseUpEventHandler += (sen, e) =>
            {
                if (selectedState != "unknown")
                {
                    Output outputDevice = new Output();
@@ -471,17 +515,23 @@
            switchView.FLayoutView(frame, len, button.Text, (Action<string>)((strValue) =>
            {
                int id = 0;
                switch (strValue) {
                    case "on": {
                switch (strValue)
                {
                    case "on":
                        {
                            id = StringId.onLogic;
                        }
                        break;
                    case "off": {
                    case "off":
                        {
                            id = StringId.offLogic;
                        } break;
                    case "stop": {
                        }
                        break;
                    case "stop":
                        {
                            id = StringId.stop;
                        } break;
                        }
                        break;
                }
                //界面显示选中值
                button.TextID = id;
@@ -523,14 +573,12 @@
                    case SPK.LightRGBW:
                    case SPK.LightCCT:
                        {
                            LogicMethod.dictionary(dic, "key", "brightness");
                            keyVlaue = "brightness";
                        }
                        break;
                    case SPK.CurtainTrietex:
                    case SPK.CurtainRoller:
                        {
                            LogicMethod.dictionary(dic, "key", "percent");
                            keyVlaue = "percent";
                        }
                        break;
@@ -564,13 +612,26 @@
            InpOrOutLogicMethod.EditState(device, dicList, button1, button2, button3, button4);
        }
        /// <summary>
        /// 添加处理选中数据
        /// 添加选中数据
        /// </summary>
        /// <param name="dicList">存储数据列表</param>
        /// <param name="keyValue">识别设备</param>
        /// <param name="KeyValue">设备属性值,云雀上定义好的</param>
        /// <param name="selectedValue">状态值</param>
        private void AddDictionary(string KeyValue, string selectedValue)
        {
            //数据封装
            Dictionary<string, string> dic = new Dictionary<string, string>();
            LogicMethod.dictionary(dic, "key", KeyValue);
            LogicMethod.dictionary(dic, "value", selectedValue);
            AddDictionaryList(KeyValue, dic, dicSateteList);
        }
        /// <summary>
        /// 更新数据列表
        /// </summary>
        /// <param name="keyValue">设备属性值,云雀上定义好的</param>
        /// <param name="dictionary">选中数据</param>
        /// <param name="dicList">存储数据列表</param>
        /// <returns></returns>
        private void AddDictionaryData(List<Dictionary<string, string>> dicList, string keyValue, Dictionary<string, string> dictionary)
        private void AddDictionaryList(string keyValue, Dictionary<string, string> dictionary, List<Dictionary<string, string>> dicList)
        {
            int indexValue = -1;
            for (int i = 0; i < dicList.Count; i++)
@@ -625,7 +686,7 @@
            }
        }
    }