| | |
| | | /// </summary> |
| | | public static void MainShow() |
| | | { |
| | | automationPage.RemoveAll(); |
| | | VerticalRefreshLayout vv = new VerticalRefreshLayout(); |
| | | vv.Height = Application.GetRealHeight(667 - 64 - 49);//模拟高度 |
| | | automationPage.AddChidren(vv); |
| | | vv.BeginHeaderRefreshingAction += () => |
| | | |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | //清除之前自动化列表; |
| | | Logic.LogicList.Clear(); |
| | | //获取自动列表 |
| | | GetLogicList(); |
| | | //刷新自动化界面 |
| | | MainShow(); |
| | | //关闭刷新View; |
| | | vv.EndHeaderRefreshing(); |
| | | }; |
| | | //获取自动化列表 |
| | | GetLogicList(); |
| | | for (int i = Logic.LogicList.Count - 1; i >= 0; i--)//降序排列 |
| | | //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 = currLogic.name; |
| | | logicView.btnWeekText.Text = GetCyclicText(currLogic); |
| | | logicView.btnclick.MouseUpEventHandler += (sen, e) => |
| | | try |
| | | { |
| | | //Logic.currlogic = currLogic; |
| | | //var addLogic = new AddLogic(); |
| | | //MainPage.BasePageView.AddChidren(addLogic); |
| | | //addLogic.Show(); |
| | | //MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | new MainView { }.SkipAddLogicPage(currLogic); |
| | | }; |
| | | //开关图标的点击事件 |
| | | logicView.btnSwitchIcon.MouseUpEventHandler += (sender1, e1) => |
| | | //获取自动化列表 |
| | | GetLogicList(); |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = !logicView.btnSwitchIcon.IsSelected; |
| | | if (logicView.btnSwitchIcon.IsSelected) |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = true; |
| | | currLogic.enable = "true"; |
| | | } |
| | | else |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = false; |
| | | currLogic.enable = "false"; |
| | | } |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | |
| | | automationPage.RemoveAll(); |
| | | VerticalRefreshLayout vv = new VerticalRefreshLayout(); |
| | | vv.Height = Application.GetRealHeight(667 - 64 - 49);//模拟高度 |
| | | automationPage.AddChidren(vv); |
| | | vv.BeginHeaderRefreshingAction += () => |
| | | { |
| | | //逻辑使能的命令 |
| | | Send.Current.EnableLogic(currLogic); |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | //强制更新自动化列表; |
| | | Logic.LogicList.Clear(); |
| | | //获取自动化列表 |
| | | GetLogicList(); |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //刷新自动化界面 |
| | | MainShow(); |
| | | //关闭刷新View; |
| | | vv.EndHeaderRefreshing(); |
| | | |
| | | }); |
| | | } |
| | | |
| | | }); |
| | | |
| | | |
| | | }; |
| | | |
| | | for (int i = Logic.LogicList.Count - 1; i >= 0; 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 = currLogic.name; |
| | | logicView.btnWeekText.Text = GetCyclicText(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; |
| | | new MainView { }.SkipAddLogicPage(currLogic); |
| | | }; |
| | | //开关图标的点击事件 |
| | | logicView.btnSwitchIcon.MouseUpEventHandler += (sender1, e1) => |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = !logicView.btnSwitchIcon.IsSelected; |
| | | if (logicView.btnSwitchIcon.IsSelected) |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = true; |
| | | currLogic.enable = "true"; |
| | | } |
| | | else |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = false; |
| | | currLogic.enable = "false"; |
| | | } |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | //逻辑使能的命令 |
| | | Send.Current.EnableLogic(currLogic); |
| | | |
| | | } |
| | | catch { } |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | }; |
| | | |
| | | |
| | | GetSelectIcon(logicView.frameLayout, currLogic); |
| | | if (i == 0)//降序排列 |
| | | { |
| | | ///最后一个距离最底部12,界面显示效果作用; |
| | | vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(20) }); |
| | | } |
| | | if (currLogic.enable == "true") |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = false; |
| | | } |
| | | ///显示特殊自动化标志 |
| | | if (currLogic.tag == true) |
| | | { |
| | | logicView.btnIsDelTag.Visible = true; |
| | | } |
| | | else |
| | | { |
| | | logicView.btnIsDelTag.Visible = false; |
| | | } |
| | | } |
| | | catch { } |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | }; |
| | | if (Logic.LogicList.Count == 0) |
| | | { |
| | | Button btnTipNot = new Button() |
| | | { |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = Application.GetRealHeight(120), |
| | | Width = Application.GetRealWidth(180), |
| | | Height = Application.GetRealWidth(180), |
| | | UnSelectedImagePath = "TipNot.png", |
| | | }; |
| | | automationPage.AddChidren(btnTipNot); |
| | | Button btnTipNotText = new Button() |
| | | { |
| | | Y = btnTipNot.Bottom + Application.GetRealHeight(16), |
| | | Height = Application.GetRealHeight(20), |
| | | TextID = StringId.logicnull, |
| | | TextAlignment = TextAlignment.Center, |
| | | TextSize = LogicView.TextSize.text14, |
| | | TextColor = CSS.CSS_Color.textConfirmColor, |
| | | }; |
| | | automationPage.AddChidren(btnTipNotText); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | }); |
| | | |
| | | GetSelectIcon(logicView.frameLayout, currLogic); |
| | | if (i == 0)//降序排列 |
| | | //if (Logic.LogicList.Count - 1 == i) |
| | | { |
| | | ///最后一个距离最底部12,界面显示效果作用; |
| | | vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12) }); |
| | | } |
| | | if (currLogic.enable == "true") |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | logicView.btnSwitchIcon.IsSelected = false; |
| | | } |
| | | ///显示特殊自动化标志 |
| | | if (currLogic.tag == true) |
| | | { |
| | | logicView.btnIsDelTag.Visible = true; |
| | | } |
| | | else |
| | | { |
| | | logicView.btnIsDelTag.Visible = false; |
| | | } |
| | | } |
| | | |
| | | if (Logic.LogicList.Count == 0) |
| | | { |
| | | Button btnTipNot = new Button() |
| | | { |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = Application.GetRealHeight(120), |
| | | Width = Application.GetRealWidth(180), |
| | | Height = Application.GetRealWidth(180), |
| | | UnSelectedImagePath = "TipNot.png", |
| | | }; |
| | | automationPage.AddChidren(btnTipNot); |
| | | Button btnTipNotText = new Button() |
| | | { |
| | | Y = btnTipNot.Bottom + Application.GetRealHeight(16), |
| | | Height = Application.GetRealHeight(20), |
| | | TextID = StringId.logicnull, |
| | | TextAlignment = TextAlignment.Center, |
| | | TextSize = LogicView.TextSize.text14, |
| | | TextColor = CSS.CSS_Color.textConfirmColor, |
| | | }; |
| | | automationPage.AddChidren(btnTipNotText); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 按+跳转到逻辑界面的方法 |
| | |
| | | //自动化列表为0才去获取自动化列表; |
| | | return; |
| | | } |
| | | List<string> logicIdList = new List<string>(); |
| | | var logicIdList = new List<string>(); |
| | | //获取逻辑ID列表 |
| | | var idStr = Send.Current.GetLogicIdList(); |
| | | if (idStr != null) |
| | | var dateList = Send.Current.GetLogicIdList(); |
| | | if (dateList != null) |
| | | { |
| | | var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data); |
| | | var dateList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicData>>(date); |
| | | for (int i = 0; i < dateList.Count; i++) |
| | | { |
| | | //添加逻辑ID |
| | |
| | | } |
| | | } |
| | | //获取自动化列表 |
| | | var logicListStr = Send.Current.GetLogic(logicIdList); |
| | | if (logicListStr != null) |
| | | var logicList = Send.Current.GetLogic(logicIdList); |
| | | if (logicList != null) |
| | | { |
| | | var logicList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Logic>>(logicListStr.Data.ToString()); |
| | | for (int j = 0; j < logicList.Count; j++) |
| | | { |
| | | var logic = logicList[j]; |
| | | if (logic != null) |
| | | { |
| | | //查找是否已经存在该逻辑 |
| | | //去重 |
| | | var if_logic = Logic.LogicList.Find((c) => c.userLogicId == logic.userLogicId); |
| | | if (if_logic == null) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | class LogicData |
| | | } |
| | | public class LogicIdData |
| | | { |
| | | /// <summary> |
| | | /// 云端唯一id |