Tree
ConsoleMonster.Widgets
A hierarchy with guide lines (├──, └──, │ on Full/Basic; |-- on Ascii). Guides use the border colour so the labels carry the attention. Long labels are truncated with an ellipsis.
Inheritance
- object
- Tree
Usage
Explore 62 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 31
- Method Ui.Tree
- Method ConsoleView.BuildTree
- Method InspectorTree.Build
- Extension method Tree.CollapsedSummaryBy
- Extension method Tree.CompactGuides
- Extension method Tree.DetectRepeatedNodes
- Extension method Tree.Presentation
- Extension method Tree.Root
- Extension method Tree.ShowRoot
- Extension method Tree.ShowValueHeaders
- Extension method Tree.Title
- Extension method Tree.TruncateLabelsInMiddle
- Extension method Tree.TruncateNotesInMiddle
- Extension method Tree.ValueColumn
- Extension method Tree.ValueColumns
- Extension method Tree.ValuePlacement
- Extension method Tree.WrapLabels
- Method TreeFluent.CollapsedSummaryBy
- Method TreeFluent.CompactGuides
- Method TreeFluent.DetectRepeatedNodes
- Method TreeFluent.Presentation
- Method TreeFluent.Root
- Method TreeFluent.ShowRoot
- Method TreeFluent.ShowValueHeaders
- Method TreeFluent.Title
- Method TreeFluent.TruncateLabelsInMiddle
- Method TreeFluent.TruncateNotesInMiddle
- Method TreeFluent.ValueColumn
- Method TreeFluent.ValueColumns
- Method TreeFluent.ValuePlacement
- Method TreeFluent.WrapLabels
Accepted by parameters 31
- Method ContentBuilder.Tree
- Method ContentBuilder.Tree
- Method Ui.Tree
- Extension method Tree.CollapsedSummaryBy
- Extension method Tree.CompactGuides
- Extension method Tree.DetectRepeatedNodes
- Extension method Tree.Presentation
- Extension method Tree.Root
- Extension method Tree.ShowRoot
- Extension method Tree.ShowValueHeaders
- Extension method Tree.Title
- Extension method Tree.TruncateLabelsInMiddle
- Extension method Tree.TruncateNotesInMiddle
- Extension method Tree.ValueColumn
- Extension method Tree.ValueColumns
- Extension method Tree.ValuePlacement
- Extension method Tree.WrapLabels
- Method TreeFluent.CollapsedSummaryBy
- Method TreeFluent.CompactGuides
- Method TreeFluent.DetectRepeatedNodes
- Method TreeFluent.Presentation
- Method TreeFluent.Root
- Method TreeFluent.ShowRoot
- Method TreeFluent.ShowValueHeaders
- Method TreeFluent.Title
- Method TreeFluent.TruncateLabelsInMiddle
- Method TreeFluent.TruncateNotesInMiddle
- Method TreeFluent.ValueColumn
- Method TreeFluent.ValueColumns
- Method TreeFluent.ValuePlacement
- Method TreeFluent.WrapLabels
Constructors
public Tree(string? title = null) #Creates a tree.
Parameters
- title string? = null
- The root label (markup), or null to show only the children as top-level nodes.
Methods
public TreeNode Add(string label, StatusKind? status = null, string? detail = null) #Adds a top-level node.
Parameters
- label string
- The label (markup).
- status ConsoleMonster.Styling.StatusKind? = null
- An optional status.
- detail string? = null
- An optional muted detail.
public TreeNode Add(RichText label, StatusKind? status = null, string? detail = null) #Adds a top-level node with a multicolour label.
Parameters
- label ConsoleMonster.Text.RichText
- The label.
- status ConsoleMonster.Styling.StatusKind? = null
- An optional status.
- detail string? = null
- An optional muted detail.
public Size Measure(Constraints constraints, RenderContext context) #Returns the size the widget wants within the constraints.
Parameters
- constraints ConsoleMonster.Layout.Constraints
- The space offered.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
public void Render(Region region, RenderContext context) #Renders into a region. The region may be smaller or larger than the measured size.
Parameters
- region ConsoleMonster.Canvas.Region
- The target region.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
Inherited Methods
Properties
public IList<TableColumn> ValueColumns { get; } #Aligned value columns, keyed by TableColumn.Id in TreeNode.Values. Default alignment is right. Wide layouts reserve at least 40% for labels and shrink value columns before dropping them. Below 120 cells fitting detail precedes value notes. Lower priorities drop first; labels always receive space first. With columns the tree uses single-line labels, regardless of Tree.WrapLabels.
public bool ShowValueHeaders { get; set; } #Show headings above aligned value columns (default true).
public string? Title { get; set; } #The root title (markup); null hides the root while preserving its children.
public bool CompactGuides { get; set; } #Use three-cell guides rather than the original four-cell guides.
public TreeValuePlacement ValuePlacement { get; set; } #Where value columns begin. Default views use AfterLabel.
public bool WrapLabels { get; set; } #Wrap labels, values and notes with a hanging indent instead of shortening them (default false).
public bool TruncateLabelsInMiddle { get; set; } #Use a middle ellipsis for shortened identity labels, preserving both ends (default false).
public bool TruncateNotesInMiddle { get; set; } #Use the rendering context's middle ellipsis for shortened notes and value notes, preserving both ends (default false). Labels keep priority; wrapped notes continue to wrap.
public bool DetectRepeatedNodes { get; set; } #Mark identities seen on earlier branches as shown above instead of expanding them again.
public Func<TreeNode, string>? CollapsedSummary { get; set; } #Fluent("CollapsedSummaryBy")Produces a plain text aggregate for explicitly collapsed nodes; never enumerates descendants itself.
public PresentationOptions Presentation { get; set; } #Culture, clock and time zone for node values.
Extension Methods
public static Tree CollapsedSummaryBy(Tree tree, Func<TreeNode, string>? value) #Sets Tree.CollapsedSummary: Produces a plain text aggregate for explicitly collapsed nodes; never enumerates descendants itself.
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- value System.Func<ConsoleMonster.Widgets.TreeNode, string>?
- The callback.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.Tree { CollapsedSummary = value }; Ui.Tree().CollapsedSummaryBy(value);public static Tree CompactGuides(Tree tree, bool value = true) #Sets Tree.CompactGuides: Use three-cell guides rather than the original four-cell guides.
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.Tree { CompactGuides = value }; Ui.Tree().CompactGuides(value);public static Tree DetectRepeatedNodes(Tree tree, bool value = true) #Sets Tree.DetectRepeatedNodes: Mark identities seen on earlier branches as shown above instead of expanding them again.
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.Tree { DetectRepeatedNodes = value }; Ui.Tree().DetectRepeatedNodes(value);public static Tree Presentation(Tree tree, PresentationOptions value) #Sets Tree.Presentation: Culture, clock and time zone for node values.
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- value ConsoleMonster.Presenters.PresentationOptions
- The value.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.Tree { Presentation = value }; Ui.Tree().Presentation(value);public static Tree Presentation(Tree tree, Action<PresentationOptions> configure) #Configures Tree.Presentation in place (creating it when not set): Culture, clock and time zone for node values.
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- configure System.Action<ConsoleMonster.Presenters.PresentationOptions>
- Configures the value.
public static Tree Root(Tree tree, Action<TreeNode> configure) #Configures Tree.Root in place: The root node.
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- configure System.Action<ConsoleMonster.Widgets.TreeNode>
- Configures the value.
public static Tree ShowRoot(Tree tree, bool value = true) #Sets Tree.ShowRoot: Whether the root label is shown.
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.Tree { ShowRoot = value }; Ui.Tree().ShowRoot(value);public static Tree ShowValueHeaders(Tree tree, bool value = true) #Sets Tree.ShowValueHeaders: Show headings above aligned value columns (default true).
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.Tree { ShowValueHeaders = value }; Ui.Tree().ShowValueHeaders(value);public static Tree Title(Tree tree, string? value) #Sets Tree.Title: The root title (markup); null hides the root while preserving its children.
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- value string?
- The value.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.Tree { Title = value }; Ui.Tree().Title(value);public static Tree TruncateLabelsInMiddle(Tree tree, bool value = true) #Sets Tree.TruncateLabelsInMiddle: Use a middle ellipsis for shortened identity labels, preserving both ends (default false).
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.Tree { TruncateLabelsInMiddle = value }; Ui.Tree().TruncateLabelsInMiddle(value);public static Tree TruncateNotesInMiddle(Tree tree, bool value = true) #Sets Tree.TruncateNotesInMiddle: Use the rendering context's middle ellipsis for shortened notes and value notes, preserving both ends (default false). Labels keep priority; wrapped notes continue to wrap.
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.Tree { TruncateNotesInMiddle = value }; Ui.Tree().TruncateNotesInMiddle(value);public static Tree ValueColumn(Tree tree, TableColumn item) #Adds an item to Tree.ValueColumns: Aligned value columns, keyed by TableColumn.Id in TreeNode.Values. Default alignment is right. Wide layouts reserve at least 40% for labels and shrink value columns before dropping them. Below 120 cells fitting detail precedes value notes. Lower priorities drop first; labels always receive space first. With columns the tree uses single-line labels, regardless of Tree.WrapLabels.
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- item ConsoleMonster.Widgets.TableColumn
- The item.
public static Tree ValueColumns(Tree tree, IEnumerable<TableColumn> items) #Adds items to Tree.ValueColumns: Aligned value columns, keyed by TableColumn.Id in TreeNode.Values. Default alignment is right. Wide layouts reserve at least 40% for labels and shrink value columns before dropping them. Below 120 cells fitting detail precedes value notes. Lower priorities drop first; labels always receive space first. With columns the tree uses single-line labels, regardless of Tree.WrapLabels.
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- items System.Collections.Generic.IEnumerable<ConsoleMonster.Widgets.TableColumn>
- The items, in order.
public static Tree ValuePlacement(Tree tree, TreeValuePlacement value) #Sets Tree.ValuePlacement: Where value columns begin. Default views use AfterLabel.
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- value ConsoleMonster.Widgets.TreeValuePlacement
- The value.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.Tree { ValuePlacement = value }; Ui.Tree().ValuePlacement(value);public static Tree WrapLabels(Tree tree, bool value = true) #Sets Tree.WrapLabels: Wrap labels, values and notes with a hanging indent instead of shortening them (default false).
Parameters
- tree ConsoleMonster.Widgets.Tree
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.Tree { WrapLabels = value }; Ui.Tree().WrapLabels(value);