111 lines
2.7 KiB
C#
111 lines
2.7 KiB
C#
using InnovEnergy.Lib.Utils;
|
|
|
|
namespace InnovEnergy.App.SaliMax;
|
|
|
|
public static class AsciiArt
|
|
{
|
|
|
|
public static String CreateBox(params Object[] elements)
|
|
{
|
|
var aligned = elements
|
|
.Select(e => e.ToString()!)
|
|
.JoinLines()
|
|
.AlignLeft();
|
|
|
|
var w = aligned.Width();
|
|
|
|
var line = "".PadRight(w + 2, '─');
|
|
var top = "┌" + line + "┐";
|
|
var bottom = "└" + line + "┘";
|
|
|
|
return aligned
|
|
.SplitLines()
|
|
.Select(l => l.SurroundWith(" "))
|
|
.Select(l => l.SurroundWith("│"))
|
|
.Prepend(top)
|
|
.Append(bottom)
|
|
.JoinLines();
|
|
}
|
|
|
|
public static String CreateHorizontalArrow(Decimal value, String separator)
|
|
{
|
|
var valueToString = " " + value.W();
|
|
|
|
if (value == 0)
|
|
{
|
|
valueToString = "";
|
|
}
|
|
|
|
var contentWidth = separator.Length;
|
|
|
|
var horizontal = "".PadRight(contentWidth, ' ');
|
|
|
|
var v = valueToString.PadRight(contentWidth);
|
|
var s = separator.PadRight(contentWidth);
|
|
|
|
return StringUtils.JoinLines(
|
|
horizontal,
|
|
v,
|
|
s,
|
|
horizontal
|
|
);
|
|
}
|
|
|
|
public static String CreateTransitionPadLeft(String value, String separator)
|
|
{
|
|
var contentWidth = separator.Length + 2;
|
|
|
|
var horizontal = "".PadLeft(contentWidth, ' ');
|
|
|
|
var v = value.PadLeft(contentWidth);
|
|
var s = separator.PadLeft(contentWidth);
|
|
|
|
return StringUtils.JoinLines(
|
|
horizontal,
|
|
v,
|
|
s,
|
|
horizontal
|
|
);
|
|
}
|
|
|
|
public static String CreateVerticalPad(String value, Int32 contentVerticalWidth, Boolean direction, String name)
|
|
{
|
|
var v = value.PadLeft(contentVerticalWidth);
|
|
var n = name.PadLeft(contentVerticalWidth);
|
|
|
|
if (direction) // up
|
|
{
|
|
var horizontal = "".PadLeft(contentVerticalWidth - 4, ' ').V();
|
|
|
|
return StringUtils.JoinLines(
|
|
n,
|
|
horizontal,
|
|
horizontal,
|
|
v,
|
|
horizontal,
|
|
horizontal
|
|
);
|
|
}
|
|
else // down
|
|
{
|
|
var horizontal = "".PadLeft(contentVerticalWidth - 4, ' ').V();
|
|
|
|
return StringUtils.JoinLines(
|
|
horizontal,
|
|
horizontal,
|
|
v,
|
|
horizontal,
|
|
horizontal,
|
|
n
|
|
);
|
|
}
|
|
}
|
|
|
|
public static String CreateVerticalArrow(Decimal power, Int32 width = 0)
|
|
{
|
|
var flow = "V".NewLine() + "V".NewLine() + power.W().NewLine() + "V".NewLine() + "V";
|
|
|
|
return flow.AlignCenterHorizontal(width);
|
|
}
|
|
|
|
} |