Пример #1
0
Файл: Bound.cs Проект: jniac/Kit
        static int Bounded(int index, int count, SelectBoundMode mode)
        {
            switch (mode)
            {
            case SelectBoundMode.LOOP_OVER_NONE:

                index %= count + 1;

                if (index < 0)
                {
                    index += count + 1;
                }

                return(index == count ? -1 : index);

            case SelectBoundMode.LOOP:

                index %= count;

                return(index < 0 ? index + count : index);

            case SelectBoundMode.CLAMP:

                return(index < 0 ? 0 : index >= count ? count - 1 : index);

            default:

                return(index < 0 ? -1 : index >= count ? count - 1 : index);
            }
        }
Пример #2
0
            void Increment(SelectBoundMode incrementBoundMode, int step)
            {
                T   currentItem  = set.FirstOrDefault();
                int currentIndex = select.list.IndexOf(currentItem);

                if (currentIndex != -1)
                {
                    DoExit(currentItem);
                }

                int nextIndex = Bounded(currentIndex + 1, select.Count, incrementBoundMode);
                T   nextItem  = select.list[nextIndex];

                if (nextIndex != -1)
                {
                    DoEnter(nextItem);
                }

                DoChange();
            }
Пример #3
0
 public void Previous(SelectBoundMode boundMode)
 => Increment(boundMode, -1);
Пример #4
0
 public void Next(SelectBoundMode boundMode)
 => Increment(boundMode, 1);
Пример #5
0
 public void Previous <TLayer>(SelectBoundMode boundMode)
 => GetLayer <TLayer>().Previous(boundMode);
Пример #6
0
 public void Previous(object layerKey, SelectBoundMode boundMode)
 => GetLayer(layerKey).Previous(boundMode);
Пример #7
0
 public void Previous(SelectBoundMode boundMode)
 => GetLayer(defaultLayerKey).Previous(boundMode);
Пример #8
0
 public void Next <TLayer>(SelectBoundMode boundMode)
 => GetLayer <TLayer>().Next(boundMode);
Пример #9
0
 public void Next(object layerKey, SelectBoundMode boundMode)
 => GetLayer(layerKey).Next(boundMode);
Пример #10
0
 public void Next(SelectBoundMode boundMode)
 => GetLayer(defaultLayerKey).Next(boundMode);