Skip to main content

Hyprism.Desktop

Desktop is the Avalonia application host. It composes Core services, provides native capabilities, and adapts their state into views and commands

Composition and screens​

LocationResponsibility
Program.csService registrations, renderer configuration, application entry point
App.axaml and App.axaml.csResources, window creation, startup and shutdown
ShellMain window, navigation, startup overlay, account presentation, and screen composition
Screens/InstancesInstance lifecycle, selection, launch activity, mods, catalog, worlds, console state, and instance view
Screens/ProfilesProfile cards, activation, editing, creation and sign-in
Screens/SettingsSettings, persistence, storage usage, and About presentation
Screens/NewsFeed and article loading, cache coordination, image state, HTML parsing, structured articles, and news view
Integrations/GitHubGitHub repository metadata, commits, contributors, and avatar API
PlatformBrowser and folder opening, file picker, memory and GPU discovery, image cache
Integrations/DiscordHost implementation of Core presence
LocalizationResource strings and runtime language selection

Window chrome​

The shell uses Avalonia 12's WindowDrawnDecorations model. The main window extends its client area into the decoration region. Windows selects WindowDecorations="Full" so native DWM state transitions and snap behavior remain available, while WindowDecorations.axaml replaces Avalonia's default drawn decoration content

Other platforms keep WindowDecorations="None" through the platform-specific value and use the same custom shell. Linux enables Avalonia X11 client-side decorations in Program.cs so the element roles become native window-manager move and resize requests. The main window marks the title bar, caption buttons, and resize hit regions with WindowDecorationProperties.ElementRole; keep that option paired with ExtendClientAreaToDecorationsHint and do not reintroduce manual Win32 position updates

Caption buttons render vector resources from Assets/Icons/MaterialSymbols.axaml. The minimize and close buttons use fixed glyphs, while the maximize button switches between MaximizeIcon and RestoreIcon when WindowState changes. Keep their standard arrow cursor separate from the hand cursor used by ordinary action buttons so native caption hit testing remains stable

Views and state​

Compiled bindings are enabled for the Desktop project. Views declare x:DataType; view models expose observable state and commands. Code-behind handles behavior tied to input, layout, focus, or animation

MainWindowViewModel owns only shell state and composes screen view models. InstancesViewModel and NewsViewModel own their screen state and service subscriptions. MainWindow.axaml passes those child models into InstancesView and NewsView, so screen bindings do not depend on Shell properties

Each Screens/<Screen> directory is a vertical UI slice. It may contain the view, its view model, screen-local presentation models, and Desktop adapters that exist only for that screen

The following fragment illustrates a compiled binding to the existing settings view model:

<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:settings="using:Hyprism.Desktop.Screens.Settings"
x:DataType="settings:SettingsViewModel">
<ToggleSwitch IsChecked="{Binding CloseAfterLaunch}" />
</UserControl>

Startup constructs the shell and screen view models on a worker thread. Timers that update the interface must explicitly use Dispatcher.UIThread. Publish observable collection changes on that dispatcher. Unsubscribe from service events and release image resources when their owner is disposed.

The instance action reads process state when selecting an instance and handles typed process events. Its elapsed-time timer uses the stored start time without querying the process registry on each tick. Selecting a different instance applies the new button state immediately. Launch progress within the same instance retains its normal animations.

Shared UI foundation​

UI/Foundation/Themes/HyprismTheme.axaml provides the application-owned templates for the window, scrolling, text input, selection, list, combo box, progress, tooltip, and popup surfaces. UI/Foundation/Tokens contains primitive and semantic values. UI/Components/ControlThemes.axaml contains named framework control themes. UI/Components/Components.axaml defines shared control families, UI/Components/ManagerStyles.axaml owns repeated manager and detail patterns, and UI/Foundation/GlobalStyles.axaml contains application-wide selectors. Each screen includes its own style dictionary locally

The Desktop UI architecture page defines the component catalog, resource order, placement rules, and state contract

ControlResponsibility
AdaptiveMasterDetailHostShared wide and compact navigation
DeferredContentControlDelayed creation and retention of screen views
WizardHostWizard state, step transitions, and navigation coordination
OverlayModalShared dialog sheet
FadingPopup and FadingComboBoxPopup lifecycle and selection menus
ReorderableListControllerDrag handles, previews, and drop positions
NoteCardInformational and important callouts
EmptyStateConsistent empty content hierarchy with screen-provided icon, text, and action
FormRowShared label, hint, and trailing editor layout
SmoothScrollViewerShared wheel and precision-touchpad scrolling; optional middle-button auto-scroll

Animation timing belongs in MotionDurations or the owning reusable control. The performance guide explains layout and rendering checks

App-owned scroll hosts use SmoothScrollViewer, so mouse-wheel and precision-touchpad deltas feed one frame-based easing loop. Its template uses SmoothScrollContentPresenter to intercept wheel input before Avalonia's default immediate offset update. Middle-button auto-scroll is opt-in and remains enabled only for News views. The scrollbar keeps a fixed 6 px thumb layout slot and animates its idle 3 px appearance through RenderTransform; keep future thickness animations on render properties rather than Width

Network presentation​

News and GitHub clients use the shared HTTP identity. Parsed news lives in Cache/News; encoded remote images live in Cache/Images. Article text is prepared before image decoding, and decoded article bitmaps are released when the article closes

RemoteBitmapLoader is shared by screens that display images. It validates remote URLs, uses RemoteImageCache when available, and decodes bitmaps away from the Avalonia dispatcher

Native file selection uses Avalonia's StorageProvider. External links preserve escaped absolute URIs, including OAuth parameters. Neither capability belongs in Core

Source: MainWindowViewModel, InstancesViewModel, NewsViewModel, Shared controls

Edit this page on GitHub