Class PropInteger

Integer properties represent a feature whose value is an integer number.

Inheritance

PropInteger

Implements

Namespace: ic4
Assembly: ic4dotnet.dll
Syntax
public class PropInteger : Property, IDisposable
Remarks

Common examples for a integer properties are Width or Height.

An integer property can limit the range of valid values. The range of possible values can be queried by reading Minimum and Maximum.

The possible values can be further restricted by an increment value or a set of value values. Check IncrementMode, Increment and ValidValueSet for details.

An integer property property supplies hints that can be useful when creating a user interface:

PropInteger instances are created in multiple ways:

Properties

Increment

The step size for valid values accepted by this integer property

Declaration

public long Increment { get; }
Property Value
Type Description
long

The step size for valid values accepted by this integer property

Remarks

The increment restricts the set of valid values for a integer property.

For example, if the property's minimum value is 0, the maximum is 10, and the increment is 2, 1 is not a valid value for the property

Accessing Increment will throw an exception if IncrementMode is not equal to Increment.

Exceptions

Type Condition
IC4Exception

Check ErrorCode and ToString() for details.

IncrementMode

Indicates how this float property restricts which values are valid between its minimum and maximum value.

Declaration

public PropertyIncrementMode IncrementMode { get; }
Property Value
Type Description
PropertyIncrementMode

The property's increment mode

Remarks

An integer property has 1 of 2 possible increment modes:

Increment modeDescription
Increment Only multiples of Increment can be set.
ValueSet Only values that are part of ValidValueSet can be set.

Maximum

The maximum value accepted by this property.

Declaration

public long Maximum { get; }
Property Value
Type Description
long

The maximum value accepted by this property.

Exceptions

Type Condition
IC4Exception

Check ErrorCode and ToString() for details.

Minimum

The minimum value accepted by this property.

Declaration

public long Minimum { get; }
Property Value
Type Description
long

The minimum value accepted by this property.

Exceptions

Type Condition
IC4Exception

Check ErrorCode and ToString() for details.

Representation

The suggested representation for this integer property

Declaration

public IntRepresentation Representation { get; }
Property Value
Type Description
IntRepresentation

The suggested representation for this integer property

Remarks

The representation can be used as a hint when creating user interfaces

Unit

The unit of this integer property

Declaration

public string Unit { get; }
Property Value
Type Description
string

The unit of this integer property

Exceptions

Type Condition
IC4Exception

Check ErrorCode and ToString() for details.

ValidValueSet

The set of valid values for this property

Declaration

public IReadOnlyList<long> ValidValueSet { get; }
Property Value
Type Description
IReadOnlyList<long>

A list containing the values that are valid for this property

Remarks

Accessing Increment will throw an exception if IncrementMode is not equal to ValueSet.

Exceptions

Type Condition
IC4Exception

Check ErrorCode and ToString() for details.

Value

The current value of this property

The value is only writable is the property's writability is not restricted. See IsLocked, IsReadonly, IsAvailable.

Declaration

public long Value { get; set; }
Property Value
Type Description
long

The current value of this property

Remarks

If exceptions are not desired when accessing the value, use TryGetValue(out long) or TrySetValue(long).

Exceptions

Type Condition
IC4Exception

Check ErrorCode and ToString() for details.

Methods

TryGetValue(out long)

Tries to get the current value of the property.

Declaration

public bool TryGetValue(out long val)

Parameters

Type Name Description
long val

Output parameter receiving the current value of the property on success

Returns

Type Description
bool

true, if the operation was successful, otherwise false.

Remarks

In contrast to reading the Value property directly, this method does not throw an exception in case of an error.

TrySetValue(long)

Tries to set the current value of the property.

Declaration

public bool TrySetValue(long val)

Parameters

Type Name Description
long val

The new value

Returns

Type Description
bool

true, if the operation was successful, otherwise false.

Remarks

In contrast to writing the Value property directly, this method does not throw an exception in case of an error.

Implements