Example #1
0
        public void ChangeList(int pNewIndex)
        {
            DragableListSwitchDirection direction = Math.Sign(pNewIndex - CurrentListIndex) == -1
                ? DragableListSwitchDirection.Back
                : DragableListSwitchDirection.Forward;

            // Return if at the beginning or end of list
            if (pNewIndex < 0 ||
                pNewIndex >= _listCollection.Count)
            {
                return;
            }

            if (BeforeListChanged != null)
            {
                BeforeListChanged(this, new ListChangeEventArgs(direction, pNewIndex));
            }

            ExecuteChangeList(direction, pNewIndex);

            if (AfterListChanged != null)
            {
                AfterListChanged(this, new ListChangeEventArgs(direction, pNewIndex));
            }
        }
Example #2
0
        private void ExecuteChangeList(DragableListSwitchDirection pDirection, int pNewIndex)
        {
            int directionSign = pDirection == DragableListSwitchDirection.Back ? -1 : 1;

            var currentList    = _listCollection[_currentListIndex];
            var transitionList = _listCollection[pNewIndex];

            transitionList.StartRender();

            float  length    = ListOrientation == Orientation.Vertical ? this.Width : this.Height;
            double j         = 1;
            float  listShift = 0;


            // fast switch
            while (Math.Abs(_listShiftPx) < length)
            {
                if (Math.Abs(_listShiftPx) < length - 200)
                {
                    _listShiftPx += directionSign * -100;
                }
                else
                {
                    _listShiftPx += directionSign * (int)(-100 / j);
                    j            += .5;
                }
                if (Math.Abs(_listShiftPx) > length)
                {
                    _listShiftPx = Math.Sign(_listShiftPx) * length;
                }
                //_listShiftPx += directionSign * -10;

                if (ListOrientation == Orientation.Vertical)
                {
                    float transitionShift = _listShiftPx - (this.Width * Math.Sign(_listShiftPx));

                    currentList.Bounds    = new Rectangle(_listShiftPx, 0, length, this.Height);
                    transitionList.Bounds = new Rectangle(transitionShift, 0, length, this.Height);
                }
                else
                {
                    float transitionShift = _listShiftPx - (this.Height * Math.Sign(_listShiftPx));

                    currentList.Bounds    = new Rectangle(0, _listShiftPx, this.Width, length);
                    transitionList.Bounds = new Rectangle(0, transitionShift, this.Width, length);
                }
                Thread.Sleep(10);
            }

            currentList.Bounds = new Rectangle(this.Width, 0, this.Width, this.Height);

            transitionList.Bounds = new Rectangle(0, 0, this.Width, this.Height);

            currentList.StopRenderer();
            FutureListTransition = null;
            _currentListIndex    = pNewIndex;
            _listShiftPx         = 0;
        }
Example #3
0
 public ListChangeEventArgs(DragableListSwitchDirection pSwitchDirection, int pNewIndex)
 {
     _switchDirection = pSwitchDirection;
     _newIndex        = pNewIndex;
 }
Example #4
0
 /// <summary>
 /// Moves in the provided direction as long as there is a list available
 /// </summary>
 private void ChangeList(DragableListSwitchDirection pDirection)
 {
 }