Пример #1
0
 private void Refresh()
 {
     if (this.Sections == null || this.Sections.Count == 0)
     {
         return;
     }
     using (List <ListPanelItem> .Enumerator enumerator = this.displayAllItems.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             ListPanelItem current = enumerator.Current;
             if (current.IndexInSection == -1)
             {
                 this.DestroySectionItem(current as ListPanel.ListPanelSectionItem);
             }
             else
             {
                 this.DestroyListItem(current);
             }
         }
     }
     this.displayAllItems.Clear();
     this.animationState = ListPanel.AnimationState.None;
     this.terminalState  = ListPanel.TerminalState.None;
     this.animation      = false;
     this.UpdateItems(0f);
 }
Пример #2
0
        public ListPanel()
        {
            this.backgroundSprt = new UISprite(1);
            base.RootUIElement.AddChildLast(this.backgroundSprt);
            UISpriteUnit unit = this.backgroundSprt.GetUnit(0);

            unit.Color     = new UIColor(0f, 0f, 0f, 0f);
            this.scrollBar = new ScrollBar(ScrollBarOrientation.Vertical);
            this.AddChildLast(this.scrollBar);
            this.displayAllItems     = new List <ListPanelItem>();
            this.displayListItems    = new List <ListPanelItem>();
            this.cacheListItems      = new List <ListPanelItem>();
            this.displaySectionItems = new List <ListPanel.ListPanelSectionItem>();
            this.cacheSectionItems   = new List <ListPanel.ListPanelSectionItem>();
            this.animationState      = ListPanel.AnimationState.None;
            this.terminalState       = ListPanel.TerminalState.None;
            this.terminalDistance    = 0f;
            this.Sections            = null;
            this.ShowSection         = true;
            this.ShowEmptySection    = true;
            this.ShowItemBorder      = true;
            base.Clip = true;
            base.HookChildTouchEvent = true;
            DragGestureDetector dragGestureDetector = new DragGestureDetector();

            dragGestureDetector.DragDetected += new EventHandler <DragEventArgs>(this.DragEventHandler);
            base.AddGestureDetector(dragGestureDetector);
            FlickGestureDetector flickGestureDetector = new FlickGestureDetector();

            flickGestureDetector.FlickDetected += new EventHandler <FlickEventArgs>(this.FlickEventHandler);
            base.AddGestureDetector(flickGestureDetector);
        }
Пример #3
0
 private void DragEventHandler(object sender, DragEventArgs e)
 {
     if (this.IsScrollable())
     {
         base.ResetState(false);
         this.animationState = ListPanel.AnimationState.Drag;
         this.UpdateItems(e.Distance.Y);
         this.animation = false;
     }
 }
Пример #4
0
        private void OnTouchEventImpl(TouchEventCollection touchEvents)
        {
            switch (touchEvents.PrimaryTouchEvent.Type)
            {
            case TouchEventType.Up:
                if (this.animationState == ListPanel.AnimationState.Drag)
                {
                    this.animationState = ListPanel.AnimationState.None;
                    this.animation      = false;
                    switch (this.terminalState)
                    {
                    case ListPanel.TerminalState.Top:
                        this.terminalState = ListPanel.TerminalState.TopReset;
                        this.animation     = true;
                        break;

                    case ListPanel.TerminalState.Bottom:
                        this.terminalState = ListPanel.TerminalState.BottomReset;
                        this.animation     = true;
                        break;
                    }
                }
                if (this.ScrollBarVisibility == ScrollBarVisibility.ScrollingVisible && !this.animation)
                {
                    this.scrollBar.Visible = false;
                }
                return;

            case TouchEventType.Down:
                switch (this.terminalState)
                {
                case ListPanel.TerminalState.None:
                    this.animationState = ListPanel.AnimationState.None;
                    this.animation      = false;
                    return;

                case ListPanel.TerminalState.Top:
                case ListPanel.TerminalState.TopReset:
                    this.ResetTopTerminalItems();
                    return;

                case ListPanel.TerminalState.Bottom:
                case ListPanel.TerminalState.BottomReset:
                    this.ResetBottomTerminalItems();
                    return;

                default:
                    return;
                }

//				break;
            default:
                return;
            }
        }
Пример #5
0
        private void ResetBottomTerminalItems()
        {
            float num = this.Height;

            for (int i = this.displayAllItems.Count - 1; i >= 0; i--)
            {
                ListPanelItem listPanelItem = this.displayAllItems[i];
                listPanelItem.Y = num - listPanelItem.ContainEdgeHeight;
                num             = listPanelItem.Y;
            }
            this.terminalState    = ListPanel.TerminalState.None;
            this.terminalDistance = 0f;
            this.animationState   = ListPanel.AnimationState.None;
            this.animation        = false;
        }
Пример #6
0
        private void ResetTopTerminalItems()
        {
            float y = 0f;

            using (List <ListPanelItem> .Enumerator enumerator = this.displayAllItems.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ListPanelItem current = enumerator.Current;
                    current.Y = y;
                    y         = current.Y + current.ContainEdgeHeight;
                }
            }
            this.terminalState    = ListPanel.TerminalState.None;
            this.terminalDistance = 0f;
            this.animationState   = ListPanel.AnimationState.None;
            this.animation        = false;
        }
Пример #7
0
        private void FlickEventHandler(object sender, FlickEventArgs e)
        {
            if (this.IsScrollable())
            {
                base.ResetState(false);
                this.animationState = ListPanel.AnimationState.Flick;
                this.animation      = true;
                switch (this.terminalState)
                {
                case ListPanel.TerminalState.Top:
                case ListPanel.TerminalState.Bottom:
                    this.scrollVelocity = 0f;
                    return;

                default:
                    this.scrollVelocity = e.Speed.Y * this.flickStartRatio;
                    break;
                }
            }
        }
Пример #8
0
        protected override void OnUpdate(float elapsedTime)
        {
            base.OnUpdate(elapsedTime);
            if (!this.animation)
            {
                return;
            }
            ListPanel.AnimationState animationState = this.animationState;
            if (animationState == ListPanel.AnimationState.Flick)
            {
                if (this.terminalState == ListPanel.TerminalState.None)
                {
                    this.scrollVelocity *= (float)Math.Pow((double)(1f - this.flickDecelerationRatio), (double)(elapsedTime / 16.6f));
                }
                else
                {
                    this.scrollVelocity *= (float)Math.Pow((double)(1f - this.terminalDecelerationRatio), (double)(elapsedTime / 16.6f));
                }
                if (Math.Abs(this.scrollVelocity * elapsedTime / 16.6f) < 0.03012048f || Math.Abs(this.terminalDistance) >= this.maxTerminalDistance)
                {
                    this.scrollVelocity = 0f;
                    this.animationState = ListPanel.AnimationState.None;
                    switch (this.terminalState)
                    {
                    case ListPanel.TerminalState.Top:
                        this.terminalState = ListPanel.TerminalState.TopReset;
                        this.animation     = true;
                        break;

                    case ListPanel.TerminalState.Bottom:
                        this.terminalState = ListPanel.TerminalState.BottomReset;
                        this.animation     = true;
                        break;

                    default:
                        this.animation = false;
                        break;
                    }
                }
                else
                {
                    this.UpdateItems(this.scrollVelocity);
                }
            }
            switch (this.terminalState)
            {
            case ListPanel.TerminalState.TopReset:
                if (this.terminalDistance < 1f)
                {
                    this.ResetTopTerminalItems();
                }
                else
                {
                    this.UpdateItems(this.terminalDistance * (float)Math.Pow((double)(1f - this.terminalReturnRatio), (double)(elapsedTime / 16.6f)) - this.terminalDistance);
                }
                break;

            case ListPanel.TerminalState.BottomReset:
                if (this.terminalDistance > -1f)
                {
                    this.ResetBottomTerminalItems();
                }
                else
                {
                    this.UpdateItems(this.terminalDistance * (float)Math.Pow((double)(1f - this.terminalReturnRatio), (double)(elapsedTime / 16.6f)) - this.terminalDistance);
                }
                break;
            }
            this.UpdateScrollBarVisible();
        }