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 features

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 feature composition
Features/InstancesInstance lifecycle, selection, launch activity, mods, catalog, worlds, console state, and instance view
Features/ProfilesProfile cards, activation, editing, creation and sign-in
Features/SettingsSettings, persistence, storage usage, and About presentation
Features/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 feature view models. InstancesViewModel and NewsViewModel own their feature state and service subscriptions. MainWindow.axaml passes those child models into InstancesView and NewsView, so feature bindings do not depend on Shell properties

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.Features.Settings"
x:DataType="settings:SettingsViewModel">
<ToggleSwitch IsChecked="{Binding CloseAfterLaunch}" />
</UserControl>

Publish observable collection changes on the UI dispatcher. Unsubscribe from service events and release image resources when their owner is disposed

Shared UI foundation

Styles/HyprismTheme.axaml provides the application-owned templates for the window, scrolling, text input, selection, list, combo box, progress, tooltip, and popup surfaces. It must remain before the shared styles so feature-specific selectors can override its defaults. Styles/Tokens.axaml defines the colors and semantic tokens used by the theme, while Styles/Controls.axaml defines shared control styles. Reuse their classes instead of copying feature-specific variants

ControlResponsibility
AdaptiveMasterDetailHostShared wide and compact navigation
DeferredContentControlDelayed creation and retention of feature 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
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 image-bearing features. 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