| | |
| | | ///各种条件的View |
| | | LogicView.AddOutputInputView inputView = new LogicView.AddOutputInputView(); |
| | | inputView.FLayoutView(viewLayout); |
| | | //添加没有延时,隐藏延时按钮; |
| | | inputView.btnDelay.Visible = false; |
| | | ///记录条件类型 |
| | | inputView.btnClick.Name = inputCondition.condition_type; |
| | | ///记录条件索引 |
| | | inputView.btnClick.Tag = inputCondition; |
| | | inputView.btnClick.Tag = inputCondition.sid; |
| | | ///条件状态数组 |
| | | List<Dictionary<string, string>> dicList = inputCondition.condition; |
| | | List<Dictionary<string, string>> dicList = inputCondition.condition as List<Dictionary<string, string>>; |
| | | //显示条件各种类型状态 |
| | | switch (inputCondition.condition_type) |
| | | { |
| | |
| | | case "3": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(inputCondition.sid); |
| | | var device = LogicMethod.GetDevice(inputCondition.sid); |
| | | //用设备的functionType类型找到对应图标; |
| | | inputView.btnIcon.UnSelectedImagePath = LogicMethod.CurrLogicMethod.GetIconPath(device.spk); |
| | | inputView.btnIcon.UnSelectedImagePath = LogicMethod.GetIconPath(device.spk); |
| | | //显示设备名称 |
| | | inputView.btnText.Text = device.name; |
| | | //改变设备名称显示控件宽度 |
| | |
| | | { |
| | | if (value == "true") |
| | | { |
| | | str += Language.StringByID(StringId.youren) + ";"; |
| | | str+= Language.StringByID(StringId.youren)+";"; |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | } |
| | | break; |
| | | case SPK.SenesorEnvironment: |
| | | { |
| | | string strtext = ""; |
| | | foreach (var dic in dicList) |
| | | { |
| | | string key = dic["key"]; |
| | | string value = dic["value"]; |
| | | string comparator = dic["comparator"]; |
| | | switch (key) |
| | | { |
| | | |
| | | case "temperature": |
| | | { |
| | | if (comparator == ">") |
| | | { |
| | | strtext = ">" + value + "℃"; |
| | | } |
| | | else if (comparator == "<") |
| | | { |
| | | strtext = "<" + value + "℃"; |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case "humidity": |
| | | { |
| | | if (comparator == ">") |
| | | { |
| | | strtext = ">" + value + "%"; |
| | | } |
| | | else if (comparator == "<") |
| | | { |
| | | strtext = "<" + value + "%"; |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case "co2": |
| | | { |
| | | strtext = Language.StringByID(StringId.co2) + new PublicInterface { }.GetString("co2", value); |
| | | } |
| | | break; |
| | | case "pm25": |
| | | { |
| | | strtext = Language.StringByID(StringId.pm25) + new PublicInterface { }.GetString("pm25", value); |
| | | } |
| | | break; |
| | | case "tvoc": |
| | | { |
| | | strtext = Language.StringByID(StringId.tvoc) + new PublicInterface { }.GetString("tvoc", value); |
| | | } |
| | | break; |
| | | } |
| | | inputView.btnState.Text = strtext; |
| | | } |
| | | |
| | | |
| | | } |
| | | break; |
| | | |
| | | } |
| | | } |
| | |
| | | { |
| | | case "outdoor_temp": |
| | | { |
| | | strvalue = value + "℃"; |
| | | strvalue = value; |
| | | if (comparator == ">") |
| | | { |
| | | strtext = Language.StringByID(StringId.wendugaoyu); |
| | |
| | | break; |
| | | case "outdoor_humity": |
| | | { |
| | | strvalue = value + "%"; |
| | | strvalue = value; |
| | | if (comparator == ">") |
| | | { |
| | | strtext = Language.StringByID(StringId.shidugaoyu); |
| | |
| | | case "pm2.5": |
| | | { |
| | | strtext = Language.StringByID(StringId.PM25); |
| | | strvalue = new PublicInterface { }.GetString("pm25", value); |
| | | strvalue = new OutdoorEnvironment { }.GetString(value); |
| | | } |
| | | break; |
| | | |
| | |
| | | } |
| | | } |
| | | break; |
| | | case "9": |
| | | { |
| | | inputView.btnIcon.UnSelectedImagePath = "LogicIcon/changesinoutdoor.png"; |
| | | foreach (var dic in dicList) |
| | | { |
| | | string strtext = ""; |
| | | string value = dic["value"]; |
| | | switch (value) |
| | | { |
| | | case "excellent": |
| | | { |
| | | strtext = Language.StringByID(StringId.kongqiyou); |
| | | |
| | | } |
| | | break; |
| | | case "good": |
| | | { |
| | | |
| | | strtext = Language.StringByID(StringId.kongqiliang); |
| | | |
| | | } |
| | | break; |
| | | case "poor": |
| | | { |
| | | strtext = Language.StringByID(StringId.kongqicha); |
| | | } |
| | | break; |
| | | |
| | | } |
| | | inputView.btnText.TextID = StringId.kongqizhiliang; |
| | | inputView.btnState.Text = strtext; |
| | | } |
| | | } |
| | | break; |
| | | |
| | | } |
| | | //再次编辑条件状态点击事件 |
| | | inputView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | Button button = (Button)sen; |
| | | //当前编辑的条件 |
| | | Input ckcliInput = inputView.btnClick.Tag as Input; |
| | | //找到当前编辑的索引 |
| | | int indexVulae = 0; |
| | | for (int index = 0; index < Logic.currlogic.input.Count; index++) |
| | | { |
| | | Input input = Logic.currlogic.input[index]; |
| | | if (input.sid == ckcliInput.sid) |
| | | if (input.sid == inputView.btnClick.Tag.ToString()) |
| | | { |
| | | if (button.Name == "3") |
| | | { |
| | | //有些设备比较特殊(例如:海林传感器还是要判断属性值,温湿度属性还要判断比较关系,才能确认是否已经存在该条件,其他设备条件直接用sid判断即可) |
| | | //加一级判断是为兼容特殊设备 |
| | | if (new ConditionDeviceFunList { }.IsContainsAll(ckcliInput.condition, input.condition)) |
| | | { |
| | | //用户可能删除数据,使列表索引发生改变; |
| | | //通过唯一sid重新查找到索引且更新索引值 |
| | | indexVulae = index; |
| | | break; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //用户可能删除数据,使列表索引发生改变; |
| | | //通过唯一sid重新查找到索引且更新索引值 |
| | | indexVulae = index; |
| | | break; |
| | | } |
| | | //用户可能删除数据,使列表索引发生改变; |
| | | //通过唯一sid重新查找到索引且更新索引值 |
| | | indexVulae = index; |
| | | break; |
| | | } |
| | | } |
| | | //标记编辑状态 |
| | |
| | | Input _input = Logic.currlogic.input[indexVulae]; |
| | | if (_input.condition_type == "1") |
| | | { |
| | | var dicLists = _input.condition; |
| | | var dicLists = _input.condition as List<Dictionary<string, string>>; |
| | | foreach (var dic in dicLists) |
| | | { |
| | | string keyValue = dic["key"]; |
| | |
| | | case "3": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(inputCondition.sid); |
| | | if (device.spk == SPK.SenesorEnvironment) |
| | | { |
| | | //这个设备比较特殊 |
| | | ConditionDeviceFunList conditionDeviceFunList = new ConditionDeviceFunList(); |
| | | ///当前的索引值数据对象 |
| | | Input inputedit = Logic.currlogic.input[indexVulae]; |
| | | ///状态值 |
| | | string stateValue = ""; |
| | | foreach (var dic in inputedit.condition) |
| | | { |
| | | string key = dic["key"]; |
| | | string comparator = dic["comparator"]; |
| | | stateValue = dic["value"]; |
| | | switch (key) |
| | | { |
| | | |
| | | case "temperature": |
| | | { |
| | | int titleInt = 0; |
| | | if (comparator == ">") |
| | | { |
| | | titleInt = StringId.wendugaoyu; |
| | | } |
| | | else if (comparator == "<") |
| | | { |
| | | titleInt = StringId.wendudiyu; |
| | | } |
| | | conditionDeviceFunList.InputBoxAction(device, titleInt, indexVulae, true, stateValue); |
| | | } |
| | | break; |
| | | case "humidity": |
| | | { |
| | | int titleInt = 0; |
| | | if (comparator == ">") |
| | | { |
| | | titleInt = StringId.shidugaoyu; |
| | | } |
| | | else if (comparator == "<") |
| | | { |
| | | titleInt = StringId.shidudiyu; |
| | | } |
| | | conditionDeviceFunList.InputBoxAction(device, titleInt, indexVulae, true, stateValue); |
| | | } |
| | | break; |
| | | case "co2": |
| | | { |
| | | conditionDeviceFunList.PmCo2TvocAction(thisView, device, "co2", StringId.co2, indexVulae, true, stateValue); |
| | | } |
| | | break; |
| | | case "pm25": |
| | | { |
| | | conditionDeviceFunList.PmCo2TvocAction(thisView, device, "pm25", StringId.pm25, indexVulae, true, stateValue); |
| | | |
| | | } |
| | | break; |
| | | case "tvoc": |
| | | { |
| | | conditionDeviceFunList.PmCo2TvocAction(thisView, device, "tvoc", StringId.tvoc, indexVulae, true, stateValue); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | ConditionDeviceFunList deviceFunList = new ConditionDeviceFunList(); |
| | | MainPage.BasePageView.AddChidren(deviceFunList); |
| | | deviceFunList.Show(device, indexVulae, edit); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | } |
| | | var device = LogicMethod.GetDevice(inputCondition.sid); |
| | | ConditionDeviceFunList deviceFunList = new ConditionDeviceFunList(); |
| | | MainPage.BasePageView.AddChidren(deviceFunList); |
| | | deviceFunList.Show(device, indexVulae, edit); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | } |
| | | break; |
| | | case "4": |
| | |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | } |
| | | break; |
| | | case "9": |
| | | { |
| | | |
| | | AirQuality airQuality = new AirQuality(); |
| | | MainPage.BasePageView.AddChidren(airQuality); |
| | | airQuality.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | } |
| | | break; |
| | | } |
| | | }; |
| | | ///删除控件 |
| | |
| | | ///记录条件索引 |
| | | targetView.btnClick.Tag = outputTarget.sid; |
| | | ///条件状态数组 |
| | | List<Dictionary<string, string>> dicList = outputTarget.status; |
| | | //显示状态值 |
| | | string stateStr = ""; |
| | | List<Dictionary<string, string>> dicList = outputTarget.status as List<Dictionary<string, string>>; |
| | | //显示输出条件各种类型状态 |
| | | switch (outputTarget.target_type) |
| | | { |
| | | case "1": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid); |
| | | var device = LogicMethod.GetDevice(outputTarget.sid); |
| | | //用设备的functionType类型找到对应图标; |
| | | targetView.btnIcon.UnSelectedImagePath = LogicMethod.CurrLogicMethod.GetIconPath(device.spk); |
| | | targetView.btnIcon.UnSelectedImagePath = LogicMethod.GetIconPath(device.spk); |
| | | //显示设备名称 |
| | | targetView.btnText.Text = device.name; |
| | | //改变设备名称显示控件宽度 |
| | | targetView.btnText.Width = Application.GetRealWidth(80); |
| | | |
| | | //第一个变量显示状态值 |
| | | string stateStr = ""; |
| | | //区别不同设备,显示不同设备状态 |
| | | switch (device.spk) |
| | | { |
| | |
| | | stateStr = Language.StringByID(StringId.offLogic); |
| | | } |
| | | } |
| | | targetView.btnState.Text = stateStr; |
| | | } |
| | | break; |
| | | case SPK.LightRGB: |
| | |
| | | { |
| | | stateStr = brightness + "%"; |
| | | } |
| | | |
| | | targetView.btnState.Text = stateStr; |
| | | } |
| | | break; |
| | | case SPK.CurtainSwitch: |
| | |
| | | break; |
| | | } |
| | | } |
| | | targetView.btnState.Text = stateStr; |
| | | } |
| | | break; |
| | | case SPK.AcStandard: |
| | |
| | | } |
| | | if (on_off != "" && on_off == "off") |
| | | { |
| | | stateStr = Language.StringByID(StringId.offLogic); |
| | | targetView.btnState.Text = Language.StringByID(StringId.offLogic); |
| | | } |
| | | else |
| | | { |
| | | stateStr = stateStr.TrimEnd(','); |
| | | targetView.btnState.Text = stateStr.TrimEnd(','); |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | if (on_off != "" && on_off == "off") |
| | | { |
| | | stateStr = Language.StringByID(StringId.offLogic); |
| | | targetView.btnState.Text = Language.StringByID(StringId.offLogic); |
| | | } |
| | | else |
| | | { |
| | | stateStr = stateStr.TrimEnd(','); |
| | | targetView.btnState.Text = stateStr.TrimEnd(','); |
| | | |
| | | } |
| | | } |
| | |
| | | case "2": |
| | | { |
| | | //用sid找到场景; |
| | | var scene = LogicMethod.CurrLogicMethod.GetSecne(outputTarget.sid); |
| | | var scene = LogicMethod.GetSecne(outputTarget.sid); |
| | | targetView.btnIcon.UnSelectedImagePath = "LogicIcon/scene.png"; |
| | | targetView.btnNextIcon.Visible = false; |
| | | //显示场景名称 |
| | | stateStr = scene.name; |
| | | targetView.btnText.Text = scene.name; |
| | | } |
| | | break; |
| | | case "3": |
| | |
| | | foreach (var dic in dicList) |
| | | { |
| | | string value = dic["value"]; |
| | | stateStr = value; |
| | | targetView.btnText.Text = value; |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | |
| | | if (outputTarget.target_type == "1") |
| | | { |
| | | targetView.btnState.Text =new InpOrOutLogicMethod { }.GetTimeText(outputTarget.delay) + stateStr; |
| | | } |
| | | else |
| | | { |
| | | targetView.btnText.Text = new InpOrOutLogicMethod { }.GetTimeText(outputTarget.delay) + stateStr; |
| | | } |
| | | //再次编辑条件状态点击事件 |
| | | targetView.btnClick.MouseUpEventHandler += (sen, e) => |
| | |
| | | case "1": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid); |
| | | var device = LogicMethod.GetDevice(outputTarget.sid); |
| | | TargetDeviceFunList deviceFunList = new TargetDeviceFunList(); |
| | | MainPage.BasePageView.AddChidren(deviceFunList); |
| | | deviceFunList.Show(device, indexVulae, edit); |
| | |
| | | } |
| | | break; |
| | | } |
| | | }; |
| | | //延时点击事件 |
| | | targetView.btnDelay.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | |
| | | InpOrOutLogicMethod inpOrOutLogicMethod = new InpOrOutLogicMethod(); |
| | | inpOrOutLogicMethod.Delayed(thisView, outputTarget, (value) => |
| | | { |
| | | outputTarget.delay = value.ToString(); |
| | | if (outputTarget.target_type == "1") |
| | | { |
| | | targetView.btnState.Text = new InpOrOutLogicMethod { }.GetTimeText(outputTarget.delay) + stateStr; |
| | | } |
| | | else |
| | | { |
| | | targetView.btnText.Text = new InpOrOutLogicMethod { }.GetTimeText(outputTarget.delay) + stateStr; |
| | | } |
| | | }); |
| | | |
| | | }; |
| | | ///删除控件 |
| | | targetView.btnDel.MouseUpEventHandler += (sender, e) => |
| | |
| | | break; |
| | | case "brightness": |
| | | { |
| | | if (button2 == null) |
| | | { |
| | | //怕调试软件乱上东西导致抛异常 |
| | | break; |
| | | } |
| | | |
| | | button2.Text = value + "%"; |
| | | } |
| | | break; |
| | |
| | | break; |
| | | case "set_temp": |
| | | { |
| | | if (button2 == null) |
| | | { |
| | | //怕调试软件乱上东西导致抛异常 |
| | | break; |
| | | } |
| | | button2.Text = value + "℃"; |
| | | } |
| | | break; |
| | | case "mode": |
| | | { |
| | | if (button3 == null) |
| | | { |
| | | //怕调试软件乱上东西导致抛异常 |
| | | break; |
| | | } |
| | | switch (value) |
| | | { |
| | | case "cool": |
| | |
| | | break; |
| | | case "fan": |
| | | { |
| | | if (button4 == null) |
| | | { |
| | | //怕调试软件乱上东西导致抛异常 |
| | | break; |
| | | } |
| | | switch (value) |
| | | { |
| | | case "high": |
| | |
| | | break; |
| | | case "set_temp": |
| | | { |
| | | if (button2 == null) |
| | | { |
| | | //怕调试软件乱上东西导致抛异常 |
| | | break; |
| | | } |
| | | button2.Text = value + "℃"; |
| | | } |
| | | break; |
| | | case "mode": |
| | | { |
| | | if (button3 == null) |
| | | { |
| | | //怕调试软件乱上东西导致抛异常 |
| | | break; |
| | | } |
| | | switch (value) |
| | | { |
| | | case "day": |
| | |
| | | case "3": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(inputCondition.sid); |
| | | var device = LogicMethod.GetDevice(inputCondition.sid); |
| | | name = device.name + "-"; |
| | | } |
| | | break; |
| | |
| | | case "1": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid); |
| | | var device = LogicMethod.GetDevice(outputTarget.sid); |
| | | //显示设备名称 |
| | | name += device.name; |
| | | string stateStr = ""; |
| | |
| | | case "2": |
| | | { |
| | | //用sid找到场景; |
| | | var scene = LogicMethod.CurrLogicMethod.GetSecne(outputTarget.sid); |
| | | var scene = LogicMethod.GetSecne(outputTarget.sid); |
| | | name += scene.name; |
| | | |
| | | } |
| | |
| | | catch { } |
| | | return name; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 延时时间方法 |
| | | /// </summary> |
| | | /// <param name="fLayout">在哪个界面显示</param> |
| | | /// <param name="edit">(true=编辑;false=新建)</param> |
| | | /// <param name="index">编辑条件的索引</param> |
| | | private void Delayed(FrameLayout thisFLayout, Output output, Action<int> action) |
| | | { |
| | | FrameLayout fLayout = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | thisFLayout.AddChidren(fLayout); |
| | | LogicView.TimeView timePointView = new LogicView.TimeView(); |
| | | timePointView.FLayoutView(fLayout); |
| | | EventHandler<MouseEventArgs> RemovefLayout = (sender, e1) => |
| | | { |
| | | //移除fLayout界面 |
| | | fLayout.RemoveFromParent(); |
| | | }; |
| | | //取消点击事件 |
| | | timePointView.btnCancel.MouseUpEventHandler += RemovefLayout; |
| | | |
| | | //加载数据界面的设置方法(列表互不联动) |
| | | timePointView.mUIPickerView.setNPicker(timePointView.GetmStringList(), timePointView.GetsStringList(), null); |
| | | //默认初始选中状态 |
| | | timePointView.mUIPickerView.setCurrentItems(0, 5, 0); |
| | | //定义一个局部变量记录选中时间 |
| | | int timepoint = 5; |
| | | |
| | | if (output.delay != "0") |
| | | { |
| | | int intValue = int.Parse(output.delay); |
| | | var m = intValue / 60; |
| | | var s = intValue % 60; |
| | | |
| | | string timeValue = m.ToString() + ":" + s.ToString(); |
| | | int mIndex = timePointView.GetValueIndex(timeValue, 0, 1, timePointView.GetmIntList()); |
| | | int sIndex = timePointView.GetValueIndex(timeValue, 1, 0, timePointView.GetmIntList()); |
| | | //更新初始状态 |
| | | timePointView.mUIPickerView.setCurrentItems(mIndex, sIndex, 0); |
| | | timepoint = intValue; |
| | | } |
| | | |
| | | |
| | | //选中时间回调方法,时间变化一次回调一次 |
| | | timePointView.mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) => |
| | | { |
| | | string minuet = timePointView.GethStringList0()[index1].Split(' ')[0]; |
| | | string second = timePointView.GetmStringList()[index2].Split(' ')[0]; |
| | | int minuetIntValue = int.Parse(minuet); |
| | | int secondIntValue = int.Parse(second); |
| | | timepoint = minuetIntValue * 60 + secondIntValue; |
| | | }; |
| | | //确定点击事件 |
| | | timePointView.btnConfirm.MouseUpEventHandler += (sender, e3) => |
| | | { |
| | | if (timepoint == 0) |
| | | { |
| | | //提示 |
| | | return; |
| | | } |
| | | fLayout.RemoveFromParent(); |
| | | action(timepoint); |
| | | }; |
| | | } |
| | | /// <summary> |
| | | /// 获取时间文本描述 |
| | | /// </summary> |
| | | /// <param name="strTimeValue">时间值(单位s秒)</param> |
| | | /// <returns></returns> |
| | | private string GetTimeText(string strTimeValue) |
| | | { |
| | | var timeValue = int.Parse(strTimeValue); |
| | | string state = ""; |
| | | var minutes = timeValue / 60; |
| | | var seconds = timeValue % 60; |
| | | if (minutes != 0) |
| | | { |
| | | if (seconds == 0) |
| | | { |
| | | state = minutes.ToString() + Language.StringByID(StringId.minute); |
| | | } |
| | | else |
| | | { |
| | | state = minutes.ToString() + Language.StringByID(StringId.minute) + seconds.ToString() + Language.StringByID(StringId.s); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (seconds != 0) |
| | | { |
| | | state = seconds.ToString() + Language.StringByID(StringId.s); |
| | | } |
| | | } |
| | | if (!string.IsNullOrEmpty(state)) { |
| | | state = Language.StringByID(StringId.delayLogic) + state; |
| | | } |
| | | return state; |
| | | } |
| | | |
| | | } |
| | | } |