| | |
| | | Tag = "Logic"; |
| | | } |
| | | |
| | | public void Show(Entity.Function device) |
| | | public void Show(Entity.Function device, int index, bool edit) |
| | | { |
| | | #region 界面布局 |
| | | this.BackgroundColor = CSS.CSS_Color.viewMiddle; |
| | | LogicView.TopView topView = new LogicView.TopView(); |
| | | this.AddChidren(topView.FLayoutView()); |
| | |
| | | Height = Application.GetRealHeight(667 - 64), |
| | | }; |
| | | this.AddChidren(fLayout); |
| | | |
| | | Input inputdevice = new Input(); |
| | | inputdevice.condition_type = "3"; |
| | | inputdevice.sid = device.sid; |
| | | |
| | | #endregion |
| | | |
| | | //定义一个变量,记录选中状态 |
| | | string selectedState = "unknown"; |
| | | |
| | | Input inputdevice = new Input(); |
| | | inputdevice.condition_type = "3"; |
| | | inputdevice.sid = device.sid; |
| | | |
| | | |
| | | switch (device.functionType) |
| | | { |
| | | //开关灯光 |
| | | case FunctionType.Relay: |
| | | { |
| | | |
| | | |
| | | |
| | | //for (int i = 0; i < device.function.Count; i++) |
| | | //{ |
| | | //} |
| | |
| | | relayView.btnState.Visible = true; |
| | | relayView.btnText.TextSize = LogicView.TextSize.text16; |
| | | relayView.btnText.Height = Application.GetRealHeight(22); |
| | | relayView.btnText.TextID =StringId.switchLogic; |
| | | relayView.btnText.TextID = StringId.switchLogic; |
| | | relayView.btnText.X = Application.GetRealWidth(16); |
| | | relayView.btnText.Width= Application.GetRealWidth(130); |
| | | relayView.btnText.Width = Application.GetRealWidth(130); |
| | | relayView.btnLine.X = Application.GetRealWidth(16); |
| | | relayView.btnLine.Width = Application.GetRealWidth(343); |
| | | fLayout.AddChidren(relayView.FLayoutView()); |
| | |
| | | this.AddChidren(relayFunView); |
| | | LogicView.SwitchView switchView = new LogicView.SwitchView(); |
| | | switchView.FLayoutView(relayFunView, 2); |
| | | |
| | | |
| | | Button btnOn = new Button |
| | | { |
| | | TextAlignment = TextAlignment.Center, |
| | |
| | | LogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.dictionary(dic, "data_type", "string"); |
| | | inputdevice.condition.Add(dic); |
| | | btnOn.MouseUpEventHandler += (sender2, e2) => { |
| | | btnOn.MouseUpEventHandler += (sender2, e2) => |
| | | { |
| | | LogicMethod.dictionary(dic, "value", "on"); |
| | | RemView(relayFunView); |
| | | relayView.btnState.TextID = StringId.onLogic; |
| | | selectedState = device.functionType + "_on"; |
| | | }; |
| | | btnOff.MouseUpEventHandler += (sender3, e3) => { |
| | | btnOff.MouseUpEventHandler += (sender3, e3) => |
| | | { |
| | | LogicMethod.dictionary(dic, "value", "off"); |
| | | RemView(relayFunView); |
| | | relayView.btnState.TextID = StringId.offLogic; |
| | | selectedState = device.functionType + "_off"; |
| | | }; |
| | | |
| | | }; |
| | | if (edit) |
| | | { |
| | | Input inputs = Logic.currlogic.input[index]; |
| | | if (inputs.condition_type == "3") |
| | | { |
| | | List<Dictionary<string, string>> dicList = inputs.condition as List<Dictionary<string, string>>; |
| | | foreach (var dic in dicList) |
| | | { |
| | | string value = dic["value"]; |
| | | if (value == "on") |
| | | { |
| | | relayView.btnState.Text = Language.StringByID(StringId.onLogic); |
| | | |
| | | } |
| | | else |
| | | { |
| | | relayView.btnState.Text = Language.StringByID(StringId.offLogic); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | break; |
| | |
| | | this.AddChidren(saveView.FLayoutView()); |
| | | saveView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | //if (edit) |
| | | //{ |
| | | // //移除旧数据 |
| | | // Logic.currlogic.input.RemoveAt(index); |
| | | // //新数据插入旧数据的位置; |
| | | // Logic.currlogic.input.Insert(index, inputdevice); |
| | | //} |
| | | //else |
| | | //{ |
| | | // //添加一个新的时间点条件 |
| | | // Logic.currlogic.input.Add(inputdevice); |
| | | //} |
| | | |
| | | //添加一个新的时间点条件 |
| | | Logic.currlogic.input.Add(inputdevice); |
| | | if (selectedState != "unknown") |
| | | { |
| | | if (edit) |
| | | { |
| | | //移除旧数据 |
| | | Logic.currlogic.input.RemoveAt(index); |
| | | //新数据插入旧数据的位置; |
| | | Logic.currlogic.input.Insert(index, inputdevice); |
| | | } |
| | | else |
| | | { |
| | | //添加一个新的时间点条件 |
| | | Logic.currlogic.input.Add(inputdevice); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (!edit) |
| | | { |
| | | //提示用户 |
| | | return; |
| | | } |
| | | this.RemoveFromParent(); |
| | | return; |
| | | } |
| | | RemoveViewByTag("Logic"); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | |
| | | /// 移除控件 |
| | | /// </summary> |
| | | /// <param name="frame"></param> |
| | | public void RemView(FrameLayout frame) { |
| | | public void RemView(FrameLayout frame) |
| | | { |
| | | frame.RemoveFromParent(); |
| | | } |
| | | |
| | | public void GetState(Entity.Function device, bool edit, int index,Button button1,Button button2,Button button3,Button button4) |
| | | { |
| | | if (edit) |
| | | { |
| | | Input inputs = Logic.currlogic.input[index]; |
| | | var dicList = inputs.condition as List<Dictionary<string, string>>; |
| | | switch (device.functionType) |
| | | { |
| | | //开关灯光 |
| | | case FunctionType.Relay: |
| | | { |
| | | foreach (var dic in dicList) |
| | | { |
| | | string value = dic["value"]; |
| | | //if (value == "on") |
| | | //{ |
| | | // relayView.btnState.Text = Language.StringByID(StringId.onLogic); |
| | | |
| | | //} |
| | | //else |
| | | //{ |
| | | // relayView.btnState.Text = Language.StringByID(StringId.offLogic); |
| | | //} |
| | | } |
| | | } |
| | | break; |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |