public ConOut CoverCenter(string line, ConColor color = null) { using (new InkScope()) { var len = line.GetLengthA(); int left; if (Console.WindowWidth <= len) { left = 0; } else { var total = Console.WindowWidth - len; left = total / 2; if (total.IsOdd()) { left += 1; } } RowBeginning(); Console.SetCursorPosition(left, Console.CursorTop); Print(line, color); return(this); } }
public ConOut Left(string line, ConColor color = null) { using (new InkScope()) { RowBeginning(); Print($"{line}{" ".Repeat(Console.WindowWidth - line.GetLengthA())}", color); return(this); } }
public ConOut Center(string line, ConColor color = null) { using (new InkScope()) { RowBeginning(); Print($"{line.Center(Console.WindowWidth)}", color); return(this); } }
public ConOut CoverRight(string line, ConColor color = null) { using (new InkScope()) { RowBeginning(); Console.SetCursorPosition(Console.WindowWidth - line.GetLengthA(), Console.CursorTop); Print(line, color); return(this); } }
public ConOut CoverLeft(string line, ConColor color = null) { using (new InkScope()) { RowBeginning(); Console.SetCursorPosition(0, Console.CursorTop); Print(line, color); return(this); } }
public ConOut Print(string content, ConColor color = null) { void Process() { Console.Write(content); } if (color is null) { Process(); } else { var originColor = ConColor; ConColor = color; Process(); ConColor = originColor; } return(this); }
public ConOut Right(string line, ConColor color = null) { RowBeginning(); Print($"{" ".Repeat(Console.WindowWidth - line.GetLengthA())}{line}", color); return(this); }
public ConOut Line(string content, ConColor color = null) { Print(content, color); Console.WriteLine(); return(this); }
public static ConOut CoverRight(string line, ConColor color = null) => Instance.CoverRight(line, color);
public static ConOut CoverCenter(string line, ConColor color = null) => Instance.CoverCenter(line, color);
public static ConOut Left(string line, ConColor color = null) => Instance.Left(line, color);
public static ConOut Print(string content, ConColor color = null) => Instance.Print(content, color);
public static ConOut Line(string content, ConColor color = null) => Instance.Line(content, color);