| | |
| | | ///各种条件的View |
| | | LogicView.AddOutputInputView inputView = new LogicView.AddOutputInputView(); |
| | | inputView.FLayoutView(viewLayout); |
| | | //添加没有延时,隐藏延时按钮; |
| | | inputView.btnDelay.Visible = false; |
| | | ///记录条件类型 |
| | | inputView.btnClick.Name = inputCondition.condition_type; |
| | | ///记录条件索引 |
| | | inputView.btnClick.Tag = inputCondition.sid; |
| | | inputView.btnClick.Tag = inputCondition; |
| | | ///条件状态数组 |
| | | List<Dictionary<string, string>> dicList = inputCondition.condition as List<Dictionary<string, string>>; |
| | | List<Dictionary<string, string>> dicList = inputCondition.condition; |
| | | //显示条件各种类型状态 |
| | | switch (inputCondition.condition_type) |
| | | { |
| | |
| | | case "3": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.GetDevice(inputCondition.sid); |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(inputCondition.sid); |
| | | //用设备的functionType类型找到对应图标; |
| | | inputView.btnIcon.UnSelectedImagePath = LogicMethod.GetIconPath(device.spk); |
| | | inputView.btnIcon.UnSelectedImagePath = LogicMethod.CurrLogicMethod.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 OutdoorEnvironment { }.GetString(value); |
| | | strvalue = new PublicInterface { }.GetString("pm25", 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 == inputView.btnClick.Tag.ToString()) |
| | | if (input.sid == ckcliInput.sid) |
| | | { |
| | | //用户可能删除数据,使列表索引发生改变; |
| | | //通过唯一sid重新查找到索引且更新索引值 |
| | | indexVulae = index; |
| | | break; |
| | | if (button.Name == "3") |
| | | { |
| | | //有些设备比较特殊(例如:海林传感器还是要判断属性值,温湿度属性还要判断比较关系,才能确认是否已经存在该条件,其他设备条件直接用sid判断即可) |
| | | //加一级判断是为兼容特殊设备 |
| | | if (new ConditionDeviceFunList { }.IsContainsAll(ckcliInput.condition, input.condition)) |
| | | { |
| | | //用户可能删除数据,使列表索引发生改变; |
| | | //通过唯一sid重新查找到索引且更新索引值 |
| | | indexVulae = index; |
| | | break; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //用户可能删除数据,使列表索引发生改变; |
| | | //通过唯一sid重新查找到索引且更新索引值 |
| | | indexVulae = index; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | //标记编辑状态 |
| | |
| | | Input _input = Logic.currlogic.input[indexVulae]; |
| | | if (_input.condition_type == "1") |
| | | { |
| | | var dicLists = _input.condition as List<Dictionary<string, string>>; |
| | | var dicLists = _input.condition; |
| | | foreach (var dic in dicLists) |
| | | { |
| | | string keyValue = dic["key"]; |
| | |
| | | case "3": |
| | | { |
| | | //用sid找到设备; |
| | | 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; |
| | | 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; |
| | | } |
| | | } |
| | | 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 as List<Dictionary<string, string>>; |
| | | List<Dictionary<string, string>> dicList = outputTarget.status; |
| | | //显示状态值 |
| | | string stateStr = ""; |
| | | //显示输出条件各种类型状态 |
| | |
| | | case "1": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.GetDevice(outputTarget.sid); |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid); |
| | | //用设备的functionType类型找到对应图标; |
| | | targetView.btnIcon.UnSelectedImagePath = LogicMethod.GetIconPath(device.spk); |
| | | targetView.btnIcon.UnSelectedImagePath = LogicMethod.CurrLogicMethod.GetIconPath(device.spk); |
| | | //显示设备名称 |
| | | targetView.btnText.Text = device.name; |
| | | //改变设备名称显示控件宽度 |
| | | targetView.btnText.Width = Application.GetRealWidth(80); |
| | | |
| | | |
| | | //区别不同设备,显示不同设备状态 |
| | | switch (device.spk) |
| | | { |
| | |
| | | { |
| | | stateStr = brightness + "%"; |
| | | } |
| | | |
| | | |
| | | } |
| | | break; |
| | | case SPK.CurtainSwitch: |
| | |
| | | case "2": |
| | | { |
| | | //用sid找到场景; |
| | | var scene = LogicMethod.GetSecne(outputTarget.sid); |
| | | var scene = LogicMethod.CurrLogicMethod.GetSecne(outputTarget.sid); |
| | | targetView.btnIcon.UnSelectedImagePath = "LogicIcon/scene.png"; |
| | | targetView.btnNextIcon.Visible = false; |
| | | //显示场景名称 |
| | |
| | | } |
| | | else |
| | | { |
| | | targetView.btnText.Text = new InpOrOutLogicMethod { }.GetTimeText(outputTarget.delay)+ stateStr; |
| | | targetView.btnText.Text = new InpOrOutLogicMethod { }.GetTimeText(outputTarget.delay) + stateStr; |
| | | } |
| | | //再次编辑条件状态点击事件 |
| | | targetView.btnClick.MouseUpEventHandler += (sen, e) => |
| | |
| | | case "1": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.GetDevice(outputTarget.sid); |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid); |
| | | TargetDeviceFunList deviceFunList = new TargetDeviceFunList(); |
| | | MainPage.BasePageView.AddChidren(deviceFunList); |
| | | deviceFunList.Show(device, indexVulae, edit); |
| | |
| | | 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.GetDevice(inputCondition.sid); |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(inputCondition.sid); |
| | | name = device.name + "-"; |
| | | } |
| | | break; |
| | |
| | | case "1": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.GetDevice(outputTarget.sid); |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid); |
| | | //显示设备名称 |
| | | name += device.name; |
| | | string stateStr = ""; |
| | |
| | | case "2": |
| | | { |
| | | //用sid找到场景; |
| | | var scene = LogicMethod.GetSecne(outputTarget.sid); |
| | | var scene = LogicMethod.CurrLogicMethod.GetSecne(outputTarget.sid); |
| | | name += scene.name; |
| | | |
| | | } |
| | |
| | | /// <param name="fLayout">在哪个界面显示</param> |
| | | /// <param name="edit">(true=编辑;false=新建)</param> |
| | | /// <param name="index">编辑条件的索引</param> |
| | | private void Delayed(FrameLayout thisFLayout, Output output,Action<int>action) |
| | | private void Delayed(FrameLayout thisFLayout, Output output, Action<int> action) |
| | | { |
| | | FrameLayout fLayout = new FrameLayout |
| | | { |
| | |
| | | string second = timePointView.GetmStringList()[index2].Split(' ')[0]; |
| | | int minuetIntValue = int.Parse(minuet); |
| | | int secondIntValue = int.Parse(second); |
| | | timepoint = minuetIntValue*60+secondIntValue; |
| | | timepoint = minuetIntValue * 60 + secondIntValue; |
| | | }; |
| | | //确定点击事件 |
| | | timePointView.btnConfirm.MouseUpEventHandler += (sender, e3) => |
| | | { |
| | | if (timepoint==0) |
| | | if (timepoint == 0) |
| | | { |
| | | //提示 |
| | | return; |
| | |
| | | state = seconds.ToString() + Language.StringByID(StringId.s); |
| | | } |
| | | } |
| | | if (!string.IsNullOrEmpty(state)) { |
| | | state = Language.StringByID(StringId.delayLogic) + state; |
| | | } |
| | | return state; |
| | | } |
| | | |
| | | } |
| | | } |