using System; using System.Collections.Generic; using Shared; using Shared.Phone; using Shared.R; using Shared.Common; namespace Shared.Phone.Device.Logic { public class EverymonthPage : FrameLayout { public EverymonthPage() { Tag = "Logic"; } public void Show(string titlename) { #region 上面的布局代码 TopView view = new TopView(); this.AddChidren(view.TopRowView()); view.toptitleNameBtn.Text = titlename; view.clickBtn.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); }; #endregion var middle = new FrameLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(Method.H - 184), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); var frameLayout = new FrameLayout { Y = Application.GetRealHeight(80), X = Application.GetRealWidth(50), Width = Application.GetRealWidth(1080 - 100), Height = Application.GetRealHeight(180 * 5 + 50), BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, }; middle.AddChidren(frameLayout); var saveBtn = new Button { Y = middle.Height - Application.GetRealHeight(260), 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, }; middle.AddChidren(saveBtn); var monselectedlist = new List(); monselectedlist.Clear(); if (Common.Logic.CurrentLogic.TimeAttribute.Repeat == 3) { if (Common.Logic.CurrentLogic.TimeAttribute.MonthDate != 0) { string len = ""; var maxvalue = Convert.ToString(Common.Logic.CurrentLogic.TimeAttribute.MonthDate, 2); var str = maxvalue.Insert(0, new string('0', 32 - maxvalue.Length)); for (int j = 31; 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") { monselectedlist.Add((j + 1).ToString()); } } } } int k = 1; for (int i = 0; i < 5; i++) { var timeRow = new RowLayout { Height = Application.GetRealHeight(180), Y = Application.GetRealHeight(180 * i), LineColor = ZigbeeColor.Current.LogicBackgroundColor, }; frameLayout.AddChidren(timeRow); for (int j = 1; j < 8; j++) { if (k > 31) { continue; } var monBtn = new Button { Text = k.ToString().Length == 1 ? "0" + k.ToString() : k.ToString(), Y = Application.GetRealHeight(40), Height = Application.GetMinRealAverage(100), Width = Application.GetMinRealAverage(100), X = Application.GetRealWidth(35 * j) + Application.GetRealWidth(100 * (j - 1)), TextColor = ZigbeeColor.Current.LogicTextBlackColor, SelectedTextColor = ZigbeeColor.Current.LogicBlankBackgroundColor, Radius = (uint)Application.GetMinRealAverage(50), BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, SelectedBackgroundColor = ZigbeeColor.Current.LogicAddColor, Tag = k, }; timeRow.AddChidren(monBtn); if (monselectedlist.Contains(k.ToString())) { monBtn.IsSelected = true; } k++; monBtn.MouseDownEventHandler += (sender, e) => { monBtn.IsSelected = !monBtn.IsSelected; var selectedmon = monselectedlist.Find((c) => { return c == monBtn.Tag.ToString(); }); if (monBtn.IsSelected) { if (selectedmon == null) { monselectedlist.Add(monBtn.Tag.ToString()); } } else { if (selectedmon != null) { monselectedlist.Remove(monBtn.Tag.ToString()); } } }; } } saveBtn.MouseUpEventHandler += (sedder, e) => { if (monselectedlist.Count == 0) { var alert = new ShowMsgControl(ShowMsgType.Normal, Language.StringByID(MyInternationalizationString.selectweek), Language.StringByID(MyInternationalizationString.confrim)); alert.Show(); return; } string s = ""; for (int i = 32; i > 0; i--) { var selectedmon = monselectedlist.Find((a) => { return a == i.ToString(); }); if (selectedmon != null) { s += "1"; } else { s += "0"; } } var intvalue = Convert.ToInt32(s, 2); Common.Logic.CurrentLogic.TimeAttribute.Repeat = 3; Common.Logic.CurrentLogic.TimeAttribute.MonthDate = intvalue; var logicCommunalPage = new LogicCommunalPage(); UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }; } } }