Advertisement
Guest User

Console Header

a guest
Apr 24th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1.   private static void WriterHeader(string writeWhat, byte fara8, char mnBara)
  2.         {
  3.             if (fara8 > 43) fara8 = 43;
  4.             System.Console.OutputEncoding = System.Console.InputEncoding = Encoding.UTF8;
  5.             System.Console.ForegroundColor = ConsoleColor.DarkGray;
  6.             string text = "";
  7.             string adEh = "";
  8.             for (int i = 0; i < fara8; i++) adEh += " ";
  9.             text += mnBara + adEh;
  10.             text += writeWhat;
  11.             text += adEh + mnBara;
  12.             string header = "";
  13.             for (int i = 0; i < text.Length; i++) header += mnBara;
  14.             string emptyLine = "";
  15.             for (int i = 0; i < text.Length; i++)
  16.             {
  17.                 if (i == 0 || i == text.Length - 1)
  18.                     emptyLine += mnBara;
  19.                 else emptyLine += " ";
  20.             }
  21.             string[] whatToWrite = new string[] { header, emptyLine, emptyLine, text, emptyLine, emptyLine, header };
  22.             foreach (var line in whatToWrite)
  23.             {
  24.                 Console.SetCursorPosition((Console.WindowWidth - line.Length) / 2, Console.CursorTop);
  25.                 Console.WriteLine(line);
  26.             }
  27.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement