Beispiel #1
0
        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);
                }
            };
        }
Beispiel #2
0
 public DropdownEx(ScrollY scroll, EventCallBack parent)
 {
     main         = parent.Target;
     parent.Click = Show;
     ShowLabel    = main.GetComponentInChildren <Text>();
     scrollY      = scroll;
 }
Beispiel #3
0
        static void CenterScroll(ScrollY scroll)
        {
            var   eve = scroll.eventCall;
            var   tar = scroll.eventCall.ScrollDistanceY;
            float ty  = scroll.ScrollView.sizeDelta.y * 0.5f;
            float v   = scroll.Point + tar + ty;
            float sy  = scroll.ItemSize.y;
            float oy  = v % sy;

            tar -= oy;
            if (oy > sy * 0.5f)
            {
                tar += sy;
            }
            tar += sy * 0.5f;
            scroll.eventCall.ScrollDistanceY = tar;
            v = scroll.Point + tar + ty;
            int i = (int)(v / sy);
            int c = scroll.DataLength;

            i %= c;
            if (i < 0)
            {
                i += c - 1;
            }
            scroll.PreDockindex = i;
        }
Beispiel #4
0
        void MonthScrollToEnd(ScrollY scroll)
        {
            var item = ScrollY.GetCenterItem(scroll.Items);

            month = item.index + 1;
            RefreshDay();
        }
Beispiel #5
0
        void UpdateItems(ScrollY scroll)
        {
            var   items = scroll.Items;
            float hy    = scroll.Enity.SizeDelta.y * 0.5f;

            for (int i = 0; i < items.Count; i++)
            {
                var   mod   = items[i].target;
                var   txt   = (items[i].obj as ItemView).Item;
                float h     = txt.SizeDelta.y;
                float y     = mod.localPosition.y;
                float angle = y / h * 15f;

                mod.localRotation = Quaternion.Euler(angle, 0, 0);
                var v = MathH.Tan2(90 - angle);
                mod.localPosition = new Vector3(0, v.y * 100, 0);
                float r = y / hy;
                if (r < 0)
                {
                    r = -r;
                }
                r = 1 - r;
                if (r < 0)
                {
                    r = 0;
                }
                var col = txt.MainColor;
                col.a         = (byte)(r * 255);
                txt.MainColor = col;
            }
        }
        void UpdateItems(ScrollY scroll)
        {
            var items = scroll.Items;

            for (int i = 0; i < items.Count; i++)
            {
                var   mod   = items[i].target;
                float h     = mod.data.sizeDelta.y;
                float y     = mod.data.localPosition.y;
                float angle = y / h * 15f;
                mod.data.localRotation = Quaternion.Euler(angle, 0, 0);

                var v = MathH.Tan2(90 - angle);
                mod.data.localPosition.y = v.y * 100;
                mod.IsChanged            = true;
                var txt = (items[i].obj as ItemView).Item;
                var col = txt.color;
                angle /= 45;
                if (angle < 0)
                {
                    angle = -angle;
                }
                col.a     = 1 - angle;
                txt.color = col;
            }
        }
Beispiel #7
0
        public override void Initial(FakeStruct mod, UIElement script, Initializer initializer)
        {
            base.Initial(mod, script, initializer);
            var trans = Enity.transform;

            Label          = trans.Find("Label").GetComponent <HText>();
            callBack       = Enity.RegEvent <UserEvent>();
            callBack.Click = Show;
            var scroll = trans.Find("Scroll");

            if (scroll != null)
            {
                scroll.gameObject.SetActive(false);
                var ui = scroll.GetComponent <UIElement>();
                if (ui != null)
                {
                    m_scroll = ui.composite as ScrollY;
                    if (m_scroll != null)
                    {
                        m_scroll.SetItemUpdate <PopItemMod, object>(ItemUpdate);
                        m_scroll.eventCall.LostFocus   = LostFocus;
                        m_scroll.eventCall.DataContext = this;
                    }
                }
            }
        }
Beispiel #8
0
        public static ScrollY CreateSrollY(string name)
        {
            var mod    = CreateScroll(name);
            var scroll = new ScrollY();

            scroll.Initial(mod);
            return(scroll);
        }
Beispiel #9
0
        void YearScrollToEnd(ScrollY scroll)
        {
            var item = ScrollY.GetCenterItem(scroll.Items);

            if (item == null)
            {
                return;
            }
            year = ys[item.index];
            RefreshDay();
        }
        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;
            }
        }
Beispiel #11
0
        /// <summary>
        /// 滚动项目居中
        /// </summary>
        /// <param name="scroll"></param>
        public static void CenterScroll(ScrollY scroll)
        {
            var   eve = scroll.eventCall;
            var   tar = scroll.eventCall.ScrollDistanceY;
            float ty  = scroll.Size.y * 0.5f;
            float v   = scroll.Point + tar + ty;
            float sy  = scroll.ctSize.y;
            float oy  = v % sy;

            tar -= oy;
            if (oy > sy * 0.5f)
            {
                tar += sy;
            }
            tar += sy * 0.5f;
            scroll.eventCall.ScrollDistanceY = tar;
        }
Beispiel #12
0
        public override void Initial(FakeStruct mod, UIElement script, UIInitializer initializer)
        {
            base.Initial(mod, script, initializer);
            Label          = Enity.Find("Label") as HText;
            callBack       = Enity.RegEvent <UserEvent>();
            callBack.Click = Show;
            var scroll = Enity.Find("Scroll");

            if (scroll != null)
            {
                scroll.activeSelf = false;
                m_scroll          = scroll.composite as ScrollY;
                if (m_scroll != null)
                {
                    m_scroll.SetItemUpdate <PopItemMod, object>(ItemUpdate);
                    m_scroll.eventCall.LostFocus   = LostFocus;
                    m_scroll.eventCall.DataContext = this;
                }
            }
        }
Beispiel #13
0
        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);
        }
Beispiel #14
0
        void DayScrollToEnd(ScrollY scroll)
        {
            var item = ScrollY.GetCenterItem(scroll.Items);

            day = item.index + 1;
        }
Beispiel #15
0
 void Scrolling(ScrollY scroll, Vector2 vector)
 {
     UpdateItems(scroll);
 }
        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);
        }