static int Main(string[] args) { PrintMenu menu = new PrintMenu(); var root = TraversalDemo.makeTree(); menu.AddMenuEntry('1', "Level Order Traversal Demo"); menu.AddMenuEntry('2', "Pre-Order Traversal Demo"); menu.AddMenuEntry('3', "Post-Order Traversal Demo"); menu.AddMenuEntry('4', "Compute Directory Size (without exception handling in enumeration)"); menu.AddMenuEntry('5', "Compute Directory Size (WITH exception handling and Generic class)"); while (true) { Console.WriteLine(); Console.WriteLine("This program demos TreeLib applications and use cases by example."); var key = menu.ShowMenu(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); switch (key) { case '1': TraversalDemo.TestLevelOrder(root); break; case '2': TraversalDemo.TestPreOrder(root); break; case '3': TraversalDemo.TestPostOrder(root); break; case '4': DirSizeWoException.DemoDirectoryTreeTraversal(); break; case '5': DirectorySize.DemoDirectoryTreeTraversal(); break; default: return(0); } } }
private static void Start(Shop shop) { string command = string.Empty; while (true) { PrintMenu.item = singnIn; command = PrintMenu.MenuShow(); SighIn(shop, command); PrintMenu.item = generalHandler; command = PrintMenu.MenuShow(); GeneralHandler(shop, command); } }
static void Main(string[] args) { // Print menu PrintMenu print = new PrintMenu(); Console.WriteLine(print.MenuItems()); Console.Write("Enter your selection: "); var choice = int.Parse(Console.ReadLine()); var camera = print.BuildMenu(choice); //print.TypeMenu(); // An instance of the monitor system CameraMonitor mon = new CameraMonitor(); // Add them to the monitor mon.AttachCamera(camera); // Start mon.StartCamera(); }
static void Main(string[] args) { while (true) { string option = ""; int valueOption = 0; int limiteMenu = Components.GetEnumDescriptions <EnumTipoMenu>().Count() + 1; while (!(valueOption < limiteMenu && valueOption > 0)) { do { PrintMenu.View(); Console.Write("Enter this valid option: "); option = Console.ReadLine(); } while (!int.TryParse(option, out valueOption)); } Run(valueOption); } }
// Prints and takes the correct option from the given menu public static int ExecuteMenu(PrintMenu delegateForPrint, int inOption) { while (true) { // Prints obtained menu delegateForPrint(); // Get some number from the user Console.Write($"Select an option [1-{inOption}]"); int option = int.Parse(Console.ReadLine()); Console.WriteLine(); if (option >= 1 && option <= inOption) { return(option); } else { Console.WriteLine("Invalid option!"); } } }