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