Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace C_sharp_Light
- {
- class Program
- {
- static void Main(string[] args)
- {
- DrawBar(50, 10, ConsoleColor.Red, 5, 5);
- DrawBar(10, 16, ConsoleColor.Green, 5, 6);
- DrawBar(100, 20, ConsoleColor.Yellow, 5, 7);
- Console.ReadKey();
- }
- static void DrawBar(int FillingPercent, int sizeBar, ConsoleColor color, int xPos, int yPos)
- {
- if (FillingPercent > 100)
- FillingPercent = 100;
- if (FillingPercent < 0)
- FillingPercent = 0;
- FillingPercent = sizeBar * FillingPercent / 100;
- Console.SetCursorPosition(xPos, yPos);
- for (int i = 0; i <= sizeBar+1; i++)
- {
- if (i == 0)
- {
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write('[');
- }
- else if (i == sizeBar+1)
- {
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write(']');
- }
- else if (i <= FillingPercent)
- {
- Console.ForegroundColor = color;
- Console.Write('#');
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write('_');
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement