New to Telerik UI for WinForms? Start a free 30-day trial

Creates undoable diagram-item property changes and provides reflection-based property assignment helpers.

Definition

Namespace:Telerik.WinControls.UI.Diagrams

Assembly:Telerik.WinControls.RadDiagram.dll

Syntax:

C#
public class UndoRedoHelper

Inheritance: objectUndoRedoHelper

Constructors

C#
public UndoRedoHelper()

Methods

Converts values for int, double, bool, decimal, and string targets; other target types receive the original value.

C#
public static object ConvertValue(Type targetType, object value)
Parameters:targetTypeType

The type requested by the destination property.

valueobject

The value to convert. A null value for a double target becomes NaN.

Returns:

object

The converted value for a supported target type, or the original value for other types.

Sets a property resolved from an object by a dot-separated property path.

C#
public static bool SetProperty(string propertyName, object source, object value)
Parameters:propertyNamestring

The property path to resolve, starting at source.

sourceobject

The object from which to resolve the first property.

valueobject

The value to convert and assign to the final property.

Returns:

bool

true if conversion and assignment complete; false if conversion or the setter throws.

Exceptions: ArgumentNullException

source is null.

ArgumentException

The resolved property is read-only.

NullReferenceException

A property in the path cannot be resolved or an intermediate property value is null.

Creates and executes an undo command that assigns a new value to a diagram item's property.

C#
public static bool ValueChanged(IDiagramItem diagramItem, string propertyName, object newValue, object oldValue)
Parameters:diagramItemIDiagramItem

A diagram item backed by a RadElement and owned by a RadDiagramElement.

propertyNamestring

The property path assigned by the command.

newValueobject

The value assigned when the command executes or is redone.

oldValueobject

The value restored when the command is undone.

Returns:

bool

true when command submission completes; this does not report whether the property assignment succeeded.

Exceptions: InvalidCastException

diagramItem is not a RadElement.

InvalidOperationException

diagramItem has no owning RadDiagramElement.

The current implementation compares oldValue and newValue by reference, so distinct boxed values can be treated as a change even when their contents are equal.