public override void Initial(ModelElement mod) { model = mod; var scr = mod.Find("Scroll"); scroll = new ScrollY(); scroll.Initial(scr); var sli = mod.Find("Slider"); slider = new UISlider(); slider.Initial(sli); scroll.Scroll = (o, e) => { slider.Percentage = 1 - scroll.Pos; if (Scroll != null) { Scroll(o, e); } }; slider.OnValueChanged = (o) => { scroll.Pos = 1 - slider.Percentage; if (OnValueChanged != null) { OnValueChanged(o); } }; }
public static ScrollY CreateSrollY(string name) { var mod = CreateScroll(name); var scroll = new ScrollY(); scroll.Initial(mod); return(scroll); }
public override void Initial(ModelElement mod) { main = mod; Label = mod.Find("Label"); ShowLabel = Label.GetComponent <TextElement>(); callBack = EventCallBack.RegEvent <EventCallBack>(mod); callBack.Click = Show; var scroll = mod.Find("Scroll"); if (scroll != null) { m_scroll = new ScrollY(); m_scroll.Initial(scroll); scroll.activeSelf = false; } }
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); }