GridContext class Core

One grid's texts, icons, sort culture and module catalogues; GridContext.Default serves every grid without its own context and the static facades outside a grid's scope.

public sealed class GridContext
Namespace
ArionUI.Presentation
Package
ArionUI.Presentation · dotnet add package ArionUI.Presentation --prerelease

Remarks

GridContext.Current is a per-thread ambient like ArionTheme.Current: a grid stamps its context around every render, input and accessibility pass with GridContext.Use, so template code keeps reading the static facades. A scope is a ref struct and cannot span an await.

Constructors

GridContext

public GridContext();

Properties

ButtonPainter

public Action<IRenderSurface, LogRect, string, ButtonVisual, bool, bool> ButtonPainter { get; set; }

Draws every button of the grid (surface, rect, label, visual, hot, pressed); the keyboard focus ring is drawn over it regardless.

Catalog

public ITextCatalog? Catalog { get; set; }

Where a LocalText made from a key finds its text; null means the catalog of the grid around it, outside every grid that of GridContext.Default, and without one the key itself. Set on a grid that shows, its texts are resolved anew.

Culture

public CultureInfo? Culture { get; set; }

The culture the grid formats and parses numbers and dates with — cell text, editors, filters, calendar, chart axes — and the language a LocalText shows in; null means the culture of the grid around it (a tile on a board formats as its board does), outside every grid the thread's current culture. Stamped as FormatCulture.Current with every scope of this context, so two grids in one process can format in two languages. Set on a grid that shows, its texts are resolved anew and laid out again (GridContext.TextsChanged).

Current

public static GridContext Current { get; }

The context of the grid currently rendering, hit-testing or announcing on this thread; GridContext.Default when no grid has stamped one.

CurrentCatalog

public static ITextCatalog CurrentCatalog { get; }

The catalog a LocalText resolves through on this thread: that of the innermost context in scope that has one, else that of GridContext.Default, else none.

Default

public static GridContext Default { get; }

The process-wide context: every grid without its own, and the static facades outside a grid's scope.

Icons

public ArionIcons Icons { get; set; }

The grid's chrome icons.

PanePainter

public Action<IRenderSurface, LogRect, double> PanePainter { get; set; }

Draws every pane card of the grid (surface, bounds, corner radius).

SortCulture

public CultureInfo? SortCulture { get; init; }

The culture text is sorted, grouped and listed by; null means the process-wide SortFilterSource.SortCulture. Fixed at construction because a grid applies it when the context is assigned.

Texts

public ArionTexts Texts { get; set; }

The grid's user-visible strings.

Methods

Get

public T Get<T>() where T : class, new();

The catalogue of a module (a Pro module's texts, for example), created on first access. Modules keep their static facades and resolve through here. A text catalogue (IArionTextCatalogue) created after GridContext.UseGerman starts in German.

RefreshTexts

public void RefreshTexts();

The catalog's texts changed (one that asks the business logic): what it said is forgotten and every grid of this context resolves and lays out its texts anew.

Set

public void Set<T>(T value) where T : class;

Replaces a module catalogue wholesale.

Use

public void Use(CultureInfo culture);

EVERY text of this context in the language of culture: German for a German culture, English for every other.

Use

public static GridContext.ContextScope Use(GridContext context);

Makes context the ambient one for the current synchronous operation; a catalog it does not set comes from the scope around it. Nested scopes restore their caller's context, also when the operation throws.

UseEnglish

public void UseEnglish();

EVERY text of this context in English (the shipped default) -- the mirror of GridContext.UseGerman.

UseGerman

public void UseGerman();

EVERY text of this context in German: GridContext.Texts and each module catalogue that implements IArionTextCatalogue -- the ones already created and the ones created later. English is the shipped default.

Events

TextsChanged

public event Action? TextsChanged;

The texts of this context changed - its culture, its catalog, its language: a grid that shows it lays its texts out anew.

Remarks

Raised on the thread that changed the context. A grid hands it to its own UI thread and lays out once for several changes in a row (a culture and a language set together); a hidden grid catches up when it is shown (GridContext.TextsVersion).

Nested types

GridContext.ContextScope struct