old mode 100755
new mode 100644
| | |
| | | /// 定义一个变量,记录选中状态 |
| | | /// </summary> |
| | | private string selectedState = "unknown"; |
| | | /// <summary> |
| | | /// 定义一个变量,记录选中状态记录属性 |
| | | /// </summary> |
| | | private string keyVlaue = ""; |
| | | public void Show(Entity.Function device, int index, bool edit) |
| | | { |
| | | #region 界面布局 |
| | |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(frame); |
| | | SwitchViewMethod(frame, device, lightSwitchView.btnState, 2); |
| | | 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); |
| | | |
| | | }); |
| | | }; |
| | | if (edit) |
| | | { |
| | |
| | | this.AddChidren(saveView.FLayoutView()); |
| | | saveView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | |
| | | |
| | | if (selectedState != "unknown") |
| | | { |
| | | Input inputDevice = new Input(); |
| | |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 开关功能展开界面 |
| | | /// </summary> |
| | | /// <param name="frame"></param> |
| | | /// <param name="device"></param> |
| | | /// <param name="button"></param> |
| | | /// <param name="len"></param> |
| | | public void SwitchViewMethod(FrameLayout frame, Entity.Function device, Button button, int len) |
| | | { |
| | | |
| | | LogicView.SwitchView switchView = new LogicView.SwitchView(); |
| | | switchView.FLayoutView(frame, len, button.Text, (strValue) => |
| | | { |
| | | int id = 0; |
| | | switch (strValue) |
| | | { |
| | | case "on": |
| | | { |
| | | id = StringId.onLogic; |
| | | } |
| | | break; |
| | | case "off": |
| | | { |
| | | id = StringId.offLogic; |
| | | } |
| | | break; |
| | | } |
| | | button.TextID = id; |
| | | keyVlaue = "on_off"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", "on_off"); |
| | | LogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.dictionary(dic, "value", strValue); |
| | | AddDictionaryData(dicSateteList, keyVlaue, dic); |
| | | selectedState = device.functionType + "_" + strValue; |
| | | |
| | | }); |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 显示编辑之前的设备状态 |
| | | /// </summary> |
| | | /// <param name="device">编辑设备</param> |
| | |
| | | /// <param name="button2">显示Btn</param> |
| | | /// <param name="button3">显示Btn</param> |
| | | /// <param name="button4">显示Btn</param> |
| | | private void GetEditState(Entity.Function device , int index, Button button1, Button button2, Button button3, Button button4) |
| | | private void GetEditState(Entity.Function device, int index, Button button1, Button button2, Button button3, Button button4) |
| | | { |
| | | Input inputs = Logic.currlogic.input[index]; |
| | | var dicList = inputs.condition as List<Dictionary<string, string>>; |
| | |
| | | //有数据重新赋值 |
| | | dicSateteList = dicList; |
| | | } |
| | | switch (device.functionType) |
| | | { |
| | | //开关灯光 light.Switch |
| | | case FunctionType.Dimmer: |
| | | case FunctionType.RGB: |
| | | case FunctionType.RGBW: |
| | | case FunctionType.ColorTemperature: |
| | | case FunctionType.Relay: |
| | | //窗帘 |
| | | case FunctionType.Curtain: |
| | | case FunctionType.RollingShutter: |
| | | case FunctionType.MotorCurtain: |
| | | //空调 |
| | | case FunctionType.AC: |
| | | //地热 |
| | | case FunctionType.FloorHeating: |
| | | { |
| | | foreach (var dic in dicList) |
| | | { |
| | | string value = dic["value"]; |
| | | if (value == "on") |
| | | { |
| | | button1.Text = Language.StringByID(StringId.onLogic); |
| | | } |
| | | else |
| | | { |
| | | button1.Text = Language.StringByID(StringId.offLogic); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | |
| | | } |
| | | 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, "comparator", "="); |
| | | LogicMethod.dictionary(dic, "data_type", "string"); |
| | | 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++) |
| | |
| | | Logic.currlogic.input.Add(input); |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 移除控件 |
| | | /// </summary> |
| | | /// <param name="frame"></param> |
| | | private void RemView(FrameLayout frame) |
| | | { |
| | | frame.RemoveFromParent(); |
| | | } |
| | | } |
| | | } |