diff --git a/examples/Cli/Delegates/BarSettings.cs b/examples/Cli/Delegates/BarSettings.cs index 75fa93c..61dc9f7 100644 --- a/examples/Cli/Delegates/BarSettings.cs +++ b/examples/Cli/Delegates/BarSettings.cs @@ -1,7 +1,7 @@ using System.ComponentModel; using Spectre.Console.Cli; -namespace Delegates +namespace Spectre.Console.Examples { public static partial class Program { diff --git a/examples/Cli/Delegates/Delegates.csproj b/examples/Cli/Delegates/Delegates.csproj index 4c6756c..4a163f3 100644 --- a/examples/Cli/Delegates/Delegates.csproj +++ b/examples/Cli/Delegates/Delegates.csproj @@ -1,4 +1,4 @@ - + Exe @@ -11,7 +11,7 @@ - + diff --git a/examples/Cli/Delegates/Program.cs b/examples/Cli/Delegates/Program.cs index 6592372..2523ddb 100644 --- a/examples/Cli/Delegates/Program.cs +++ b/examples/Cli/Delegates/Program.cs @@ -1,7 +1,6 @@ -using System; using Spectre.Console.Cli; -namespace Delegates +namespace Spectre.Console.Examples { public static partial class Program { @@ -22,7 +21,7 @@ namespace Delegates private static int Foo(CommandContext context) { - Console.WriteLine("Foo"); + AnsiConsole.WriteLine("Foo"); return 0; } @@ -30,7 +29,7 @@ namespace Delegates { for (var index = 0; index < settings.Count; index++) { - Console.WriteLine("Bar"); + AnsiConsole.WriteLine("Bar"); } return 0; diff --git a/examples/Cli/Dynamic/Dynamic.csproj b/examples/Cli/Dynamic/Dynamic.csproj index 2066c58..93e4730 100644 --- a/examples/Cli/Dynamic/Dynamic.csproj +++ b/examples/Cli/Dynamic/Dynamic.csproj @@ -1,4 +1,4 @@ - + Exe @@ -11,7 +11,7 @@ - + diff --git a/examples/Cli/Dynamic/MyCommand.cs b/examples/Cli/Dynamic/MyCommand.cs index b16caa8..220a6b1 100644 --- a/examples/Cli/Dynamic/MyCommand.cs +++ b/examples/Cli/Dynamic/MyCommand.cs @@ -1,7 +1,7 @@ using System; using Spectre.Console.Cli; -namespace Dynamic +namespace Spectre.Console.Examples { public sealed class MyCommand : Command { @@ -13,7 +13,7 @@ namespace Dynamic } - Console.WriteLine("Value = {0}", data); + AnsiConsole.WriteLine("Value = {0}", data); return 0; } } diff --git a/examples/Cli/Dynamic/Program.cs b/examples/Cli/Dynamic/Program.cs index 519fab7..b90e53c 100644 --- a/examples/Cli/Dynamic/Program.cs +++ b/examples/Cli/Dynamic/Program.cs @@ -1,7 +1,7 @@ using System.Linq; using Spectre.Console.Cli; -namespace Dynamic +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Cli/Injection/Commands/DefaultCommand.cs b/examples/Cli/Injection/Commands/DefaultCommand.cs index 1ae059f..fe2e282 100644 --- a/examples/Cli/Injection/Commands/DefaultCommand.cs +++ b/examples/Cli/Injection/Commands/DefaultCommand.cs @@ -2,7 +2,7 @@ using System; using System.ComponentModel; using Spectre.Console.Cli; -namespace Injection.Commands +namespace Spectre.Console.Examples { public sealed class DefaultCommand : Command { diff --git a/examples/Cli/Injection/IGreeter.cs b/examples/Cli/Injection/IGreeter.cs index a2c285b..be7d888 100644 --- a/examples/Cli/Injection/IGreeter.cs +++ b/examples/Cli/Injection/IGreeter.cs @@ -1,6 +1,4 @@ -using System; - -namespace Injection +namespace Spectre.Console.Examples { public interface IGreeter { @@ -11,7 +9,7 @@ namespace Injection { public void Greet(string name) { - Console.WriteLine($"Hello {name}!"); + AnsiConsole.WriteLine($"Hello {name}!"); } } } diff --git a/examples/Cli/Injection/Infrastructure/TypeRegistrar.cs b/examples/Cli/Injection/Infrastructure/TypeRegistrar.cs index c0e3342..ce9b364 100644 --- a/examples/Cli/Injection/Infrastructure/TypeRegistrar.cs +++ b/examples/Cli/Injection/Infrastructure/TypeRegistrar.cs @@ -2,7 +2,7 @@ using System; using Microsoft.Extensions.DependencyInjection; using Spectre.Console.Cli; -namespace Injection +namespace Spectre.Console.Examples { public sealed class TypeRegistrar : ITypeRegistrar { diff --git a/examples/Cli/Injection/Infrastructure/TypeResolver.cs b/examples/Cli/Injection/Infrastructure/TypeResolver.cs index dde7dc1..8ff91be 100644 --- a/examples/Cli/Injection/Infrastructure/TypeResolver.cs +++ b/examples/Cli/Injection/Infrastructure/TypeResolver.cs @@ -2,7 +2,7 @@ using System; using Microsoft.Extensions.DependencyInjection; using Spectre.Console.Cli; -namespace Injection +namespace Spectre.Console.Examples { public sealed class TypeResolver : ITypeResolver, IDisposable { diff --git a/examples/Cli/Injection/Injection.csproj b/examples/Cli/Injection/Injection.csproj index 4c14b62..99b9923 100644 --- a/examples/Cli/Injection/Injection.csproj +++ b/examples/Cli/Injection/Injection.csproj @@ -15,7 +15,7 @@ - + diff --git a/examples/Cli/Injection/Program.cs b/examples/Cli/Injection/Program.cs index 1206df9..8ebaa0c 100644 --- a/examples/Cli/Injection/Program.cs +++ b/examples/Cli/Injection/Program.cs @@ -1,8 +1,7 @@ -using Injection.Commands; using Microsoft.Extensions.DependencyInjection; using Spectre.Console.Cli; -namespace Injection +namespace Spectre.Console.Examples { public class Program { diff --git a/examples/Cli/Logging/Commands/HelloCommand.cs b/examples/Cli/Logging/Commands/HelloCommand.cs index 710f136..2bbff0c 100644 --- a/examples/Cli/Logging/Commands/HelloCommand.cs +++ b/examples/Cli/Logging/Commands/HelloCommand.cs @@ -1,8 +1,7 @@ -using Microsoft.Extensions.Logging; -using Spectre.Console; +using Microsoft.Extensions.Logging; using Spectre.Console.Cli; -namespace Logging.Commands +namespace Spectre.Console.Examples { public class HelloCommand : Command { diff --git a/examples/Cli/Logging/Commands/LogCommandSettings.cs b/examples/Cli/Logging/Commands/LogCommandSettings.cs index 4160e9d..da47b56 100644 --- a/examples/Cli/Logging/Commands/LogCommandSettings.cs +++ b/examples/Cli/Logging/Commands/LogCommandSettings.cs @@ -1,11 +1,11 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; using Serilog.Events; using Spectre.Console.Cli; -namespace Logging.Commands +namespace Spectre.Console.Examples { public class LogCommandSettings : CommandSettings { diff --git a/examples/Cli/Logging/Infrastructure/LogInterceptor.cs b/examples/Cli/Logging/Infrastructure/LogInterceptor.cs index 423a640..31adaff 100644 --- a/examples/Cli/Logging/Infrastructure/LogInterceptor.cs +++ b/examples/Cli/Logging/Infrastructure/LogInterceptor.cs @@ -1,8 +1,7 @@ -using Logging.Commands; using Serilog.Core; using Spectre.Console.Cli; -namespace Logging +namespace Spectre.Console.Examples { public class LogInterceptor : ICommandInterceptor { diff --git a/examples/Cli/Logging/Infrastructure/LoggingEnricher.cs b/examples/Cli/Logging/Infrastructure/LoggingEnricher.cs index 86007a7..e9e41e2 100644 --- a/examples/Cli/Logging/Infrastructure/LoggingEnricher.cs +++ b/examples/Cli/Logging/Infrastructure/LoggingEnricher.cs @@ -1,7 +1,7 @@ -using Serilog.Core; +using Serilog.Core; using Serilog.Events; -namespace Logging +namespace Spectre.Console.Examples { internal class LoggingEnricher : ILogEventEnricher { diff --git a/examples/Cli/Logging/Infrastructure/TypeRegistrar.cs b/examples/Cli/Logging/Infrastructure/TypeRegistrar.cs index 7975df4..bd7692f 100644 --- a/examples/Cli/Logging/Infrastructure/TypeRegistrar.cs +++ b/examples/Cli/Logging/Infrastructure/TypeRegistrar.cs @@ -1,8 +1,8 @@ -using System; +using System; using Microsoft.Extensions.DependencyInjection; using Spectre.Console.Cli; -namespace Logging +namespace Spectre.Console.Examples { public sealed class TypeRegistrar : ITypeRegistrar { diff --git a/examples/Cli/Logging/Infrastructure/TypeResolver.cs b/examples/Cli/Logging/Infrastructure/TypeResolver.cs index 6e95cab..e449c85 100644 --- a/examples/Cli/Logging/Infrastructure/TypeResolver.cs +++ b/examples/Cli/Logging/Infrastructure/TypeResolver.cs @@ -1,8 +1,8 @@ -using System; +using System; using Microsoft.Extensions.DependencyInjection; using Spectre.Console.Cli; -namespace Logging +namespace Spectre.Console.Examples { public sealed class TypeResolver : ITypeResolver { diff --git a/examples/Cli/Logging/Logging.csproj b/examples/Cli/Logging/Logging.csproj index 6cc4960..8fe73db 100644 --- a/examples/Cli/Logging/Logging.csproj +++ b/examples/Cli/Logging/Logging.csproj @@ -20,7 +20,7 @@ - + diff --git a/examples/Cli/Logging/Program.cs b/examples/Cli/Logging/Program.cs index 5ed226a..16f3517 100644 --- a/examples/Cli/Logging/Program.cs +++ b/examples/Cli/Logging/Program.cs @@ -1,4 +1,3 @@ -using Logging.Commands; using Microsoft.Extensions.DependencyInjection; using Serilog; using Spectre.Console.Cli; @@ -13,7 +12,7 @@ using Spectre.Console.Cli; * Spectre.Console CommandInterceptor */ -namespace Logging +namespace Spectre.Console.Examples { public class Program { diff --git a/examples/Console/Borders/Borders.csproj b/examples/Console/Borders/Borders.csproj index f51cc16..3d8b7b9 100644 --- a/examples/Console/Borders/Borders.csproj +++ b/examples/Console/Borders/Borders.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Borders/Program.cs b/examples/Console/Borders/Program.cs index 2854107..a0dc06a 100644 --- a/examples/Console/Borders/Program.cs +++ b/examples/Console/Borders/Program.cs @@ -1,7 +1,6 @@ -using Spectre.Console; using Spectre.Console.Rendering; -namespace BordersExample +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Calendars/Calendars.csproj b/examples/Console/Calendars/Calendars.csproj index 119a479..6e58f4f 100644 --- a/examples/Console/Calendars/Calendars.csproj +++ b/examples/Console/Calendars/Calendars.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Calendars/Program.cs b/examples/Console/Calendars/Program.cs index 1ac1b49..fbe2311 100644 --- a/examples/Console/Calendars/Program.cs +++ b/examples/Console/Calendars/Program.cs @@ -1,6 +1,4 @@ -using Spectre.Console; - -namespace Calendars +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Canvas/Canvas.csproj b/examples/Console/Canvas/Canvas.csproj index 182d9e5..96055f0 100644 --- a/examples/Console/Canvas/Canvas.csproj +++ b/examples/Console/Canvas/Canvas.csproj @@ -9,8 +9,8 @@ + - diff --git a/examples/Console/Canvas/Mandelbrot.cs b/examples/Console/Canvas/Mandelbrot.cs index 7f3a3da..005b2d1 100644 --- a/examples/Console/Canvas/Mandelbrot.cs +++ b/examples/Console/Canvas/Mandelbrot.cs @@ -4,9 +4,8 @@ Licensed under GNU Free Documentation License 1.2 */ using System; -using Spectre.Console; -namespace CanvasExample +namespace Spectre.Console.Examples { public static class Mandelbrot { diff --git a/examples/Console/Canvas/Program.cs b/examples/Console/Canvas/Program.cs index 29827eb..0e2ce7e 100644 --- a/examples/Console/Canvas/Program.cs +++ b/examples/Console/Canvas/Program.cs @@ -1,10 +1,9 @@ using System.Diagnostics; using System.Reflection; using SixLabors.ImageSharp.Processing; -using Spectre.Console; using Spectre.Console.Rendering; -namespace CanvasExample +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Charts/Charts.csproj b/examples/Console/Charts/Charts.csproj index 3763e82..f9190ef 100644 --- a/examples/Console/Charts/Charts.csproj +++ b/examples/Console/Charts/Charts.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Charts/Program.cs b/examples/Console/Charts/Program.cs index 229047f..f0c7664 100644 --- a/examples/Console/Charts/Program.cs +++ b/examples/Console/Charts/Program.cs @@ -1,7 +1,6 @@ -using Spectre.Console; using Spectre.Console.Rendering; -namespace Charts +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Colors/Colors.csproj b/examples/Console/Colors/Colors.csproj index 32185ad..f4967f0 100644 --- a/examples/Console/Colors/Colors.csproj +++ b/examples/Console/Colors/Colors.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Colors/Program.cs b/examples/Console/Colors/Program.cs index 3075c8e..5e7708d 100644 --- a/examples/Console/Colors/Program.cs +++ b/examples/Console/Colors/Program.cs @@ -1,27 +1,23 @@ -using Spectre.Console; - -namespace ColorExample +namespace Spectre.Console.Examples { public static class Program { public static void Main() { + ///////////////////////////////////////////////////////////////// + // No colors + ///////////////////////////////////////////////////////////////// if (AnsiConsole.Profile.ColorSystem == ColorSystem.NoColors) { - ///////////////////////////////////////////////////////////////// - // No colors - ///////////////////////////////////////////////////////////////// - AnsiConsole.WriteLine("No colors are supported."); return; } + ///////////////////////////////////////////////////////////////// + // 3-BIT + ///////////////////////////////////////////////////////////////// if (AnsiConsole.Profile.Supports(ColorSystem.Legacy)) { - ///////////////////////////////////////////////////////////////// - // 3-BIT - ///////////////////////////////////////////////////////////////// - AnsiConsole.ResetColors(); AnsiConsole.WriteLine(); AnsiConsole.Render(new Rule("[yellow bold underline]3-bit Colors[/]").RuleStyle("grey").LeftAligned()); @@ -30,6 +26,7 @@ namespace ColorExample for (var i = 0; i < 8; i++) { AnsiConsole.Background = Color.FromInt32(i); + AnsiConsole.Foreground = AnsiConsole.Background.GetInvertedColor(); AnsiConsole.Write(string.Format(" {0,-9}", AnsiConsole.Background.ToString())); AnsiConsole.ResetColors(); if ((i + 1) % 8 == 0) @@ -39,12 +36,11 @@ namespace ColorExample } } + ///////////////////////////////////////////////////////////////// + // 4-BIT + ///////////////////////////////////////////////////////////////// if (AnsiConsole.Profile.Supports(ColorSystem.Standard)) { - ///////////////////////////////////////////////////////////////// - // 4-BIT - ///////////////////////////////////////////////////////////////// - AnsiConsole.ResetColors(); AnsiConsole.WriteLine(); AnsiConsole.Render(new Rule("[yellow bold underline]4-bit Colors[/]").RuleStyle("grey").LeftAligned()); @@ -53,6 +49,7 @@ namespace ColorExample for (var i = 0; i < 16; i++) { AnsiConsole.Background = Color.FromInt32(i); + AnsiConsole.Foreground = AnsiConsole.Background.GetInvertedColor(); AnsiConsole.Write(string.Format(" {0,-9}", AnsiConsole.Background.ToString())); AnsiConsole.ResetColors(); if ((i + 1) % 8 == 0) @@ -62,12 +59,11 @@ namespace ColorExample } } + ///////////////////////////////////////////////////////////////// + // 8-BIT + ///////////////////////////////////////////////////////////////// if (AnsiConsole.Profile.Supports(ColorSystem.EightBit)) { - ///////////////////////////////////////////////////////////////// - // 8-BIT - ///////////////////////////////////////////////////////////////// - AnsiConsole.ResetColors(); AnsiConsole.WriteLine(); AnsiConsole.Render(new Rule("[yellow bold underline]8-bit Colors[/]").RuleStyle("grey").LeftAligned()); @@ -79,6 +75,7 @@ namespace ColorExample { var number = i * 16 + j; AnsiConsole.Background = Color.FromInt32(number); + AnsiConsole.Foreground = AnsiConsole.Background.GetInvertedColor(); AnsiConsole.Write(string.Format(" {0,-4}", number)); AnsiConsole.ResetColors(); if ((number + 1) % 16 == 0) @@ -89,31 +86,17 @@ namespace ColorExample } } + ///////////////////////////////////////////////////////////////// + // 24-BIT + ///////////////////////////////////////////////////////////////// if (AnsiConsole.Profile.Supports(ColorSystem.TrueColor)) { - ///////////////////////////////////////////////////////////////// - // 24-BIT - ///////////////////////////////////////////////////////////////// - AnsiConsole.ResetColors(); AnsiConsole.WriteLine(); AnsiConsole.Render(new Rule("[yellow bold underline]24-bit Colors[/]").RuleStyle("grey").LeftAligned()); AnsiConsole.WriteLine(); - var index = 0; - for (var i = 0.0005; i < 1; i += 0.0025) - { - index++; - - var color = Utilities.HSL2RGB(i, 0.5, 0.5); - AnsiConsole.Background = new Color(color.R, color.G, color.B); - AnsiConsole.Write(" "); - - if (index % 50 == 0) - { - AnsiConsole.WriteLine(); - } - } + AnsiConsole.Render(new ColorBox(width: 80, height: 15)); } } } diff --git a/examples/Console/Colors/Utilities.cs b/examples/Console/Colors/Utilities.cs deleted file mode 100644 index 3f32bcd..0000000 --- a/examples/Console/Colors/Utilities.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using Spectre.Console; - -namespace ColorExample -{ - public static class Utilities - { - // Borrowed from https://geekymonkey.com/Programming/CSharp/RGB2HSL_HSL2RGB.htm - public static Color HSL2RGB(double h, double sl, double l) - { - double v; - double r, g, b; - - r = l; // default to gray - g = l; - b = l; - v = (l <= 0.5) ? (l * (1.0 + sl)) : (l + sl - l * sl); - - if (v > 0) - { - double m; - double sv; - int sextant; - double fract, vsf, mid1, mid2; - - m = l + l - v; - sv = (v - m) / v; - h *= 6.0; - - sextant = (int)h; - fract = h - sextant; - vsf = v * sv * fract; - mid1 = m + vsf; - mid2 = v - vsf; - - switch (sextant) - { - case 0: - r = v; - g = mid1; - b = m; - break; - case 1: - r = mid2; - g = v; - b = m; - break; - case 2: - r = m; - g = v; - b = mid1; - break; - case 3: - r = m; - g = mid2; - b = v; - break; - case 4: - r = mid1; - g = m; - b = v; - break; - case 5: - r = v; - g = m; - b = mid2; - break; - } - } - - return new Color( - Convert.ToByte(r * 255.0f), - Convert.ToByte(g * 255.0f), - Convert.ToByte(b * 255.0f)); - } - } -} diff --git a/examples/Console/Columns/Columns.csproj b/examples/Console/Columns/Columns.csproj index 474b855..543f1ef 100644 --- a/examples/Console/Columns/Columns.csproj +++ b/examples/Console/Columns/Columns.csproj @@ -13,7 +13,7 @@ - + diff --git a/examples/Console/Columns/Program.cs b/examples/Console/Columns/Program.cs index c7e90b5..9e20f15 100644 --- a/examples/Console/Columns/Program.cs +++ b/examples/Console/Columns/Program.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; -using Spectre.Console; -namespace ColumnsExample +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Columns/User.cs b/examples/Console/Columns/User.cs index 4125dcc..88e5fc7 100644 --- a/examples/Console/Columns/User.cs +++ b/examples/Console/Columns/User.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace ColumnsExample +namespace Spectre.Console.Examples { public sealed class User { @@ -22,9 +22,9 @@ namespace ColumnsExample }, new User { - FirstName = "Brandon", - LastName = "Cole", - City = "Washington", + FirstName = "Phil", + LastName = "Scott", + City = "Dayton", Country = "United States", }, new User diff --git a/examples/Console/Cursor/Cursor.csproj b/examples/Console/Cursor/Cursor.csproj index 9daddac..622ace0 100644 --- a/examples/Console/Cursor/Cursor.csproj +++ b/examples/Console/Cursor/Cursor.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Cursor/Program.cs b/examples/Console/Cursor/Program.cs index e2645c2..796b857 100644 --- a/examples/Console/Cursor/Program.cs +++ b/examples/Console/Cursor/Program.cs @@ -1,6 +1,4 @@ -using Spectre.Console; - -namespace Cursor +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Emojis/Emojis.csproj b/examples/Console/Emojis/Emojis.csproj index eceb0bd..ebb420b 100644 --- a/examples/Console/Emojis/Emojis.csproj +++ b/examples/Console/Emojis/Emojis.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Emojis/Program.cs b/examples/Console/Emojis/Program.cs index c67932f..b91e296 100644 --- a/examples/Console/Emojis/Program.cs +++ b/examples/Console/Emojis/Program.cs @@ -1,6 +1,4 @@ -using Spectre.Console; - -namespace EmojiExample +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Exceptions/Exceptions.csproj b/examples/Console/Exceptions/Exceptions.csproj index 128d8c0..9797995 100644 --- a/examples/Console/Exceptions/Exceptions.csproj +++ b/examples/Console/Exceptions/Exceptions.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Exceptions/Program.cs b/examples/Console/Exceptions/Program.cs index 559dac3..bb9a365 100644 --- a/examples/Console/Exceptions/Program.cs +++ b/examples/Console/Exceptions/Program.cs @@ -1,8 +1,7 @@ using System; using System.Security.Authentication; -using Spectre.Console; -namespace Exceptions +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Figlet/Figlet.csproj b/examples/Console/Figlet/Figlet.csproj index fbac2d6..88e7331 100644 --- a/examples/Console/Figlet/Figlet.csproj +++ b/examples/Console/Figlet/Figlet.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Figlet/Program.cs b/examples/Console/Figlet/Program.cs index 0310a7b..60f3760 100644 --- a/examples/Console/Figlet/Program.cs +++ b/examples/Console/Figlet/Program.cs @@ -1,6 +1,4 @@ -using Spectre.Console; - -namespace EmojiExample +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Grids/Grids.csproj b/examples/Console/Grids/Grids.csproj index 95c9004..d6ade50 100644 --- a/examples/Console/Grids/Grids.csproj +++ b/examples/Console/Grids/Grids.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Grids/Program.cs b/examples/Console/Grids/Program.cs index ae59488..6320429 100644 --- a/examples/Console/Grids/Program.cs +++ b/examples/Console/Grids/Program.cs @@ -1,6 +1,4 @@ -using Spectre.Console; - -namespace GridExample +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Info/Info.csproj b/examples/Console/Info/Info.csproj index f4ec75f..05d3666 100644 --- a/examples/Console/Info/Info.csproj +++ b/examples/Console/Info/Info.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Info/Program.cs b/examples/Console/Info/Program.cs index 3cb5f82..2d757df 100644 --- a/examples/Console/Info/Program.cs +++ b/examples/Console/Info/Program.cs @@ -1,6 +1,4 @@ -using Spectre.Console; - -namespace InfoExample +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Links/Links.csproj b/examples/Console/Links/Links.csproj index 5054afa..ba60633 100644 --- a/examples/Console/Links/Links.csproj +++ b/examples/Console/Links/Links.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Links/Program.cs b/examples/Console/Links/Program.cs index f61972e..1977008 100644 --- a/examples/Console/Links/Program.cs +++ b/examples/Console/Links/Program.cs @@ -1,6 +1,4 @@ -using Spectre.Console; - -namespace LinkExample +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Panels/Panels.csproj b/examples/Console/Panels/Panels.csproj index 03add39..10a9680 100644 --- a/examples/Console/Panels/Panels.csproj +++ b/examples/Console/Panels/Panels.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Panels/Program.cs b/examples/Console/Panels/Program.cs index d43c110..2c61b0b 100644 --- a/examples/Console/Panels/Program.cs +++ b/examples/Console/Panels/Program.cs @@ -1,6 +1,4 @@ -using Spectre.Console; - -namespace PanelExample +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Progress/DescriptionGenerator.cs b/examples/Console/Progress/DescriptionGenerator.cs index a4f7861..3f4f0a2 100644 --- a/examples/Console/Progress/DescriptionGenerator.cs +++ b/examples/Console/Progress/DescriptionGenerator.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace ProgressExample +namespace Spectre.Console.Examples { public static class DescriptionGenerator { diff --git a/examples/Console/Progress/Program.cs b/examples/Console/Progress/Program.cs index 82ae6b0..b30f96d 100644 --- a/examples/Console/Progress/Program.cs +++ b/examples/Console/Progress/Program.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading; -using Spectre.Console; -namespace ProgressExample +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Progress/Progress.csproj b/examples/Console/Progress/Progress.csproj index 859b3f2..6a226b0 100644 --- a/examples/Console/Progress/Progress.csproj +++ b/examples/Console/Progress/Progress.csproj @@ -13,7 +13,7 @@ - + diff --git a/examples/Console/Prompt/Program.cs b/examples/Console/Prompt/Program.cs index 0c716c2..d9a0ac9 100644 --- a/examples/Console/Prompt/Program.cs +++ b/examples/Console/Prompt/Program.cs @@ -1,6 +1,4 @@ -using Spectre.Console; - -namespace Cursor +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Prompt/Prompt.csproj b/examples/Console/Prompt/Prompt.csproj index c0d2d42..3abb410 100644 --- a/examples/Console/Prompt/Prompt.csproj +++ b/examples/Console/Prompt/Prompt.csproj @@ -10,7 +10,7 @@ - + diff --git a/examples/Console/Rules/Program.cs b/examples/Console/Rules/Program.cs index 8a03924..7b08fff 100644 --- a/examples/Console/Rules/Program.cs +++ b/examples/Console/Rules/Program.cs @@ -1,6 +1,4 @@ -using Spectre.Console; - -namespace EmojiExample +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Rules/Rules.csproj b/examples/Console/Rules/Rules.csproj index 7d590fc..8447b1e 100644 --- a/examples/Console/Rules/Rules.csproj +++ b/examples/Console/Rules/Rules.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Showcase/ColorBox.cs b/examples/Console/Showcase/ColorBox.cs deleted file mode 100644 index 4060c32..0000000 --- a/examples/Console/Showcase/ColorBox.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using Spectre.Console; -using Spectre.Console.Rendering; - -namespace Showcase -{ - public static partial class Program - { - public sealed class ColorBox : Renderable - { - private readonly int _height; - - public ColorBox(int height) - { - _height = height; - } - - protected override Measurement Measure(RenderContext context, int maxWidth) - { - return new Measurement(1, maxWidth); - } - - protected override IEnumerable Render(RenderContext context, int maxWidth) - { - for (var y = 0; y < _height; y++) - { - for (var x = 0; x < maxWidth; x++) - { - var h = x / (float)maxWidth; - var l = 0.1f + ((y / (float)_height) * 0.7f); - var (r1, g1, b1) = ColorFromHSL(h, l, 1.0f); - var (r2, g2, b2) = ColorFromHSL(h, l + (0.7f / 10), 1.0f); - - var background = new Color((byte)(r1 * 255), (byte)(g1 * 255), (byte)(b1 * 255)); - var foreground = new Color((byte)(r2 * 255), (byte)(g2 * 255), (byte)(b2 * 255)); - - yield return new Segment("▄", new Style(foreground, background)); - } - - yield return Segment.LineBreak; - } - } - - private static (float, float, float) ColorFromHSL(double h, double l, double s) - { - double r = 0, g = 0, b = 0; - if (l != 0) - { - if (s == 0) - { - r = g = b = l; - } - else - { - double temp2; - if (l < 0.5) - { - temp2 = l * (1.0 + s); - } - else - { - temp2 = l + s - (l * s); - } - - var temp1 = 2.0 * l - temp2; - - r = GetColorComponent(temp1, temp2, h + 1.0 / 3.0); - g = GetColorComponent(temp1, temp2, h); - b = GetColorComponent(temp1, temp2, h - 1.0 / 3.0); - } - } - - return ((float)r, (float)g, (float)b); - - } - - private static double GetColorComponent(double temp1, double temp2, double temp3) - { - if (temp3 < 0.0) - { - temp3 += 1.0; - } - else if (temp3 > 1.0) - { - temp3 -= 1.0; - } - - if (temp3 < 1.0 / 6.0) - { - return temp1 + (temp2 - temp1) * 6.0 * temp3; - } - else if (temp3 < 0.5) - { - return temp2; - } - else if (temp3 < 2.0 / 3.0) - { - return temp1 + ((temp2 - temp1) * ((2.0 / 3.0) - temp3) * 6.0); - } - else - { - return temp1; - } - } - } - } -} diff --git a/examples/Console/Showcase/ExceptionGenerator.cs b/examples/Console/Showcase/ExceptionGenerator.cs index baa6625..1f9355e 100644 --- a/examples/Console/Showcase/ExceptionGenerator.cs +++ b/examples/Console/Showcase/ExceptionGenerator.cs @@ -1,7 +1,6 @@ using System; -using Spectre.Console; -namespace Showcase +namespace Spectre.Console.Examples { public static class ExceptionGenerator { diff --git a/examples/Console/Showcase/Program.cs b/examples/Console/Showcase/Program.cs index f91a376..9cfb2c3 100644 --- a/examples/Console/Showcase/Program.cs +++ b/examples/Console/Showcase/Program.cs @@ -1,10 +1,6 @@ -using System; -using Spectre.Console; -using SixLabors.ImageSharp.Processing; -using System.Threading; using Spectre.Console.Rendering; -namespace Showcase +namespace Spectre.Console.Examples { public static partial class Program { @@ -102,7 +98,7 @@ namespace Showcase "✓ [bold purple]8-bit color[/]\n" + "✓ [bold yellow]Truecolor (16.7 million)[/]\n" + "✓ [bold aqua]Automatic color conversion[/]"), - new ColorBox(6)); + new ColorBox(height: 6)); return colorTable; } diff --git a/examples/Console/Showcase/Showcase.csproj b/examples/Console/Showcase/Showcase.csproj index 99dea6d..7a6518f 100644 --- a/examples/Console/Showcase/Showcase.csproj +++ b/examples/Console/Showcase/Showcase.csproj @@ -1,16 +1,15 @@ - + Exe - netcoreapp3.1 + net5.0 Showcase Demonstation of Spectre.Console. Misc - - + diff --git a/examples/Console/Status/Program.cs b/examples/Console/Status/Program.cs index 36fde30..f0558ae 100644 --- a/examples/Console/Status/Program.cs +++ b/examples/Console/Status/Program.cs @@ -1,7 +1,6 @@ using System.Threading; -using Spectre.Console; -namespace ProgressExample +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Status/Status.csproj b/examples/Console/Status/Status.csproj index eb20f18..d364616 100644 --- a/examples/Console/Status/Status.csproj +++ b/examples/Console/Status/Status.csproj @@ -13,7 +13,7 @@ - + diff --git a/examples/Console/Tables/Program.cs b/examples/Console/Tables/Program.cs index ce7b6cf..805cc2a 100644 --- a/examples/Console/Tables/Program.cs +++ b/examples/Console/Tables/Program.cs @@ -1,7 +1,4 @@ -using System.Diagnostics; -using Spectre.Console; - -namespace TableExample +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Tables/Tables.csproj b/examples/Console/Tables/Tables.csproj index 451f79a..447d374 100644 --- a/examples/Console/Tables/Tables.csproj +++ b/examples/Console/Tables/Tables.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Trees/Program.cs b/examples/Console/Trees/Program.cs index 33747cd..df9d587 100644 --- a/examples/Console/Trees/Program.cs +++ b/examples/Console/Trees/Program.cs @@ -1,6 +1,4 @@ -using Spectre.Console; - -namespace TableExample +namespace Spectre.Console.Examples { public static class Program { diff --git a/examples/Console/Trees/Trees.csproj b/examples/Console/Trees/Trees.csproj index 9291334..e0c3b3a 100644 --- a/examples/Console/Trees/Trees.csproj +++ b/examples/Console/Trees/Trees.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Shared/ColorBox.cs b/examples/Shared/ColorBox.cs new file mode 100644 index 0000000..e855f46 --- /dev/null +++ b/examples/Shared/ColorBox.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using Spectre.Console.Rendering; + +namespace Spectre.Console.Examples +{ + public sealed class ColorBox : Renderable + { + private readonly int _height; + private int? _width; + + public ColorBox(int height) + { + _height = height; + } + + public ColorBox(int width, int height) + : this(height) + { + _width = width; + } + + protected override Measurement Measure(RenderContext context, int maxWidth) + { + return new Measurement(1, GetWidth(maxWidth)); + } + + protected override IEnumerable Render(RenderContext context, int maxWidth) + { + maxWidth = GetWidth(maxWidth); + + for (var y = 0; y < _height; y++) + { + for (var x = 0; x < maxWidth; x++) + { + var h = x / (float)maxWidth; + var l = 0.1f + ((y / (float)_height) * 0.7f); + var (r1, g1, b1) = ColorFromHSL(h, l, 1.0f); + var (r2, g2, b2) = ColorFromHSL(h, l + (0.7f / 10), 1.0f); + + var background = new Color((byte)(r1 * 255), (byte)(g1 * 255), (byte)(b1 * 255)); + var foreground = new Color((byte)(r2 * 255), (byte)(g2 * 255), (byte)(b2 * 255)); + + yield return new Segment("▄", new Style(foreground, background)); + } + + yield return Segment.LineBreak; + } + } + + private int GetWidth(int maxWidth) + { + var width = maxWidth; + if (_width != null) + { + width = Math.Min(_width.Value, width); + } + + return width; + } + + private static (float, float, float) ColorFromHSL(double h, double l, double s) + { + double r = 0, g = 0, b = 0; + if (l != 0) + { + if (s == 0) + { + r = g = b = l; + } + else + { + double temp2; + if (l < 0.5) + { + temp2 = l * (1.0 + s); + } + else + { + temp2 = l + s - (l * s); + } + + var temp1 = 2.0 * l - temp2; + + r = GetColorComponent(temp1, temp2, h + 1.0 / 3.0); + g = GetColorComponent(temp1, temp2, h); + b = GetColorComponent(temp1, temp2, h - 1.0 / 3.0); + } + } + + return ((float)r, (float)g, (float)b); + + } + + private static double GetColorComponent(double temp1, double temp2, double temp3) + { + if (temp3 < 0.0) + { + temp3 += 1.0; + } + else if (temp3 > 1.0) + { + temp3 -= 1.0; + } + + if (temp3 < 1.0 / 6.0) + { + return temp1 + (temp2 - temp1) * 6.0 * temp3; + } + else if (temp3 < 0.5) + { + return temp2; + } + else if (temp3 < 2.0 / 3.0) + { + return temp1 + ((temp2 - temp1) * ((2.0 / 3.0) - temp3) * 6.0); + } + else + { + return temp1; + } + } + } +} diff --git a/examples/Shared/Extensions/ColorExtensions.cs b/examples/Shared/Extensions/ColorExtensions.cs new file mode 100644 index 0000000..0322c5b --- /dev/null +++ b/examples/Shared/Extensions/ColorExtensions.cs @@ -0,0 +1,15 @@ +namespace Spectre.Console.Examples +{ + public static class ColorExtensions + { + public static Color GetInvertedColor(this Color color) + { + return GetLuminance(color) < 140 ? Color.White : Color.Black; + } + + private static float GetLuminance(this Color color) + { + return (float)((0.2126 * color.R) + (0.7152 * color.G) + (0.0722 * color.B)); + } + } +} diff --git a/examples/Shared/Shared.csproj b/examples/Shared/Shared.csproj new file mode 100644 index 0000000..bdcfea0 --- /dev/null +++ b/examples/Shared/Shared.csproj @@ -0,0 +1,12 @@ + + + + net5.0 + false + + + + + + + diff --git a/src/Spectre.Console.Tests/Unit/Cli/CommandAppTests.Constructor.cs b/src/Spectre.Console.Tests/Unit/Cli/CommandAppTests.Constructor.cs index 6a689ba..c86b494 100644 --- a/src/Spectre.Console.Tests/Unit/Cli/CommandAppTests.Constructor.cs +++ b/src/Spectre.Console.Tests/Unit/Cli/CommandAppTests.Constructor.cs @@ -1,8 +1,6 @@ using Shouldly; using Spectre.Console.Cli; using Spectre.Console.Testing; -using Spectre.Console.Tests.Data; -using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit.Cli diff --git a/src/Spectre.Console.sln b/src/Spectre.Console.sln index 2962472..dea2096 100644 --- a/src/Spectre.Console.sln +++ b/src/Spectre.Console.sln @@ -82,6 +82,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Logging", "..\examples\Cli\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Showcase", "..\examples\Console\Showcase\Showcase.csproj", "{4C30C028-E97D-4B4C-AD17-C90F338A4DFF}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{A0C772BA-C5F4-451D-AA7A-4045F2FA0201}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shared", "..\examples\Shared\Shared.csproj", "{8428A7DD-29FC-4417-9CA0-B90D34B26AB2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -440,6 +444,18 @@ Global {4C30C028-E97D-4B4C-AD17-C90F338A4DFF}.Release|x64.Build.0 = Release|Any CPU {4C30C028-E97D-4B4C-AD17-C90F338A4DFF}.Release|x86.ActiveCfg = Release|Any CPU {4C30C028-E97D-4B4C-AD17-C90F338A4DFF}.Release|x86.Build.0 = Release|Any CPU + {8428A7DD-29FC-4417-9CA0-B90D34B26AB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8428A7DD-29FC-4417-9CA0-B90D34B26AB2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8428A7DD-29FC-4417-9CA0-B90D34B26AB2}.Debug|x64.ActiveCfg = Debug|Any CPU + {8428A7DD-29FC-4417-9CA0-B90D34B26AB2}.Debug|x64.Build.0 = Debug|Any CPU + {8428A7DD-29FC-4417-9CA0-B90D34B26AB2}.Debug|x86.ActiveCfg = Debug|Any CPU + {8428A7DD-29FC-4417-9CA0-B90D34B26AB2}.Debug|x86.Build.0 = Debug|Any CPU + {8428A7DD-29FC-4417-9CA0-B90D34B26AB2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8428A7DD-29FC-4417-9CA0-B90D34B26AB2}.Release|Any CPU.Build.0 = Release|Any CPU + {8428A7DD-29FC-4417-9CA0-B90D34B26AB2}.Release|x64.ActiveCfg = Release|Any CPU + {8428A7DD-29FC-4417-9CA0-B90D34B26AB2}.Release|x64.Build.0 = Release|Any CPU + {8428A7DD-29FC-4417-9CA0-B90D34B26AB2}.Release|x86.ActiveCfg = Release|Any CPU + {8428A7DD-29FC-4417-9CA0-B90D34B26AB2}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -473,6 +489,8 @@ Global {CA7AF967-3FA5-4CB1-9564-740CF4527895} = {F0575243-121F-4DEE-9F6B-246E26DC0844} {33C7075A-DF97-44FC-8AB3-0CCFBA03341A} = {42792D7F-0BB6-4EE1-A314-8889305A4C48} {4C30C028-E97D-4B4C-AD17-C90F338A4DFF} = {F0575243-121F-4DEE-9F6B-246E26DC0844} + {A0C772BA-C5F4-451D-AA7A-4045F2FA0201} = {F0575243-121F-4DEE-9F6B-246E26DC0844} + {8428A7DD-29FC-4417-9CA0-B90D34B26AB2} = {A0C772BA-C5F4-451D-AA7A-4045F2FA0201} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {5729B071-67A0-48FB-8B1B-275E6822086C} diff --git a/src/Spectre.Console/Emoji.cs b/src/Spectre.Console/Emoji.cs index 3a42c52..89afcc6 100644 --- a/src/Spectre.Console/Emoji.cs +++ b/src/Spectre.Console/Emoji.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Design; using System.Text; -using System.Text.RegularExpressions; namespace Spectre.Console {