Duplicate File Locator
1.0
Home
GitHub Repo
Loading...
Searching...
No Matches
ConsoleUtility.cs
Go to the documentation of this file.
1
using
System;
2
using
System.Collections.Generic;
3
using
System.Linq;
4
using
System.Text;
5
using
System.Threading.Tasks;
6
7
namespace
ProofOfConcept
8
{
9
// Ref: https://www.codeproject.com/Tips/5255878/A-Console-Progress-Bar-in-Csharp
10
public
static
class
ConsoleUtility
11
{
12
const
char
_block =
'■'
;
13
const
string
_back =
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
;
14
const
string
_twirl =
"-\\|/"
;
15
16
public
static
void
WriteProgressBar(
int
percent,
bool
update =
false
)
17
{
18
if
(update)
19
Console.Write(_back);
20
Console.Write(
"["
);
21
var p = (int)((percent / 10f) + .5f);
22
for
(var i = 0; i < 10; ++i)
23
{
24
if
(i >= p)
25
Console.Write(
' '
);
26
else
27
Console.Write(_block);
28
}
29
Console.Write(
"] {0,3:##0}%"
, percent);
30
}
31
32
public
static
void
WriteProgress(
int
progress,
bool
update =
false
)
33
{
34
if
(update)
35
Console.Write(
"\b"
);
36
Console.Write(_twirl[progress % _twirl.Length]);
37
}
38
}
39
}
ProofOfConcept
Definition
ConsoleUtility.cs:8
ProofOfConcept
ConsoleUtility.cs
Generated by
1.14.0