Move increment constraints into ShowNext/ShowPrevious methods
This commit is contained in:
parent
ac40f00378
commit
51fff1de0d
1 changed files with 7 additions and 6 deletions
|
|
@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl.Tour
|
||||||
|
|
||||||
public void ShowNext()
|
public void ShowNext()
|
||||||
{
|
{
|
||||||
ShowLocation(this.ActiveIndex + 1);
|
ShowLocation((this.ActiveIndex >= this.Count ? 0 : this.ActiveIndex + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowPrevious()
|
public void ShowPrevious()
|
||||||
|
|
@ -95,6 +95,12 @@ namespace MatterHackers.MatterControl.Tour
|
||||||
{
|
{
|
||||||
if (_activeIndex != value)
|
if (_activeIndex != value)
|
||||||
{
|
{
|
||||||
|
// Constrain to valid range
|
||||||
|
if (value < 0 || value >= this.Count)
|
||||||
|
{
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
_activeIndex = value;
|
_activeIndex = value;
|
||||||
this.ActiveItem = tourLocations[_activeIndex];
|
this.ActiveItem = tourLocations[_activeIndex];
|
||||||
|
|
||||||
|
|
@ -108,11 +114,6 @@ namespace MatterHackers.MatterControl.Tour
|
||||||
|
|
||||||
private void ShowLocation(int locationIndex)
|
private void ShowLocation(int locationIndex)
|
||||||
{
|
{
|
||||||
if (locationIndex < 0 || locationIndex >= this.Count)
|
|
||||||
{
|
|
||||||
locationIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ActiveIndex = locationIndex;
|
this.ActiveIndex = locationIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue