New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Shared; |
| | | namespace HDL_ON.UI.UI2.Intelligence.Automation |
| | | { |
| | | public class TimeTpye : FrameLayout |
| | | { |
| | | public TimeTpye() |
| | | { |
| | | Tag = "Logic"; |
| | | } |
| | | |
| | | public void Show() |
| | | { |
| | | #region 界面布局 |
| | | LogicView.TopView topView = new LogicView.TopView(); |
| | | this.AddChidren(topView.FLayoutView()); |
| | | topView.clickBackBtn.MouseUpEventHandler += (e, sen) => |
| | | { |
| | | RemoveFromParent(); |
| | | }; |
| | | topView.topNameBtn.TextID = StringId.selectionTimeCondition; |
| | | |
| | | FrameLayout viewLayout = new FrameLayout |
| | | { |
| | | Y = Application.GetRealHeight(64), |
| | | Width = Application.GetRealWidth(LogicView.TextSize.view375), |
| | | Height = Application.GetRealHeight(LogicView.TextSize.view667 - 64), |
| | | BackgroundColor = CSS.CSS_Color.viewMiddle, |
| | | }; |
| | | this.AddChidren(viewLayout); |
| | | |
| | | //时刻 |
| | | LogicView.SelectTypeView timepointView = new LogicView.SelectTypeView(); |
| | | timepointView.btnIcon.Visible = false; |
| | | timepointView.btnText.X = Application.GetRealWidth(16); |
| | | timepointView.btnLine.X = Application.GetRealWidth(16); |
| | | timepointView.btnLine.Width = Application.GetRealWidth(375 - 16 - 16); |
| | | timepointView.btnText.TextID = StringId.hour; |
| | | viewLayout.AddChidren(timepointView.FLayoutView()); |
| | | |
| | | //时间范围 |
| | | LogicView.SelectTypeView timeHorizonView = new LogicView.SelectTypeView(); |
| | | timeHorizonView.frameLayout.Y = timepointView.frameLayout.Bottom; |
| | | timeHorizonView.btnIcon.Visible = false; |
| | | timeHorizonView.btnText.X = Application.GetRealWidth(16); |
| | | timeHorizonView.btnLine.X = Application.GetRealWidth(16); |
| | | timeHorizonView.btnLine.Width = Application.GetRealWidth(375 - 16 - 16); |
| | | timeHorizonView.btnText.TextID = StringId.timeHorizon; |
| | | viewLayout.AddChidren(timeHorizonView.FLayoutView()); |
| | | |
| | | |
| | | //日出/日落/正午 |
| | | LogicView.SelectTypeView timeSpecialView = new LogicView.SelectTypeView(); |
| | | timeSpecialView.frameLayout.Y = timeHorizonView.frameLayout.Bottom; |
| | | timeSpecialView.btnIcon.Visible = false; |
| | | timeSpecialView.btnText.X = Application.GetRealWidth(16); |
| | | timeSpecialView.btnLine.X = Application.GetRealWidth(16); |
| | | timeSpecialView.btnLine.Width = Application.GetRealWidth(375 - 16 - 16); |
| | | timeSpecialView.btnText.TextID = StringId.timespecia; |
| | | viewLayout.AddChidren(timeSpecialView.FLayoutView()); |
| | | |
| | | #endregion |
| | | |
| | | #region 时间点 时间范围点击事件 |
| | | //时间点点击事件 |
| | | timepointView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | //主界面控件 |
| | | FrameLayout fLayout = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(fLayout); |
| | | TimePoint(fLayout, false, 100); |
| | | |
| | | }; |
| | | //时间范围点击事件 |
| | | timeHorizonView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | //主界面控件 |
| | | FrameLayout fLayout = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | //添加主界面 |
| | | this.AddChidren(fLayout); |
| | | //var fLayout = GetFrame(this,"2"); |
| | | |
| | | TimeHorizon(fLayout, false, 0); |
| | | }; |
| | | //日出/日落/正午点击事件 |
| | | timeSpecialView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | SpeciaTime speciaTime = new SpeciaTime(); |
| | | MainPage.BasePageView.AddChidren(speciaTime); |
| | | speciaTime.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | |
| | | }; |
| | | #endregion |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 时间点方法 |
| | | /// </summary> |
| | | /// <param name="fLayout">在哪个界面显示</param> |
| | | /// <param name="edit">(true=编辑;false=新建)</param> |
| | | /// <param name="index">编辑条件的索引</param> |
| | | public void TimePoint(FrameLayout fLayout, bool edit, int index) |
| | | { |
| | | //编辑之前的时间状态值 |
| | | string editTime= ""; |
| | | if (edit) |
| | | { |
| | | Input inputs = Logic.currlogic.input[index]; |
| | | if (inputs.condition_type == "1") |
| | | { |
| | | List<Dictionary<string, string>> dicList = inputs.condition as List<Dictionary<string, string>>; |
| | | foreach (var dic in dicList) |
| | | { |
| | | string timeValue = dic["value"]; |
| | | editTime = timeValue; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | LogicView.TimeView timePointView = new LogicView.TimeView(); |
| | | timePointView.FLayoutView(fLayout); |
| | | timePointView.TimePoint(fLayout, editTime, (timeValue)=>{ |
| | | Input inputTime = new Input(); |
| | | inputTime.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | inputTime.condition_type = "1"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", "timepoint"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", timeValue); |
| | | inputTime.condition.Add(dic); |
| | | AddCondition(inputTime, edit, index); |
| | | }); |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 时间范围方法 |
| | | /// </summary> |
| | | /// <param name="fLayout">在哪个界面显示</param> |
| | | /// <param name="edit">(true=编辑;false=新建)</param> |
| | | /// <param name="index">编辑条件的索引</param> |
| | | public void TimeHorizon(FrameLayout fLayout, bool edit, int index) |
| | | { |
| | | #region 界面布局 |
| | | LogicView.TimeHorizonView timeHorizonView = new LogicView.TimeHorizonView(); |
| | | timeHorizonView.FLayoutView(fLayout); |
| | | //开始时间 |
| | | LogicView.SelectTypeView startTimeView = new LogicView.SelectTypeView(); |
| | | startTimeView.frameLayout.Y = Application.GetRealHeight(87); |
| | | startTimeView.btnIcon.Visible = false; |
| | | startTimeView.btnText.X = Application.GetRealWidth(16); |
| | | startTimeView.btnText.TextID = StringId.startTime; |
| | | startTimeView.btnLine.X = Application.GetRealWidth(16); |
| | | startTimeView.btnLine.Width = Application.GetRealWidth(375 - 16 - 16); |
| | | startTimeView.btnNextIcon.X = Application.GetRealWidth(307); |
| | | timeHorizonView.frameLayout.AddChidren(startTimeView.FLayoutView()); |
| | | //显示开始时间文本 |
| | | Button btnStartTimeText = new Button |
| | | { |
| | | TextSize = LogicView.TextSize.text12, |
| | | Width = Application.GetRealWidth(32 + 3+20), |
| | | Height = Application.GetRealHeight(17), |
| | | TextColor = CSS.CSS_Color.textCancelColor, |
| | | Y = Application.GetRealHeight(17), |
| | | X = Application.GetRealWidth(260-20), |
| | | Tag = "0", |
| | | }; |
| | | startTimeView.frameLayout.AddChidren(btnStartTimeText); |
| | | |
| | | //结束时间 |
| | | LogicView.SelectTypeView endTimeView = new LogicView.SelectTypeView(); |
| | | endTimeView.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight); |
| | | endTimeView.frameLayout.Y = startTimeView.frameLayout.Bottom; |
| | | endTimeView.btnIcon.Visible = false; |
| | | endTimeView.btnLine.Visible = false; |
| | | endTimeView.btnText.X = Application.GetRealWidth(16); |
| | | endTimeView.btnText.TextID = StringId.endTime; |
| | | endTimeView.btnNextIcon.X = Application.GetRealWidth(307); |
| | | timeHorizonView.frameLayout.AddChidren(endTimeView.FLayoutView()); |
| | | //显示结束时间文本 |
| | | Button btnEndTimeText = new Button |
| | | { |
| | | TextSize = LogicView.TextSize.text12, |
| | | Width = Application.GetRealWidth(32 + 3+20), |
| | | Height = Application.GetRealHeight(17), |
| | | TextColor = CSS.CSS_Color.textCancelColor, |
| | | Y = Application.GetRealHeight(17), |
| | | X = Application.GetRealWidth(260-20), |
| | | Tag = "0", |
| | | }; |
| | | endTimeView.frameLayout.AddChidren(btnEndTimeText); |
| | | |
| | | #endregion |
| | | |
| | | #region 点击事件 |
| | | //开始时间点击事件 |
| | | EventHandler<MouseEventArgs> StartTimeClick = (sender,e) => { |
| | | SelectedTimeHorizon(fLayout, btnStartTimeText); |
| | | }; |
| | | startTimeView.btnClick.MouseUpEventHandler += StartTimeClick; |
| | | btnStartTimeText.MouseUpEventHandler += StartTimeClick; |
| | | //结束时间点击事件 |
| | | EventHandler<MouseEventArgs> EndTimeClick = (sender, e) => { |
| | | SelectedTimeHorizon(fLayout, btnEndTimeText); |
| | | }; |
| | | endTimeView.btnClick.MouseUpEventHandler += EndTimeClick; |
| | | btnEndTimeText.MouseUpEventHandler += EndTimeClick; |
| | | |
| | | |
| | | //确定点击事件 |
| | | timeHorizonView.btnConfirm.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | |
| | | if (btnStartTimeText.Tag.ToString() == "0"&& btnEndTimeText.Tag.ToString() == "0") |
| | | { |
| | | //提示:时间未设置,请设置时间。 |
| | | new LogicView.TipPopView().TipBox(StringId.tip, StringId.timeNoSet); |
| | | return; |
| | | } |
| | | |
| | | if (btnStartTimeText.Tag.ToString() == "0") |
| | | { |
| | | //提示:开始时间未设置,请设置开始时间。 |
| | | new LogicView.TipPopView().TipBox(StringId.tip,StringId.setStartTime); |
| | | return; |
| | | } |
| | | if (btnEndTimeText.Tag.ToString() == "0") |
| | | { |
| | | //提示:结束时间未设置,请设置结束时间。 |
| | | new LogicView.TipPopView().TipBox(StringId.tip, StringId.setEndTime); |
| | | return; |
| | | } |
| | | if (btnStartTimeText.Tag.ToString() == btnEndTimeText.Tag.ToString()) |
| | | { |
| | | //提示:开始时间和结束时间不能一样。 |
| | | new LogicView.TipPopView().TipBox(StringId.tip, StringId.unlikeTime); |
| | | return; |
| | | } |
| | | if (int.Parse(btnStartTimeText.Tag.ToString()) > int.Parse(btnEndTimeText.Tag.ToString())) |
| | | { |
| | | //提示:开始时间不能大于结束时间。 |
| | | new LogicView.TipPopView().TipBox(StringId.tip, StringId.startTimeLessThanEndTime); |
| | | return; |
| | | } |
| | | |
| | | Input inputTime = new Input(); |
| | | inputTime.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | inputTime.condition_type = "2"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", "timesection"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", btnStartTimeText.Text + "-" + btnEndTimeText.Text); |
| | | inputTime.condition.Add(dic); |
| | | AddCondition(inputTime, edit, index); |
| | | |
| | | |
| | | }; |
| | | #endregion |
| | | |
| | | if (edit) |
| | | { |
| | | Input inputs = Logic.currlogic.input[index]; |
| | | if (inputs.condition_type == "2") |
| | | { |
| | | List<Dictionary<string, string>> dicList = inputs.condition as List<Dictionary<string, string>>; |
| | | foreach (var dic in dicList) |
| | | { |
| | | string value = dic["value"]; |
| | | string startTime = value.Split('-')[0]; |
| | | string endtTime = value.Split('-')[1]; |
| | | btnStartTimeText.Text = startTime; |
| | | btnStartTimeText.Tag = int.Parse(startTime.Split(':')[0]) * 60 + int.Parse(startTime.Split(':')[1]); |
| | | btnEndTimeText.Text = endtTime; |
| | | btnEndTimeText.Tag = int.Parse(endtTime.Split(':')[0]) * 60 + int.Parse(endtTime.Split(':')[1]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 设置时间段值 |
| | | /// </summary> |
| | | /// <param name="fLayout"></param> |
| | | /// <param name="btn"></param> |
| | | public void SelectedTimeHorizon(FrameLayout fLayout, Button btn) |
| | | { |
| | | //编辑之前的时间状态值 |
| | | string editTime = ""; |
| | | if (btn.Tag.ToString() != "0") |
| | | { |
| | | string h = "", m = ""; |
| | | int sumTime = int.Parse(btn.Tag.ToString()); |
| | | if ((sumTime / 60) < 10) |
| | | { |
| | | h = "0" + (sumTime / 60).ToString(); |
| | | } |
| | | else |
| | | { |
| | | h = (sumTime / 60).ToString(); |
| | | } |
| | | |
| | | if ((sumTime % 60) < 10) |
| | | { |
| | | m = "0" + (sumTime % 60).ToString(); |
| | | } |
| | | else |
| | | { |
| | | m = (sumTime % 60).ToString(); |
| | | } |
| | | editTime = h + ":" + m; |
| | | } |
| | | LogicView.TimeView timePointView = new LogicView.TimeView(); |
| | | timePointView.FLayoutView(fLayout); |
| | | timePointView.TimePoint(timePointView.frameLayout, editTime, (timeValue) => |
| | | { |
| | | int hour = int.Parse(timeValue.Split(':')[0]); |
| | | int minuet = int.Parse(timeValue.Split(':')[1]); |
| | | int intValueTag = hour * 60 + minuet; |
| | | //标记值,用于比较开始时间和结束时间大小; |
| | | btn.Tag = intValueTag; |
| | | //显示时间文本 |
| | | btn.Text = timeValue; |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加条件 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | private void AddCondition(Input input,bool edit,int index) |
| | | { |
| | | if (edit) |
| | | { |
| | | //移除旧数据 |
| | | Logic.currlogic.input.RemoveAt(index); |
| | | //新数据插入旧数据的位置 |
| | | Logic.currlogic.input.Insert(index, input); |
| | | } |
| | | else |
| | | { |
| | | //添加一个新的时间条件 |
| | | Logic.currlogic.input.Add(input); |
| | | } |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 灰色弹框父控件 |
| | | /// </summary> |
| | | /// <param name="frame">显示在哪个界面</param> |
| | | /// <returns></returns> |
| | | public FrameLayout GetFrame(FrameLayout frame, string tagKey) |
| | | { |
| | | for (int i = 0; i < frame.ChildrenCount; i++) |
| | | { |
| | | var fra = frame.GetChildren(i); |
| | | if (fra != null) |
| | | { |
| | | fra.RemoveFromParent(); |
| | | } |
| | | } |
| | | |
| | | |
| | | FrameLayout fLayout = new FrameLayout() |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | |
| | | }; |
| | | frame.AddChidren(fLayout); |
| | | |
| | | |
| | | return fLayout; |
| | | } |
| | | } |
| | | } |