New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Shared; |
| | | using Shared.Phone; |
| | | using Shared.R; |
| | | using Shared.Common; |
| | | namespace Shared.Phone.Device.Logic |
| | | { |
| | | public class EveryyearPage : FrameLayout |
| | | { |
| | | |
| | | |
| | | public void Show() |
| | | { |
| | | |
| | | this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor; |
| | | var topFrameLayout = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(140), |
| | | Y = Application.GetRealHeight(80), |
| | | // BackgroundColor = 0xFF1F1F1F, |
| | | }; |
| | | AddChidren(topFrameLayout); |
| | | |
| | | var titleName = new Button |
| | | { |
| | | TextID = MyInternationalizationString.cycle, |
| | | TextSize = 16, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | IsBold = true, |
| | | }; |
| | | topFrameLayout.AddChidren(titleName); |
| | | |
| | | var hdl = new Button |
| | | { |
| | | Width = Application.GetRealWidth(154), |
| | | Height = Application.GetRealHeight(90), |
| | | X = Application.GetRealWidth(1080 - 160), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "Logo/Logo.png", |
| | | }; |
| | | //topFrameLayout.AddChidren(hdl); |
| | | |
| | | 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), |
| | | //BackgroundColor = 0xff0f0f0f, |
| | | 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(Method.H - 220 - 180); |
| | | middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor; |
| | | this.AddChidren(middle); |
| | | |
| | | |
| | | var startdateRowLayout = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(180), |
| | | }; |
| | | middle.AddChidren(startdateRowLayout); |
| | | |
| | | var startdatetext = new Button |
| | | { |
| | | X = Application.GetRealWidth(40), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Gravity = Gravity.CenterVertical, |
| | | //Text = "起始日期", |
| | | Width = Application.GetRealWidth(400), |
| | | TextID = MyInternationalizationString.startdate, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | startdateRowLayout.AddChidren(startdatetext); |
| | | |
| | | ///显示起始日期控件 |
| | | var btnStartdate = new Button |
| | | { |
| | | Width = Application.GetRealWidth(400), |
| | | Height = Application.GetRealHeight(180), |
| | | X = Application.GetRealWidth(440), |
| | | Gravity = Gravity.CenterVertical, |
| | | Tag = 0, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | |
| | | }; |
| | | startdateRowLayout.AddChidren(btnStartdate); |
| | | |
| | | var btnStartdateback = new Button |
| | | { |
| | | Width = Application.GetRealWidth(110), |
| | | Height = Application.GetRealHeight(110), |
| | | UnSelectedImagePath = "ZigeeLogic/next.png", |
| | | X = Application.GetRealWidth(1080 - 140), |
| | | Gravity = Gravity.CenterVertical, |
| | | }; |
| | | startdateRowLayout.AddChidren(btnStartdateback); |
| | | |
| | | var enddateRowLayout = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(180), |
| | | }; |
| | | middle.AddChidren(enddateRowLayout); |
| | | |
| | | var enddtaetext = new Button |
| | | { |
| | | X = Application.GetRealWidth(40), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Gravity = Gravity.CenterVertical, |
| | | TextID = MyInternationalizationString.enddate, |
| | | Width = Application.GetRealWidth(400), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | //Text = "结束日期", |
| | | }; |
| | | enddateRowLayout.AddChidren(enddtaetext); |
| | | |
| | | ///显示结束日期控件 |
| | | var btndateEnddate = new Button |
| | | { |
| | | Width = Application.GetRealWidth(400), |
| | | Height = Application.GetRealHeight(180), |
| | | X = Application.GetRealWidth(440), |
| | | Gravity = Gravity.CenterVertical, |
| | | Tag = 0, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | |
| | | }; |
| | | enddateRowLayout.AddChidren(btndateEnddate); |
| | | |
| | | |
| | | var btnenddateback = new Button |
| | | { |
| | | Width = Application.GetRealWidth(110), |
| | | Height = Application.GetRealHeight(110), |
| | | UnSelectedImagePath = "ZigeeLogic/next.png", |
| | | X = Application.GetRealWidth(1080 - 140), |
| | | Gravity = Gravity.CenterVertical, |
| | | }; |
| | | enddateRowLayout.AddChidren(btnenddateback); |
| | | |
| | | |
| | | ///起始日期点击事件 |
| | | EventHandler<MouseEventArgs> startdateclick = (sender33, e33) => |
| | | { |
| | | var list = new List<KeyValuePair<string, string[]>> { }; |
| | | for (int month = 1; month <= 12; month++) |
| | | { |
| | | int days = DateTime.DaysInMonth(DateTime.Now.Year, month); |
| | | var listValues = new List<string> { }; |
| | | for (int day = 1; day <= days; day++) |
| | | { |
| | | listValues.Add(day.ToString() + " " + Language.StringByID(MyInternationalizationString.day)); |
| | | } |
| | | list.Add(new KeyValuePair<string, string[]>(month.ToString() + " " + Language.StringByID(MyInternationalizationString.month), listValues.ToArray())); |
| | | } |
| | | /* |
| | | PickerView.Show(list, (obj) => |
| | | { |
| | | |
| | | var month = obj.Split(',')[0].Split(' ')[0]; |
| | | var day = obj.Split(',')[1].Split(' ')[0]; |
| | | |
| | | if (month.Length < 2) |
| | | { |
| | | month = "0" + month; |
| | | } |
| | | if (day.Length < 2) |
| | | { |
| | | day = "0" + day; |
| | | } |
| | | var leng = month + day; |
| | | |
| | | if (btndateEnddate.Tag.ToString() != "0" && int.Parse(btndateEnddate.Tag.ToString()) < int.Parse(leng)) |
| | | { |
| | | var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt), |
| | | Language.StringByID(MyInternationalizationString.monthday), |
| | | Language.StringByID(MyInternationalizationString.OK)); |
| | | alert.Show(); |
| | | } |
| | | else |
| | | { |
| | | btnStartdate.Text = month + "/" + day; |
| | | btnStartdate.Tag = leng; |
| | | |
| | | if (string.IsNullOrEmpty(btndateEnddate.Text)) |
| | | { |
| | | btndateEnddate.Text = month + "/" + day; |
| | | btndateEnddate.Tag = leng; |
| | | } |
| | | time(btnStartdate, btndateEnddate); |
| | | } |
| | | |
| | | }, Language.StringByID(MyInternationalizationString.complete), ""); |
| | | */ |
| | | }; |
| | | startdateRowLayout.MouseUpEventHandler += startdateclick; |
| | | btnStartdate.MouseUpEventHandler += startdateclick; |
| | | startdatetext.MouseUpEventHandler += startdateclick; |
| | | btnStartdateback.MouseUpEventHandler += startdateclick; |
| | | |
| | | |
| | | |
| | | ///结束日期点击事件 |
| | | EventHandler<MouseEventArgs> enddateclick = (sender1, e1) => |
| | | { |
| | | |
| | | var list1 = new List<KeyValuePair<string, string[]>> { }; |
| | | for (int month = 1; month <= 12; month++) |
| | | { |
| | | int days = DateTime.DaysInMonth(DateTime.Now.Year, month); |
| | | var listValues = new List<string> { }; |
| | | for (int day = 1; day <= days; day++) |
| | | { |
| | | listValues.Add(day.ToString() + " " + Language.StringByID(MyInternationalizationString.day)); |
| | | } |
| | | list1.Add(new KeyValuePair<string, string[]>(month.ToString() + " " + Language.StringByID(MyInternationalizationString.month), listValues.ToArray())); |
| | | } |
| | | /* |
| | | PickerView.Show(list1, (obj) => |
| | | { |
| | | var month = obj.Split(',')[0].Split(' ')[0]; |
| | | var day = obj.Split(',')[1].Split(' ')[0]; |
| | | if (month.Length < 2) |
| | | { |
| | | month = "0" + month; |
| | | } |
| | | if (day.Length < 2) |
| | | { |
| | | day = "0" + day; |
| | | } |
| | | var leng = month + day; |
| | | |
| | | if (btnStartdate.Tag.ToString() != "0" && int.Parse(btnStartdate.Tag.ToString()) > int.Parse(leng)) |
| | | { |
| | | var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt), |
| | | Language.StringByID(MyInternationalizationString.monthday), |
| | | Language.StringByID(MyInternationalizationString.OK)); |
| | | alert.Show(); |
| | | } |
| | | else |
| | | { |
| | | btndateEnddate.Text = month + "/" + day; |
| | | btndateEnddate.Tag = leng; |
| | | |
| | | if (string.IsNullOrEmpty(btnStartdate.Text)) |
| | | { |
| | | btnStartdate.Text = month + "/" + day; |
| | | btnStartdate.Tag = leng; |
| | | } |
| | | |
| | | time(btnStartdate, btndateEnddate); |
| | | } |
| | | |
| | | }, Language.StringByID(MyInternationalizationString.complete), ""); |
| | | |
| | | */ |
| | | }; |
| | | enddateRowLayout.MouseUpEventHandler += enddateclick; |
| | | enddtaetext.MouseUpEventHandler += enddateclick; |
| | | btndateEnddate.MouseUpEventHandler += enddateclick; |
| | | btnenddateback.MouseUpEventHandler += enddateclick; |
| | | |
| | | if (Common.Logic.CurrentLogic.TimeAttribute.Repeat == 4) |
| | | { |
| | | |
| | | Dictionary<int, int> dictionary = new Dictionary<int, int>(); |
| | | ///找出执行的月份和天数 |
| | | if (Common.Logic.CurrentLogic.TimeAttribute.SelectMonDate.Count != 0) |
| | | { |
| | | for (int i = 0; i < Common.Logic.CurrentLogic.TimeAttribute.SelectMonDate.Count; i++) |
| | | { |
| | | var dayvalue = Common.Logic.CurrentLogic.TimeAttribute.SelectMonDate[i]; |
| | | if (dayvalue != 0) |
| | | { |
| | | dictionary.Add(i + 1, dayvalue); |
| | | } |
| | | } |
| | | } |
| | | if (dictionary.Count != 0 && dictionary.Count == 1) |
| | | { |
| | | string len = "", leng = ""; |
| | | int minvalue = 0, Maximum = 0; |
| | | foreach (var value in dictionary) |
| | | { |
| | | ///取出月份 |
| | | var month = value.Key; |
| | | ///取出日数 |
| | | var day = value.Value; |
| | | ///转换成二进制bit |
| | | var maxvalue = Convert.ToString(day, 2); |
| | | ///转换成32位string; |
| | | var str = maxvalue.Insert(0, new string('0', 32 - maxvalue.Length)); |
| | | ///重新排列32位string顺序; |
| | | 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") |
| | | { |
| | | minvalue = j + 1; |
| | | break; |
| | | } |
| | | } |
| | | ///找出结束日 |
| | | for (int j = 0; j < len.Length; j++) |
| | | { |
| | | var strvalue = len.Substring(j, 1); |
| | | if (strvalue == "1") |
| | | { |
| | | Maximum = j + 1; |
| | | |
| | | } |
| | | } |
| | | |
| | | if (month.ToString().Length < 2) |
| | | { |
| | | leng = "0" + month.ToString(); |
| | | } |
| | | else |
| | | { |
| | | leng = month.ToString(); |
| | | } |
| | | |
| | | btnStartdate.Text = leng + "/" + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString()); |
| | | btndateEnddate.Text = leng + "/" + (Maximum.ToString().Length < 2 ? "0" + Maximum.ToString() :Maximum.ToString()); |
| | | btnStartdate.Tag = leng + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString()); |
| | | btndateEnddate.Tag = leng + (Maximum.ToString().Length < 2 ? "0" + Maximum.ToString() : Maximum.ToString()); |
| | | |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | int b = 0; |
| | | foreach (var value in dictionary) |
| | | { |
| | | string len = "", leng = ""; |
| | | int minvalue = 0,Maximum=0; |
| | | ///取出月份 |
| | | var month = value.Key; |
| | | ///取出日数 |
| | | var day = value.Value; |
| | | ///转换成二进制bit |
| | | var maxvalue = Convert.ToString(day, 2); |
| | | ///转换成32位string; |
| | | var str = maxvalue.Insert(0, new string('0', 32 - maxvalue.Length)); |
| | | ///重新排列32位string顺序; |
| | | for (int j = 31; j >= 0; j--) |
| | | { |
| | | len += str.Substring(j, 1); |
| | | } |
| | | |
| | | |
| | | if (month.ToString().Length < 2) |
| | | { |
| | | leng = "0" + month.ToString(); |
| | | } |
| | | else |
| | | { |
| | | leng = month.ToString(); |
| | | } |
| | | ///第一个dictionary元素 |
| | | if (b == 0) |
| | | { |
| | | ///找出开始日 |
| | | for (int j = 0; j < len.Length; j++) |
| | | { |
| | | var strvalue = len.Substring(j, 1); |
| | | if (strvalue == "1") |
| | | { |
| | | minvalue = j + 1; |
| | | break; |
| | | } |
| | | } |
| | | btnStartdate.Text = leng + "/" + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString()); |
| | | btnStartdate.Tag = leng + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString()); |
| | | |
| | | } |
| | | ///第二个dictionary元素 |
| | | if (b == dictionary.Count - 1) |
| | | { |
| | | ///找出结束日 |
| | | for (int j = 0; j < len.Length; j++) |
| | | { |
| | | var strvalue = len.Substring(j, 1); |
| | | if (strvalue == "1") |
| | | { |
| | | Maximum = j + 1; |
| | | } |
| | | } |
| | | btndateEnddate.Text = leng + "/" + (Maximum.ToString().Length < 2 ? "0" + Maximum.ToString() : Maximum.ToString()); |
| | | btndateEnddate.Tag = leng + (Maximum.ToString().Length < 2 ? "0" + Maximum.ToString() : Maximum.ToString()); |
| | | |
| | | } |
| | | b++; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 日期处理的方法 |
| | | /// </summary> |
| | | void time(Button btnStartdate, Button btndateEnddate) |
| | | { |
| | | |
| | | DateTime dtNow = DateTime.Now; |
| | | Common.Logic.CurrentLogic.TimeAttribute.Repeat = 4; |
| | | int a1 = int.Parse(btnStartdate.Tag.ToString()); |
| | | int a2 = int.Parse(btndateEnddate.Tag.ToString()); |
| | | int b1 = int.Parse(btnStartdate.Tag.ToString().Substring(0, 2)); |
| | | int b2 = int.Parse(btndateEnddate.Tag.ToString().Substring(0, 2)); |
| | | int c1 = int.Parse(btnStartdate.Tag.ToString().Substring(2, 2)); |
| | | int c2 = int.Parse(btndateEnddate.Tag.ToString().Substring(2, 2)); |
| | | int[] intlist = new int[12]; |
| | | int oXvalue = 0, monthvalue = 0; |
| | | ///1,先判断处理相同的月份;2,再处理不相同的月份; |
| | | if (b1 == b2) |
| | | { |
| | | for (int i = 1; i < 13; i++) |
| | | { |
| | | if (b1 == b2 && i == b1) |
| | | { |
| | | switch (i) |
| | | { |
| | | case 1: |
| | | { |
| | | oXvalue = 1; |
| | | } |
| | | break; |
| | | case 2: |
| | | { |
| | | oXvalue = 2; |
| | | } |
| | | break; |
| | | case 3: |
| | | { |
| | | oXvalue = 4; |
| | | } |
| | | break; |
| | | case 4: |
| | | { |
| | | oXvalue = 8; |
| | | } |
| | | break; |
| | | case 5: |
| | | { |
| | | oXvalue = 16; |
| | | } |
| | | break; |
| | | case 6: |
| | | { |
| | | oXvalue = 32; |
| | | } |
| | | break; |
| | | case 7: |
| | | { |
| | | oXvalue = 64; |
| | | } |
| | | break; |
| | | case 8: |
| | | { |
| | | oXvalue = 96; |
| | | } |
| | | break; |
| | | case 9: |
| | | { |
| | | oXvalue = 128; |
| | | } |
| | | break; |
| | | case 10: |
| | | { |
| | | oXvalue = 256; |
| | | } |
| | | break; |
| | | case 11: |
| | | { |
| | | oXvalue = 512; |
| | | } |
| | | break; |
| | | case 12: |
| | | { |
| | | oXvalue = 1024; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | string s = ""; |
| | | |
| | | for (int j = 32; j > 0; j--) |
| | | { |
| | | if (j >= c1 && j <= c2) |
| | | { |
| | | s += "1"; |
| | | } |
| | | else |
| | | { |
| | | s += "0"; |
| | | } |
| | | |
| | | } |
| | | var intvalue = Convert.ToInt32(s, 2); |
| | | monthvalue = oXvalue; |
| | | intlist[i - 1] = intvalue; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | for (int i = 1; i < 13; i++) |
| | | { |
| | | |
| | | if (i >= b1 && i <= b2) |
| | | { |
| | | switch (i) |
| | | { |
| | | case 1: |
| | | { |
| | | oXvalue = 1; |
| | | } |
| | | break; |
| | | case 2: |
| | | { |
| | | oXvalue = 2; |
| | | } |
| | | break; |
| | | case 3: |
| | | { |
| | | oXvalue = 4; |
| | | } |
| | | break; |
| | | case 4: |
| | | { |
| | | oXvalue = 8; |
| | | } |
| | | break; |
| | | case 5: |
| | | { |
| | | oXvalue = 16; |
| | | } |
| | | break; |
| | | case 6: |
| | | { |
| | | oXvalue = 32; |
| | | } |
| | | break; |
| | | case 7: |
| | | { |
| | | oXvalue = 64; |
| | | } |
| | | break; |
| | | case 8: |
| | | { |
| | | oXvalue = 96; |
| | | } |
| | | break; |
| | | case 9: |
| | | { |
| | | oXvalue = 128; |
| | | } |
| | | break; |
| | | case 10: |
| | | { |
| | | oXvalue = 256; |
| | | } |
| | | break; |
| | | case 11: |
| | | { |
| | | oXvalue = 512; |
| | | } |
| | | break; |
| | | case 12: |
| | | { |
| | | oXvalue = 1024; |
| | | } |
| | | break; |
| | | |
| | | } |
| | | string s = ""; |
| | | int days = DateTime.DaysInMonth(dtNow.Year, i); |
| | | |
| | | if (i == b1) |
| | | { |
| | | for (int j = 32; j > 0; j--) |
| | | { |
| | | if (j >= c1 && j <= days) |
| | | { |
| | | s += "1"; |
| | | } |
| | | else |
| | | { |
| | | s += "0"; |
| | | } |
| | | |
| | | } |
| | | } |
| | | else if (i == b2) |
| | | { |
| | | for (int j = 32; j > 0; j--) |
| | | { |
| | | if (j >= 0 && j <= c2) |
| | | { |
| | | s += "1"; |
| | | } |
| | | else |
| | | { |
| | | s += "0"; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | for (int j = 32; j > 0; j--) |
| | | { |
| | | if (j >= 0 && j <= days) |
| | | { |
| | | s += "1"; |
| | | } |
| | | else |
| | | { |
| | | s += "0"; |
| | | } |
| | | |
| | | } |
| | | } |
| | | var intvalue = Convert.ToInt32(s, 2); |
| | | intlist[i - 1] = intvalue; |
| | | monthvalue += oXvalue; |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | Common.Logic.CurrentLogic.TimeAttribute.SelectMonth = monthvalue; |
| | | Common.Logic.CurrentLogic.TimeAttribute.SelectMonDate = new List<int>(intlist); |
| | | } |
| | | } |
| | | } |