wxr
2021-01-04 c4f0723cc7053933a6e598eb0c58cfdf4e9d7459
HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs
@@ -51,14 +51,57 @@
                case FunctionType.RGBW:
                case FunctionType.ColorTemperature:
                    {
                        //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 FunctionType.Relay:
                    {
                        //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;
                //窗帘
@@ -66,8 +109,24 @@
                case FunctionType.MotorCurtain:
                case FunctionType.RollingShutter:
                    {
                        //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 FunctionType.AC:
@@ -107,19 +166,17 @@
                        {
                            ///之前的状态文本
                            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.functionType + "_"+ keyVlaue;
                                selectedState = device.functionType + "_" + 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);
                            });
@@ -131,20 +188,16 @@
                            string currText = acModehView.btnState.Text;
                            //设备属性值,云雀上定义好的;
                            string keyVlaue = "mode";
                            selectedState = device.functionType + "_"+keyVlaue;
                            selectedState = device.functionType + "_" + 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));
                               });
                        };
@@ -165,10 +218,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));
                               });
                        };
@@ -207,6 +257,7 @@
                        ///开关点击事件
                        floorHeatingSwitchVie.btnClick.MouseUpEventHandler += (sender, e) =>
                        {
                            SwitchViewMethod(device, floorHeatingSwitchVie.btnState, 2);
                        };
                        ///温度点击事件
@@ -214,33 +265,30 @@
                        {
                            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;
                                //设备属性值,云雀上定义好的;
                                string keyVlaue = "set_temp";
                                selectedState = device.functionType + "_"+ keyVlaue;
                                selectedState = device.functionType + "_" + 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.functionType + "_"+ keyVlaue;
                            selectedState = device.functionType + "_" + keyVlaue;
                            PublicInterface modeView = new PublicInterface();
                            var modeListStr = modeView.GetViewList("floorheatingmode");
                            modeView.SingleSelectionShow(this, modeListStr, Language.StringByID(StringId.modeLogic), currText
@@ -249,10 +297,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"));
                               });
                        };
@@ -271,8 +316,6 @@
            #region  保存点击事件
            saveView.btnClick.MouseUpEventHandler += (sen, e) =>
            {
                if (selectedState != "unknown")
                {
                    Output outputDevice = new Output();
@@ -372,85 +415,6 @@
            #endregion
        }
        /// <summary>
        ///开关=界面
        /// </summary>
        /// <param name="fLayout"></param>
        /// <param name="device"></param>
        /// <param name="index"></param>
        /// <param name="edit"></param>
        /// <param name="intView">选中View的数量</param>
        private void SwitchView(FrameLayout fLayout, Entity.Function device, int index, bool edit, int intView)
        {
            #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, intView);
            };
            if (edit)
            {
                //显示编辑之前的设备状态
                GetEditState(device, index, curtainSwitchView.btnState, null, null, null);
            }
            #endregion
        }
        /// <summary>
        ///(开关+亮度/百分比)界面
        /// </summary>
        /// <param name="fLayout"></param>
        /// <param name="device"></param>
        /// <param name="index"></param>
        /// <param name="edit"></param>
        /// <param name="intView">选中View的数量</param>
        private void SwitchBrightnessView(FrameLayout fLayout, Entity.Function device, int index, bool edit, int intView)
        {
            #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;
            if (device.functionType == FunctionType.MotorCurtain || device.functionType == FunctionType.RollingShutter)
            {
                brightnessView.btnText.TextID = StringId.percentum;
            }
            else
            {
                brightnessView.btnText.TextID = StringId.brightnesLogic;
            }
            fLayout.AddChidren(brightnessView.FLayoutView());
            #endregion
            #region 点击事件
            ///开关点击事件
            lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
            {
                SwitchViewMethod(device, lightSwitchView.btnState, intView);
            };
            ///亮度点击事件
            brightnessView.btnClick.MouseUpEventHandler += (sender, e) =>
            {
                BrightnessMethod(device, brightnessView.btnState, brightnessView.btnText.Text);
            };
            if (edit)
            {
                //显示编辑之前的设备状态
                GetEditState(device, index, lightSwitchView.btnState, brightnessView.btnState, null, null);
            }
            #endregion
        }
        /// <summary>
        /// 开关=功能下一级界面
        /// </summary>
@@ -469,28 +433,31 @@
            switchView.FLayoutView(frame, len, button.Text, (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;
                selectedState = device.functionType + "_" + strValue;
                //设备属性值,云雀上定义好的;
                string keyVlaue = "on_off";
                //数据封装
                Dictionary<string, string> dic = new Dictionary<string, string>();
                LogicMethod.dictionary(dic, "key", "on_off");
                LogicMethod.dictionary(dic, "value", strValue);
                AddDictionaryData(dicSateteList, keyVlaue, dic);
                AddDictionary(keyVlaue, strValue);
            });
            #endregion
        }
@@ -508,11 +475,10 @@
            brightness.FLayoutView(this, titleName, stateVlaue, (brightnesValue) =>
            {
                //界面显示选中值
                button.Text = brightnesValue+"%";
                string keyVlaue = "";
                button.Text = brightnesValue + "%";
                selectedState = device.functionType + brightnesValue.ToString();
                //数据封装
                Dictionary<string, string> dic = new Dictionary<string, string>();
                //设备属性值,云雀上定义好的;
                string keyVlaue = "";
                switch (device.functionType)
                {
                    //开关灯光 light.Switch
@@ -521,20 +487,18 @@
                    case FunctionType.RGBW:
                    case FunctionType.ColorTemperature:
                        {
                            LogicMethod.dictionary(dic, "key", "brightness");
                            keyVlaue = "brightness";
                        }
                        break;
                    case FunctionType.MotorCurtain:
                    case FunctionType.RollingShutter:
                        {
                            LogicMethod.dictionary(dic, "key", "percent");
                            keyVlaue = "percent";
                        }
                        break;
                }
                LogicMethod.dictionary(dic, "value", brightnesValue.ToString());
                AddDictionaryData(dicSateteList, keyVlaue, dic);
                //数据封装
                AddDictionary(keyVlaue, brightnesValue);
            });
            #endregion
@@ -562,13 +526,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++)
@@ -623,7 +600,7 @@
            }
        }
    }