Skip to content

API Reference

This page provides an overview of the Elaris.UI API structure, namespaces, and common patterns.

Elaris.UI uses a clear namespace structure:

  • Ambystech.Elaris.UI - Core application and main types
  • Ambystech.Elaris.UI.Widgets - Base widget class
  • Ambystech.Elaris.UI.Widgets.Layout - Layout widgets
  • Ambystech.Elaris.UI.Widgets.Display - Display widgets
  • Ambystech.Elaris.UI.Widgets.Input - Input widgets
  • Ambystech.Elaris.UI.Widgets.Data - Data widgets
  • Ambystech.Elaris.UI.Widgets.Menu - Menu widgets
  • Ambystech.Elaris.UI.Rendering - Rendering system
  • Ambystech.Elaris.UI.Input - Input handling
  • Ambystech.Elaris.UI.Core - Core utilities
  • Ambystech.Elaris.UI.Enums - Enumerations

The main application class that manages the event loop and rendering.

MethodDescription
Run(Widget rootWidget)Starts the application with the specified root widget
Stop()Stops the application
SetFocus(Widget widget)Sets the focused widget
PropertyTypeDescription
ScreenScreen?The current screen instance
TargetFpsintTarget frames per second (default: 30)
InitialFocusWidgetWidget?Widget to receive initial focus

The terminal screen abstraction with double-buffered rendering.

MethodDescription
Clear()Clears the back buffer
SetCell(int x, int y, Cell cell)Sets a cell in the back buffer
WriteText(int x, int y, string text, ...)Writes text to the back buffer
FillRectangle(Rectangle rect, ...)Fills a rectangle
DrawRectangle(Rectangle rect, ...)Draws a rectangle border
Render()Renders the back buffer to console
Resize(int width, int height)Resizes the screen buffer

The abstract base class for all UI widgets.

MethodDescription
Add(Widget child)Adds a child widget
Remove(Widget child)Removes a child widget
Clear()Removes all children
Render(Screen screen)Renders the widget
PropertyTypeDescription
BoundsRectangleWidget bounds
X, Y, Width, HeightintPosition and size
VisibleboolVisibility
EnabledboolEnabled state
ForegroundColorColorText color
BackgroundColorColorBackground color
ZIndexintRendering order
ParentWidget?Parent widget
ChildrenIReadOnlyList<Widget>Child widgets
IsFocusableboolCan receive focus
HasFocusboolCurrently has focus
var app = new Application();
var rootWidget = new Frame("My App");
app.Run(rootWidget);
var container = new Container();
var label = new Label("Hello");
container.Add(label);
button.Click += () =>
{
Console.WriteLine("Clicked!");
};
// Using ColorHelper
var color = ColorHelper.FromRgb(100, 200, 255);
var hexColor = ColorHelper.FromHex("#64C8FF");
// Using System.Drawing.Color
var white = Color.White;
var transparent = Color.Transparent;
  • Absolute - Children maintain manual positions
  • Vertical - Children stacked vertically
  • Horizontal - Children arranged horizontally
  • Fill - Children fill container
  • None - No border
  • Single - Single-line border
  • Double - Double-line border
  • Rounded - Rounded corners
  • Standard - Standard button
  • Rounded - Rounded corners
  • Outline - Outlined button
  • Gradient - Gradient background
  • Left - Left aligned
  • Center - Center aligned
  • Right - Right aligned
  • Top - Top aligned
  • Middle - Middle aligned
  • Bottom - Bottom aligned

Static utility class for color operations.

MethodDescription
FromRgb(byte r, byte g, byte b)Creates color from RGB
FromRgba(byte r, byte g, byte b, byte a)Creates color from RGBA
FromHex(string hex)Creates color from hex string
TryFromHex(string hex, Color fallback)Tries to parse hex color
Lerp(Color start, Color end, float t)Linear interpolation

Elaris.UI includes comprehensive XML documentation comments. When viewing the code in an IDE, you’ll see detailed documentation for all public members.