-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds option to configure the Foreground Done Color (#97)
Co-authored-by: Martijn Laarman <[email protected]>
- Loading branch information
Showing
6 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/ShellProgressBar.Example/Examples/AlternateFinishedColorExample.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace ShellProgressBar.Example.Examples | ||
{ | ||
public class AlternateFinishedColorExample : ExampleBase | ||
{ | ||
protected override void Start() | ||
{ | ||
var options = new ProgressBarOptions | ||
{ | ||
ForegroundColor = ConsoleColor.Yellow, | ||
ForegroundColorDone = ConsoleColor.DarkGreen, | ||
ForegroundColorError = ConsoleColor.Red, | ||
BackgroundColor = ConsoleColor.DarkGray, | ||
BackgroundCharacter = '\u2593' | ||
}; | ||
|
||
using (var pbar = new ProgressBar(100, "100 ticks", options)) | ||
{ | ||
Task.Run( | ||
() => | ||
{ | ||
for (var i = 0; i < 10; i++) | ||
{ | ||
Task.Delay(10).Wait(); | ||
pbar.Tick($"Step {i}"); | ||
} | ||
pbar.WriteErrorLine("The task ran into an issue!"); | ||
// OR pbar.ObservedError = true; | ||
}).Wait(); | ||
pbar.Message= "Indicate the task is done, but the status is not Green."; | ||
} | ||
|
||
Task.Delay(5000).Wait(); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters