Class CommonExtensions
A collection of generic extensions used across the codebase.
Inheritance
Inherited Members
Namespace: Telerik.Windows.Diagrams.Core
Assembly: Telerik.WinControls.RadDiagram.dll
Syntax
public static class CommonExtensions
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
|
System.Collections.Generic.ICollection<T>
collection
A collection to be augmented with the given items. |
|
System.Collections.Generic.IEnumerable<T>
newItems
The new items to add. |
Type Parameters
|
T
|
Exceptions
|
System.ArgumentNullException
Will be raised if either the |
ClearIfSet(RadObject, RadProperty)
Clears the property if a value has been set.
Declaration
public static bool ClearIfSet(this RadObject dependencyObject, RadProperty dependencyProperty)
Parameters
|
RadObject
dependencyObject
The dependency object. |
|
RadProperty
dependencyProperty
The dependency property to clear. |
Returns
|
System.Boolean
Returns |
Exceptions
|
System.ArgumentNullException
Will be raised if either the |
Clone(IEnumerable<Double>)
Clones the list of doubles and returns a DoubleCollection.
Declaration
public static List<double> Clone(this IEnumerable<double> doubles)
Parameters
|
System.Collections.Generic.IEnumerable<System.Double>
doubles
The list to clone. |
Returns
|
System.Collections.Generic.List<System.Double>
The cloned list. |
See Also
Clone(DoubleCollection)
Clones the list of doubles and returns a DoubleCollection.
Declaration
public static DoubleCollection Clone(this DoubleCollection doubles)
Parameters
|
DoubleCollection
doubles
The list to clone. |
Returns
|
DoubleCollection
The cloned list. |
See Also
Clone<T>(IEnumerable<T>)
Clones the list.
Declaration
public static IList<T> Clone<T>(this IEnumerable<T> list)
Parameters
|
System.Collections.Generic.IEnumerable<T>
list
The list to clone. |
Returns
|
System.Collections.Generic.IList<T>
The cloned list. |
Type Parameters
|
T
The data type of the list. |
Exceptions
|
System.ArgumentNullException
Will be raised if the underlying |
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
|
System.Collections.Generic.IEnumerable<T>
collection
A collection to be tested for the given items. |
|
System.Collections.Generic.IEnumerable<T>
otherCollection
The other collection. |
Returns
|
System.Boolean
|
Type Parameters
|
T
|
Exceptions
|
System.ArgumentNullException
Will be raised if either the |
EnsureListCount<T>(IList<T>, Int32, 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
|
System.Collections.Generic.IList<T>
list
The list to check. |
|
System.Int32
count
The expected count. |
|
System.Func<T>
factory
The factory function if more items need to be created. |
Returns
|
System.Boolean
Returns |
Type Parameters
|
T
The data type of the list. |
Exceptions
|
System.ArgumentNullException
Will be raised if the underlying |
EnsureListCountAtLeast<T>(IList<T>, Int32, 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
|
System.Collections.Generic.IList<T>
list
The list to check. |
|
System.Int32
count
The expected count. |
|
System.Func<T>
factory
The factory function if more items need to be created. |
Returns
|
System.Boolean
Returns |
Type Parameters
|
T
The data type of the list. |
Exceptions
|
System.ArgumentNullException
Will be raised if the underlying |
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
|
System.Collections.Generic.IEnumerable<T>
collection
The collection to iterate. |
|
System.Action<T>
action
The action to execute on each item. |
Type Parameters
|
T
|
Exceptions
|
System.ArgumentNullException
Will be raised if either the |
GetActualBounds(IDiagramItem, Boolean)
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
|
IDiagramItem
item
An IDiagramItem item. |
|
System.Boolean
isShapeActualBounds
Indicates whether to get the actual (rotated) shape bounds or the normal bounds. |
Returns
|
Rect
|
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
|
IDiagramItem
item
An IDiagramItem item. |
Returns
|
Rect
|
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
|
IDiagramItem
item
An IDiagramItem item. |
Returns
|
Rect
|
GetEnclosingBounds(IEnumerable<IDiagramItem>, Boolean, Boolean, Boolean)
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
|
System.Collections.Generic.IEnumerable<IDiagramItem>
items
The diagram items. |
|
System.Boolean
isGraphVirtualized
If set to |
|
System.Boolean
isShapeActualBounds
Indicates whether to get the actual (rotated) shape bounds or the normal bounds. |
|
System.Boolean
useControlBoundingRectangle
useControlBoundingRectangle |
Returns
|
Rect
|
GetEnclosingBoundsRotated(IEnumerable<IDiagramItem>)
Gets the enclosing bounds of the list of diagram items.
Declaration
public static Rect GetEnclosingBoundsRotated(this IEnumerable<IDiagramItem> items)
Parameters
|
System.Collections.Generic.IEnumerable<IDiagramItem>
items
The diagram items. |
Returns
|
Rect
|
GetEnclosingBoundsWithoutTransform(IEnumerable<IDiagramItem>, Boolean, Boolean, Boolean)
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
|
System.Collections.Generic.IEnumerable<IDiagramItem>
items
The diagram items. |
|
System.Boolean
isGraphVirtualized
If set to |
|
System.Boolean
isShapeActualBounds
Indicates whether to get the actual (rotated) shape bounds or the normal bounds. |
|
System.Boolean
useControlBoundingRectangle
|
Returns
|
Rect
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
|
RadObject
dependencyObject
The dependency object. |
|
RadProperty
property
The property. |
Returns
|
System.Boolean
|
See Also
RemoveLast<T>(IList<T>)
Removes the last item in the list.
Declaration
public static void RemoveLast<T>(this IList<T> list)
Parameters
|
System.Collections.Generic.IList<T>
list
The list. |
Type Parameters
|
T
The data type of the list. |
Exceptions
|
System.ArgumentNullException
Will be raised if the underlying |
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
|
RadObject
dependencyObject
The dependency object. |
|
RadProperty
dependencyProperty
The dependency property. |
|
System.Object
value
The value to set if currently different. |
Returns
|
System.Boolean
Return |
Exceptions
|
System.ArgumentNullException
Will be raised if either the |