public static TEnum ReadEnum <TEnum>(string prompt) where TEnum : struct, IConvertible, IComparable, IFormattable { Type type = typeof(TEnum); if (!type.IsEnum) { throw new ArgumentException("TEnum must be an enumerated type"); } Output.WriteLine(prompt); Menu menu = new Menu(); TEnum choice = default(TEnum); foreach (var value in Enum.GetValues(type)) { menu.Add(Enum.GetName(type, value), () => { choice = (TEnum)value; }); } menu.Display(); if (Settings.ShowSelectedEnumText) { //go to previous line after "Choose an option: [N]" int cursorPosition = 18 + menu.SelectedIndex.ToString().Length; Console.SetCursorPosition(cursorPosition, Console.CursorTop - 1); Output.WriteLine(Settings.UserInputColor, $" ({choice})"); } return(choice); }
static void Main(string[] args) { var menu = new EasyConsole.Menu() .Add("Sum Even Numbers in an array - For loop", () => sumEvenNumbersInAnArray()) .Add("Sum Numbers in an array - Extension method", () => ConvertArrayToListAndSumWithExtensionMethod()) .Add("Check if string is a palindrome", () => CheckIfPalindrome()) .Add("Exit", () => Environment.Exit(0)); menu.Display(); //ConvertArrayToListAndSumWithExtensionMethod(); //Environment.Exit(0); // //sumEvenNumbersInAnArray(); // //SumDigitsInANumber(); // // //int num, sum = 0, r; //Console.WriteLine("Enter a number: "); //num = int.Parse(Console.ReadLine()); //Console.WriteLine(num); //while (num != 0) //{ // r = num % 10; // sum = sum + r; // num /= 10 ; // //} //Console.WriteLine("Sum of the digits: {0}", sum); Console.WriteLine("Press and key to continue..."); Console.ReadLine(); }
internal static void Start() { var menu = new EasyConsole.Menu() .Add("foo", () => Console.WriteLine("foo selected")) .Add("bar", () => Console.WriteLine("bar selected")); menu.Display(); }
public static void Main() { Console.Clear(); Console.WriteLine("Advent Of Code 2019"); Console.WriteLine("by André K."); Console.WriteLine(""); var menu = new EasyConsole.Menu() .Add("Day 1", () => Days.Day1.Execute()) .Add("Day 2", () => Days.Day2.Execute()) .Add("Day 3", () => Days.Day3.Execute()); menu.Display(); }
public static void Main() { Console.Clear(); Console.WriteLine("Advent Of Code 2018"); Console.WriteLine("by André K."); Console.WriteLine(""); var menu = new EasyConsole.Menu() .Add("Day 1", () => Days.Day1.execute()) .Add("Day 2", () => Days.Day2.execute()) .Add("Day 3", () => Days.Day3.execute()) .Add("Day 4", () => Days.Day4.execute()) .Add("Day 5", () => Days.Day5.execute()) .Add("Day 6", () => ThereIsNoDay6()) .Add("Day 7", () => Days.Day7.execute()); menu.Display(); }
static void Main(string[] args) { var exit = false; while (true) { var menu = new EasyConsole.Menu() .Add("Get module info", () => GetActorInfo()) .Add("Add produced event", () => AddProducedEvent()) .Add("Get sim data", () => GetSimData()) .Add("Get all modules", () => GetAllModules()) .Add("Quit", () => exit = true); menu.Display(); if (exit) { break; } } }
public static TEnum ReadEnum <TEnum>(string prompt) where TEnum : struct, IConvertible, IComparable, IFormattable { Type type = typeof(TEnum); if (!type.IsEnum) { throw new ArgumentException("TEnum must be an enumerated type"); } Output.WriteLine(prompt); Menu menu = new Menu(); TEnum choice = default; foreach (var value in Enum.GetValues(type)) { menu.Add(Enum.GetName(type, value), () => { choice = (TEnum)value; }); } menu.Display(); return(choice); }
static void Main(string[] args) { Console.Title = $"{nameof(HoNCameraHack)} - {Version}"; var honinfo = new HoNInfos(); if (!string.IsNullOrEmpty(honinfo.DllPath)) { Console.WriteLine($"DLL Path: {honinfo.DllPath}"); Console.WriteLine($"HoN Version: {honinfo.Version}\n"); if (!Program.IsAdministrator) { Output.WriteLine(ConsoleColor.DarkRed, "You should run this program as Administrator or it may fail\n"); } try { Console.WriteLine($"Default values: Find => {honinfo.FindValue} / Patch => {honinfo.PatchValue} "); var addresses = honinfo.FindOffset(); switch (addresses.Count()) { case 0: { Output.WriteLine(ConsoleColor.Red, @"/!\ No offset found :( already patched?"); break; } case 1: { var offset = addresses.First(); Console.WriteLine($"Offset found! {offset:X}"); if (honinfo.Patch(offset)) { Output.WriteLine(ConsoleColor.Green, "PATCHED!"); } else { Output.WriteLine(ConsoleColor.Red, "Unable to patch :("); } break; } default: { var menu = new EasyConsole.Menu(); Output.WriteLine(ConsoleColor.Yellow, @"/!\ Multiple offsets found"); Console.WriteLine($"recommended to patch the first"); for (int i = 0; i < addresses.Count(); i++) { var address = addresses[i]; menu.Add($"{address:X}", () => { if (honinfo.Patch(address)) { Output.WriteLine(ConsoleColor.Green, "PATCHED!"); } else { Output.WriteLine(ConsoleColor.Red, "Unable to patch :("); } }); } menu.Display(); break; } } } catch (Exception ex) { Output.WriteLine(ConsoleColor.DarkRed, $"{ex.GetType()} => {ex.Message}" + Environment.NewLine); } } else { Output.WriteLine(ConsoleColor.Red, "HoN not found :("); } Output.WriteLine(ConsoleColor.Gray, "Press any key to close..."); Console.ReadLine(); }