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 has been using by hand all along, so a notification looks like it belongs to the app rather than to a palette invented for it.
Fields
DefaultError
Something is broken: the red already used by the tunnel warning.
public const string DefaultError = "#E05561"
Field Value
DefaultInfo
Neither good nor bad: the blue already used by the update banner.
public const string DefaultInfo = "#2F6FB0"
Field Value
DefaultSuccess
Something went right: the green already used for a healthy server.
public const string DefaultSuccess = "#3FB950"
Field Value
DefaultWarning
Worth knowing: the amber already used by every warning panel.
public const string DefaultWarning = "#E3A82B"
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.
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.