using System; using System.Collections.Generic; using Shared; using Shared.Common; using Shared.Phone.Device; using Shared.R; using ZigBee.Device; namespace Shared.Phone.Device.Logic { public class AddLogicPage : FrameLayout { public AddLogicPage () { 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 { TextID = MyInternationalizationString.selection, TextSize = 17, TextColor = ZigbeeColor.Current.LogicTextBlackColor, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(150), }; 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 FrameLayout (); middle.Y = topFrameLayout.Bottom; middle.Height = Application.GetRealHeight (1920 - 220); middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor; this.AddChidren (middle); #region ----时间条件---- var timerowlayout = new RowLayout { Height = Application.GetRealHeight (180), //Y=pointtimerowlayout.Bottom, }; middle.AddChidren (timerowlayout); ///时间条件 var btntime = new Button { Text=Language.StringByID (MyInternationalizationString.timecondition), TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth (60), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; timerowlayout.AddChidren (btntime); var btntimeback = new Button { Width = Application.GetRealWidth (110), Height = Application.GetRealHeight (110), UnSelectedImagePath = "ZigeeLogic/next.png", SelectedImagePath = "ZigeeLogic/NextSelecte.png", X = Application.GetRealWidth (1080 - 140), Gravity = Gravity.CenterVertical, }; timerowlayout.AddChidren (btntimeback); EventHandler timeclick = (sender, e) => { //var timePage = new TimePage (); //UserView.HomePage.Instance.AddChidren (timePage); //UserView.HomePage.Instance.PageIndex += 1; //timePage.Show (); TimeView(); }; btntime.MouseUpEventHandler += timeclick; btntimeback.MouseUpEventHandler += timeclick; #endregion #region ----设备状态条件---- var devicerowlayout = new RowLayout { Height = Application.GetRealHeight (180), Y=timerowlayout.Bottom, }; middle.AddChidren (devicerowlayout); ///设备状态条件 var btndevice = new Button { //Text = "设备状态条件", TextID = MyInternationalizationString.device, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth (60), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; devicerowlayout.AddChidren (btndevice); 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), Gravity = Gravity.CenterVertical, }; devicerowlayout.AddChidren (btndeviceback); EventHandler devicestateclick = (sender, e) => { Common.Logic.LogicDviceList.Clear(); if (Common.Logic.LogicDviceList.Count == 0) { Common.Logic.LogicDviceList.AddRange(LocalDevice.Current.listAllDevice.ToArray()); } var deviceStateCondition = new DeviceStateCondition(); UserView.HomePage.Instance.AddChidren(deviceStateCondition); UserView.HomePage.Instance.PageIndex += 1; deviceStateCondition.Show(); }; devicerowlayout.MouseUpEventHandler += devicestateclick; btndevice.MouseUpEventHandler += devicestateclick; btndeviceback.MouseUpEventHandler += devicestateclick; #endregion #region ----安防条件---- var securityrowlayout = new RowLayout { Height = Application.GetRealHeight(180), Y = devicerowlayout.Bottom, }; middle.AddChidren(securityrowlayout); var btnsecurity = new Button { //Text = "安防条件", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(60), TextID = MyInternationalizationString.security, TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; securityrowlayout.AddChidren(btnsecurity); 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), Gravity = Gravity.CenterVertical, }; securityrowlayout.AddChidren(btnsecurityback); EventHandler securityclick = (sender, e) => { var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; this.AddChidren(flMain); SecurityView(flMain, false); }; securityrowlayout.MouseUpEventHandler += securityclick; btnsecurity.MouseUpEventHandler += securityclick; btnsecurityback.MouseUpEventHandler += securityclick; #endregion #region ----已有自动化条件---- var existencerowlayout = new RowLayout { Height = Application.GetRealHeight (180), Y= securityrowlayout.Bottom, }; //middle.AddChidren (existencerowlayout); ///已有自动化条件 var btnexistence = new Button { //Text = "已有自动化条件", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(60), TextID = MyInternationalizationString.automation, TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; existencerowlayout.AddChidren (btnexistence); 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), Gravity=Gravity.CenterVertical, }; existencerowlayout.AddChidren (btnexistenceback); EventHandler logicclick = (sender, e) => { var logicListAutomation = new LogicListAutomation (); UserView.HomePage.Instance.AddChidren (logicListAutomation); UserView.HomePage.Instance.PageIndex += 1; logicListAutomation.Show (); }; btnexistenceback.MouseUpEventHandler += logicclick; btnexistence.MouseUpEventHandler += logicclick; existencerowlayout.MouseUpEventHandler += logicclick; #endregion #region ----地理围栏条件---- var locationrowlayout = new RowLayout { Height = Application.GetRealHeight(180), Y = securityrowlayout.Bottom, }; //middle.AddChidren(locationrowlayout); var btnlocation = new Button { //Text = "地理围栏", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(60), TextID = MyInternationalizationString.location, TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; locationrowlayout.AddChidren(btnlocation); var btnlocationback = new Button { Width = Application.GetRealWidth(110), Height = Application.GetRealHeight(110), UnSelectedImagePath = "ZigeeLogic/next.png", SelectedImagePath = "ZigeeLogic/NextSelecte.png", X = Application.GetRealWidth(1080 - 140), Gravity = Gravity.CenterVertical, }; locationrowlayout.AddChidren(btnlocationback); EventHandler locationclick = (sender, e) => { var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; this.AddChidren(flMain); LocationView(flMain, false); }; locationrowlayout.MouseUpEventHandler += locationclick; btnlocation.MouseUpEventHandler += locationclick; btnlocationback.MouseUpEventHandler += locationclick; #endregion } /// /// 安防条件View /// /// Fl main. /// If set to true edit. public static void SecurityView(FrameLayout flMain, bool edit) { UserView.HomePage.Instance.ScrollEnabled = false; Dictionary SecurityConditionsInfo = new Dictionary(); //var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; //this.AddChidren(flMain); flMain.MouseUpEventHandler += (sender12, e12) => { flMain.RemoveFromParent(); }; var devicefra = new FrameLayout { Width = Application.GetRealWidth(1080 - 80), Height = Application.GetRealHeight(720), Y = Application.GetRealHeight(1920 - 30 - 720), X = Application.GetRealWidth(40), BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, Radius = (uint)Application.GetRealHeight(50), }; flMain.AddChidren(devicefra); var devicename = new Button { Y = Application.GetRealHeight(20), TextID = MyInternationalizationString.securityconditions, TextColor = ZigbeeColor.Current.LogicTextBlackColor, Height = Application.GetRealHeight(150), Width = Application.GetRealWidth(1080 - 80), }; devicefra.AddChidren(devicename); if (SecurityConditionsInfo.ContainsKey("Type")) { SecurityConditionsInfo.Remove("Type"); } if (SecurityConditionsInfo.ContainsKey("IsValid")) { SecurityConditionsInfo.Remove("IsValid"); } if (SecurityConditionsInfo.ContainsKey("ModeId")) { SecurityConditionsInfo.Remove("ModeId"); } SecurityConditionsInfo.Add("Type", "6"); SecurityConditionsInfo.Add("IsValid", "1"); SecurityConditionsInfo.Add("ModeId", "0"); var defenceRowLayout = new RowLayout { Height = Application.GetRealHeight(180), Y = devicename.Bottom, }; devicefra.AddChidren(defenceRowLayout); var btndefence = new Button { Width = Application.GetRealWidth(600), TextID = MyInternationalizationString.defence, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), TextColor = ZigbeeColor.Current.LogicTextBlackColor, //Text="布防", }; defenceRowLayout.AddChidren(btndefence); var defenceSelected = new Button { X = Application.GetRealWidth(1000 - 150), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/YesSelected.png", Visible = false, Gravity = Gravity.CenterVertical }; defenceRowLayout.AddChidren(defenceSelected); var withdrawalRowLayout = new RowLayout { Y = defenceRowLayout.Bottom, Height = Application.GetRealHeight(180), }; devicefra.AddChidren(withdrawalRowLayout); var btnwithdrawal = new Button { Width = Application.GetRealWidth(600), TextID = MyInternationalizationString.withdrawal, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), TextColor = ZigbeeColor.Current.LogicTextBlackColor, //Text = "撤防", }; withdrawalRowLayout.AddChidren(btnwithdrawal); var withdrawalSelected = new Button { X = Application.GetRealWidth(1000 - 150), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/YesSelected.png", Visible = false, Gravity = Gravity.CenterVertical }; withdrawalRowLayout.AddChidren(withdrawalSelected); ///布防点击事件 EventHandler copenclick = (sedner14, e14) => { UserView.HomePage.Instance.ScrollEnabled = true; defenceSelected.Visible = true; withdrawalSelected.Visible = false; if (SecurityConditionsInfo.ContainsKey("EnOrWithdrawMode")) { SecurityConditionsInfo.Remove("EnOrWithdrawMode"); } SecurityConditionsInfo.Add("EnOrWithdrawMode", "0"); LogicIfon.AddSecurityconditions(SecurityConditionsInfo); var logicCommunalPage = new LogicCommunalPage(); UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }; btndefence.MouseUpEventHandler += copenclick; defenceRowLayout.MouseUpEventHandler += copenclick; defenceSelected.MouseUpEventHandler += copenclick; ///撤防点击事件 EventHandler disableclick = (sedner15, e15) => { UserView.HomePage.Instance.ScrollEnabled = true; defenceSelected.Visible = false; withdrawalSelected.Visible = true; if (SecurityConditionsInfo.ContainsKey("EnOrWithdrawMode")) { SecurityConditionsInfo.Remove("EnOrWithdrawMode"); } SecurityConditionsInfo.Add("EnOrWithdrawMode", "1"); LogicIfon.AddSecurityconditions(SecurityConditionsInfo); var logicCommunalPage = new LogicCommunalPage(); UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }; withdrawalRowLayout.MouseUpEventHandler += disableclick; btnwithdrawal.MouseUpEventHandler += disableclick; withdrawalSelected.MouseUpEventHandler += disableclick; if (edit) { foreach (var securityifon in Common.Logic.CurrentLogic.Conditions) { if (securityifon["Type"] == "6") { if (securityifon["EnOrWithdrawMode"] == "0") { defenceSelected.Visible = true; withdrawalSelected.Visible = false; } else { defenceSelected.Visible = false; withdrawalSelected.Visible = true; } break; } } } var cancel = new Button { Height = Application.GetRealHeight(160), TextID = MyInternationalizationString.cancel, TextColor = ZigbeeColor.Current.LogicTextBlackColor, TextSize = 16, BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor, Y = devicefra.Height - Application.GetRealHeight(160), }; devicefra.AddChidren(cancel); cancel.MouseUpEventHandler += (sender16, e16) => { flMain.RemoveFromParent(); UserView.HomePage.Instance.ScrollEnabled = true; }; } /// /// 地理围栏View /// /// Fl main. /// If set to true edit. public static void LocationView(FrameLayout flMain, bool edit) { UserView.HomePage.Instance.ScrollEnabled = false; Dictionary LocationConditionsInfo = new Dictionary(); //var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; //this.AddChidren(flMain); flMain.MouseUpEventHandler += (sender12, e12) => { flMain.RemoveFromParent(); }; var Locationfra = new FrameLayout { Width = Application.GetRealWidth(1080 - 80), Height = Application.GetRealHeight(720), Y = Application.GetRealHeight(1920 - 30 - 720), X = Application.GetRealWidth(40), BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, Radius = (uint)Application.GetRealHeight(50), }; flMain.AddChidren(Locationfra); var locationviewname = new Button { Y = Application.GetRealHeight(20), TextID = MyInternationalizationString.locationmode, TextColor = ZigbeeColor.Current.LogicTextBlackColor, Height = Application.GetRealHeight(150), Width = Application.GetRealWidth(1080 - 80), //Text="位置模式", }; Locationfra.AddChidren(locationviewname); if (LocationConditionsInfo.ContainsKey("Type")) { LocationConditionsInfo.Remove("Type"); } if (LocationConditionsInfo.ContainsKey("IsValid")) { LocationConditionsInfo.Remove("IsValid"); } LocationConditionsInfo.Add("Type", "7"); LocationConditionsInfo.Add("IsValid", "1"); var leavehomeRowLayout = new RowLayout { Height = Application.GetRealHeight(180), Y = locationviewname.Bottom, }; Locationfra.AddChidren(leavehomeRowLayout); var btnleavehome = new Button { Width = Application.GetRealWidth(600), TextID = MyInternationalizationString.leavehome, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), TextColor = ZigbeeColor.Current.LogicTextBlackColor, //Text="离家", }; leavehomeRowLayout.AddChidren(btnleavehome); var leavehomeSelected = new Button { X = Application.GetRealWidth(1000 - 150), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/YesSelected.png", Visible = false, Gravity = Gravity.CenterVertical }; leavehomeRowLayout.AddChidren(leavehomeSelected); var athomeRowLayout = new RowLayout { Y = leavehomeRowLayout.Bottom, Height = Application.GetRealHeight(180), }; Locationfra.AddChidren(athomeRowLayout); var btnathome = new Button { Width = Application.GetRealWidth(600), TextID = MyInternationalizationString.athome, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), TextColor = ZigbeeColor.Current.LogicTextBlackColor, //Text = "在家", }; athomeRowLayout.AddChidren(btnathome); var athomeSelected = new Button { X = Application.GetRealWidth(1000 - 150), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/YesSelected.png", Visible = false, Gravity = Gravity.CenterVertical }; athomeRowLayout.AddChidren(athomeSelected); ///离家点击事件 EventHandler leavehomeclick = (sedner14, e14) => { UserView.HomePage.Instance.ScrollEnabled = true; leavehomeSelected.Visible = true; athomeSelected.Visible = false; if (LocationConditionsInfo.ContainsKey("AtHome")) { LocationConditionsInfo.Remove("AtHome"); } LocationConditionsInfo.Add("AtHome", "0"); LogicIfon.AddLocationconditions(LocationConditionsInfo); var logicCommunalPage = new LogicCommunalPage(); UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }; btnleavehome.MouseUpEventHandler += leavehomeclick; leavehomeSelected.MouseUpEventHandler += leavehomeclick; leavehomeRowLayout.MouseUpEventHandler += leavehomeclick; ///在家点击事件 EventHandler athomeclick = (sedner15, e15) => { UserView.HomePage.Instance.ScrollEnabled = true; leavehomeSelected.Visible = false; athomeSelected.Visible = true; if (LocationConditionsInfo.ContainsKey("AtHome")) { LocationConditionsInfo.Remove("AtHome"); } LocationConditionsInfo.Add("AtHome", "1"); LogicIfon.AddLocationconditions(LocationConditionsInfo); var logicCommunalPage = new LogicCommunalPage(); UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }; btnathome.MouseUpEventHandler += athomeclick; athomeSelected.MouseUpEventHandler += athomeclick; athomeRowLayout.MouseUpEventHandler += athomeclick; if (edit) { foreach (var Locationifon in Common.Logic.CurrentLogic.Conditions) { if (Locationifon["Type"] == "7") { if (Locationifon["AtHome"] == "0") { leavehomeSelected.Visible = true; athomeSelected.Visible = false; } else { leavehomeSelected.Visible = false; athomeSelected.Visible = true; } break; } } } var cancel = new Button { Height = Application.GetRealHeight(160), TextID = MyInternationalizationString.cancel, TextColor = ZigbeeColor.Current.LogicTextBlackColor, TextSize = 16, BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor, Y = Locationfra.Height - Application.GetRealHeight(160), }; Locationfra.AddChidren(cancel); cancel.MouseUpEventHandler += (sender16, e16) => { flMain.RemoveFromParent(); UserView.HomePage.Instance.ScrollEnabled = true; }; } /// /// 时间条件View /// void TimeView() { UserView.HomePage.Instance.ScrollEnabled = false; Dictionary SecurityConditionsInfo = new Dictionary(); var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; this.AddChidren(flMain); flMain.MouseUpEventHandler += (sender12, e12) => { flMain.RemoveFromParent(); }; var timetypeframelayout = new FrameLayout { Width = Application.GetRealWidth(1080 - 80), Height = Application.GetRealHeight(720), Y = Application.GetRealHeight(1920 - 30 - 720), X = Application.GetRealWidth(40), BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, Radius = (uint)Application.GetRealHeight(50), }; flMain.AddChidren(timetypeframelayout); var Btntitle= new Button { Y = Application.GetRealHeight(20), TextID = MyInternationalizationString.Selectedtimetype, TextColor = ZigbeeColor.Current.LogicTextBlackColor, Height = Application.GetRealHeight(150), Width = Application.GetRealWidth(1080 - 80), //Text="时间类型", }; timetypeframelayout.AddChidren(Btntitle); var timepointrow= new RowLayout { Height = Application.GetRealHeight(180), Y = Btntitle.Bottom, }; timetypeframelayout.AddChidren(timepointrow); var Btntimepoint = new Button { Width = Application.GetRealWidth(600), TextID = MyInternationalizationString.immediateexecution, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), TextColor = ZigbeeColor.Current.LogicTextBlackColor, //Text="立即执行", }; timepointrow.AddChidren(Btntimepoint); var timerow = new RowLayout { Y = timepointrow.Bottom, Height = Application.GetRealHeight(180), }; timetypeframelayout.AddChidren(timerow); var Btntime = new Button { Width = Application.GetRealWidth(600), TextID = MyInternationalizationString.timeframe, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), TextColor = ZigbeeColor.Current.LogicTextBlackColor, //Text = "时间范围", }; timerow.AddChidren(Btntime); ///立即执行点击事件 EventHandler timepointclick = (sedner14, e14) => { Dictionary timeConditionsInfo = new Dictionary(); timeConditionsInfo.Add("Type", "0"); timeConditionsInfo.Add("IsValid", "1"); timeConditionsInfo.Add("DateType", "1"); timeConditionsInfo.Add("RemindTime", "0"); timeConditionsInfo.Add("EnDelay", "0"); timeConditionsInfo.Add("DelayTime", "0"); timeConditionsInfo.Add("AdjustTime", "0"); UserView.HomePage.Instance.ScrollEnabled = true; flMain.RemoveFromParent(); var timePoint = new TimePoint(); UserView.HomePage.Instance.AddChidren(timePoint); UserView.HomePage.Instance.PageIndex += 1; timePoint.Show(timeConditionsInfo); }; Btntimepoint.MouseUpEventHandler += timepointclick; timepointrow.MouseUpEventHandler += timepointclick; ///时间范围点击事件 EventHandler timeclick = (sedner15, e15) => { UserView.HomePage.Instance.ScrollEnabled = true; flMain.RemoveFromParent(); var timePage = new TimePage(); UserView.HomePage.Instance.AddChidren (timePage); UserView.HomePage.Instance.PageIndex += 1; timePage.Show (); }; Btntime.MouseUpEventHandler += timeclick; timerow.MouseUpEventHandler += timeclick; var cancel = new Button { Height = Application.GetRealHeight(160), TextID = MyInternationalizationString.cancel, TextColor = ZigbeeColor.Current.LogicTextBlackColor, TextSize = 16, BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor, Y = timetypeframelayout.Height - Application.GetRealHeight(160), }; timetypeframelayout.AddChidren(cancel); cancel.MouseUpEventHandler += (sender16, e16) => { flMain.RemoveFromParent(); UserView.HomePage.Instance.ScrollEnabled = true; }; } } }