Decimal Method Call

A Decimal Method Call is a Method Call that returns a Decimal Expression.

  • See Methods for explanations of the basics and for Code examples and for the declaration of Method Calls.
    See How to use Method Calls for general information on using Method Calls.

Code Example

 

private IntegerProperty Number => IntegerProperty(null, IntegerDefinition.GetInstance(IntegerSize.Integer, false, maxValue:10));
private ReadOnlyDecimalProperty ComposedDecimal => CalculatedDecimalProperty(ComposeTheDecimal);

protected override IUIElement CreateGui()
{

    return new VBox
    {
        new HBox(alignH:AlignH.Fill, alignV:AlignV.Fill)
        {
            new GroupBox("example")
            {
                new VBox(2)
                {
                    new Label("number (1 till 10):"),
                    new TextBox(Number),

                    new Label("calculated string:"),
                    new Label(ComposedDecimal),
                },
            },
            CodeContent
        },

        new HBox(alignH:AlignH.Fill)
        {
            EmptySpace.FillH,
            new Button(Close())
        }
    };
}


private DecimalMethodCall ComposeTheDecimal()
{
    return DecimalMethod(() => new Body
    {
        new If(Number.IsEqualTo(1))
        {
            new Return(12.23)
        },

        ...

        new ElseIf(Number.IsEqualTo(10))
        {
            new Return(-18.99)
        },
        new Else
        {
            new Return(0.00)
        }
    });
}

 

Explanation of the code example

  • In this example, in line 2, the private property ComposedDecimal is filled with the return value of the Decimal Method Call with the name ComposeTheDecimal().
  • This private property is then in line 19 displayed in a form, using new Return(12.34) (some Decimal value).
  • This method is defined in lines 34-54.

Example of the result

A form like the one defined above, could look like this.

When nothing has been entered:

 

When 1 has been entered:

 

When 10 has been entered: