private static void WriteMenuItem(string menuItem, Interpretor interpretor) { if (menuItem.EndsWith(interpretor.OnTopMarker)) { Console.ForegroundColor = ConsoleColor.Green; } Console.WriteLine(menuItem.ReplaceLast(interpretor.OnTopMarker)); if (Console.ForegroundColor != ConsoleColor.White) { Console.ForegroundColor = ConsoleColor.White; } }
public static void Main(string[] args) { Console.Title = Assembly.GetExecutingAssembly().GetName().Name; Console.OutputEncoding = Encoding.UTF8; var process = Process.GetCurrentProcess(); var interpretor = new Interpretor(process.MainWindowHandle); interpretor.CursorMove += InterpretorOnCursorMove; //interpretor.KeyPressed += InterpretorOnKeyPressed; ConsoleKeyInfo?key = null; while (true) { Console.Clear(); foreach (var menuItem in interpretor.GetMenu()) { WriteMenuItem(menuItem, interpretor); } Console.Write("Input > "); var continueLoop = false; if (key.HasValue) { InterpretorOnKeyPressed(interpretor, new KeyPressArgs(key.Value)); } while (!continueLoop) { key = Console.ReadKey(true); continueLoop = interpretor.Response(key.Value); InterpretorOnKeyPressed(interpretor, new KeyPressArgs(key.Value)); } } }