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) => Horizontal(amount, 10); public static TextBlock Horizontal(Unit amount, Int32 width) { var label = amount.ToDisplayString(); 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.AlignCenterHorizontal(label, arrow, ""); } public static TextBlock Vertical(Unit amount) => Vertical(amount, 4); [SuppressMessage("ReSharper", "PossibleMultipleEnumeration")] [SuppressMessage("ReSharper", "CoVariantArrayConversion")] public static TextBlock Vertical(Unit amount, Int32 height) { var label = amount.ToDisplayString(); 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.AlignCenterHorizontal(lines); } }