//====================================================== // Underheader Text //====================================================== /// <summary> /// Add text below the header. /// </summary> /// <param name="underHeaderText"> The text to appear under the header </param> /// <param name="color"> The color of the text</param> public static void Write_UnderHeader(string underHeaderText, ConsoleColor color = ConsoleColor.Yellow) { string belowHeader_Underline = string.Concat(Enumerable.Repeat("`", underHeaderText.Length + 4)); Console.SetCursorPosition(10 + 5, Console.CursorTop); CTools.Color_Write(underHeaderText, color, true); Console.SetCursorPosition(10 + 3, Console.CursorTop); CTools.Color_Write(belowHeader_Underline, color, false); }
/// <summary> /// Writes a string with a single word in colored text. It will find ONLY the first instance of the word and color it. /// </summary> /// <param name="fullString">The entire string</param> /// <param name="wordToColor">The word in the full string to be colored</param> /// <param name="color">What color will the special word be</param> public static void Write_StringWith_ColoredWord(string fullString, string wordToColor, ConsoleColor color) { int coloredWordStartIndex = fullString.IndexOf(wordToColor); string beforeColoredWord = fullString.Substring(0, coloredWordStartIndex); string afterColoredWord = fullString.Substring(coloredWordStartIndex + wordToColor.Length, fullString.Length - (coloredWordStartIndex + wordToColor.Length)); Console.Write(beforeColoredWord); CTools.Color_Write(wordToColor, color, false); Console.Write(afterColoredWord); }
/// <summary> /// Use this to write out a standard header with autosized borders AND highlight a word /// </summary> /// <param name="headerString"></param> /// <param name="consoleLine"></param> /// <param name="highlightedWord"></param> /// <param name="color"></param> public static void Write_Header(string fullHeaderString, int consoleLine, string wordToHighlight, ConsoleColor color, int leftStart = 2, int minBorderWidth = 30) { int minBorderLength = minBorderWidth; int letterCount = fullHeaderString.Length; int borderLength = (int)Math.Max(minBorderLength, (letterCount + 6)); string border = string.Concat(Enumerable.Repeat("=", borderLength)); int highlightedWordStartIndex = fullHeaderString.IndexOf(wordToHighlight); string beforeHighlightedWord = fullHeaderString.Substring(0, highlightedWordStartIndex); leftStart += 10; Console.SetCursorPosition(leftStart, consoleLine); Console.WriteLine(border); Console.SetCursorPosition(leftStart, Console.CursorTop); Console.Write(" " + beforeHighlightedWord); CTools.Color_Write(wordToHighlight, color, false); Console.WriteLine(); Console.SetCursorPosition(leftStart, Console.CursorTop); Console.WriteLine(border); }