-
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.
* started on porting this to .netstandard 1.3 * updated progressbar to be displayed correctly on OSX with the help of #12, finally able to find the time to whip out the macbook :) * updated fixes for OSX from #12 to not bite windows * xmldocs and nuget info in csproj * update build.bat to quickly build/release' * Added coding examples for the various options which will make it into to the README as gifs shortly * finished adding examples to support documentation * indentation
- Loading branch information
Showing
36 changed files
with
471 additions
and
432 deletions.
There are no files selected for viewing
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,21 @@ | ||
root=true | ||
|
||
[*.cs] | ||
trim_trailing_whitespace=true | ||
insert_final_newline=true | ||
|
||
[*] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[*.cshtml] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[*.{fs,fsx}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[*.{md,markdown,json,js,csproj,fsproj,targets}] | ||
indent_style = space | ||
indent_size = 2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MsBuild.exe" ^ | ||
build\Build.proj /p:NuspecFile=build\ShellProgressBar.nuspec;BUILD_NUMBER=%1 /t:NugetPackage | ||
@ECHO OFF | ||
|
||
pushd src | ||
|
||
dotnet restore | ||
|
||
IF "%~1"=="" ( dotnet build ) | ||
IF NOT "%~1"=="" ( dotnet pack -c Release /p:Version=%1 ) | ||
|
||
popd | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,34 @@ | ||
using System; | ||
|
||
namespace ShellProgressBar.Example.Examples | ||
{ | ||
public class ChildrenExample : ExampleBase | ||
{ | ||
protected override void Start() | ||
{ | ||
const int totalTicks = 10; | ||
var options = new ProgressBarOptions | ||
{ | ||
ForegroundColor = ConsoleColor.Yellow, | ||
BackgroundColor = ConsoleColor.DarkYellow, | ||
ProgressCharacter = '─' | ||
}; | ||
var childOptions = new ProgressBarOptions | ||
{ | ||
ForegroundColor = ConsoleColor.Green, | ||
BackgroundColor = ConsoleColor.DarkGreen, | ||
ProgressCharacter = '─' | ||
}; | ||
using (var pbar = new ProgressBar(totalTicks, "main progressbar", options)) | ||
{ | ||
TickToCompletion(pbar, totalTicks, sleep: 10, childAction: () => | ||
{ | ||
using (var child = pbar.Spawn(totalTicks, "child actions", childOptions)) | ||
{ | ||
TickToCompletion(child, totalTicks, sleep: 100); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/ShellProgressBar.Example/Examples/ChildrenNoCollapseExample.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,35 @@ | ||
using System; | ||
|
||
namespace ShellProgressBar.Example.Examples | ||
{ | ||
public class ChildrenNoCollapseExample : ExampleBase | ||
{ | ||
protected override void Start() | ||
{ | ||
const int totalTicks = 10; | ||
var options = new ProgressBarOptions | ||
{ | ||
ForegroundColor = ConsoleColor.Yellow, | ||
BackgroundColor = ConsoleColor.DarkYellow, | ||
ProgressCharacter = '─' | ||
}; | ||
var childOptions = new ProgressBarOptions | ||
{ | ||
ForegroundColor = ConsoleColor.Green, | ||
BackgroundColor = ConsoleColor.DarkGreen, | ||
ProgressCharacter = '─', | ||
CollapseWhenFinished = false | ||
}; | ||
using (var pbar = new ProgressBar(totalTicks, "main progressbar", options)) | ||
{ | ||
TickToCompletion(pbar, totalTicks, sleep: 10, childAction: () => | ||
{ | ||
using (var child = pbar.Spawn(totalTicks, "child actions", childOptions)) | ||
{ | ||
TickToCompletion(child, totalTicks, sleep: 100); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/ShellProgressBar.Example/Examples/DontDisplayInRealTimeExample.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,18 @@ | ||
namespace ShellProgressBar.Example.Examples | ||
{ | ||
public class DontDisplayInRealTimeExample : ExampleBase | ||
{ | ||
protected override void Start() | ||
{ | ||
const int totalTicks = 5; | ||
var options = new ProgressBarOptions | ||
{ | ||
DisplayTimeInRealTime = false | ||
}; | ||
using (var pbar = new ProgressBar(totalTicks, "only draw progress on tick", options)) | ||
{ | ||
TickToCompletion(pbar, totalTicks); | ||
} | ||
} | ||
} | ||
} |
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,34 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace ShellProgressBar.Example.Examples | ||
{ | ||
public abstract class ExampleBase : IProgressBarExample | ||
{ | ||
private bool RequestToQuit { get; set; } | ||
|
||
protected void TickToCompletion(IProgressBar pbar, int ticks, int sleep = 1750, Action childAction = null) | ||
{ | ||
var initialMessage = pbar.Message; | ||
for (var i = 0; i < ticks && !RequestToQuit; i++) | ||
{ | ||
pbar.Message = $"Start {i + 1} of {ticks}: {initialMessage}"; | ||
childAction?.Invoke(); | ||
Thread.Sleep(sleep); | ||
pbar.Tick($"End {i + 1} of {ticks}: {initialMessage}"); | ||
} | ||
} | ||
|
||
public Task Start(CancellationToken token) | ||
{ | ||
RequestToQuit = false; | ||
token.Register(() => RequestToQuit = true); | ||
|
||
this.Start(); | ||
return Task.FromResult(1); | ||
} | ||
|
||
protected abstract void Start(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/ShellProgressBar.Example/Examples/ProgressBarOnBottomExample.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,21 @@ | ||
using System; | ||
|
||
namespace ShellProgressBar.Example.Examples | ||
{ | ||
public class ProgressBarOnBottomExample : ExampleBase | ||
{ | ||
protected override void Start() | ||
{ | ||
const int totalTicks = 10; | ||
var options = new ProgressBarOptions | ||
{ | ||
ProgressCharacter = '─', | ||
ProgressBarOnBottom = true | ||
}; | ||
using (var pbar = new ProgressBar(totalTicks, "progress bar is on the bottom now", options)) | ||
{ | ||
TickToCompletion(pbar, totalTicks, sleep: 500); | ||
} | ||
} | ||
} | ||
} |
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,23 @@ | ||
using System; | ||
|
||
namespace ShellProgressBar.Example.Examples | ||
{ | ||
public class StylingExample : ExampleBase | ||
{ | ||
protected override void Start() | ||
{ | ||
const int totalTicks = 10; | ||
var options = new ProgressBarOptions | ||
{ | ||
ForegroundColor = ConsoleColor.Yellow, | ||
ForegroundColorDone = ConsoleColor.DarkGreen, | ||
BackgroundColor = ConsoleColor.DarkGray, | ||
BackgroundCharacter = '\u2593' | ||
}; | ||
using (var pbar = new ProgressBar(totalTicks, "showing off styling", options)) | ||
{ | ||
TickToCompletion(pbar, totalTicks, sleep: 500); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.