Skip to content

Models

These classes ease the widget development providing ready to use solutions for custom settings.

Model base

This is a base class of all models that need the OnPropertyChanged method.

Methods

NameParametersDescriptionReturns
SetPropertyref T property, T value, [CallerMemberName] string propertyName = nullIt sets the new value to a property and calls the OnPropertyChanged method.void

Usage

This example shows the usage of the SetProperty method.

C#

public class MyClass : ModelBase
{
    [JsonIgnore]
    private Color _color { get; set; } = Color.FromArgb(255, 255, 255, 255);
    public Color Color
    {
        get => _color;
        set => SetProperty(ref _color, Color);
    }
}

Described exception

This class is used to add a custom message to an exception.

Constructor

C#
public DescribedException(Exception exception, string description) { ... }

Properties

NameTypeDescriptionDefault
DescriptionstringCustom description.null
ExceptionExceptionException that occured.null

Usage

C#
new DescribedException(exception: Exception, description: "Custom description.");

Widget thickness

This class is used to wrap Thickness into a JSON saveable class.

Constructor

C#
public WidgetThickness(int thickness) { ... }
public WidgetThickness(int left, int top, int right, int bottom) { ... }

Properties

NameTypeDescriptionDefault
GetThicknessReturns Thickness.new Thickness(Left, Top, Right, Bottom);
LeftintLeft margin.0
TopintTop margin.0
RightintRight margin.0
BottomintBottom margin.0

Usage

C#
new WidgetThickness(thickness: 24); // All sides
new WidgetThickness(left: 8, top: 16, right: 8, bottom: 16);

Widget uniform thickness

This class derives from WidgetThickness. Each side of this thickness has the same margin.

Constructor

C#
public WidgetUniformThickness(int thickness) { ... }

Properties

NameTypeDescriptionDefault
ValueThicknessUniform margin value.0
GetThicknessReturns Thickness.new Thickness(Value);
LeftintLeft margin.0
TopintTop margin.0
RightintRight margin.0
BottomintBottom margin.0

Usage

C#
new WidgetUniformThickness(thickness: 24); // All sides

Widget corner radius

This class is used to wrap CornerRadius into a JSON saveable class.

Constructor

C#
public WidgetCornerRadius(int cornerRadius) { ... }

Properties

NameTypeDescriptionDefault
RadiusintUniform corner radius value.0
CornersCornerRadiusReturns CornerRadius.new CornerRadius(Corners);

Usage

C#
new WidgetCornerRadius(cornerRadius: 8);

Widget border

This class is used to store data about widget's border.

Properties

NameTypeDescriptionDefault
ColorColorSpeficies the color of the border.Color.FromArgb(255, 0, 0, 0);
ThicknessWidgetUniformThicknessSpecifies the WidgetUniformThickness to use for the border.new WidgetUniformThickness(0);

Usage

C#
new WidgetBorder();

Widget background

This class is used to store data about widget's background.

Properties

NameTypeDescriptionDefault
ColorColorSpeficies the color of the background.Color.FromArgb(255, 0, 0, 0);

Usage

C#
new WidgetBackground();

Released under CC-BY-4.0