ClassExtensionMethods
This class contains extension methods for layout operations in Telerik Windows Documents.
Definition
Namespace:Telerik.Windows.Documents.Layout
Assembly:Telerik.Windows.Controls.RichTextBox.dll
Syntax:
public static class ExtensionMethods
Inheritance: objectExtensionMethods
Methods
AddWidth(Size, Size)
Adds the width of two Size instances.
Declaration
public static Size AddWidth(this Size size1, Size size2)
Parameters
size1
Size
The first Size instance to be added.
size2
Size
The second Size instance to be added.
Returns
Size
A new Size instance that represents the total width of the two input sizes.
AreClose(RectangleF, RectangleF)
Determines whether two RectangleF instances are close to each other, based on their dimensions and positions.
Declaration
public static bool AreClose(this RectangleF rect1, RectangleF rect2)
Parameters
rect1
The first rectangle to compare.
rect2
The second rectangle to compare.
Returns
True if the two rectangles are considered close; otherwise, false.
BlendWith(Color, Color)
Blends two colors together using a specified blending algorithm.
Declaration
public static Color BlendWith(this Color color, Color backColor)
Parameters
color
Color
The first color to blend.
backColor
Color
The second color to blend.
Returns
Color
A new color that is the result of blending color and backColor.
Darker(Color)
Darkens the specified color by a certain factor.
Declaration
public static Color Darker(this Color color)
Parameters
color
Color
The color to be darkened.
Returns
Color
A new Color that is a darker version of the specified color.
Darker(Color, byte)
Darkens the specified color by a given amount.
Declaration
public static Color Darker(this Color color, byte factor)
Parameters
color
Color
The color to be darkened.
factor
The amount by which to darken the color, represented as a byte value.
Returns
Color
A new color that is darker than the original color.
GetAssociatedLayoutBox(UIElement)
Retrieves the associated layout box for the specified UI element.
Declaration
public static LayoutBox GetAssociatedLayoutBox(this UIElement element)
Parameters
element
UIElement
The UI element to retrieve the associated layout box for.
Returns
The associated layout box of type T if found; otherwise, null.
GetCurrentSectionBox(LayoutBox)
Retrieves the current section box for the specified layout box.
Declaration
public static SectionLayoutBox GetCurrentSectionBox(this LayoutBox box)
Parameters
box
The layout box from which to obtain the current section box.
Returns
Returns the current section box associated with the provided layout box.
GetElement<T>(HierarchicalIndex, RadDocument)
Retrieves an element of type T from the specified hierarchical index within the given RadDocument.
Declaration
public static T GetElement<T>(this HierarchicalIndex index, RadDocument document) where T : DocumentElement
Parameters
index
The hierarchical index from which to retrieve the element.
document
The RadDocument that contains the elements.
Returns
T
A value of type T representing the retrieved element, or the default value of T if not found.
GetLocation(Rect)
Retrieves the location of a specified rectangle within the layout.
Declaration
public static Point GetLocation(this Rect rect)
Parameters
rect
Rect
The rectangle whose location is to be retrieved.
Returns
Point
A Point representing the location of the specified rectangle.
GetSize(Rect)
Calculates the size of the specified rectangle.
Declaration
public static Size GetSize(this Rect rect)
Parameters
rect
Rect
The rectangle for which to calculate the size.
Returns
Size
A Size object representing the width and height of the rectangle.
IntersectsWith(Rect, Rect)
Determines whether two rectangles intersect with each other.
Declaration
public static bool IntersectsWith(this Rect rect, Rect rect1)
Parameters
rect
Rect
The first rectangle to check for intersection.
rect1
Rect
The second rectangle to check for intersection.
Returns
True if the two rectangles intersect; otherwise, false.
Lighter(Color)
Creates a lighter version of the specified Color.
Declaration
public static Color Lighter(this Color color)
Parameters
color
Color
The Color to be lightened.
Returns
Color
A new Color that is lighter than the original color.
Lighter(Color, byte)
Adjusts the brightness of the specified color by a certain amount.
Declaration
public static Color Lighter(this Color color, byte factor)
Parameters
color
Color
The color to be lightened.
factor
The amount by which to lighten the color. A positive value increases brightness.
Returns
Color
A new Color that is lighter than the original color by the specified amount.
LighterUsingHsl(Color)
Converts the specified color to a lighter shade using the HSL (Hue, Saturation, Lightness) method.
Declaration
public static Color LighterUsingHsl(this Color color)
Parameters
color
Color
The color to be lightened.
Returns
Color
A Color object representing the lighter shade of the specified color.
ProbeDequeue<T>(Queue<T>)
Retrieves and removes the object at the front of the specified queue, or returns the default value if the queue is empty.
Declaration
public static T ProbeDequeue<T>(this Queue<T> queue)
Parameters
queue
Queue<T>
The queue from which to dequeue the object.
Returns
T
The object at the front of the queue if available; otherwise, the default value for the type T.
ProbePeek<T>(Stack<T>)
Examines the top element of the specified stack without removing it, providing a way to check the value at the top without modifying the stack's state.
Declaration
public static T ProbePeek<T>(this Stack<T> stack)
Parameters
stack
Stack<T>
The stack from which to probe the top element.
Returns
T
The top element of the stack if it exists; otherwise, the default value of type T.
ProbePop<T>(Stack<T>)
Probes the specified stack of type T and retrieves the top element without removing it.
Declaration
public static T ProbePop<T>(this Stack<T> stack)
Parameters
stack
Stack<T>
The stack from which to probe the top element.
Returns
T
The top element of the stack if it exists; otherwise, the default value of type T.
SetAssociatedLayoutBox(UIElement, LayoutBox)
Sets the associated layout box for the specified UI element.
Declaration
public static void SetAssociatedLayoutBox(this UIElement element, LayoutBox value)
Parameters
element
UIElement
The UI element to associate with the layout box.
value
The layout box to be associated with the UI element.
SetSource(BitmapImage, Stream)
Sets the source of the specified BitmapImage from the given Stream.
Declaration
public static void SetSource(this BitmapImage bitmapImage, Stream imageStream)
Parameters
bitmapImage
BitmapImage
The BitmapImage to which the source will be set.
imageStream
The Stream that contains the image data.
SetSourceEx(BitmapImage, Stream, ref string)
Sets the source of the specified BitmapImage from the given Stream, updating the provided string reference if necessary.
Declaration
public static Stream SetSourceEx(this BitmapImage bitmapImage, Stream imageStream, ref string extension)
Parameters
bitmapImage
BitmapImage
The BitmapImage to set the source for.
imageStream
The Stream containing the image data.
extension
A reference to a string that can be updated with the new image extension.
Returns
Returns true if the source was successfully set, otherwise returns false.
SetSourceEx(BitmapImage, byte[], ref string)
Sets the source of a BitmapImage using a byte array and updates a reference string.
Declaration
public static byte[] SetSourceEx(this BitmapImage bitmapImage, byte[] imageBytes, ref string extension)
Parameters
bitmapImage
BitmapImage
The BitmapImage to set the source for.
imageBytes
byte[]
The byte array representing the source data.
extension
A reference string that may be modified by the method.
Returns
byte[]
A boolean value indicating whether the operation was successful.
Split(string, string)
Splits the input string into two parts based on the specified delimiter.
ToPadding(Thickness)
Converts a Thickness instance to a padding format suitable for layout purposes.
Declaration
public static Padding ToPadding(this Thickness thickness)
Parameters
thickness
Thickness
A Thickness structure that defines the padding values.
Returns
A Thickness instance representing the padding in the layout.
ToPoint(PointF)
Converts a PointF to a point representation used in layout.
ToPointF(Point)
Converts a Point to a PointF representation.
ToRect(RectangleF)
Converts a RectangleF to a Rect.
Declaration
public static Rect ToRect(this RectangleF rectangle)
Parameters
rectangle
The rectangle to be converted.
Returns
Rect
A Rect that represents the converted rectangle.
ToRectangleF(Rect)
Converts a Rect to a RectangleF.
Declaration
public static RectangleF ToRectangleF(this Rect rectangle)
Parameters
rectangle
Rect
The Rect instance to be converted.
Returns
A RectangleF that represents the converted rectangle.
ToSizeF(Size)
Converts a Size structure to a SizeF structure.
ToThickness(Padding)
Converts a Padding instance into a Thickness instance.
Declaration
public static Thickness ToThickness(this Padding padding)
Parameters
padding
The padding to convert.
Returns
Thickness
A Thickness that represents the converted padding.