mirror of
https://git.battle-of-pip.de/root/vpr-mitarbeiterverwaltung.git
synced 2025-06-20 15:53:16 +02:00
63 lines
1.5 KiB
C#
63 lines
1.5 KiB
C#
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<string> lines)
|
|
{
|
|
ms.SaveOnly(true);
|
|
Console.Clear();
|
|
string message = "";
|
|
|
|
List<int> longestLine = new List<int>();
|
|
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;
|
|
}
|
|
} |