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
| Location | Responsibility |
|---|---|
Program.cs | Service registrations, renderer configuration, application entry point |
App.axaml and App.axaml.cs | Resources, window creation, startup and shutdown |
Shell | Main window, navigation, startup overlay, account presentation, and screen composition |
Screens/Instances | Instance lifecycle, selection, launch activity, mods, catalog, worlds, console state, and instance view |
Screens/Profiles | Profile cards, activation, editing, creation and sign-in |
Screens/Settings | Settings, persistence, storage usage, and About presentation |
Screens/News | Feed and article loading, cache coordination, image state, HTML parsing, structured articles, and news view |
Integrations/GitHub | GitHub repository metadata, commits, contributors, and avatar API |
Platform | Browser and folder opening, file picker, memory and GPU discovery, image cache |
Integrations/Discord | Host implementation of Core presence |
Localization | Resource 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
| Control | Responsibility |
|---|---|
AdaptiveMasterDetailHost | Shared wide and compact navigation |
DeferredContentControl | Delayed creation and retention of screen views |
WizardHost | Wizard state, step transitions, and navigation coordination |
OverlayModal | Shared dialog sheet |
FadingPopup and FadingComboBox | Popup lifecycle and selection menus |
ReorderableListController | Drag handles, previews, and drop positions |
NoteCard | Informational and important callouts |
EmptyState | Consistent empty content hierarchy with screen-provided icon, text, and action |
FormRow | Shared label, hint, and trailing editor layout |
SmoothScrollViewer | Shared 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