| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Shared; |
| | | namespace HDL_ON.UI.UI2.Intelligence.Automation |
| | | { |
| | | public class AddTarget:FrameLayout |
| | | public class AddTarget : FrameLayout |
| | | { |
| | | public AddTarget() |
| | | { |
| | |
| | | functionView.btnText.TextID = StringId.funLogic; |
| | | functionView.btnIcon.UnSelectedImagePath = "LogicIcon/functionicon.png"; |
| | | viewLayout.AddChidren(functionView.FLayoutView()); |
| | | |
| | | //场景 |
| | | LogicView.SelectTypeView sceneView = new LogicView.SelectTypeView(); |
| | | sceneView.frameLayout.Y = functionView.frameLayout.Bottom; |
| | | sceneView.btnText.TextID = StringId.Scenes; |
| | | sceneView.btnIcon.UnSelectedImagePath = "LogicIcon/scene.png"; |
| | | viewLayout.AddChidren(sceneView.FLayoutView()); |
| | | |
| | | //延时 |
| | | LogicView.SelectTypeView delayView = new LogicView.SelectTypeView(); |
| | | delayView.frameLayout.Y = sceneView.frameLayout.Bottom; |
| | | delayView.btnText.TextID = StringId.delayLogic; |
| | | delayView.btnIcon.UnSelectedImagePath = "LogicIcon/delayed.png"; |
| | | viewLayout.AddChidren(delayView.FLayoutView()); |
| | | #endregion |
| | | |
| | | #region 所有点击事件 |
| | | functionView.btnClick.MouseUpEventHandler += (sen, e) => { |
| | | functionView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | FunTpye funTpye = new FunTpye(); |
| | | MainPage.BasePageView.AddChidren(funTpye); |
| | | funTpye.Show(LogicMethod.target_if); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | |
| | | }; |
| | | |
| | | sceneView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | |
| | | FrameLayout fLayout = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(fLayout); |
| | | SceneMethod(fLayout); |
| | | }; |
| | | |
| | | delayView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | |
| | | FrameLayout fLayout = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(fLayout); |
| | | Delayed(fLayout,false,1000); |
| | | }; |
| | | #endregion |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加场景 |
| | | /// </summary> |
| | | /// <param name="fLayout">弹框主控件</param> |
| | | public void SceneMethod(FrameLayout fLayout) |
| | | { |
| | | LogicView.DateView dateView = new LogicView.DateView(); |
| | | dateView.btnTitle.TextID = StringId.addSceneLogic; |
| | | dateView.FLayoutView(fLayout, 5); |
| | | dateView.btnCancel.MouseUpEventHandler += (sender2, e2) => |
| | | { |
| | | fLayout.RemoveFromParent(); |
| | | }; |
| | | VerticalRefreshLayout verticalRefresh = new VerticalRefreshLayout |
| | | { |
| | | Y = Application.GetRealHeight(56), |
| | | Height = Application.GetRealHeight(50 * 5), |
| | | |
| | | }; |
| | | dateView.frameLayout.AddChidren(verticalRefresh); |
| | | |
| | | //定义一个局部变量记录选中状态 |
| | | Button buttonClick = new Button(); |
| | | HDL_ON.Entity.Scene sceneSelecetd = null; |
| | | var sceneList = LogicMethod.GetSceneList(); |
| | | for (int i = 0; i < sceneList.Count; i++) |
| | | { |
| | | var scene = sceneList[i]; |
| | | LogicView.SelectTypeView sceneView = new LogicView.SelectTypeView(); |
| | | sceneView.frameLayout.BackgroundColor = CSS.CSS_Color.viewTranslucence; |
| | | sceneView.btnIcon.Visible = false; |
| | | sceneView.btnText.X = Application.GetRealWidth(20); |
| | | sceneView.btnText.Text = scene.name; |
| | | sceneView.btnLine.X = Application.GetRealWidth(20); |
| | | sceneView.btnLine.Width = Application.GetRealWidth(303); |
| | | sceneView.btnNextIcon.X = Application.GetRealWidth(303); |
| | | sceneView.btnNextIcon.Width = Application.GetMinRealAverage(28); |
| | | sceneView.btnNextIcon.Height = Application.GetMinRealAverage(28); |
| | | sceneView.btnNextIcon.UnSelectedImagePath = "LogicIcon/weekoff.png"; |
| | | sceneView.btnNextIcon.SelectedImagePath = "LogicIcon/weekon.png"; |
| | | verticalRefresh.AddChidren(sceneView.FLayoutView()); |
| | | sceneView.btnClick.Tag = scene;//标记索引 |
| | | |
| | | //场景的点击事件 |
| | | sceneView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | buttonClick.IsSelected = false; |
| | | sceneView.btnNextIcon.IsSelected = true; |
| | | buttonClick = sceneView.btnNextIcon; |
| | | sceneSelecetd =sceneView.btnClick.Tag as HDL_ON.Entity.Scene; |
| | | }; |
| | | |
| | | } |
| | | //确认点击事件 |
| | | dateView.btnConfirm.MouseUpEventHandler += (sender1, e1) => |
| | | { |
| | | if (sceneSelecetd == null) |
| | | { |
| | | //提示:还没选中执行周期 |
| | | return; |
| | | } |
| | | Output outputDevice = new Output(); |
| | | outputDevice.target_type = "2"; |
| | | outputDevice.sid = sceneSelecetd.sid; |
| | | AddOutput(outputDevice); |
| | | fLayout.RemoveFromParent(); |
| | | LogicMethod.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 延时时间方法 |
| | | /// </summary> |
| | | /// <param name="fLayout">在哪个界面显示</param> |
| | | /// <param name="edit">(true=编辑;false=新建)</param> |
| | | /// <param name="index">编辑条件的索引</param> |
| | | public void Delayed(FrameLayout fLayout, bool edit, int index) |
| | | { |
| | | 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.GethStringList0(), timePointView.GetmStringList(), null); |
| | | //默认初始选中状态 |
| | | timePointView.mUIPickerView.setCurrentItems(0, 5, 0); |
| | | //定义一个局部变量记录选中时间 |
| | | string timepoint = "00:05"; |
| | | |
| | | if (edit) |
| | | { |
| | | Output output = Logic.currlogic.output[index]; |
| | | if (output.target_type == "3") |
| | | { |
| | | List<Dictionary<string, string>> dicList = output.status as List<Dictionary<string, string>>; |
| | | foreach (var dic in dicList) |
| | | { |
| | | string timeValue = dic["value"]; |
| | | int hIndex = timePointView.GetValueIndex(timeValue, 0, 1, timePointView.GethIntList0()); |
| | | int mIndex = timePointView.GetValueIndex(timeValue, 1, 0, timePointView.GetmIntList()); |
| | | //更新初始状态 |
| | | timePointView.mUIPickerView.setCurrentItems(hIndex, mIndex, 0); |
| | | timepoint = timeValue; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //选中时间回调方法,时间变化一次回调一次 |
| | | timePointView.mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) => |
| | | { |
| | | string hour = timePointView.GethStringList0()[index1].Split(' ')[0]; |
| | | string minuet = timePointView.GetmStringList()[index2].Split(' ')[0]; |
| | | timepoint = hour + ":" + minuet; |
| | | }; |
| | | //确定点击事件 |
| | | timePointView.btnConfirm.MouseUpEventHandler += (sender, e3) => |
| | | { |
| | | if (timepoint=="00:00") { |
| | | //提示 |
| | | return; |
| | | } |
| | | Output outputTime= new Output(); |
| | | outputTime.sid = LogicMethod.NewSid(); |
| | | outputTime.target_type = "3"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", "delay"); |
| | | LogicMethod.dictionary(dic, "value", timepoint); |
| | | outputTime.status.Add(dic); |
| | | if (edit) |
| | | { |
| | | //移除旧数据 |
| | | Logic.currlogic.output.RemoveAt(index); |
| | | //新数据插入旧数据的位置; |
| | | Logic.currlogic.output.Insert(index, outputTime); |
| | | } |
| | | else |
| | | { |
| | | //添加一个新的时间点条件 |
| | | AddOutput(outputTime); |
| | | } |
| | | fLayout.RemoveFromParent(); |
| | | LogicMethod.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加目标 |
| | | /// </summary> |
| | | /// <param name="target"></param> |
| | | private void AddOutput(Output target) |
| | | { |
| | | int indexValue = -1; |
| | | for (int i = 0; i < Logic.currlogic.output.Count; i++) |
| | | { |
| | | if (Logic.currlogic.output[i].sid == target.sid) |
| | | { |
| | | indexValue = i; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (indexValue != -1) |
| | | { |
| | | Logic.currlogic.output.RemoveAt(indexValue); |
| | | Logic.currlogic.output.Insert(indexValue, target); |
| | | } |
| | | else |
| | | { |
| | | Logic.currlogic.output.Add(target); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |