Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Set progress by percentage #65

Closed
KoalaBear84 opened this issue Jun 2, 2020 · 2 comments · Fixed by #70
Closed

Feature request: Set progress by percentage #65

KoalaBear84 opened this issue Jun 2, 2020 · 2 comments · Fixed by #70

Comments

@KoalaBear84
Copy link

I would like to set the progress by percentage.

Something like this:

// Set progress to 10.7%
ProgressBar.SetPercentage(10.7);
// or
ProgressBar.SetPercentage(10.7m);

Currently using hardcoded 1000 ticks and:

ProgressBar.Tick((int)(progress / 0.1m));

Also would be nice to support a single digits after the comma separator, so it will display "10.7%" instead of "10.70%". Also because it's faster to read, and not as

Thanks!

@0xced
Copy link
Contributor

0xced commented Sep 24, 2020

You can already achieve this by using AsProgress<float>() which returns an IProgress<float> that you can use to report progression as percentage:

using var progressBar = new ProgressBar(10000, "My Progress Message");
var progress = progressBar.AsProgress<float>();
progress.Report(0.107); // 10.7%

@KoalaBear84
Copy link
Author

Thanks, if this could be added to the readme it would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants