Beispiel #1
0
        private void WriteSpacePadding(int charCount, int lineLen, OutputColor color)
        {
            var padLen = lineLen - charCount;

            if (padLen > 0)
            {
                Write(new string(' ', padLen), color);
            }
        }
Beispiel #2
0
        /// <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);
        }
Beispiel #3
0
 /// <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();
     }
 }
Beispiel #4
0
        /// <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);
        }
Beispiel #5
0
 /// <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();
     }
 }
Beispiel #6
0
 public static void SetColor(OutputColor color)
 {
     Console.ForegroundColor = color.ForegroundColor;
     Console.BackgroundColor = color.BackgroundColor;
 }
Beispiel #7
0
 /// <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);
 }
Beispiel #8
0
 /// <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);
 }