mirror of
https://git.battle-of-pip.de/root/vpr-mitarbeiterverwaltung.git
synced 2025-12-13 22:31:38 +01:00
Initial Commit
This commit is contained in:
63
DX86/Modules/InputBox.cs
Normal file
63
DX86/Modules/InputBox.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user