118 lines
3.4 KiB
C#
118 lines
3.4 KiB
C#
|
using System.Diagnostics.CodeAnalysis;
|
||
|
using InnovEnergy.Lib.Units;
|
||
|
using InnovEnergy.Lib.Utils;
|
||
|
|
||
|
|
||
|
|
||
|
namespace InnovEnergy.App.SaliMax;
|
||
|
|
||
|
public static class Flow
|
||
|
{
|
||
|
private static readonly String RightArrowChar = ">";
|
||
|
private static readonly String LeftArrowChar = "<";
|
||
|
private static readonly String DownArrowChar = "V";
|
||
|
private static readonly String UpArrowChar = "^";
|
||
|
|
||
|
public static TextBlock Horizontal(Unit amount, Int32 width = 10)
|
||
|
{
|
||
|
var label = amount.ToString();
|
||
|
var arrowChar = amount.Value < 0 ? LeftArrowChar : RightArrowChar;
|
||
|
var arrow = Enumerable.Repeat(arrowChar, width).Join();
|
||
|
|
||
|
// note : appending "fake label" below to make it vertically symmetric
|
||
|
return TextBlock.CenterHorizontal(label, arrow, "");
|
||
|
}
|
||
|
|
||
|
[SuppressMessage("ReSharper", "PossibleMultipleEnumeration")]
|
||
|
[SuppressMessage("ReSharper", "CoVariantArrayConversion")]
|
||
|
public static TextBlock Vertical(Unit amount, Int32 height = 8)
|
||
|
{
|
||
|
var label = amount.ToString();
|
||
|
var arrowChar = amount.Value < 0 ? UpArrowChar : DownArrowChar;
|
||
|
var halfArrow = Enumerable.Repeat(arrowChar, height/2);
|
||
|
|
||
|
var lines = halfArrow
|
||
|
.Append(label)
|
||
|
.Concat(halfArrow)
|
||
|
.ToArray(height / 2 * 2 + 1);
|
||
|
|
||
|
return TextBlock.CenterHorizontal(lines);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//
|
||
|
// 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();
|
||
|
//
|
||
|
// var contentWidth = separator.Length;
|
||
|
//
|
||
|
// var horizontal = "".PadRight(contentWidth, ' ');
|
||
|
//
|
||
|
// var v = valueToString.PadRight(contentWidth);
|
||
|
// var s = separator.PadRight(contentWidth);
|
||
|
//
|
||
|
// return StringUtils.JoinLines(
|
||
|
// horizontal,
|
||
|
// horizontal,
|
||
|
// horizontal,
|
||
|
// v,
|
||
|
// s,
|
||
|
// horizontal,
|
||
|
// horizontal,
|
||
|
// 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 CreateVerticalArrow(Decimal power, Int32 width = 0)
|
||
|
// {
|
||
|
// var flow = "V".NewLine() + "V".NewLine() + power.W().NewLine() + "V".NewLine() + "V";
|
||
|
//
|
||
|
// return flow.AlignCenterHorizontal(width);
|
||
|
// }
|
||
|
//
|
||
|
// }
|