Hello World Example
The Hello World example demonstrates the most basic usage of Elaris.UI - creating an application, adding widgets, and running it.
What It Demonstrates
Section titled “What It Demonstrates”- Creating an
Applicationinstance - Creating a
Framewidget with borders - Adding
Labelwidgets - Running the application
- Basic color usage
using System.Drawing;using Ambystech.Elaris.UI;using Ambystech.Elaris.UI.Core;using Ambystech.Elaris.UI.Enums;using Ambystech.Elaris.UI.Widgets.Display;using Ambystech.Elaris.UI.Widgets.Layout;
var app = new Application();
var mainFrame = new Frame("Hello Elaris!"){ BorderStyle = BorderStyle.Rounded, ForegroundColor = ColorHelper.FromRgb(100, 200, 255),};
var label = new Label("Welcome to Elaris CLI UI Library!"){ X = 2, Y = 2, Width = 50, Height = 1, ForegroundColor = ColorHelper.FromRgb(255, 200, 100), Bold = true};
var infoLabel = new Label("Press ESC or Ctrl+C to exit"){ X = 2, Y = 4, Width = 50, Height = 1, ForegroundColor = Color.Gray};
mainFrame.Add(label);mainFrame.Add(infoLabel);
app.Run(mainFrame);Key Features
Section titled “Key Features”- Application Creation:
new Application()creates the main application instance - Frame Widget: Creates a bordered container with a title
- Label Widgets: Display text with colors and styling
- Widget Hierarchy: Adding widgets to the frame using
Add() - Running:
app.Run()starts the event loop
Running the Example
Section titled “Running the Example”cd examples/Elaris.Examples.HelloWorlddotnet runLearning Points
Section titled “Learning Points”- Every Elaris.UI application needs an
Applicationinstance - Widgets are added to containers using
Add() - Colors can be created using
ColorHelper.FromRgb() - The application runs until ESC or Ctrl+C is pressed
Next Steps
Section titled “Next Steps”- Installation - Learn how to install Elaris.UI
- Base Widget - Understand the widget system
- Frame - Learn about frames
- Label - Learn about labels