Table of Contents

Class ToastService

Namespace
McServerLauncher.Views
Assembly
McServerLauncher.dll

Small toast notifications drawn as borderless always-on-top windows in the bottom-right corner of the screen (pure Avalonia, no external dependencies, works even while the main window is hidden in the tray). They never steal focus, close by themselves after a few seconds — a bar along the bottom shows how many are left, and the pointer resting on a card stops the clock — and clicking one restores the main window. Used for "player joined" / "server crashed" style events.

public sealed class ToastService
Inheritance
ToastService
Inherited Members

Fields

Shared

public static readonly ToastService Shared

Field Value

ToastService

Properties

MainWindowInactive

True when nobody is looking at the app (window hidden in the tray, minimized or just not focused) — the situations in which a toast is actually useful.

public static bool MainWindowInactive { get; }

Property Value

bool

Methods

Notify(string, string, string, Symbol, NotificationLevel, NotificationSettings?)

Shows a toast (thread-safe; marshals to the UI thread).

public void Notify(string heading, string source, string message, Symbol icon, NotificationLevel level = NotificationLevel.Info, NotificationSettings? colours = null)

Parameters

heading string

What happened, in a few words: the coloured line at the top.

source string

Where it came from — the server's name — kept small beside the time.

message string

The detail.

icon Symbol

The mark inside the ring.

level NotificationLevel

How serious it is, which decides the colour and how long it stays.

colours NotificationSettings

The colours to draw the level with; the defaults when null.

Remarks

The level and the mark are passed in rather than worked out here, because what a toast means is not something the window that draws it can know. Every toast used to look identical — the same panel with the same faint green border whether somebody had joined or the server had died — so the only way to tell them apart was to stop and read.