| | |
| | | using System; |
| | | using HDL_ON.UI.UI2.Intelligence.Automation.LogicView; |
| | | using Shared; |
| | | using System.Collections.Generic; |
| | | namespace HDL_ON.UI.UI2.Intelligence.Automation |
| | | { |
| | | public class MainView |
| | |
| | | /// </summary> |
| | | public static void MainShow() |
| | | { |
| | | |
| | | automationPage.RemoveAll(); |
| | | VerticalScrolViewLayout vv = new VerticalScrolViewLayout(); |
| | | automationPage.AddChidren(vv); |
| | | |
| | | for (int i = 0; i < 2; i++) |
| | | { |
| | | Logic.LogicList.Add(new Logic { name = "123456" }); |
| | | } |
| | | |
| | | for (int i = 0; i < Logic.LogicList.Count; i++) |
| | | { |
| | | var currLogic = Logic.LogicList[i]; |
| | | ///上下间隔12像素 |
| | | vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12) }); |
| | | LogicView.SingleLogicView logicView = new LogicView.SingleLogicView(); |
| | | vv.AddChidren(logicView.FLayoutView()); |
| | | logicView.btnLogicName.Text = i.ToString(); |
| | | logicView.btnWeekText.Text = "每天"; |
| | | |
| | | logicView.btnWeekText.Text = GetWeekText(currLogic); |
| | | logicView.btnclick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | Logic.currlogic = currLogic; |
| | | var addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }; |
| | | logicView.btnSwitchIcon.MouseUpEventHandler += (sender1, e1) => |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = !logicView.btnSwitchIcon.IsSelected; |
| | | if (logicView.btnSwitchIcon.IsSelected) |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = false; |
| | | } |
| | | }; |
| | | if (currLogic.enable == "true") |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = false; |
| | | } |
| | | } |
| | | |
| | | if (Logic.LogicList.Count == 0) |
| | |
| | | addLogic.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | } |
| | | /// <summary> |
| | | ///返回循环描述文本 |
| | | /// </summary> |
| | | /// <param name="logic"></param> |
| | | public static string GetWeekText(Logic logic) |
| | | { |
| | | |
| | | string weekName = ""; |
| | | /// (执行一次:once,每天:day,每月:mon,星期:week,日期段:date_to_date) |
| | | switch (logic.cycle.type) |
| | | { |
| | | case "once": |
| | | { |
| | | weekName = Language.StringByID(StringId.performA); |
| | | } |
| | | break; |
| | | case "day": |
| | | { |
| | | weekName = Language.StringByID(StringId.days); |
| | | } |
| | | break; |
| | | case "week": |
| | | { |
| | | |
| | | weekName = GetWeekString(logic.cycle.value); |
| | | |
| | | } |
| | | break; |
| | | case "mon": |
| | | { |
| | | weekName = GetMonString(logic.cycle.value); |
| | | } |
| | | break; |
| | | } |
| | | return weekName; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取星期的字符串 |
| | | /// </summary> |
| | | /// <param name="weekList"></param> |
| | | /// <returns></returns> |
| | | public static string GetWeekString(List<string> weekList) |
| | | { |
| | | string weekTextName = ""; |
| | | |
| | | if (weekList.Contains("0")) |
| | | { |
| | | weekTextName += Language.StringByID(StringId.monday) + ","; |
| | | } |
| | | if (weekList.Contains("1")) |
| | | { |
| | | weekTextName += Language.StringByID(StringId.tuesday) + ","; |
| | | } |
| | | if (weekList.Contains("2")) |
| | | { |
| | | weekTextName += Language.StringByID(StringId.wednesday) + ","; |
| | | } |
| | | if (weekList.Contains("3")) |
| | | { |
| | | weekTextName += Language.StringByID(StringId.thursday) + ","; |
| | | } |
| | | if (weekList.Contains("4")) |
| | | { |
| | | weekTextName += Language.StringByID(StringId.friday) + ","; |
| | | } |
| | | if (weekList.Contains("5")) |
| | | { |
| | | weekTextName += Language.StringByID(StringId.saturday) + ","; |
| | | } |
| | | if (weekList.Contains("6")) |
| | | { |
| | | weekTextName += Language.StringByID(StringId.sunday) + ","; |
| | | } |
| | | if (weekTextName == "") |
| | | { |
| | | return ""; |
| | | } |
| | | return weekTextName.TrimEnd(','); |
| | | } |
| | | /// <summary> |
| | | /// 获取每月的字符串 |
| | | /// </summary> |
| | | /// <param name="monList"></param> |
| | | /// <returns></returns> |
| | | public static string GetMonString(List<string> monList) |
| | | { |
| | | string monTextName = Language.StringByID(StringId.monthly); |
| | | |
| | | for (int i = 1; i < 32; i++) |
| | | { |
| | | if (monList.Contains(i.ToString())) |
| | | { |
| | | monTextName += i.ToString() + ","; |
| | | } |
| | | } |
| | | return monTextName.TrimEnd(','); |
| | | } |
| | | } |
| | | } |