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 (string titlename) { var weeklist = new List (); #region 最上面的布局代码 var topRowLayout = new RowLayout { BackgroundColor = ZigbeeColor.Current.LogicTopBackgroundColor, Height = Application.GetRealHeight(184), LineColor = ZigbeeColor.Current.LogicRowLayoutTopLineColor, }; this.AddChidren(topRowLayout); var titleName = new Button { TextSize = 17, TextColor = ZigbeeColor.Current.LogicTextBlackColor, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(176), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(69), Y = Application.GetRealHeight(92), Text = titlename, IsBold = true, }; topRowLayout.AddChidren(titleName); var clickBtn = new Button { Width = Application.GetRealWidth(81 + 51), Height = Application.GetRealHeight(58 + 40), Y = Application.GetRealHeight(98 - 40), }; topRowLayout.AddChidren(clickBtn); clickBtn.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); }; var back = new Button { Width = Application.GetRealWidth(30), Height = Application.GetRealHeight(51), X = Application.GetRealWidth(81), Y = Application.GetRealHeight(98), //Gravity = Gravity.CenterVertical; UnSelectedImagePath = "ZigeeLogic/back.png", }; topRowLayout.AddChidren(back); back.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); }; #endregion var middle = new VerticalScrolViewLayout { Y = topRowLayout.Bottom, Height = Application.GetRealHeight(1920 - 184-260), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); var saveFramelayout = new FrameLayout { Y = middle.Bottom, Height = Application.GetRealHeight(260), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(saveFramelayout); var saveBtn= new Button { X = Application.GetRealWidth(85), Height = Application.GetRealHeight(130),//194 Width = Application.GetRealWidth(910), Radius = (uint)Application.GetRealHeight(60), BackgroundColor = ZigbeeColor.Current.LogicBtnSaveBackgroundColor, TextID = MyInternationalizationString.Save, TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor, TextSize = 16, }; saveFramelayout.AddChidren(saveBtn); 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 weekFramelayout = new FrameLayout { Height = Application.GetRealHeight(160), BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor, }; middle.AddChidren(weekFramelayout); var weekIconBtn = new Button { Width = Application.GetRealWidth(81), Height = Application.GetRealHeight(81), UnSelectedImagePath = "ZigeeLogic/point.png", X = Application.GetRealWidth(58), Y = Application.GetRealHeight(55), }; weekFramelayout.AddChidren(weekIconBtn); var weekRow = new RowLayout { Y = Application.GetRealHeight(30), Width = Application.GetRealWidth(850), Height = Application.GetRealHeight(130), X = Application.GetRealWidth(176), LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, }; weekFramelayout.AddChidren(weekRow); var weekTextBtn = new Button { TextAlignment = TextAlignment.CenterLeft, Text = name, TextColor = ZigbeeColor.Current.LogicTextBlackColor, TextSize = 15, }; weekRow.AddChidren(weekTextBtn); var selectedBtn = new Button { X = Application.GetRealWidth(789), Width = Application.GetMinRealAverage(60), Height = Application.GetMinRealAverage(60), UnSelectedImagePath = "ZigeeLogic/selected.png", Gravity = Gravity.CenterVertical, Visible = false, }; weekRow.AddChidren(selectedBtn); if (Language.StringByID(MyInternationalizationString.sun) == name) { weekRow.LineColor = ZigbeeColor.Current.LogicBlankBackgroundColor; } var str = weeklist.Find((o) => { return o == name; }); if (str != null) { selectedBtn.Visible = true; } EventHandler weekclick = (sender, e) => { selectedBtn.Visible = !selectedBtn.Visible; if (selectedBtn.Visible) { var d = weeklist.Find((o) => { return o == name; }); if (d == null) { weeklist.Add(name); } } else { weeklist.RemoveAll((o) => { return o == name; }); } }; weekFramelayout.MouseUpEventHandler += weekclick; weekTextBtn.MouseUpEventHandler += weekclick; selectedBtn.MouseUpEventHandler += weekclick; weekIconBtn.MouseUpEventHandler += weekclick; weekRow.MouseUpEventHandler += weekclick; } saveBtn.MouseUpEventHandler += (sender, e) => { 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; } } if (weekvalue == 0) { var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal, Language.StringByID(MyInternationalizationString.selectweek), Language.StringByID(MyInternationalizationString.confrim)); alert.Show(); return; } Common.Logic.CurrentLogic.TimeAttribute.Repeat = 5; Common.Logic.CurrentLogic.TimeAttribute.WeekDay = weekvalue; var logicCommunalPage = new LogicCommunalPage { }; UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }; } } }