using System; using System.Collections.Generic; using Shared; using Shared.Common; using Shared.Phone; using Shared.R; using ZigBee.Device; namespace Shared.Phone.Device.Logic { public class DeviceTarget : FrameLayout { public DeviceTarget() { Tag = "Logic"; } public void Show() { this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor; var topFrameLayout = new FrameLayout { Height = Application.GetRealHeight(140), Y = Application.GetRealHeight(80), }; AddChidren(topFrameLayout); var titleName = new Button { //Text = "添加执行目标", TextID = MyInternationalizationString.addImplementationgoals, TextSize = 17, TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; topFrameLayout.AddChidren(titleName); var back = new Button { Width = Application.GetRealWidth(110), Height = Application.GetRealHeight(110), X = Application.GetRealWidth(20), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "ZigeeLogic/Back.png", }; topFrameLayout.AddChidren(back); back.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); }; var middle = new VerticalScrolViewLayout(); middle.Y = topFrameLayout.Bottom; middle.Height = Application.GetRealHeight(1920 - 220); middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor; this.AddChidren(middle); #region ----- 设备------ var deviceRowLayout = new RowLayout { Height = Application.GetRealHeight(180), //BackgroundColor = 0xff323232, }; middle.AddChidren(deviceRowLayout); var device = new Button { Width = Application.GetRealWidth(400), TextID = MyInternationalizationString.device, //Text = "设备", TextSize = 16, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; deviceRowLayout.AddChidren(device); var btndeviceback = new Button { Width = Application.GetRealWidth(110), Height = Application.GetRealHeight(110), UnSelectedImagePath = "ZigeeLogic/next.png", SelectedImagePath = "ZigeeLogic/NextSelecte.png", X = Application.GetRealWidth(1080 - 140),//550 Gravity = Gravity.CenterVertical, }; deviceRowLayout.AddChidren(btndeviceback); EventHandler deviceclick = (sender, e) => { Common.Logic.LogicDviceList.Clear(); if (Common.Logic.LogicDviceList.Count == 0) { Common.Logic.LogicDviceList.AddRange(LocalDevice.Current.listAllDevice.ToArray()); } var logicDevicePage = new LogicDevicePage(); UserView.HomePage.Instance.AddChidren(logicDevicePage); UserView.HomePage.Instance.PageIndex += 1; logicDevicePage.Show(); }; deviceRowLayout.MouseUpEventHandler += deviceclick; device.MouseUpEventHandler += deviceclick; btndeviceback.MouseUpEventHandler += deviceclick; #endregion #region ----- 场景------ var sceneRowLayout = new RowLayout { Height = Application.GetRealHeight(180), //BackgroundColor = 0xff323232, Y = deviceRowLayout.Bottom, }; middle.AddChidren(sceneRowLayout); var scene = new Button { Width = Application.GetRealWidth(400), TextID = MyInternationalizationString.scene, //Text = "场景", TextSize = 16, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; sceneRowLayout.AddChidren(scene); var btnsceneback = new Button { Width = Application.GetRealWidth(110), Height = Application.GetRealHeight(110), UnSelectedImagePath = "ZigeeLogic/next.png", SelectedImagePath = "ZigeeLogic/NextSelecte.png", X = Application.GetRealWidth(1080 - 140),//550 Gravity = Gravity.CenterVertical, }; sceneRowLayout.AddChidren(btnsceneback); EventHandler sceneclick = (sender, e) => { CommonPage.Loading.Start(); System.Threading.Tasks.Task.Run(() => { Application.RunOnMainThread(() => { CommonPage.Loading.Hide(); var addScenePage = new AddScenePage(); UserView.HomePage.Instance.AddChidren(addScenePage); UserView.HomePage.Instance.PageIndex += 1; addScenePage.Show(); }); }); }; sceneRowLayout.MouseUpEventHandler += sceneclick; scene.MouseUpEventHandler += sceneclick; btnsceneback.MouseUpEventHandler += sceneclick; #endregion #region ----- 安防模式------ ///安防模式 var securityRowLayout = new RowLayout { Height = Application.GetRealHeight(180), //BackgroundColor = 0xff323232, Y = sceneRowLayout.Bottom, }; middle.AddChidren(securityRowLayout); var security = new Button { Width = Application.GetRealWidth(400), TextID = MyInternationalizationString.securitymode, //Text = "安防模式", TextSize = 16, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; securityRowLayout.AddChidren(security); var btnsecurityback = new Button { Width = Application.GetRealWidth(110), Height = Application.GetRealHeight(110), UnSelectedImagePath = "ZigeeLogic/next.png", SelectedImagePath = "ZigeeLogic/NextSelecte.png", X = Application.GetRealWidth(1080 - 140),//550 Gravity = Gravity.CenterVertical, }; securityRowLayout.AddChidren(btnsecurityback); EventHandler securityclick = (sender, e) => { var securityMode = new SecurityMode(); UserView.HomePage.Instance.AddChidren(securityMode); UserView.HomePage.Instance.PageIndex += 1; securityMode.Show(); }; securityRowLayout.MouseUpEventHandler += securityclick; security.MouseUpEventHandler += securityclick; btnsecurityback.MouseUpEventHandler += securityclick; #endregion #region ----- 已有自动化------ ///已有自动化 var existenceRowLayout = new RowLayout { Height = Application.GetRealHeight(180), //BackgroundColor = 0xff323232, Y = securityRowLayout.Bottom, }; //middle.AddChidren(existenceRowLayout); var existence = new Button { Width = Application.GetRealWidth(400), TextID = MyInternationalizationString.Alreadyautomated, //Text = "已有自动化", TextSize = 16, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; existenceRowLayout.AddChidren(existence); var btnexistenceback = new Button { Width = Application.GetRealWidth(110), Height = Application.GetRealHeight(110), UnSelectedImagePath = "ZigeeLogic/next.png", SelectedImagePath = "ZigeeLogic/NextSelecte.png", X = Application.GetRealWidth(1080 - 140),//550 Gravity = Gravity.CenterVertical, }; existenceRowLayout.AddChidren(btnexistenceback); EventHandler existenceclick = (sender, e) => { var logicListPage = new LogicListPage(); UserView.HomePage.Instance.AddChidren(logicListPage); UserView.HomePage.Instance.PageIndex += 1; logicListPage.Show(); }; existenceRowLayout.MouseUpEventHandler += existenceclick; existence.MouseUpEventHandler += existenceclick; btnexistenceback.MouseUpEventHandler += existenceclick; #endregion #region ----- 延时------ var delayedRowLayout = new RowLayout { Height = Application.GetRealHeight(180), //BackgroundColor = 0xff323232, Y = securityRowLayout.Bottom, }; //middle.AddChidren(delayedRowLayout); var delayed = new Button { Width = Application.GetRealWidth(400), TextID = MyInternationalizationString.delayed, //Text = "延时", TextSize = 16, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; delayedRowLayout.AddChidren(delayed); var btndelayedback = new Button { Width = Application.GetRealWidth(110), Height = Application.GetRealHeight(110), UnSelectedImagePath = "ZigeeLogic/next.png", SelectedImagePath = "ZigeeLogic/NextSelecte.png", X = Application.GetRealWidth(1080 - 140),//550 Gravity = Gravity.CenterVertical, }; delayedRowLayout.AddChidren(btndelayedback); EventHandler delayedclick = (sender, e) => { //var delayTime = new DelayTime(); //UserView.HomePage.Instance.AddChidren(delayTime); //UserView.HomePage.Instance.PageIndex += 1; //delayTime.Show(); DelayTimeView(); }; delayedRowLayout.MouseUpEventHandler += delayedclick; delayed.MouseUpEventHandler += delayedclick; btndelayedback.MouseUpEventHandler += delayedclick; #endregion } public static void DelayTimeView(Dictionary delayactionsInfo = null) { var listValues = new List(); for (int i = 0; i < 60; i++) { listValues.Add(i.ToString() + " " + Language.StringByID(MyInternationalizationString.second)); } var list = new List> { }; for (int i = 0; i <= 60; i++) { list.Add(new KeyValuePair(i.ToString() + " " + Language.StringByID(MyInternationalizationString.minute), listValues.ToArray())); } /* PickerView.Show(list, (obj) => { var minute = obj.Split(',')[0].Split(' ')[0]; var second = obj.Split(',')[1].Split(' ')[0]; int value = int.Parse(minute) * 60 + int.Parse(second); if (value == 0) { var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt), "时间不能为0", Language.StringByID(MyInternationalizationString.complete)); alert.Show(); return; } if (delayactionsInfo == null) { Dictionary actionsInfo = new Dictionary(); actionsInfo.Add("LinkType", 10); actionsInfo.Add("DelayTime", value); Common.Logic.CurrentLogic.Actions.Add(actionsInfo); } else { if (delayactionsInfo.ContainsKey("DelayTime")) { delayactionsInfo.Remove("DelayTime"); } delayactionsInfo.Add("DelayTime", value); } var logicCommunalPage = new LogicCommunalPage { }; UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }, Language.StringByID(MyInternationalizationString.complete), ""); */ } } }