namespace DX86.Modules; /* * Copyright 2024 SnapixLP */ public class MessageBox { private MessageSender ms; public MessageBox(MessageSender ms) { this.ms = ms; ms.Log("[MessageBox] MessageBox initialized"); } public async Task 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 maxLength = longestLine.Max(); 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.Write(" »» Press any key to continue..."); Console.ReadKey(); ms.SaveOnly(false); ms.SendHistory(); return "OK"; } }