Class NotificationPalette
- Namespace
- McServerLauncher.Services
- Assembly
- McServerLauncher.dll
The default colour of each notification level, and what counts as a valid one.
public static class NotificationPalette
- Inheritance
-
NotificationPalette
- Inherited Members
Remarks
Deliberately free of any UI framework, the same split ServerTypeCatalog keeps from
ServerTypeBrushes: hex strings are data, a Brush is not. It means the defaults can
be referenced from NotificationSettings — which is serialized to settings.json and
should not know Avalonia exists — and that the validation can be tested without a UI at all.
The four values are the ones the rest of the app draws its status marks, panels and console
lines with (the Semantic* tokens in App.axaml say the same), so a notification looks
like it belongs to the app rather than to a palette invented for it. They are muted on purpose:
bright enough to read on the dark card at a glance, quiet enough not to shout.
Fields
DefaultError
Something is broken: a dusty red, not an alarm.
public const string DefaultError = "#DB7A79"
Field Value
DefaultInfo
Neither good nor bad: a calm blue.
public const string DefaultInfo = "#7BA6CE"
Field Value
DefaultSuccess
Something went right: a soft green, also the colour of a healthy server.
public const string DefaultSuccess = "#6FB57F"
Field Value
DefaultWarning
Worth knowing: a dull amber, the one every warning panel uses.
public const string DefaultWarning = "#D9B665"
Field Value
Methods
DefaultFor(NotificationLevel)
The default hex for a level.
public static string DefaultFor(NotificationLevel level)
Parameters
levelNotificationLevel
Returns
IsValid(string?)
Whether a string is a colour this app will draw with.
public static bool IsValid(string? hex)
Parameters
hexstring
Returns
Remarks
Its own check rather than the framework's parser, for two reasons. It runs in a test with no UI, and it is stricter on purpose: the settings box is a free-text field, and accepting everything a parser tolerates — colour names, shorthand nobody typed on purpose — would let a value through that renders as something the user did not intend and cannot explain.
ModerniseColours(NotificationSettings?)
Moves a colour a settings file still holds from the old default of its level to the new one.
public static void ModerniseColours(NotificationSettings? settings)
Parameters
settingsNotificationSettings
Remarks
The colours are always written to disk, even untouched, so a file saved by an older version is full of the old defaults and changing the constants alone would only reach new installs. Nothing says whether a stored value was chosen or just never changed, so the rule is the simple one: exactly the old default becomes the new one, anything else is somebody's choice and is left alone. The cost is that a person who deliberately picked the old green gets the new one; the release notes say so.
Safe to run on every load: once a colour has moved it no longer matches, so a second pass finds nothing to do.
Sanitize(string?, NotificationLevel)
The colour, or the level's default when it is not one this app will draw with.
public static string Sanitize(string? hex, NotificationLevel level)
Parameters
hexstringlevelNotificationLevel
Returns
Remarks
Never throws and never returns nothing. These colours are read while building a toast that may be saying the server crashed, and a value mistyped in a settings box must not be able to turn that into an exception nobody sees.