Class IcyConfiguration
- Namespace
- Icy.Configuration
- Assembly
- IcyUI.dll
Aggregates library services and provides fluent configuration for all of these.
public class IcyConfiguration
- Inheritance
-
IcyConfiguration
- Inherited Members
- Extension Methods
Constructors
IcyConfiguration(IInputSystem, AssetConfiguration, IRenderContext, ReflectionConfiguration, ThemeConfiguration?, ScalingConfiguration?, ILoggerFactory?)
Initializes a new instance of the IcyConfiguration class.
public IcyConfiguration(IInputSystem input, AssetConfiguration assets, IRenderContext renderContext, ReflectionConfiguration types, ThemeConfiguration? theme = null, ScalingConfiguration? scaling = null, ILoggerFactory? logging = null)
Parameters
inputIInputSystemAn input service that is used by library in this application.
assetsAssetConfigurationConfiguration of the assets system used by library in this application.
renderContextIRenderContextThe rendering service instance used by library in this application.
typesReflectionConfigurationAn instance of the reflection-related services used in library.
themeThemeConfigurationThe default-theme configuration used by the library. Defaults to an empty ThemeConfiguration (no theme applied) when omitted.
scalingScalingConfigurationThe UI scaling defaults used by the library. Defaults to a new ScalingConfiguration (Dpi) when omitted.
loggingILoggerFactoryWhere IcyUI writes its log messages. Defaults to Instance (nothing is logged) when omitted.
Properties
Assets
Gets the assets configuration section.
public AssetConfiguration Assets { get; }
Property Value
Culture
Gets or sets the culture IcyUI formats and parses the values players read and type with.
[AllowNull]
public CultureInfo Culture { get; set; }
Property Value
- CultureInfo
The culture set for this configuration, or CurrentUICulture (read at each use) while none is set. Setting null goes back to following CurrentUICulture.
Remarks
The default follows the UI language rather than CurrentCulture (the system's
regional format): a game shows numbers the way its own language writes them, so 3,5 in Russian and
3.5 in English, whatever the player's system settings are.
Used by:
- bindings that convert between text and a value, for example a TextBox two-way bound to a float (see Culture);
- the converter of a binding's BindingConverterParameters when it has no culture of its own;
-
localized strings (
{Localize}and Localize(string, string?)): changing the culture switches them (see CultureChanged).
Changing it applies to existing bindings the next time they update. Markup itself always uses the
invariant culture: Width="3.5" means the same in every language.
Fonts
Gets a service for access to the library fonts.
public FontSystem Fonts { get; }
Property Value
Input
Gets the input service instance used by the library.
public IInputSystem Input { get; }
Property Value
Logging
Gets the factory IcyUI creates its loggers from. Categories are IcyUI's full type names, such as
Icy.Rendering.Fonts.FontSystem, so a prefix filter like "Icy.Markup" selects one area.
public ILoggerFactory Logging { get; }
Property Value
RenderContext
Gets the rendering service instance used by the library.
public IRenderContext RenderContext { get; }
Property Value
Scaling
Gets the application-wide UI scaling defaults used by every Canvas built against this configuration.
public ScalingConfiguration Scaling { get; }
Property Value
Theme
Gets the default-theme configuration used by the library.
public ThemeConfiguration Theme { get; }
Property Value
Types
Gets the services for the reflection purposes.
public ReflectionConfiguration Types { get; }
Property Value
Methods
Localize(string, string?)
public string Localize(string key, string? context = null)
Parameters
keystringThe key, such as
Menu.Play.contextstringAn optional context that tells apart keys with the same text (gettext's
msgctxt).
Returns
- string
The string, or
keyitself when the localizer has none: the text stays readable, and a warning (event 4001) is logged once per key and culture.
Events
CultureChanged
Occurs when Culture changed to a different culture. IcyUI re-applies every localized property
then ({Localize}, and Localize on elements built in code).
public event EventHandler? CultureChanged
Event Type
Remarks
Raised when setting Culture leaves it different from the culture localized texts were last shown in. Not raised by changes of CurrentUICulture alone, while Culture follows it: set Culture to switch the game's language.