namespace DX86.Modules; public class InputBox { private MessageSender ms; public InputBox(MessageSender ms) { this.ms = ms; ms.Log("[InputBox] InputBox initialized."); } public string ShowAsync(string title, List lines) { ms.SaveOnly(true); Console.Clear(); string message = ""; List longestLine = new List(); int lineNumber = 0; foreach (var line in lines) { longestLine.Add(line.Length); lineNumber++; } longestLine.Add(title.Length + 4); int minLength = 50; int maxLength = longestLine.Max(); if (maxLength < minLength) { maxLength = minLength; } string titleBar = new string('-', maxLength); Console.WriteLine("+ {0} +", titleBar); Console.WriteLine("| ยป {0}{1} |", title, new string(' ', (maxLength - title.Length) - 4)); Console.WriteLine("+ {0} +", titleBar); for (int i = 0; i < lines.Count; i++) { Console.WriteLine("| {0}{1} |", lines[i], new string(' ', maxLength - longestLine[i])); } Console.WriteLine("+ {0} +", titleBar); Console.WriteLine("| {0} |", new string(' ', maxLength)); Console.WriteLine("+ {0} +", titleBar); Console.SetCursorPosition(2, 4+lines.Count); string output = Console.ReadLine(); ms.SaveOnly(false); ms.SendHistory(); return output; } }