New to Telerik UI for WinFormsStart a free 30-day trial

A collection of generic extensions used across the codebase.

Definition

Namespace:Telerik.Windows.Diagrams.Core

Assembly:Telerik.WinControls.RadDiagram.dll

Syntax:

C#
public static class CommonExtensions

Inheritance: objectCommonExtensions

Methods

Adds the given range of items to the current collection.

C#
public static void AddRange<T>(this ICollection<T> collection, IEnumerable<T> newItems)
Parameters:collectionICollection<T>

A collection to be augmented with the given items.

newItemsIEnumerable<T>

The new items to add.

Exceptions:

ArgumentNullException

Will be raised if either the collection or the newItems is null.

Clears the property if a value has been set.

C#
public static bool ClearIfSet(this RadObject dependencyObject, RadProperty dependencyProperty)
Parameters:dependencyObjectRadObject

The dependency object.

dependencyPropertyRadProperty

The dependency property to clear.

Returns:

bool

Returns true if the value has been cleared.

Exceptions:

ArgumentNullException

Will be raised if either the dependencyObject or the dependencyProperty is null.

Clones the list of doubles and returns a DoubleCollection.

C#
public static DoubleCollection Clone(this DoubleCollection doubles)
Parameters:doublesDoubleCollection

The list to clone.

Returns:

DoubleCollection

The cloned list.

Clones the list of doubles and returns a DoubleCollection.

C#
public static List<double> Clone(this IEnumerable<double> doubles)
Parameters:doublesIEnumerable<double>

The list to clone.

Returns:

List<double>

The cloned list.

Clones the list.

C#
public static IList<T> Clone<T>(this IEnumerable<T> list)
Parameters:listIEnumerable<T>

The list to clone.

Returns:

IList<T>

The cloned list.

Exceptions:

ArgumentNullException

Will be raised if the underlying list is null.

Checks for the occurrence of the given items in the collection.

C#
public static bool ContainsAny<T>(this IEnumerable<T> collection, IEnumerable<T> otherCollection)
Parameters:collectionIEnumerable<T>

A collection to be tested for the given items.

otherCollectionIEnumerable<T>

The other collection.

Returns:

bool

True if the specified collection contains any of the otherCollection items; otherwise, false.

Exceptions:

ArgumentNullException

Will be raised if either the collection or the otherCollection is null.

Ensures the list has exactly the amount of items specified.

C#
public static bool EnsureListCount<T>(this IList<T> list, int count, Func<T> factory)
Parameters:listIList<T>

The list to check.

countint

The expected count.

factoryFunc<T>

The factory function if more items need to be created.

Returns:

bool

Returns true if items had to be removed in order to have the expect count.

Exceptions:

ArgumentNullException

Will be raised if the underlying list is null.

Ensures that the list contains at least the amount of specified items. If not, the given factory function will be used to add additional items till the expect count is reached.

C#
public static bool EnsureListCountAtLeast<T>(this IList<T> list, int count, Func<T> factory)
Parameters:listIList<T>

The list to check.

countint

The expected count.

factoryFunc<T>

The factory function if more items need to be created.

Returns:

bool

Returns true if additional items had to be added.

Exceptions:

ArgumentNullException

Will be raised if the underlying list is null.

Executes the action for each item in the collection.

C#
public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action)
Parameters:collectionIEnumerable<T>

The collection to iterate.

actionAction<T>

The action to execute on each item.

Exceptions:

ArgumentNullException

Will be raised if either the collection or the action is null.

Gets the ActualBounds if the given item is an IShape, otherwise the IDiagramItem's Bounds will be returned.

C#
public static Rect GetActualBounds(this IDiagramItem item, bool isShapeActualBounds = true)
Parameters:itemIDiagramItem

An IDiagramItem item.

isShapeActualBoundsbool

Indicates whether to get the actual (rotated) shape bounds or the normal bounds.

Returns:

Rect

Gets the ActualBounds if the given item is an IShape, otherwise the IDiagramItem's Bounds will be returned.

C#
public static Rect GetActualBoundsWithoutTransform(this IDiagramItem item)
Parameters:itemIDiagramItem

An IDiagramItem item.

Returns:

Rect

Gets the ActualBounds if the given item is an IShape, otherwise the IDiagramItem's Bounds will be returned.

C#
public static Rect GetActualBoundsWithRotationTransform(this IDiagramItem item)
Parameters:itemIDiagramItem

An IDiagramItem item.

Returns:

Rect

Gets the enclosing bounds of the list of diagram items.

C#
public static Rect GetEnclosingBounds(this IEnumerable<IDiagramItem> items, bool isGraphVirtualized = false, bool isShapeActualBounds = true, bool useControlBoundingRectangle = false)
Parameters:itemsIEnumerable<IDiagramItem>

The diagram items.

isGraphVirtualizedbool

If set to true [is graph virtualized].

isShapeActualBoundsbool

Indicates whether to get the actual (rotated) shape bounds or the normal bounds.

useControlBoundingRectanglebool

useControlBoundingRectangle

Returns:

Rect

Gets the enclosing bounds of the list of diagram items.

C#
public static Rect GetEnclosingBoundsRotated(this IEnumerable<IDiagramItem> items)
Parameters:itemsIEnumerable<IDiagramItem>

The diagram items.

Returns:

Rect

Gets the enclosing bounds of the list of diagram items.

C#
public static Rect GetEnclosingBoundsWithoutTransform(this IEnumerable<IDiagramItem> items, bool isGraphVirtualized = false, bool isShapeActualBounds = true, bool useControlBoundingRectangle = false)
Parameters:itemsIEnumerable<IDiagramItem>

The diagram items.

isGraphVirtualizedbool

If set to true [is graph virtualized].

isShapeActualBoundsbool

Indicates whether to get the actual (rotated) shape bounds or the normal bounds.

useControlBoundingRectanglebool
Returns:

Rect

enclosingBounds

Determines whether the specified dependency property local value is set.

C#
public static bool IsLocalValueSet(this RadObject dependencyObject, RadProperty property)
Parameters:dependencyObjectRadObject

The dependency object.

propertyRadProperty

The property.

Returns:

bool

Removes the last item in the list.

C#
public static void RemoveLast<T>(this IList<T> list)
Parameters:listIList<T>

The list.

Exceptions:

ArgumentNullException

Will be raised if the underlying list is null.

Sets the value of the dependencyProperty property if it's hasn't that value currently.

C#
public static bool SetIfDifferent(this RadObject dependencyObject, RadProperty dependencyProperty, object value)
Parameters:dependencyObjectRadObject

The dependency object.

dependencyPropertyRadProperty

The dependency property.

valueobject

The value to set if currently different.

Returns:

bool

Return true if the value was set.

Exceptions:

ArgumentNullException

Will be raised if either the dependencyObject or the dependencyProperty is null. The value can however be set to null.