using System; using System.Collections.Generic; using Shared; using Shared.R; using Shared.Phone; using Shared.Common; namespace Shared.Phone.Device.Logic { public class WeekPage : FrameLayout { public WeekPage () { Tag = "Logic"; } public void Show () { var weeklist = new List (); 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.cycle, 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 titlerl = new RowLayout { Height = Application.GetRealHeight (180), Y = Application.GetRealHeight (220), }; AddChidren (titlerl); titlerl.AddChidren ( new Button { X = Application.GetRealWidth (40), //Text = "请选择重复执行周期", TextID = MyInternationalizationString.repeat, TextSize = 17, TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.LogicTextBlackColor, } ); var middle = new VerticalScrolViewLayout (); middle.Y = titlerl.Bottom; middle.Height = Application.GetRealHeight (1920 - 220 - 180); middle.BackgroundColor =ZigbeeColor.Current.LogicBackgroundColor; this.AddChidren (middle); if (Common.Logic.CurrentLogic.TimeAttribute.Repeat == 5) { string len = ""; var maxvalue = Convert.ToString(Common.Logic.CurrentLogic.TimeAttribute.WeekDay, 2); var str = maxvalue.Insert(0, new string('0', 8 - maxvalue.Length)); for (int j = 7; j >= 0; j--) { len += str.Substring(j, 1); } for (int j = 0; j < len.Length; j++) { var strvalue = len.Substring(j, 1); if (strvalue == "1") { if ((j + 1) == 1) { weeklist.Add(Language.StringByID(MyInternationalizationString.mon)); } else if ((j + 1) == 2) { weeklist.Add(Language.StringByID(MyInternationalizationString.tue)); } else if ((j + 1) == 3) { weeklist.Add(Language.StringByID(MyInternationalizationString.wed)); } else if ((j + 1) == 4) { weeklist.Add(Language.StringByID(MyInternationalizationString.thu)); } else if ((j + 1) == 5) { weeklist.Add(Language.StringByID(MyInternationalizationString.frl)); } else if ((j + 1) == 6) { weeklist.Add(Language.StringByID(MyInternationalizationString.sat)); } else if ((j + 1) == 7) { weeklist.Add(Language.StringByID(MyInternationalizationString.sun)); } } } } var cyclelist = new List (); cyclelist.AddRange (new string [] { Language.StringByID(MyInternationalizationString.mon), Language.StringByID(MyInternationalizationString.tue), Language.StringByID(MyInternationalizationString.wed), Language.StringByID(MyInternationalizationString.thu), Language.StringByID(MyInternationalizationString.frl), Language.StringByID(MyInternationalizationString.sat), Language.StringByID(MyInternationalizationString.sun), }); foreach (var name in cyclelist) { var cyclerwLayout = new RowLayout { Height = Application.GetRealHeight (180), }; middle.AddChidren (cyclerwLayout); var btnname = new Button { X = Application.GetRealWidth (40), Width = Application.GetRealWidth (600), Gravity = Gravity.CenterVertical, TextAlignment = TextAlignment.CenterLeft, Text = name, TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; cyclerwLayout.AddChidren (btnname); var btnCheck = new Button { Width = Application.GetRealWidth (115), Height = Application.GetRealHeight (110), Gravity = Gravity.CenterVertical, X = Application.GetRealWidth (1080-140), SelectedImagePath = "ZigeeLogic/CheckOn.png", UnSelectedImagePath = "ZigeeLogic/Check.png", }; cyclerwLayout.AddChidren (btnCheck); var str = weeklist.Find ((o) => { return o == name; }); if (str != null) { btnCheck.IsSelected = true; } ///选中时间 EventHandler weekclick = (sender, e) => { btnCheck.IsSelected = !btnCheck.IsSelected; if (btnCheck.IsSelected) { var d = weeklist.Find((o) => { return o == name; }); if (d == null) { weeklist.Add(name); } } else { weeklist.RemoveAll((o) => { return o == name; }); } int weekvalue = 0; foreach (var strname in weeklist) { if (Language.StringByID(MyInternationalizationString.mon) == strname) { weekvalue += 1; } else if (Language.StringByID(MyInternationalizationString.tue) == strname) { weekvalue += 2; } else if (Language.StringByID(MyInternationalizationString.wed) == strname) { weekvalue += 4; } else if (Language.StringByID(MyInternationalizationString.thu) == strname) { weekvalue += 8; } else if (Language.StringByID(MyInternationalizationString.frl) == strname) { weekvalue += 16; } else if (Language.StringByID(MyInternationalizationString.sat) == strname) { weekvalue += 32; } else if (Language.StringByID(MyInternationalizationString.sun) == strname) { weekvalue += 64; } } Common.Logic.CurrentLogic.TimeAttribute.Repeat = 5; Common.Logic.CurrentLogic.TimeAttribute.WeekDay = weekvalue; }; cyclerwLayout.MouseUpEventHandler += weekclick; btnname.MouseUpEventHandler += weekclick; btnCheck.MouseUpEventHandler += weekclick; } } } }