CommonExtensions
A collection of generic extensions used across the codebase.
Definition
Namespace:Telerik.Windows.Diagrams.Core
Assembly:Telerik.WinControls.RadDiagram.dll
Syntax:
public static class CommonExtensions
Inheritance: objectCommonExtensions
Methods
Adds the given range of items to the current collection.
public static void AddRange<T>(this ICollection<T> collection, IEnumerable<T> newItems)
A collection to be augmented with the given items.
newItemsIEnumerable<T>The new items to add.
Exceptions:Will be raised if either the collection or the newItems is null.
Clears the property if a value has been set.
public static bool ClearIfSet(this RadObject dependencyObject, RadProperty dependencyProperty)
The dependency object.
dependencyPropertyRadPropertyThe dependency property to clear.
Returns:Returns true if the value has been cleared.
Will be raised if either the dependencyObject or the dependencyProperty is null.
Clones the list of doubles and returns a DoubleCollection.
public static DoubleCollection Clone(this DoubleCollection doubles)
The list to clone.
Returns:The cloned list.
Clones the list of doubles and returns a DoubleCollection.
Clones the list.
public static IList<T> Clone<T>(this IEnumerable<T> list)
The list to clone.
Returns:IList<T>
The cloned list.
Exceptions:Will be raised if the underlying list is null.
Checks for the occurrence of the given items in the collection.
public static bool ContainsAny<T>(this IEnumerable<T> collection, IEnumerable<T> otherCollection)
A collection to be tested for the given items.
otherCollectionIEnumerable<T>The other collection.
Returns:True if the specified collection contains any of the otherCollection items; otherwise, false.
Will be raised if either the collection or the otherCollection is null.
Ensures the list has exactly the amount of items specified.
public static bool EnsureListCount<T>(this IList<T> list, int count, Func<T> factory)
The list to check.
countintThe expected count.
factoryFunc<T>The factory function if more items need to be created.
Returns:Returns true if items had to be removed in order to have the expect count.
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.
public static bool EnsureListCountAtLeast<T>(this IList<T> list, int count, Func<T> factory)
The list to check.
countintThe expected count.
factoryFunc<T>The factory function if more items need to be created.
Returns:Returns true if additional items had to be added.
Will be raised if the underlying list is null.
Executes the action for each item in the collection.
public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action)
The collection to iterate.
actionAction<T>The action to execute on each item.
Exceptions: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.
public static Rect GetActualBounds(this IDiagramItem item, bool isShapeActualBounds = true)
An IDiagramItem item.
isShapeActualBoundsboolIndicates whether to get the actual (rotated) shape bounds or the normal bounds.
Returns:Gets the ActualBounds if the given item is an IShape, otherwise the IDiagramItem's Bounds will be returned.
public static Rect GetActualBoundsWithoutTransform(this IDiagramItem item)
An IDiagramItem item.
Returns:Gets the ActualBounds if the given item is an IShape, otherwise the IDiagramItem's Bounds will be returned.
public static Rect GetActualBoundsWithRotationTransform(this IDiagramItem item)
An IDiagramItem item.
Returns:Gets the enclosing bounds of the list of diagram items.
public static Rect GetEnclosingBounds(this IEnumerable<IDiagramItem> items, bool isGraphVirtualized = false, bool isShapeActualBounds = true, bool useControlBoundingRectangle = false)
The diagram items.
isGraphVirtualizedboolIf set to true [is graph virtualized].
Indicates whether to get the actual (rotated) shape bounds or the normal bounds.
useControlBoundingRectanglebooluseControlBoundingRectangle
Returns:Gets the enclosing bounds of the list of diagram items.
public static Rect GetEnclosingBoundsRotated(this IEnumerable<IDiagramItem> items)
The diagram items.
Returns:Gets the enclosing bounds of the list of diagram items.
public static Rect GetEnclosingBoundsWithoutTransform(this IEnumerable<IDiagramItem> items, bool isGraphVirtualized = false, bool isShapeActualBounds = true, bool useControlBoundingRectangle = false)
The diagram items.
isGraphVirtualizedboolIf set to true [is graph virtualized].
Indicates whether to get the actual (rotated) shape bounds or the normal bounds.
useControlBoundingRectangleboolReturns:enclosingBounds
Determines whether the specified dependency property local value is set.
public static bool IsLocalValueSet(this RadObject dependencyObject, RadProperty property)
The dependency object.
propertyRadPropertyThe property.
Returns:Removes the last item in the list.
public static void RemoveLast<T>(this IList<T> list)
The list.
Exceptions:Will be raised if the underlying list is null.
Sets the value of the dependencyProperty property if it's hasn't that value currently.
public static bool SetIfDifferent(this RadObject dependencyObject, RadProperty dependencyProperty, object value)
The dependency object.
dependencyPropertyRadPropertyThe dependency property.
valueobjectThe value to set if currently different.
Returns:Return true if the value was set.
Will be raised if either the dependencyObject or the dependencyProperty is null. The value can however be set to null.