mirror of
https://github.com/4sval/FModel.git
synced 2026-09-23 16:55:49 -05:00
46 lines
816 B
C#
46 lines
816 B
C#
using System.Collections.Generic;
|
|
|
|
namespace FModel.Framework;
|
|
|
|
public class NavigationList<T> : List<T>
|
|
{
|
|
private int _currentIndex;
|
|
public int CurrentIndex
|
|
{
|
|
get
|
|
{
|
|
if (_currentIndex > Count - 1)
|
|
{
|
|
_currentIndex = Count - 1;
|
|
}
|
|
|
|
if (_currentIndex < 0)
|
|
{
|
|
_currentIndex = 0;
|
|
}
|
|
|
|
return _currentIndex;
|
|
}
|
|
set => _currentIndex = value;
|
|
}
|
|
|
|
public T MoveNext
|
|
{
|
|
get
|
|
{
|
|
_currentIndex++;
|
|
return this[CurrentIndex];
|
|
}
|
|
}
|
|
|
|
public T MovePrevious
|
|
{
|
|
get
|
|
{
|
|
_currentIndex--;
|
|
return this[CurrentIndex];
|
|
}
|
|
}
|
|
|
|
public T Current => this[CurrentIndex];
|
|
} |