| | |
| | | { |
| | | Tag = "Logic"; |
| | | } |
| | | public void Show(bool edit = false, int index=-1) |
| | | public void Show() |
| | | { |
| | | #region 界面布局 |
| | | LogicView.TopView topView = new LogicView.TopView(); |
| | |
| | | this.AddChidren(topView.FLayoutView()); |
| | | topView.topNameBtn.TextID = StringId.selectionCondition; |
| | | //获取宽度 |
| | | int widthValue= topView.topNameBtn.GetTextWidth(); |
| | | int textWidth =(Application.GetRealWidth(255)- widthValue) / 2; |
| | | int widthValue = topView.topNameBtn.GetTextWidth(); |
| | | int textWidth = (Application.GetRealWidth(255) - widthValue) / 2; |
| | | Button locationBtn = new Button |
| | | { |
| | | Width = Application.GetRealWidth(18), |
| | | Height = Application.GetRealWidth(18), |
| | | X = Application.GetRealWidth(60+4)+ textWidth + widthValue, |
| | | Y = Application.GetRealHeight(34+1), |
| | | X = Application.GetRealWidth(60 + 4) + textWidth + widthValue, |
| | | Y = Application.GetRealHeight(34 + 1), |
| | | UnSelectedImagePath = "LogicIcon/location.png", |
| | | |
| | | }; |
| | |
| | | |
| | | FrameLayout viewLayout = new FrameLayout |
| | | { |
| | | Y = Application.GetRealHeight(64+20), |
| | | Y = Application.GetRealHeight(64 + 20), |
| | | Width = Application.GetRealWidth(LogicView.TextSize.view375), |
| | | Height = Application.GetRealHeight(LogicView.TextSize.view667 - 64-20), |
| | | Height = Application.GetRealHeight(LogicView.TextSize.view667 - 64 - 20), |
| | | BackgroundColor = CSS.CSS_Color.viewMiddle, |
| | | }; |
| | | this.AddChidren(viewLayout); |
| | |
| | | }; |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | LogicView.SelectTypeView timeView = new LogicView.SelectTypeView(); |
| | | timeView.frameLayout.Y = Application.GetRealHeight(i * 50); |
| | | timeView.btnIcon.Visible = false; |
| | | timeView.btnText.X = Application.GetRealWidth(16); |
| | | timeView.btnLine.X = Application.GetRealWidth(16); |
| | | timeView.btnLine.Width = Application.GetRealWidth(375 - 16 - 16); |
| | | timeView.btnText.Text = list[i]; |
| | | timeView.btnClick.Tag = list[i]; |
| | | viewLayout.AddChidren(timeView.FLayoutView()); |
| | | LogicView.SelectTypeView view = new LogicView.SelectTypeView(); |
| | | view.frameLayout.Y = Application.GetRealHeight(i * 50); |
| | | view.btnIcon.Visible = false; |
| | | view.btnNextIcon.Visible = false; |
| | | view.btnText.X = Application.GetRealWidth(16); |
| | | view.btnLine.X = Application.GetRealWidth(16); |
| | | view.btnLine.Width = Application.GetRealWidth(375 - 16 - 16); |
| | | view.btnText.Text = list[i]; |
| | | view.btnClick.Tag = list[i]; |
| | | viewLayout.AddChidren(view.FLayoutView()); |
| | | |
| | | timeView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | view.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | //string |
| | | //if () { } |
| | | //else if () { } |
| | | //else if () { } |
| | | string value = ""; |
| | | string text = view.btnClick.Tag.ToString(); |
| | | if (text == Language.StringByID(StringId.clearday)) |
| | | { |
| | | value = "sunny"; |
| | | } |
| | | else if (text == Language.StringByID(StringId.cloudy)) |
| | | { |
| | | value = "cloudy"; |
| | | } |
| | | else if (text == Language.StringByID(StringId.rain)) |
| | | { |
| | | value = "rainy"; |
| | | } |
| | | AddDic(value); |
| | | }; |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 封装数据 |
| | | /// </summary> |
| | | /// <param name="value"></param> |
| | | private void AddDic(string value) |
| | | { |
| | | Input input = new Input(); |
| | | input.sid = LogicMethod.NewSid(); |
| | | input.condition_type = "6"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", "weather"); |
| | | LogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.dictionary(dic, "value", value); |
| | | input.condition.Add(dic); |
| | | AddCondition(input); |
| | | } |
| | | /// <summary> |
| | | /// 添加条件 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | private void AddCondition(Input input) |
| | | { |
| | | ///记录索引值 |
| | | int index = -1; |
| | | for (var i = 0; i < Logic.currlogic.input.Count; i++) |
| | | { |
| | | var condition_type = Logic.currlogic.input[i].condition_type; |
| | | if (condition_type == "6") |
| | | { |
| | | ///找到标记索引,退出循环体 |
| | | index = i; |
| | | break; |
| | | } |
| | | } |
| | | if (index != -1) |
| | | { |
| | | //移除旧数据 |
| | | Logic.currlogic.input.RemoveAt(index); |
| | | //新数据插入旧数据的位置 |
| | | Logic.currlogic.input.Insert(index, input); |
| | | } |
| | | else |
| | | { |
| | | Logic.currlogic.input.Add(input); |
| | | } |
| | | |
| | | LogicMethod.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | |
| | | } |
| | | } |
| | | } |