Xui.Core.Abstract
Assembly: Xui.Core · C# declarations · Assembly overview
Types
class Applicationclass FixedClockclass HotReloadinterface IClockinterface IContentinterface IMacOSWindowStyleinterface IRandominterface IWindowinterface IWindow.IDesktopStyleenum IWindow.IDesktopStyle.DesktopWindowLevelenum IWindow.IDesktopStyle.WindowBackdropenum IWindow.IDesktopStyle.WindowClientAreainterface IWindow.ISoftKeyboardenum MacOSWindowBackgroundenum MacOSWindowTitleenum MacOSWindowTitleHeightclass SeededRandomclass SystemClockclass SystemRandomclass Window
class Application
Represents an abstract base class for Xui applications. This class is paired at runtime with a platform-specific counterpart, which delegates to actual system APIs on macOS, Windows, Android, etc. Users should subclass Xui.Core.Abstract.Application, override the Xui.Core.Abstract.Application.Start method, and call Xui.Core.Abstract.Application.Run to launch the application.
public abstract class Application : IServiceProvider
{
public IServiceProvider Context { get; }
public virtual object? GetService(Type serviceType);
public IRuntime Runtime { get; }
public List<IDisposable> DisposeQueue { get; }
public Application(IServiceProvider context);
public virtual int Run();
public virtual void Quit();
public abstract void Start();
public event Action? Exit;
public virtual void OnExit();
}
Application.Application(IServiceProvider context)
public Application(IServiceProvider context);
Initializes a new instance of the Xui.Core.Abstract.Application class.
IServiceProvider Application.Context
public IServiceProvider Context { get; }
The service provider for this application.
List<IDisposable> Application.DisposeQueue
public List<IDisposable> DisposeQueue { get; }
A list of disposables that are disposed when the application exits.
event Action? Application.Exit
public event Action? Exit;
Raised when the application exits on platforms with a definite exit point. See Xui.Core.Abstract.Application.OnExit for the same constraint on when this fires.
object? Application.GetService(Type serviceType)
public virtual object? GetService(Type serviceType);
Gets the service object of the specified type.
serviceType— An object that specifies the type of service object to get.
Returns: A service object of type serviceType. -or- null if there is no service object of type serviceType.
void Application.OnExit()
public virtual void OnExit();
Called by run loops that have a definite exit point (e.g. Win32, macOS) just before their Xui.Core.Actual.IRunLoop.Run returns. Not called on platforms whose run loop never exits (iOS, Browser canvas), so do not rely on this for cleanup that must always run.
void Application.Quit()
public virtual void Quit();
Requests graceful shutdown of the application's run loop. On platforms without a blocking run loop (iOS, Browser) this is a no-op.
int Application.Run()
public virtual int Run();
Starts the main application loop by delegating to the platform-specific run loop. This method may block until the application exits, or may return immediately if the platform bootstraps a runtime loop before instantiating the app delegate.
Returns: The application’s exit code.
IRuntime Application.Runtime
public IRuntime Runtime { get; }
The platform runtime used by this application.
void Application.Start()
public abstract void Start();
Called by the runtime after initialization. Override this method to set up application state and display the initial UI.
class FixedClock
Mutable clock implementation used for deterministic scenarios such as tests.
public sealed class FixedClock : IClock
{
public FixedClock(DateTime now);
public DateTime Now { get; }
public void Set(DateTime now);
public void Advance(TimeSpan delta);
}
FixedClock.FixedClock(DateTime now)
public FixedClock(DateTime now);
Initializes a new fixed clock with an initial time value.
now— The initial local time.
void FixedClock.Advance(TimeSpan delta)
public void Advance(TimeSpan delta);
Advances the current fixed time by a delta.
delta— The time delta to add.
DateTime FixedClock.Now
public DateTime Now { get; }
Gets the current fixed local time.
void FixedClock.Set(DateTime now)
public void Set(DateTime now);
Sets the current fixed time.
now— The new local time.
class HotReload
Internal integration point for .NET's MetadataUpdateHandler, enabling partial support for Hot Reload during development. This is not a stable API and should not be used by application developers.
This type is invoked automatically by the runtime when types are updated via Edit and Continue or Hot Reload. However, Hot Reload support in Xui is limited, and application developers should rely on full rebuilds for consistent behavior. The current implementation simply invalidates open windows and clears transient caches, without attempting to rehydrate or diff application state.
public static class HotReload
{
public static event Action? OnReload;
public static void ClearCache(Type[]? updatedTypes);
public static void UpdateApplication(Type[]? updatedTypes);
public static void MainThreadUpdateApplication(Type[]? updatedTypes);
}
void HotReload.ClearCache(Type[]? updatedTypes)
public static void ClearCache(Type[]? updatedTypes);
Called by the runtime to clear any cached data after a hot reload. Not intended for use by application developers.
updatedTypes— The list of updated types, if available.
void HotReload.MainThreadUpdateApplication(Type[]? updatedTypes)
public static void MainThreadUpdateApplication(Type[]? updatedTypes);
Performs a synchronous application update on the main thread. Invokes the Xui.Core.Abstract.HotReload.OnReload event so subscribers (windows) can invalidate.
updatedTypes— The list of updated types, if available.
event Action? HotReload.OnReload
public static event Action? OnReload;
Raised on the UI thread when a hot reload occurs. Windows subscribe to this event to invalidate themselves.
void HotReload.UpdateApplication(Type[]? updatedTypes)
public static void UpdateApplication(Type[]? updatedTypes);
Posts a request to the main UI dispatcher to refresh application state.
updatedTypes— The list of updated types, if available.
interface IClock
Provides access to the current clock time.
public interface IClock
{
DateTime Now { get; }
}
DateTime IClock.Now
DateTime Now { get; }
Gets the current local time.
interface IContent
Defines the contract for UI content that participates in layout, rendering, and input dispatch.
public partial interface IContent
{
void Invalidate();
void OnMouseDown(ref MouseDownEventRef e);
void OnMouseMove(ref MouseMoveEventRef e);
void OnMouseUp(ref MouseUpEventRef e);
void OnScrollWheel(ref ScrollWheelEventRef e);
void OnZoom(ref ZoomEventRef e);
void OnTouch(ref TouchEventRef e);
void OnAnimationFrame(ref FrameEventRef e);
void Update(ref RenderEventRef @event);
void OnKeyDown(ref KeyEventRef e);
void OnChar(ref KeyEventRef e);
}
void IContent.Invalidate()
void Invalidate();
Requests a visual redraw of this content.
void IContent.OnAnimationFrame(ref FrameEventRef e)
void OnAnimationFrame(ref FrameEventRef e);
Invoked on each animation frame tick.
void IContent.OnChar(ref KeyEventRef e)
void OnChar(ref KeyEventRef e);
Invoked when a character is typed.
void IContent.OnKeyDown(ref KeyEventRef e)
void OnKeyDown(ref KeyEventRef e);
Invoked when a keyboard key is pressed.
void IContent.OnMouseDown(ref MouseDownEventRef e)
void OnMouseDown(ref MouseDownEventRef e);
Invoked when a mouse button is pressed within this content's area.
void IContent.OnMouseMove(ref MouseMoveEventRef e)
void OnMouseMove(ref MouseMoveEventRef e);
Invoked when the mouse pointer moves within this content's area.
void IContent.OnMouseUp(ref MouseUpEventRef e)
void OnMouseUp(ref MouseUpEventRef e);
Invoked when a mouse button is released.
void IContent.OnScrollWheel(ref ScrollWheelEventRef e)
void OnScrollWheel(ref ScrollWheelEventRef e);
Invoked when the scroll wheel is used over this content.
void IContent.OnTouch(ref TouchEventRef e)
void OnTouch(ref TouchEventRef e);
Invoked when a touch event occurs.
void IContent.OnZoom(ref ZoomEventRef e)
void OnZoom(ref ZoomEventRef e);
Invoked when a platform magnification gesture occurs over this content.
void IContent.Update(ref RenderEventRef @event)
void Update(ref RenderEventRef @event);
Performs layout and renders this content into Xui.Core.Abstract.Events.RenderEventRef.Context.
interface IMacOSWindowStyle
Describes the macOS-specific chrome treatment for a desktop window. Implementing this interface is safe on every target; non-macOS runtimes ignore it.
public interface IMacOSWindowStyle
{
public MacOSWindowTitle Title { get; }
public MacOSWindowTitleHeight TitleHeight { get; }
public MacOSWindowBackground Background { get; }
}
MacOSWindowBackground IMacOSWindowStyle.Background
public MacOSWindowBackground Background { get; }
Selects the window background treatment.
MacOSWindowTitle IMacOSWindowStyle.Title
public MacOSWindowTitle Title { get; }
Controls whether AppKit displays the native window title.
MacOSWindowTitleHeight IMacOSWindowStyle.TitleHeight
public MacOSWindowTitleHeight TitleHeight { get; }
Selects the native title and toolbar height.
interface IRandom
Provides random value generation.
public interface IRandom
{
int Next(int minValue, int maxValue);
double NextDouble();
}
int IRandom.Next(int minValue, int maxValue)
int Next(int minValue, int maxValue);
Returns a random integer within the specified range.
minValue— Inclusive lower bound of the random number.maxValue— Exclusive upper bound of the random number.
Returns: A random integer in the specified range.
double IRandom.NextDouble()
double NextDouble();
Returns a random floating-point number in the range [0.0, 1.0).
Returns: A random floating-point number.
interface IWindow
Defines the abstract interface for a platform window in Xui. This surface hosts rendering, input handling, and layout updates.
Implementations of this interface bridge platform-specific Actual windowing with the framework’s abstract layer. It is used both for physical windows (e.g. desktop apps) and virtual windows (e.g. emulator windows).
public partial interface IWindow
{
public partial interface IDesktopStyle
{
public enum WindowBackdrop
{
Default = 0,
Chromeless = 1,
Mica = 2,
Acrylic = 3,
}
}
}
public partial interface IWindow
{
public partial interface IDesktopStyle
{
public enum WindowClientArea
{
Default,
Extended,
}
}
}
public partial interface IWindow
{
public partial interface IDesktopStyle
{
public enum DesktopWindowLevel : int
{
Normal = 0,
Floating = 100,
StatusBar = 200,
Modal = 300,
}
}
}
public partial interface IWindow
{
public partial interface IDesktopStyle
{
public WindowBackdrop Backdrop { get; }
public Size? StartupSize { get; }
public DesktopWindowLevel Level { get; }
public bool MacOSDoubleTapSoftwareMaximize { get; }
public WindowClientArea ClientArea { get; }
}
}
public partial interface IWindow
{
public interface ISoftKeyboard
{
bool HasText { get; }
bool IsSecureTextEntry { get; }
public void InsertText(ref InsertTextEventRef eventRef);
public void DeleteBackwards(ref DeleteBackwardsEventRef eventRef);
}
}
public partial interface IWindow
{
Actual.IWindow? Actual { get; }
public Rect DisplayArea { get; set; }
public Rect SafeArea { get; set; }
public nfloat ScreenCornerRadius { get; set; }
void Closed();
bool Closing();
void OnAnimationFrame(ref FrameEventRef animationFrame);
void OnMouseMove(ref MouseMoveEventRef evRef);
void OnMouseDown(ref MouseDownEventRef evRef);
void OnMouseUp(ref MouseUpEventRef evRef);
void OnScrollWheel(ref ScrollWheelEventRef evRef);
void OnZoom(ref ZoomEventRef evRef);
void OnTouch(ref TouchEventRef touchEventRef);
void Render(ref RenderEventRef render);
void WindowHitTest(ref WindowHitTestEventRef evRef);
void OnKeyDown(ref KeyEventRef e);
void OnChar(ref KeyEventRef e);
}
IWindow? IWindow.Actual
Actual.IWindow? Actual { get; }
Gets the actual window immediately downstream of this abstract window. Together with Xui.Core.Actual.IWindow.Abstract, this forms the bidirectional composed-window chain.
void IWindow.Closed()
void Closed();
Invoked when the window is closed and cleanup should occur.
bool IWindow.Closing()
bool Closing();
Invoked before the window closes. Returning false can cancel the closure.
Returns: true if the window may close; otherwise, false.
Rect IWindow.DisplayArea
public Rect DisplayArea { get; set; }
Gets or sets the total visible area of the window, including content that may be obscured by hardware cutouts, rounded corners, or system UI overlays.
Used by the layout system to determine the full available size.
void IWindow.OnAnimationFrame(ref FrameEventRef animationFrame)
void OnAnimationFrame(ref FrameEventRef animationFrame);
Invoked once per frame to propagate animation timing information.
animationFrame— Timing details for the current animation frame.
void IWindow.OnChar(ref KeyEventRef e)
void OnChar(ref KeyEventRef e);
Invoked when a character is input (after keyboard translation).
e— The keyboard event data with the translated character.
void IWindow.OnKeyDown(ref KeyEventRef e)
void OnKeyDown(ref KeyEventRef e);
Invoked when a key is pressed.
e— The keyboard event data.
void IWindow.OnMouseDown(ref MouseDownEventRef evRef)
void OnMouseDown(ref MouseDownEventRef evRef);
Invoked when a mouse button is pressed within the window.
evRef— The mouse down event data.
void IWindow.OnMouseMove(ref MouseMoveEventRef evRef)
void OnMouseMove(ref MouseMoveEventRef evRef);
Invoked when the mouse is moved within the window.
evRef— The mouse movement event data.
void IWindow.OnMouseUp(ref MouseUpEventRef evRef)
void OnMouseUp(ref MouseUpEventRef evRef);
Invoked when a mouse button is released within the window.
evRef— The mouse up event data.
void IWindow.OnScrollWheel(ref ScrollWheelEventRef evRef)
void OnScrollWheel(ref ScrollWheelEventRef evRef);
Invoked when the scroll wheel is used within the window.
evRef— The scroll wheel event data.
void IWindow.OnTouch(ref TouchEventRef touchEventRef)
void OnTouch(ref TouchEventRef touchEventRef);
Invoked when touch input occurs within the window.
touchEventRef— The touch event data.
void IWindow.OnZoom(ref ZoomEventRef evRef)
void OnZoom(ref ZoomEventRef evRef);
Invoked when a platform magnification gesture occurs within the window.
void IWindow.Render(ref RenderEventRef render)
void Render(ref RenderEventRef render);
Invoked during the render phase of the UI lifecycle. Responsible for triggering layout and visual updates.
render— The render event data, including target rect and frame info.
Rect IWindow.SafeArea
public Rect SafeArea { get; set; }
Gets or sets the "safe" area of the window, excluding obstructions like notches or status bars. Important UI elements should be placed within this area.
Especially relevant on mobile devices and in emulator scenarios.
NFloat IWindow.ScreenCornerRadius
public nfloat ScreenCornerRadius { get; set; }
Gets or sets the corner radius of the physical screen, in logical pixels. Used to offset UI elements (such as scrollbar indicators) away from rounded screen edges. Zero on desktop platforms where the window has sharp corners.
void IWindow.WindowHitTest(ref WindowHitTestEventRef evRef)
void WindowHitTest(ref WindowHitTestEventRef evRef);
Invoked when the system requests a hit test for window interaction. Allows the app to indicate whether a region is draggable, resizable, etc.
evRef— The hit test event containing pointer position and window bounds.
interface IWindow.IDesktopStyle
Provides optional desktop-specific window styling hints for platforms that support multiple top-level windows (e.g., Windows, macOS, Linux).
On mobile platforms, applications typically run in a single full-screen window, and this interface has no effect. On desktop, implementing this interface allows apps to influence window chrome, border visibility, and initial sizing.
public partial interface IDesktopStyle
{
public enum WindowBackdrop
{
Default = 0,
Chromeless = 1,
Mica = 2,
Acrylic = 3,
}
}
public partial interface IDesktopStyle
{
public enum WindowClientArea
{
Default,
Extended,
}
}
public partial interface IDesktopStyle
{
public enum DesktopWindowLevel : int
{
Normal = 0,
Floating = 100,
StatusBar = 200,
Modal = 300,
}
}
public partial interface IDesktopStyle
{
public WindowBackdrop Backdrop { get; }
public Size? StartupSize { get; }
public DesktopWindowLevel Level { get; }
public bool MacOSDoubleTapSoftwareMaximize { get; }
public WindowClientArea ClientArea { get; }
}
WindowBackdrop IDesktopStyle.Backdrop
public WindowBackdrop Backdrop { get; }
Controls the window backdrop and chrome style.
WindowClientArea IDesktopStyle.ClientArea
public WindowClientArea ClientArea { get; }
Controls whether the client area includes the title bar region.
Default: System-managed non-client area (title bar + borders behave normally).
Extended: Extends the client area into the title bar region so the app can draw its own title bar content/background while still allowing native window behaviors via hit testing.
Windows: Uses DwmExtendFrameIntoClientArea (and relies on WM_NCHITTEST returning HTCAPTION for draggable regions). This is the recommended way to hide title text/icon reliably, especially with Mica/Acrylic backdrops.
macOS: Uses full-size content view / transparent title bar with title visibility hidden.
DesktopWindowLevel IDesktopStyle.Level
public DesktopWindowLevel Level { get; }
Controls the window stacking level (Z-order) relative to other windows.
bool IDesktopStyle.MacOSDoubleTapSoftwareMaximize
public bool MacOSDoubleTapSoftwareMaximize { get; }
Enables AppKit zoom when Xui receives a double-click in a region that Xui.Core.Abstract.IWindow.WindowHitTest(Xui.Core.Abstract.Events.WindowHitTestEventRef@) reports as Title. Use this for extended client areas, where the native title bar is not handling the double-click itself. This setting applies only on macOS.
Size? IDesktopStyle.StartupSize
public Size? StartupSize { get; }
Optional startup size hint for the window. If null, the platform will decide the initial size.
enum IWindow.IDesktopStyle.DesktopWindowLevel
Cross-platform window stacking level (Z-order abstraction).
macOS: Maps to NSWindow.Level values such as .normal, .floating, .statusBar, and .modalPanel.
Windows: Maps primarily to Win32 Z-order using HWND_TOPMOST / HWND_NOTOPMOST. Higher levels may be approximated, as Windows exposes fewer public layering tiers than macOS.
public enum DesktopWindowLevel : int
{
Normal = 0,
Floating = 100,
StatusBar = 200,
Modal = 300,
}
DesktopWindowLevel.Floating
Floating = 100
Floating utility window above normal windows.
macOS: NSWindow.Level.floating.
Windows: implemented via HWND_TOPMOST.
DesktopWindowLevel.Modal
Modal = 300
Modal dialog level that blocks interaction with other app windows.
macOS: NSWindow.Level.modalPanel or sheets.
Windows: enforced via window ownership and modality, not a unique Z-order tier.
DesktopWindowLevel.Normal
Normal = 0
Standard application window.
macOS: NSWindow.Level.normal.
Windows: normal (non-topmost) window.
DesktopWindowLevel.StatusBar
StatusBar = 200
High-floating level for small status or utility UI.
macOS: NSWindow.Level.statusBar.
Windows: approximated as topmost, often with utility window styles.
enum IWindow.IDesktopStyle.WindowBackdrop
Controls the window backdrop and chrome style.
Windows: Default creates a standard WS_TILEDWINDOW. Chromeless uses WS_POPUP with no system chrome. Mica and Acrylic use DWM system backdrop APIs (Windows 11+) with system caption buttons but no icon or title text.
macOS: Chromeless maps to FullSizeContentView | Borderless with a transparent title bar and empty toolbar (traffic-light buttons remain, no chrome visible). Acrylic uses NSVisualEffectView with the same transparent-titlebar + empty-toolbar treatment. Mica falls back to this Acrylic treatment because macOS has no native Mica material.
public enum WindowBackdrop
{
Default = 0,
Chromeless = 1,
Mica = 2,
Acrylic = 3,
}
WindowBackdrop.Acrylic
Acrylic = 3
Blur-behind backdrop. On Windows 11 uses the Acrylic DWM material (more translucent than Mica). On macOS uses NSVisualEffectView with a transparent title bar and empty toolbar so traffic-light buttons are visible without any other chrome.
WindowBackdrop.Chromeless
Chromeless = 1
No system chrome. The entire surface is client area and the app draws everything.
WindowBackdrop.Default
Default = 0
Standard opaque window with full system chrome (title bar, icon, buttons).
WindowBackdrop.Mica
Mica = 2
Translucent blurred backdrop using the Windows 11 Mica material. System caption buttons are kept, but icon and title text are removed. On macOS this falls back to the same visual-effect treatment as Xui.Core.Abstract.IWindow.IDesktopStyle.WindowBackdrop.Acrylic, because macOS has no native Mica material.
enum IWindow.IDesktopStyle.WindowClientArea
Controls how much of the window area is available for application drawing.
public enum WindowClientArea
{
Default,
Extended,
}
WindowClientArea.Default
Default
System-managed non-client area (title bar + borders behave normally).
WindowClientArea.Extended
Extended
Extend the client area into the title bar region (app draws background/title area).
interface IWindow.ISoftKeyboard
Represents a handler for software keyboard input.
This interface allows focused views to receive input from the system's software keyboard, typically used on mobile platforms and the emulator. It handles character insertion and backward deletion commands. This is not meant to expose full IME or keyboard layout logic—just basic input dispatch.
public interface ISoftKeyboard
{
bool HasText { get; }
bool IsSecureTextEntry { get; }
public void InsertText(ref InsertTextEventRef eventRef);
public void DeleteBackwards(ref DeleteBackwardsEventRef eventRef);
}
void ISoftKeyboard.DeleteBackwards(ref DeleteBackwardsEventRef eventRef)
public void DeleteBackwards(ref DeleteBackwardsEventRef eventRef);
Requests deletion of content preceding the caret or selection.
eventRef— The input event representing a backspace action.
bool ISoftKeyboard.HasText
bool HasText { get; }
Whether the focused text client contains text.
void ISoftKeyboard.InsertText(ref InsertTextEventRef eventRef)
public void InsertText(ref InsertTextEventRef eventRef);
Requests insertion of one or more characters into the current input context.
eventRef— The input event containing the text to insert.
bool ISoftKeyboard.IsSecureTextEntry
bool IsSecureTextEntry { get; }
Whether the focused text client requires password entry.
enum MacOSWindowBackground
The native macOS window background treatment.
public enum MacOSWindowBackground
{
Default,
Acrylic,
Glass,
Transparent,
Borderless,
}
MacOSWindowBackground.Acrylic
Acrylic
The standard Acrylic background material.
MacOSWindowBackground.Borderless
Borderless
A transparent, application-drawn window surface intended for custom tools and widgets. The application provides its own drag and resize hit testing.
MacOSWindowBackground.Default
Default
The standard opaque AppKit window background.
MacOSWindowBackground.Glass
Glass
The dynamic macOS glass material. On macOS releases that do not provide it, this falls back to the Acrylic background material.
MacOSWindowBackground.Transparent
Transparent
A transparent borderless window background. The native title is hidden when this background is selected.
enum MacOSWindowTitle
The visibility of the native macOS window title.
public enum MacOSWindowTitle
{
Visible,
Hidden,
}
MacOSWindowTitle.Hidden
Hidden
The native title is hidden.
MacOSWindowTitle.Visible
Visible
The native title is visible.
enum MacOSWindowTitleHeight
The native macOS title and toolbar height.
public enum MacOSWindowTitleHeight
{
Default,
Medium,
Large,
}
MacOSWindowTitleHeight.Default
Default
The standard AppKit title-bar height.
MacOSWindowTitleHeight.Large
Large
The unified toolbar height.
MacOSWindowTitleHeight.Medium
Medium
The compact unified toolbar height.
class SeededRandom
Random implementation that uses a fixed seed for deterministic output.
public sealed class SeededRandom : IRandom
{
public SeededRandom(int seed);
public int Next(int minValue, int maxValue);
public double NextDouble();
}
SeededRandom.SeededRandom(int seed)
public SeededRandom(int seed);
Initializes a new seeded random instance.
seed— The deterministic seed value.
int SeededRandom.Next(int minValue, int maxValue)
public int Next(int minValue, int maxValue);
Returns a random integer within the specified range.
minValue— Inclusive lower bound of the random number.maxValue— Exclusive upper bound of the random number.
Returns: A random integer in the specified range.
double SeededRandom.NextDouble()
public double NextDouble();
Returns a random floating-point number in the range [0.0, 1.0).
Returns: A random floating-point number.
class SystemClock
Default clock implementation backed by System.DateTime.Now.
public sealed class SystemClock : IClock
{
public static SystemClock Default { get; }
public DateTime Now { get; }
}
SystemClock SystemClock.Default
public static SystemClock Default { get; }
Gets the shared default system clock instance.
DateTime SystemClock.Now
public DateTime Now { get; }
Gets the current local time.
class SystemRandom
Default random implementation backed by System.Random.Shared.
public sealed class SystemRandom : IRandom
{
public static SystemRandom Default { get; }
public int Next(int minValue, int maxValue);
public double NextDouble();
}
SystemRandom SystemRandom.Default
public static SystemRandom Default { get; }
Gets the shared default system random instance.
int SystemRandom.Next(int minValue, int maxValue)
public int Next(int minValue, int maxValue);
Returns a random integer within the specified range.
minValue— Inclusive lower bound of the random number.maxValue— Exclusive upper bound of the random number.
Returns: A random integer in the specified range.
double SystemRandom.NextDouble()
public double NextDouble();
Returns a random floating-point number in the range [0.0, 1.0).
Returns: A random floating-point number.
class Window
Represents an abstract cross-platform application window in Xui. Handles input, rendering, layout, and software keyboard integration.
This class connects the abstract UI framework with the underlying platform window, acting as a root container for layout and visual composition. Subclasses may override specific input or rendering behaviors as needed.
public class Window : Abstract.IWindow, Abstract.IWindow.ISoftKeyboard, IServiceProvider, IDisposable
{
public IServiceProvider Context { get; }
public virtual object? GetService(Type serviceType);
public List<IDisposable> DisposeQueue { get; }
public bool DestroyOnClose { get; set; }
public IRuntime Runtime { get; }
public Actual.IWindow Actual { get; }
public virtual Rect DisplayArea { get; set; }
public virtual Rect SafeArea { get; set; }
public virtual nfloat ScreenCornerRadius { get; set; }
public virtual ITextMeasureContext? TextMeasureContext { get; }
public RootView RootView { get; }
public string InstrumentationName { get; }
public IRenderSurfaceInstrumentsSink? RenderSurfaceInstruments { get; }
public View Content { init; }
public Window(IServiceProvider context);
public string Title { get; set; }
public bool RequireKeyboard { get; set; }
public void Show();
public virtual void Render(ref RenderEventRef renderEventRef);
public virtual void WindowHitTest(ref WindowHitTestEventRef evRef);
public virtual bool Closing();
public virtual void Closed();
public void Dispose();
protected virtual void Dispose(bool disposing);
protected virtual Actual.IWindow CreateActualWindow();
public virtual void Invalidate();
public virtual void OnMouseDown(ref MouseDownEventRef e);
public virtual void OnMouseMove(ref MouseMoveEventRef e);
public virtual void OnMouseUp(ref MouseUpEventRef e);
public virtual void OnScrollWheel(ref ScrollWheelEventRef e);
public virtual void OnZoom(ref ZoomEventRef e);
public virtual void OnTouch(ref TouchEventRef e);
public virtual void OnKeyDown(ref KeyEventRef e);
public virtual void OnChar(ref KeyEventRef e);
public virtual void OnAnimationFrame(ref FrameEventRef e);
public virtual bool HasText { get; }
public virtual bool IsSecureTextEntry { get; }
public virtual void InsertText(ref InsertTextEventRef eventRef);
public virtual void DeleteBackwards(ref DeleteBackwardsEventRef eventRef);
}
Window.Window(IServiceProvider context)
public Window(IServiceProvider context);
Initializes a new instance of the Xui.Core.Abstract.Window class. This creates the backing platform window.
context— An optional scopedSystem.IServiceProviderfor this window. If it implementsSystem.IDisposable, it will be disposed when the window closes.
IWindow Window.Actual
public Actual.IWindow Actual { get; }
Gets the underlying platform-specific window instance.
void Window.Closed()
public virtual void Closed();
Invoked when the window is closed and cleanup should occur.
bool Window.Closing()
public virtual bool Closing();
Invoked before the window closes. Returning false can cancel the closure.
Returns: true if the window may close; otherwise, false.
View Window.Content
public View Content { init; }
Sets the root content view of this window.
IServiceProvider Window.Context
public IServiceProvider Context { get; }
The service provider for this window.
IWindow Window.CreateActualWindow()
protected virtual Actual.IWindow CreateActualWindow();
Creates the platform-specific window for this abstract window.
Returns: The platform implementation of Xui.Core.Actual.IWindow.
void Window.DeleteBackwards(ref DeleteBackwardsEventRef eventRef)
public virtual void DeleteBackwards(ref DeleteBackwardsEventRef eventRef);
Requests deletion of content preceding the caret or selection.
eventRef— The input event representing a backspace action.
bool Window.DestroyOnClose
public bool DestroyOnClose { get; set; }
When true (the default), closing the window calls Xui.Core.Abstract.Window.Dispose. Set to false for windows that survive being closed and reopened.
Rect Window.DisplayArea
public virtual Rect DisplayArea { get; set; }
Gets or sets the total visible area of the window, including content that may be obscured by hardware cutouts, rounded corners, or system UI overlays.
Used by the layout system to determine the full available size.
void Window.Dispose()
public void Dispose();
Releases all managed resources owned by this window. If the platform window is still open, it is closed first. Items in Xui.Core.Abstract.Window.DisposeQueue are disposed in order.
void Window.Dispose(bool disposing)
protected virtual void Dispose(bool disposing);
disposing—truewhen called fromXui.Core.Abstract.Window.Dispose;falsefrom a finalizer.
List<IDisposable> Window.DisposeQueue
public List<IDisposable> DisposeQueue { get; }
A list of disposables disposed when the window closes.
object? Window.GetService(Type serviceType)
public virtual object? GetService(Type serviceType);
Gets the service object of the specified type.
serviceType— An object that specifies the type of service object to get.
Returns: A service object of type serviceType. -or- null if there is no service object of type serviceType.
bool Window.HasText
public virtual bool HasText { get; }
Whether the focused text client contains text.
void Window.InsertText(ref InsertTextEventRef eventRef)
public virtual void InsertText(ref InsertTextEventRef eventRef);
Requests insertion of one or more characters into the current input context.
eventRef— The input event containing the text to insert.
string Window.InstrumentationName
public string InstrumentationName { get; }
Stable name used to identify this window's render surface in instrumentation.
void Window.Invalidate()
public virtual void Invalidate();
Requests a visual invalidation/redraw of this window.
bool Window.IsSecureTextEntry
public virtual bool IsSecureTextEntry { get; }
Whether the focused text client requires password entry.
void Window.OnAnimationFrame(ref FrameEventRef e)
public virtual void OnAnimationFrame(ref FrameEventRef e);
Invoked once per frame to propagate animation timing information.
animationFrame— Timing details for the current animation frame.
void Window.OnChar(ref KeyEventRef e)
public virtual void OnChar(ref KeyEventRef e);
Invoked when a character is input (after keyboard translation).
e— The keyboard event data with the translated character.
void Window.OnKeyDown(ref KeyEventRef e)
public virtual void OnKeyDown(ref KeyEventRef e);
Invoked when a key is pressed.
e— The keyboard event data.
void Window.OnMouseDown(ref MouseDownEventRef e)
public virtual void OnMouseDown(ref MouseDownEventRef e);
Invoked when a mouse button is pressed within the window.
evRef— The mouse down event data.
void Window.OnMouseMove(ref MouseMoveEventRef e)
public virtual void OnMouseMove(ref MouseMoveEventRef e);
Invoked when the mouse is moved within the window.
evRef— The mouse movement event data.
void Window.OnMouseUp(ref MouseUpEventRef e)
public virtual void OnMouseUp(ref MouseUpEventRef e);
Invoked when a mouse button is released within the window.
evRef— The mouse up event data.
void Window.OnScrollWheel(ref ScrollWheelEventRef e)
public virtual void OnScrollWheel(ref ScrollWheelEventRef e);
Invoked when the scroll wheel is used within the window.
evRef— The scroll wheel event data.
void Window.OnTouch(ref TouchEventRef e)
public virtual void OnTouch(ref TouchEventRef e);
Invoked when touch input occurs within the window.
touchEventRef— The touch event data.
void Window.OnZoom(ref ZoomEventRef e)
public virtual void OnZoom(ref ZoomEventRef e);
Routes a platform magnification gesture through the view tree.
void Window.Render(ref RenderEventRef renderEventRef)
public virtual void Render(ref RenderEventRef renderEventRef);
Invoked during the render phase of the UI lifecycle. Responsible for triggering layout and visual updates.
render— The render event data, including target rect and frame info.
IRenderSurfaceInstrumentsSink? Window.RenderSurfaceInstruments
public IRenderSurfaceInstrumentsSink? RenderSurfaceInstruments { get; }
The instrumentation sink created for this window's render surface, if enabled.
bool Window.RequireKeyboard
public bool RequireKeyboard { get; set; }
Requests that the soft keyboard be shown or hidden (on supported platforms).
RootView Window.RootView
public RootView RootView { get; }
The root view that hosts the window's content hierarchy.
IRuntime Window.Runtime
public IRuntime Runtime { get; }
The platform runtime used by this window.
Rect Window.SafeArea
public virtual Rect SafeArea { get; set; }
Gets or sets the "safe" area of the window, excluding obstructions like notches or status bars. Important UI elements should be placed within this area.
Especially relevant on mobile devices and in emulator scenarios.
NFloat Window.ScreenCornerRadius
public virtual nfloat ScreenCornerRadius { get; set; }
Gets or sets the corner radius of the physical screen, in logical pixels. Used to offset UI elements (such as scrollbar indicators) away from rounded screen edges. Zero on desktop platforms where the window has sharp corners.
void Window.Show()
public void Show();
Makes the window visible and adds it to the list of open windows.
ITextMeasureContext? Window.TextMeasureContext
public virtual ITextMeasureContext? TextMeasureContext { get; }
Gets the text measure context for this window, used for hit-testing text positions during pointer events. Null on platforms that do not provide one.
string Window.Title
public string Title { get; set; }
Gets or sets the window title (where supported by the platform).
void Window.WindowHitTest(ref WindowHitTestEventRef evRef)
public virtual void WindowHitTest(ref WindowHitTestEventRef evRef);
Invoked when the system requests a hit test for window interaction. Allows the app to indicate whether a region is draggable, resizable, etc.
evRef— The hit test event containing pointer position and window bounds.