From 453360be0dfab8954293b2f9bd259fe3d1c5a240 Mon Sep 17 00:00:00 2001 From: Sylvia Oleander-Rothove Date: Sun, 27 Aug 2023 22:16:29 -0500 Subject: [PATCH] adds menu looping --- DRV3-Sharp/Program.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/DRV3-Sharp/Program.cs b/DRV3-Sharp/Program.cs index e15d25f..309a325 100644 --- a/DRV3-Sharp/Program.cs +++ b/DRV3-Sharp/Program.cs @@ -129,10 +129,25 @@ private static void MainLoop() { // Single-entry scroll case ConsoleKey.UpArrow: - if (currentMenu.FocusedEntry > 0) --currentMenu.FocusedEntry; + if (currentMenu.FocusedEntry > 0) + { + --currentMenu.FocusedEntry; + } + else if (currentMenu.FocusedEntry == 0) + { + currentMenu.FocusedEntry = cachedEntries.Length - 1; // loop menu to bottom + } break; + case ConsoleKey.DownArrow: - if (currentMenu.FocusedEntry < (cachedEntries.Length - 1)) ++currentMenu.FocusedEntry; + if (currentMenu.FocusedEntry < cachedEntries.Length - 1) + { + ++currentMenu.FocusedEntry; + } + else if (currentMenu.FocusedEntry == cachedEntries.Length - 1) + { + currentMenu.FocusedEntry = 0; // loop menu to top + } break; // Fast scroll