void RefreshDay() { int a = daysTable[month - 1]; if (a == 1) { if (year % 4 == 0)//闰二月 { a++; } } Days.Clear(); for (int i = 0; i < a; i++) { Days.Add((i + 1).ToString()); } Day.Refresh(0, Day.Point); UpdateItems(Day); }
public override void Initial(FakeStruct mod, UIElement element, Initializer initializer) { base.Initial(mod, element, initializer); var mui = Enity.GetComponent <UIElement>(); mui.userEvent.CutRect = true; var mask = Enity.transform; Year = mask.Find("Year").GetComponent <UIElement>().composite as ScrollY; Year.SetItemUpdate <ItemView, int>((o, e, i) => { o.Item.Text = e.ToString(); }); Year.Scroll = Scrolling; Year.ScrollEnd = YearScrollToEnd; Year.ItemDockCenter = true; Year.scrollType = ScrollType.Loop; Month = mask.Find("Month").GetComponent <UIElement>().composite as ScrollY; Month.SetItemUpdate <ItemView, string>((o, e, i) => { o.Item.Text = e; }); Month.Scroll = Scrolling; Month.ScrollEnd = MonthScrollToEnd; Month.ItemDockCenter = true; Month.scrollType = ScrollType.Loop; Day = mask.Find("Day").GetComponent <UIElement>().composite as ScrollY; Day.SetItemUpdate <ItemView, string>((o, e, i) => { o.Item.Text = e; }); Day.Scroll = Scrolling; Day.ScrollEnd = DayScrollToEnd; Day.ItemDockCenter = true; Day.ScrollEnd = DayScrollToEnd; Day.scrollType = ScrollType.Loop; var ex = UITransfromLoader.GetCompositeData(mod); if (ex != null) { StartYear = ex[0]; EndYear = ex[1]; if (EndYear < StartYear) { EndYear = StartYear; } } year = StartYear; month = 1; day = 1; int len = EndYear - StartYear; ys = new int[len]; int s = StartYear; for (int i = 0; i < len; i++) { ys[i] = s; s++; } Year.BindingData = ys; Year.Refresh(); ms = new string[12]; for (int i = 0; i < 12; i++) { ms[i] = (i + 1).ToString(); } Month.BindingData = ms; Month.Refresh(); Days = new List <string>(); for (int i = 0; i < 31; i++) { Days.Add((i + 1).ToString()); } Day.BindingData = Days; Day.Refresh(); UpdateItems(Year); UpdateItems(Month); UpdateItems(Day); }
public override void Initial(ModelElement mod) { model = mod; var mask = model.Find("mask"); var y = mask.Find("Year"); Year = new ScrollY(); Year.Initial(y); Year.SetItemUpdate <ItemView, int>((o, e, i) => { o.Item.text = e.ToString() + unitY; }); Year.Scroll = Scrolling; Year.ScrollEnd = YearScrollToEnd; Year.ItemDockCenter = true; Year.scrollType = ScrollType.Loop; Year.eventCall.boxSize = new Vector2(120, 160); Year.eventCall.UseAssignSize = true; var m = mask.Find("Month"); Month = new ScrollY(); Month.Initial(m); Month.SetItemUpdate <ItemView, string>((o, e, i) => { o.Item.text = e + unitM; }); Month.Scroll = Scrolling; Month.ScrollEnd = MonthScrollToEnd; Month.ItemDockCenter = true; Month.scrollType = ScrollType.Loop; Month.eventCall.boxSize = new Vector2(120, 160); Month.eventCall.UseAssignSize = true; var d = mask.Find("Day"); Day = new ScrollY(); Day.Initial(d); Day.SetItemUpdate <ItemView, string>((o, e, i) => { o.Item.text = e + unitD; }); Day.Scroll = Scrolling; Day.ScrollEnd = DayScrollToEnd; Day.ItemDockCenter = true; Day.ScrollEnd = DayScrollToEnd; Day.scrollType = ScrollType.Loop; Day.eventCall.boxSize = new Vector2(120, 160); Day.eventCall.UseAssignSize = true; var fs = mod.GetExtand() as FakeStruct; if (fs != null) { StartYear = fs[0]; EndYear = fs[1]; if (EndYear < StartYear) { EndYear = StartYear; } } year = StartYear; month = 1; day = 1; int len = EndYear - StartYear; ys = new int[len]; int s = StartYear; for (int i = 0; i < len; i++) { ys[i] = s; s++; } Year.BindingData = ys; Year.Refresh(); ms = new string[12]; for (int i = 0; i < 12; i++) { ms[i] = (i + 1).ToString(); } Month.BindingData = ms; Month.Refresh(); Days = new List <string>(); for (int i = 0; i < 31; i++) { Days.Add((i + 1).ToString()); } Day.BindingData = Days; Day.Refresh(); UpdateItems(Year); UpdateItems(Month); UpdateItems(Day); }