private void WriteSpacePadding(int charCount, int lineLen, OutputColor color) { var padLen = lineLen - charCount; if (padLen > 0) { Write(new string(' ', padLen), color); } }
/// <summary> /// Write text center aligned to the console. /// </summary> /// <param name="text">The text to be written.</param> /// <param name="color">The <see cref="T:ByteDev.Cmd.OutputColor" /> to use when writing the text.</param> public void WriteAlignCenter(string text, OutputColor color) { decimal remainingWidth = Console.WindowWidth - text.Length - 1; var rightSize = (int)Math.Round(remainingWidth / 2); var leftSize = (int)(remainingWidth - rightSize); Write(new string(' ', leftSize), color); Write(text, color); WriteLine(new string(' ', rightSize), color); }
/// <summary> /// Write text to the console. /// </summary> /// <param name="text">The text to write to the console.</param> /// <param name="color">The <see cref="T:ByteDev.Cmd.OutputColor" /> to use when writing the text.</param> public void Write(string text, OutputColor color) { if (color == null) { Console.Write(text); } else { ConsoleEx.SetColor(color); Console.Write(text); Console.ResetColor(); } }
/// <summary> /// Write left aligned and right aligned text to the console. /// </summary> /// <param name="leftText">The text to write to the left.</param> /// <param name="rightText">The text to write to the right.</param> /// <param name="color">The <see cref="T:ByteDev.Cmd.OutputColor" /> to use when writing the text.</param> public void WriteAlignToSides(string leftText, string rightText, OutputColor color) { Write(leftText, color); var size = Console.WindowWidth - 1 - leftText.Length - rightText.Length; if (size > 0) { Write(new string(' ', size), color); } WriteLine(rightText, color); }
/// <summary> /// Write character to the console. /// </summary> /// <param name="c">The character to write to the console.</param> /// <param name="color">The <see cref="T:ByteDev.Cmd.OutputColor" /> to use when writing the character.</param> public void Write(char c, OutputColor color) { if (color == null) { Console.Write(c); } else { ConsoleEx.SetColor(color); Console.Write(c); Console.ResetColor(); } }
public static void SetColor(OutputColor color) { Console.ForegroundColor = color.ForegroundColor; Console.BackgroundColor = color.BackgroundColor; }
/// <summary> /// Write a horizontal line of repeated characters to the console. /// </summary> /// <param name="character">Character repeated in the horizontal line.</param> /// <param name="color">The <see cref="T:ByteDev.Cmd.OutputColor" /> to use when writing horizontal line's text.</param> public void WriteHorizontalLine(char character, OutputColor color) { WriteLine(new string(character, Console.WindowWidth - 1), color); }
/// <summary> /// Write text right aligned to the console. /// </summary> /// <param name="text">The text to be written.</param> /// <param name="color">The <see cref="T:ByteDev.Cmd.OutputColor" /> to use when writing the text.</param> public void WriteAlignRight(string text, OutputColor color) { WriteLine(text.PadLeft(Console.WindowWidth - 1), color); }