Example #1
0
        private void SwapIndex(int indexFrom, int indexTo)
        {
            if (indexFrom == indexTo)
            {
                return;
            }

            if (indexFrom < 0)
            {
                indexFrom = 0;
            }

            if (indexTo < 0)
            {
                indexTo = 0;
            }

            if (indexFrom > indexTo)
            {
                IntExtensions.Swap(ref indexFrom, ref indexTo);
            }

            var itemA = _points[indexFrom];
            var itemB = _points[indexTo];

            // note: these are mutable, so if we store the values in local scope
            var posA = itemA.Position.Top + itemB.Position.Height;
            var posB = itemA.Position.Top;

            itemA.Reposition(new Point(0, posA));
            itemB.Reposition(new Point(0, posB));

            _points[indexFrom] = itemB;
            _points[indexTo]   = itemA;
        }