Class
ExtensionMethods

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:

cs-api-definition
public static class ExtensionMethods

Inheritance: objectExtensionMethods

Methods

AddWidth(Size, Size)

Adds the width of two Size instances.

Declaration

cs-api-definition
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

cs-api-definition
public static bool AreClose(this RectangleF rect1, RectangleF rect2)

Parameters

rect1

RectangleF

The first rectangle to compare.

rect2

RectangleF

The second rectangle to compare.

Returns

bool

True if the two rectangles are considered close; otherwise, false.

BlendWith(Color, Color)

Blends two colors together using a specified blending algorithm.

Declaration

cs-api-definition
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

cs-api-definition
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

cs-api-definition
public static Color Darker(this Color color, byte factor)

Parameters

color

Color

The color to be darkened.

factor

byte

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

cs-api-definition
public static LayoutBox GetAssociatedLayoutBox(this UIElement element)

Parameters

element

UIElement

The UI element to retrieve the associated layout box for.

Returns

LayoutBox

The associated layout box of type T if found; otherwise, null.

GetCurrentSectionBox(LayoutBox)

Retrieves the current section box for the specified layout box.

Declaration

cs-api-definition
public static SectionLayoutBox GetCurrentSectionBox(this LayoutBox box)

Parameters

box

LayoutBox

The layout box from which to obtain the current section box.

Returns

SectionLayoutBox

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

cs-api-definition
public static T GetElement<T>(this HierarchicalIndex index, RadDocument document) where T : DocumentElement

Parameters

index

HierarchicalIndex

The hierarchical index from which to retrieve the element.

document

RadDocument

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

cs-api-definition
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

cs-api-definition
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

cs-api-definition
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

bool

True if the two rectangles intersect; otherwise, false.

Lighter(Color)

Creates a lighter version of the specified Color.

Declaration

cs-api-definition
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

cs-api-definition
public static Color Lighter(this Color color, byte factor)

Parameters

color

Color

The color to be lightened.

factor

byte

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

cs-api-definition
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

cs-api-definition
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

cs-api-definition
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

cs-api-definition
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

cs-api-definition
public static void SetAssociatedLayoutBox(this UIElement element, LayoutBox value)

Parameters

element

UIElement

The UI element to associate with the layout box.

value

LayoutBox

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

cs-api-definition
public static void SetSource(this BitmapImage bitmapImage, Stream imageStream)

Parameters

bitmapImage

BitmapImage

The BitmapImage to which the source will be set.

imageStream

Stream

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

cs-api-definition
public static Stream SetSourceEx(this BitmapImage bitmapImage, Stream imageStream, ref string extension)

Parameters

bitmapImage

BitmapImage

The BitmapImage to set the source for.

imageStream

Stream

The Stream containing the image data.

extension

string

A reference to a string that can be updated with the new image extension.

Returns

Stream

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

cs-api-definition
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

string

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.

Declaration

cs-api-definition
public static string[] Split(this string input, string separator)

Parameters

input

string

The string to be split.

separator

string

The string that delimits the split.

Returns

string[]

A tuple containing the two segments of the split string.

ToPadding(Thickness)

Converts a Thickness instance to a padding format suitable for layout purposes.

Declaration

cs-api-definition
public static Padding ToPadding(this Thickness thickness)

Parameters

thickness

Thickness

A Thickness structure that defines the padding values.

Returns

Padding

A Thickness instance representing the padding in the layout.

ToPoint(PointF)

Converts a PointF to a point representation used in layout.

Declaration

cs-api-definition
public static Point ToPoint(this PointF point)

Parameters

point

PointF

The PointF instance to be converted.

Returns

Point

A point representation of the provided PointF.

ToPointF(Point)

Converts a Point to a PointF representation.

Declaration

cs-api-definition
public static PointF ToPointF(this Point point)

Parameters

point

Point

The Point to be converted.

Returns

PointF

A PointF that represents the specified Point.

ToRect(RectangleF)

Converts a RectangleF to a Rect.

Declaration

cs-api-definition
public static Rect ToRect(this RectangleF rectangle)

Parameters

rectangle

RectangleF

The rectangle to be converted.

Returns

Rect

A Rect that represents the converted rectangle.

ToRectangleF(Rect)

Converts a Rect to a RectangleF.

Declaration

cs-api-definition
public static RectangleF ToRectangleF(this Rect rectangle)

Parameters

rectangle

Rect

The Rect instance to be converted.

Returns

RectangleF

A RectangleF that represents the converted rectangle.

ToSizeF(Size)

Converts a Size structure to a SizeF structure.

Declaration

cs-api-definition
public static SizeF ToSizeF(this Size size)

Parameters

size

Size

The Size structure to be converted.

Returns

SizeF

A SizeF structure that represents the converted size.

ToThickness(Padding)

Converts a Padding instance into a Thickness instance.

Declaration

cs-api-definition
public static Thickness ToThickness(this Padding padding)

Parameters

padding

Padding

The padding to convert.

Returns

Thickness

A Thickness that represents the converted padding.