From 51fff1de0d03f4cc2fda0fd5489d083278ec6d26 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 31 Dec 2018 08:29:48 -0800 Subject: [PATCH] Move increment constraints into ShowNext/ShowPrevious methods --- MatterControlLib/SetupWizard/ProductTour.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/MatterControlLib/SetupWizard/ProductTour.cs b/MatterControlLib/SetupWizard/ProductTour.cs index 09bf57124..d904b77a1 100644 --- a/MatterControlLib/SetupWizard/ProductTour.cs +++ b/MatterControlLib/SetupWizard/ProductTour.cs @@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl.Tour public void ShowNext() { - ShowLocation(this.ActiveIndex + 1); + ShowLocation((this.ActiveIndex >= this.Count ? 0 : this.ActiveIndex + 1)); } public void ShowPrevious() @@ -95,6 +95,12 @@ namespace MatterHackers.MatterControl.Tour { if (_activeIndex != value) { + // Constrain to valid range + if (value < 0 || value >= this.Count) + { + value = 0; + } + _activeIndex = value; this.ActiveItem = tourLocations[_activeIndex]; @@ -108,11 +114,6 @@ namespace MatterHackers.MatterControl.Tour private void ShowLocation(int locationIndex) { - if (locationIndex < 0 || locationIndex >= this.Count) - { - locationIndex = 0; - } - this.ActiveIndex = locationIndex; } }