Table of Contents

Class WholeNumberConverter

Namespace
McServerLauncher.ViewModels
Assembly
McServerLauncher.dll

Binds an int setting to a Avalonia.Controls.NumericUpDown, whose value is a decimal? that is null while the box is empty.

public class WholeNumberConverter : IValueConverter
Inheritance
WholeNumberConverter
Implements
IValueConverter
Inherited Members

Remarks

An empty box writes nothing, rather than failing to write a null into an int and showing the exception under the box. WholeNumberBoxes puts the number back once the box is left empty.

Fields

Instance

public static readonly WholeNumberConverter Instance

Field Value

WholeNumberConverter

Methods

Convert(object?, Type, object?, CultureInfo)

Converts a value.

public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)

Parameters

value object

The value to convert.

targetType Type

The type of the target.

parameter object

A user-defined parameter.

culture CultureInfo

The culture to use.

Returns

object

The converted value.

Remarks

This method should not throw exceptions. If the value is not convertible, return a Avalonia.Data.BindingNotification in an error state. Any exceptions thrown will be treated as an application exception.

ConvertBack(object?, Type, object?, CultureInfo)

Converts a value.

public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)

Parameters

value object

The value to convert.

targetType Type

The type of the target.

parameter object

A user-defined parameter.

culture CultureInfo

The culture to use.

Returns

object

The converted value.

Remarks

This method should not throw exceptions. If the value is not convertible, return a Avalonia.Data.BindingNotification in an error state. Any exceptions thrown will be treated as an application exception.

ToWhole(decimal)

A box's value as the whole number it stands for, rounded the way the box shows it.

public static int ToWhole(decimal value)

Parameters

value decimal

Returns

int

Remarks

The one place a box's decimal becomes an int. Some code used to cast instead, which truncates: a box showing 3 (its format rounds 2.5) wrote 2.