public void RenderManualPosition() { var grid = new Grid { AutoPosition = false } .AddColumns(GridLength.Char(1), GridLength.Char(1), GridLength.Char(1), GridLength.Char(1)) .AddChildren( new Cell { [Grid.ColumnProperty] = 0, [Grid.RowProperty] = 0 }.AddChildren(1), new Cell { [Grid.ColumnProperty] = 3, [Grid.RowProperty] = 0 }.AddChildren(2), new Cell { [Grid.ColumnProperty] = 1, [Grid.RowProperty] = 1, [Grid.ColumnSpanProperty] = 3 }.AddChildren(3) ); GetRenderedText(grid, 8).Should().BeLines( "╔═╤══╤═╗", "║1│ │2║", "╟─┼──┴─╢", "║ │3 ║", "╚═╧════╝"); }
public void RenderManualPosition() { var grid = new Grid { AutoPosition = false, Columns = { GridLength.Char(1), GridLength.Char(1), GridLength.Char(1), GridLength.Char(1) }, Children = { new Cell { [Grid.ColumnProperty] = 0, [Grid.RowProperty] = 0, Children ={ 1 } }, new Cell { [Grid.ColumnProperty] = 3, [Grid.RowProperty] = 0, Children ={ 2 } }, new Cell { [Grid.ColumnProperty] = 1, [Grid.RowProperty] = 1, [Grid.ColumnSpanProperty] = 3, Children ={ 3 } }, } }; GetRenderedText(grid, 8).Should().BeLines( "╔═╤══╤═╗", "║1│ │2║", "╟─┼──┴─╢", "║ │3 ║", "╚═╧════╝"); }
public void RenderCustomBorders() { var headerThickness = new LineThickness(LineWidth.Single, LineWidth.Wide); var grid = new Grid { Stroke = new LineThickness(LineWidth.None) } .AddColumns(GridLength.Char(1), GridLength.Char(1), GridLength.Char(1)) .AddChildren( new Cell { Stroke = headerThickness }.AddChildren(1), new Cell { Stroke = headerThickness }.AddChildren(2), new Cell { Stroke = headerThickness }.AddChildren(3), new Cell().AddChildren(4), new Cell().AddChildren(5), new Cell().AddChildren(6) ); GetRenderedText(grid, 8).Should().BeLines( "╒═╤═╤═╕ ", "│1│2│3│ ", "╞═╪═╪═╡ ", "│4│5│6│ ", "└─┴─┴─┘ "); }
public async Task Execute(KustoFunctionsState functionsState) { try { var client = await functionsState.GetManagementClient(); var databases = await client.Databases.ListByClusterAsync(resourceGroupName : functionsState._options.ResourceGroup, clusterName : $"{functionsState._options.KustoClusterName}"); var headerThickness = new LineThickness(LineWidth.Single, LineWidth.Single); var doc = new Document( new Grid { Color = Gray, Columns = { GridLength.Auto, GridLength.Char(20), GridLength.Char(20) }, Children = { new Cell("Name") { Stroke = headerThickness }, new Cell("Row Count") { Stroke = headerThickness }, new Cell("Cache Size (GB)") { Stroke = headerThickness }, databases.Select(item => { var databasesQuery = functionsState.GetDataAdminReader(item.Name.Split('/')[1], ".show database datastats").Result; var dataStats = new KustoDatastats(databasesQuery); return(new[] { new Cell(dataStats.DatabaseName) { Color = Yellow }, new Cell(dataStats.HotRowCount), new Cell(dataStats.HotCompressedSize.ToString("##,##0.00000000", CultureInfo.InvariantCulture)) { Align = Align.Right }, }); }) } } ); ConsoleRenderer.RenderDocument(doc); } catch (Exception ex) { Console.WriteLine(ex); } }
public void ConvertToString() { _converter.ConvertToString(GridLength.Auto).Should().Be("Auto"); _converter.ConvertToString(GridLength.Char(1)).Should().Be("1"); _converter.ConvertToString(GridLength.Char(5)).Should().Be("5"); _converter.ConvertToString(GridLength.Star(1)).Should().Be("*"); _converter.ConvertToString(GridLength.Star(5)).Should().Be("5*"); }
public void ConvertFromString() { _converter.ConvertFrom("Auto").Should().Be(GridLength.Auto); _converter.ConvertFrom("AutO").Should().Be(GridLength.Auto); _converter.ConvertFrom("1").Should().Be(GridLength.Char(1)); _converter.ConvertFrom("5").Should().Be(GridLength.Char(5)); _converter.ConvertFrom("5").Should().Be(GridLength.Char(5)); _converter.ConvertFrom("1*").Should().Be(GridLength.Star(1)); _converter.ConvertFrom("5*").Should().Be(GridLength.Star(5)); _converter.ConvertFrom("5 *").Should().Be(GridLength.Star(5)); _converter.ConvertFrom("*").Should().Be(GridLength.Star(1)); }
public void RenderDefaultBorders() { var grid = new Grid() .AddColumns(GridLength.Char(1), GridLength.Char(1), GridLength.Char(1)) .AddChildren(Enumerable.Range(1, 6).Select(i => new Cell().AddChildren(i))); GetRenderedText(grid, 8).Should().BeLines( "╔═╤═╤═╗ ", "║1│2│3║ ", "╟─┼─┼─╢ ", "║4│5│6║ ", "╚═╧═╧═╝ "); }
public void RenderDefaultBorders() { var grid = new Grid { Columns = { GridLength.Char(1), GridLength.Char(1), GridLength.Char(1) }, Children = { Enumerable.Range(1, 6).Select(i => new Cell { Children = { i } }) } }; GetRenderedText(grid, 8).Should().BeLines( "╔═╤═╤═╗ ", "║1│2│3║ ", "╟─┼─┼─╢ ", "║4│5│6║ ", "╚═╧═╧═╝ "); }
private static Grid CreateGrid() { return(new() { Stroke = LineThickness.Single, StrokeColor = ConsoleColor.Blue, Columns = { new Column { Width = GridLength.Star(1) }, new Column { Width = GridLength.Char(20) } } }); }
protected override async Task <int> OnExecuteAuthenticatedAsync(QBittorrentClient client, CommandLineApplication app, IConsole console) { var root = await client.GetRssItemsAsync(false); var doc = new Document(RenderItem(root, true, true)).SetColors(ColorScheme.Current.Normal); ConsoleRenderer.RenderDocument(doc); return(ExitCodes.Success); Stack RenderFolderContent(RssFolder folder) { return(new Stack(folder.Items.Select( (item, index) => RenderItem(item, index == folder.Items.Count - 1)))); } object RenderFeed(RssFeed feed) { return(new Div( feed.Name, " ", new Span($"[{feed.Url}]").SetColors(ColorScheme.Current.Inactive))); } Grid RenderItem(RssItem item, bool last, bool isRoot = false) { var folder = item as RssFolder; return(new Grid { Columns = { new Column { Width = GridLength.Char(2) }, new Column { Width = GridLength.Star(1) } },
public void RenderCustomBorders() { var headerThickness = new LineThickness(LineWidth.Single, LineWidth.Double); var grid = new Grid { Stroke = new LineThickness(LineWidth.None), Columns = { GridLength.Char(1), GridLength.Char(1), GridLength.Char(1) }, Children = { new Cell { Stroke = headerThickness, Children ={ 1 } }, new Cell { Stroke = headerThickness, Children ={ 2 } }, new Cell { Stroke = headerThickness, Children ={ 3 } }, new Cell { Children ={ 4 } }, new Cell { Children ={ 5 } }, new Cell { Children ={ 6 } }, } }; GetRenderedText(grid, 8).Should().BeLines( "╒═╤═╤═╕ ", "│1│2│3│ ", "╞═╪═╪═╡ ", "│4│5│6│ ", "└─┴─┴─┘ "); }
public async Task Execute(KustoFunctionsState functionsState) { try { List <KustoTableDetail> tableDetails = new List <KustoTableDetail>(); var databasesQuery = await functionsState.GetDataAdminReader(functionsState._options.DatabaseName, ".show tables details"); var allTables = databasesQuery.FromDataReader(functionsState._options.DatabaseName); foreach (DataRow row in allTables.Tables[0].Rows) { tableDetails.Add(new KustoTableDetail(row)); } var headerThickness = new LineThickness(LineWidth.Single, LineWidth.Single); var doc = new Document( new Grid { Color = Gray, Columns = { GridLength.Auto, GridLength.Char(20), GridLength.Char(20), GridLength.Auto }, Children = { new Cell("Name") { Stroke = headerThickness }, new Cell("Row Count") { Stroke = headerThickness }, new Cell("Cache Size (GB)") { Stroke = headerThickness }, new Cell("Users/Groups") { Stroke = headerThickness }, tableDetails.Select(item => { var kustoAuthorised = JsonConvert.DeserializeObject <List <KustoAuthorisedPrincipals> >(item.AuthorizedPrincipals); var kaWithType = kustoAuthorised.Select(item => item.DisplayName + $" [{item.Type}]"); string principals = String.Join('\n', kaWithType); double extentSize = item.TotalExtentSize / 1000000000; return(new[] { new Cell(item.TableName) { Color = Yellow }, new Cell(item.TotalRowCount), new Cell(extentSize.ToString("##,##0.00000000", CultureInfo.InvariantCulture)) { Align = Align.Right }, new Cell(principals) { Color = Yellow }, }); }) } } ); ConsoleRenderer.RenderDocument(doc); } catch (Exception ex) { Console.WriteLine(ex); } }
public static GridLength Char(this int @this) => GridLength.Char(@this);
public async Task Execute(KustoFunctionsState functionsState) { try { var databasesQuery = await functionsState.GetDataAdminReader(functionsState._options.DatabaseName, $".add table {functionsState._options.TableName} admins('aaduser={functionsState._options.UserName}')", true); var allTables = databasesQuery.FromDataReader(functionsState._options.DatabaseName); var principals = (from DataRow row in allTables.Tables[0].Rows select new KustoPrincipal(row)).ToList(); var headerThickness = new LineThickness(LineWidth.Single, LineWidth.Single); var doc = new Document( new Grid { Color = Gray, Columns = { GridLength.Auto, GridLength.Char(20), GridLength.Char(20), GridLength.Auto }, Children = { new Cell("Role") { Stroke = headerThickness }, new Cell("Principal Type") { Stroke = headerThickness }, new Cell("Display Name") { Stroke = headerThickness }, new Cell("PrincipalFQN") { Stroke = headerThickness }, principals.Select(item => { return(new[] { new Cell(item.Role) { Color = Yellow }, new Cell(item.PrincipalType), new Cell(item.PrincipalDisplayName), new Cell(item.PrincipalFQN) { Color = Yellow }, }); }) } } ); ConsoleRenderer.RenderDocument(doc); } catch (Exception ex) { Console.WriteLine(ex); } }
public void ConvertFromNumber() { _converter.ConvertFrom(2).Should().Be(GridLength.Char(2)); _converter.ConvertFrom(2m).Should().Be(GridLength.Char(2)); _converter.ConvertFrom(2L).Should().Be(GridLength.Char(2)); }
public void Render() { System.Console.ResetColor(); var size = _cube.Size * Block.Length; var grid = new Grid { Stroke = LineThickness.None , Columns = { GridLength.Char(size) , GridLength.Char(size) , GridLength.Char(size) } , Align = Align.Center }; var document = new Document(grid); var paddingPlaceholders = new Cell[3]; foreach (var cubeFace in _cube.Faces) { var padding = GetPaddingCrossStyleByCubeFace(cubeFace); if (ShouldBreakCrossStyle(cubeFace)) { paddingPlaceholders = new[] { new Cell(), new Cell(), new Cell() } } ; for (var x = 0; x < cubeFace.Size; x++) { for (var y = 0; y < cubeFace.Size; y++) { var currentSlot = cubeFace.Slots[x, y]; paddingPlaceholders[padding] .Children.Add( new Span(Block) { Color = ToConsoleColor(currentSlot.Color) } ); } } if (!ShouldBreakCrossStyle(cubeFace)) { continue; } foreach (var placeholder in paddingPlaceholders) { grid.Children.Add(placeholder); } } ConsoleRenderer.RenderDocument(document); System.Console.ResetColor(); }