コード例 #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 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;
            }
        }
コード例 #4
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;
        }
コード例 #5
0
        private void UpdateBottomTerminalItems()
        {
            int           num           = this.displayAllItems.Count - 1;
            ListPanelItem listPanelItem = this.displayAllItems[num];

            if (this.displayAllItems.Count > 0)
            {
                if (this.terminalState == ListPanel.TerminalState.Bottom)
                {
                    this.terminalDistance -= (this.Height - (listPanelItem.Y + listPanelItem.ContainEdgeHeight)) * 2f;
                }
                else
                {
                    this.terminalDistance -= this.Height - (listPanelItem.Y + listPanelItem.ContainEdgeHeight);
                }
            }
            if (this.terminalDistance < -this.maxTerminalDistance)
            {
                this.terminalDistance = -this.maxTerminalDistance;
                this.scrollVelocity   = 0f;
                if (this.animationState == ListPanel.AnimationState.Flick)
                {
                    this.terminalState = ListPanel.TerminalState.BottomReset;
                }
            }
            if (this.terminalDistance < 0f)
            {
                float num2 = this.Height;
                float num3 = this.terminalDistance * this.terminalDistanceRatio;
                for (int i = num; i >= 0; i--)
                {
                    ListPanelItem listPanelItem2 = this.displayAllItems[i];
                    listPanelItem2.Y = num2 - listPanelItem2.ContainEdgeHeight;
                    num2             = listPanelItem2.Y + num3;
                }
                if (this.terminalState == ListPanel.TerminalState.None)
                {
                    this.terminalState = ListPanel.TerminalState.Bottom;
                    return;
                }
            }
            else
            {
                this.ResetBottomTerminalItems();
            }
        }
コード例 #6
0
 private void UpdateTopTerminalItems()
 {
     if (this.displayAllItems.Count > 0)
     {
         if (this.terminalState == ListPanel.TerminalState.Top)
         {
             this.terminalDistance += this.displayAllItems[0].Y * 2f;
         }
         else
         {
             this.terminalDistance += this.displayAllItems[0].Y;
         }
     }
     if (this.terminalDistance > this.maxTerminalDistance)
     {
         this.terminalDistance = this.maxTerminalDistance;
         this.scrollVelocity   = 0f;
         if (this.animationState == ListPanel.AnimationState.Flick)
         {
             this.terminalState = ListPanel.TerminalState.TopReset;
         }
     }
     if (this.terminalDistance > 0f)
     {
         float y   = 0f;
         float num = this.terminalDistance * this.terminalDistanceRatio;
         using (List <ListPanelItem> .Enumerator enumerator = this.displayAllItems.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 ListPanelItem current = enumerator.Current;
                 current.Y = y;
                 y         = current.Y + current.ContainEdgeHeight + num;
             }
         }
         if (this.terminalState == ListPanel.TerminalState.None)
         {
             this.terminalState = ListPanel.TerminalState.Top;
             return;
         }
     }
     else
     {
         this.ResetTopTerminalItems();
     }
 }
コード例 #7
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;
        }
コード例 #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();
        }