Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace COServer
  7. {
  8. public static class Console
  9. {
  10. private static DateTime NOW = DateTime.Now;
  11. private static Time32 NOW32 = Time32.Now;
  12. public static string Title
  13. {
  14. get
  15. {
  16. return System.Console.Title;
  17. }
  18. set
  19. {
  20. System.Console.Title = value;
  21. }
  22. }
  23.  
  24. public static int WindowWidth
  25. {
  26. get
  27. {
  28. return System.Console.WindowWidth;
  29. }
  30. set
  31. {
  32. System.Console.WindowWidth = value; ;
  33. }
  34. }
  35.  
  36. public static int WindowHeight
  37. {
  38. get
  39. {
  40. return System.Console.WindowHeight;
  41. }
  42. set
  43. {
  44. System.Console.WindowHeight = value; ;
  45. }
  46. }
  47.  
  48.  
  49. public static void WriteLine(object line, ConsoleColor color = ConsoleColor.White)
  50. {
  51.  
  52. if (line.ToString() == "" || line.ToString() == " ")
  53. System.Console.WriteLine();
  54. else
  55. {
  56. ForegroundColor = ConsoleColor.Red;
  57. System.Console.Write("");
  58. ForegroundColor = color;
  59. System.Console.Write(line + "\n");
  60. }
  61. }
  62.  
  63. public static void WriteLine()
  64. {
  65. System.Console.WriteLine();
  66. }
  67.  
  68. public static string ReadLine()
  69. {
  70. return System.Console.ReadLine();
  71. }
  72.  
  73. public static ConsoleColor BackgroundColor
  74. {
  75. get
  76. {
  77. return System.Console.BackgroundColor;
  78. }
  79. set
  80. {
  81. System.Console.BackgroundColor = value;
  82. }
  83. }
  84.  
  85. public static void Clear()
  86. {
  87. System.Console.Clear();
  88. }
  89. public static void DrawProgressBar(uint complete, uint maxVal, int barSize, char progressCharacter)
  90. {
  91. System.Console.CursorVisible = false;
  92. int Left = System.Console.CursorLeft;
  93. decimal perc = (decimal)complete / (decimal)maxVal;
  94. int chars = (int)Math.Floor(perc / ((decimal)1 / (decimal)barSize));
  95. string p1 = String.Empty, p2 = String.Empty;
  96.  
  97. for (int i = 0; i < chars; i++) p1 += progressCharacter;
  98. for (int i = 0; i < barSize - chars; i++) p2 += progressCharacter;
  99.  
  100. Console.ForegroundColor = ConsoleColor.Green;
  101. System.Console.Write(p1);
  102. System.Console.ForegroundColor = ConsoleColor.Black;
  103. System.Console.Write(p2);
  104. System.Console.ResetColor();
  105. System.Console.Write(" {0}%", (perc * 100).ToString("N2"));
  106. System.Console.CursorLeft = Left;
  107. }
  108. public static ConsoleColor ForegroundColor
  109. {
  110. get
  111. {
  112. return System.Console.ForegroundColor;
  113. }
  114. set
  115. {
  116. System.Console.ForegroundColor = value;
  117. }
  118. }
  119. public static void WriteOnBottomLine(string text)
  120. {
  121. int x = System.Console.CursorLeft;
  122. int y = System.Console.CursorTop;
  123. System.Console.CursorTop = System.Console.WindowTop + System.Console.WindowHeight - 1;
  124. System.Console.Write(text);
  125. System.Console.SetCursorPosition(x, y);
  126. }
  127. }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement