New to Telerik UI for WinForms? Start a free 30-day trial

Provides geometry, layout, color, and image helpers used by RichTextEditor.

Definition

Namespace:Telerik.WinForms.Documents.Layout

Assembly:Telerik.WinControls.RichTextEditor.dll

Syntax:

C#
public static class ExtensionMethods

Inheritance: objectExtensionMethods

Methods

Combines two sizes by summing their widths and keeping the greater height.

C#
public static Size AddWidth(this Size size1, Size size2)
Parameters:size1Size

The first size.

size2Size

The second size.

Returns:

Size

A size whose width is the sum and whose height is the larger input height.

Compares the rectangles' locations and dimensions using floating-point tolerance.

C#
public static bool AreClose(this RectangleF rect1, RectangleF rect2)
Parameters:rect1RectangleF

The first rectangle to compare.

rect2RectangleF

The second rectangle to compare.

Returns:

bool

true when all four components are close; otherwise, false.

Returns the opaque midpoint blend of the two colors' RGB channels.

C#
public static Color BlendWith(this Color color, Color backColor)
Parameters:colorColor

The foreground color.

backColorColor

The background color.

Returns:

Color

A color with each RGB channel averaged and alpha set to 255.

Subtracts a fixed amount from each RGB channel, clamping at zero while preserving alpha.

C#
public static Color Darker(this Color color, byte factor)
Parameters:colorColor

The color to darken.

factorbyte

The amount subtracted from each RGB channel.

Returns:

Color

The darkened color.

Darkens each RGB channel by 24, clamping at zero while preserving alpha.

C#
public static Color Darker(this Color color)
Parameters:colorColor

The color to darken.

Returns:

Color

The darkened color.

Gets the layout box previously associated with a UI element.

C#
public static LayoutBox GetAssociatedLayoutBox(this UIElement element)
Parameters:elementUIElement

The UI element whose layout-box association is queried.

Returns:

LayoutBox

The associated layout box, or null when none is assigned.

Walks up the layout-box parent chain to find the containing section.

C#
public static SectionLayoutBox GetCurrentSectionBox(this LayoutBox box)
Parameters:boxLayoutBox

The layout box from which to begin the search.

Returns:

SectionLayoutBox

The first section box in the chain, including box, or null if no section is found.

Resolves a hierarchical document index through the document layout and returns its associated element.

C#
public static T GetElement<T>(this HierarchicalIndex index, RadDocument document) where T : DocumentElement
Parameters:indexHierarchicalIndex

The hierarchical index to resolve.

documentRadDocument

The document whose layout is searched.

Returns:

T

The indexed element when it has type T; otherwise, null.

C#
public static Point GetLocation(this Rect rect)
Parameters:rectRectReturns:

Point

C#
public static Size GetSize(this Rect rect)
Parameters:rectRectReturns:

Size

Determines whether intersecting the two rectangles produces a non-empty rectangle.

C#
public static bool IntersectsWith(this Rect rect, Rect rect1)
Parameters:rectRect

The first rectangle.

rect1Rect

The second rectangle.

Returns:

bool

true when the intersection is non-empty; otherwise, false.

Adds a fixed amount to each RGB channel, clamping at 255 while preserving alpha.

C#
public static Color Lighter(this Color color, byte factor)
Parameters:colorColor

The color to lighten.

factorbyte

The amount added to each RGB channel.

Returns:

Color

The lightened color.

Lightens each RGB channel by 24, clamping at 255 while preserving alpha.

C#
public static Color Lighter(this Color color)
Parameters:colorColor

The color to lighten.

Returns:

Color

The lightened color.

Converts the color to HLSA, sets luminance to 0.86, and converts it back; the current implementation uses the source saturation as the output alpha.

C#
public static Color LighterUsingHsl(this Color color)
Parameters:colorColor

The color to adjust.

Returns:

Color

The converted color.

Removes and returns the next queue item when one is available.

C#
public static T ProbeDequeue<T>(this Queue<T> queue)
Parameters:queueQueue<T>

The queue to inspect.

Returns:

T

The removed item, or the default value of T when the queue is empty.

Returns the top stack item without throwing when the stack is empty.

C#
public static T ProbePeek<T>(this Stack<T> stack)
Parameters:stackStack<T>

The stack to inspect.

Returns:

T

The top item, or the default value of T when the stack is empty.

Removes and returns the top stack item when one is available.

C#
public static T ProbePop<T>(this Stack<T> stack)
Parameters:stackStack<T>

The stack to inspect.

Returns:

T

The removed item, or the default value of T when the stack is empty.

Associates a layout box with a UI element so layout-aware UI providers can retrieve it later.

C#
public static void SetAssociatedLayoutBox(this UIElement element, LayoutBox value)
Parameters:elementUIElement

The UI element that hosts the layout box.

valueLayoutBox

The layout box to associate, or null to clear the association.

Copies the remaining stream content into a memory stream and assigns it as the bitmap source.

C#
public static void SetSource(this BitmapImage bitmapImage, Stream imageStream)
Parameters:bitmapImageBitmapImage

The bitmap whose source is assigned.

imageStreamStream

The stream containing the image data.

Loads image bytes into the bitmap and returns the bytes from the stream used for loading.

C#
public static byte[] SetSourceEx(this BitmapImage bitmapImage, byte[] imageBytes, ref string extension)
Parameters:bitmapImageBitmapImage

The bitmap whose source is assigned.

imageBytesbyte[]

The encoded image data.

extensionstring

The source file extension; it is lowercased and changed to png when conversion succeeds.

Returns:

byte[]

The data from the stream used to load the bitmap, including PNG data when conversion occurs.

Loads an image stream, converting formats unsupported by the current platform to PNG when the matching decoder returns bitmap data.

C#
public static Stream SetSourceEx(this BitmapImage bitmapImage, Stream imageStream, ref string extension)
Parameters:bitmapImageBitmapImage

The bitmap whose source is assigned.

imageStreamStream

The encoded image data stream.

extensionstring

The source file extension; it is lowercased and changed to png when conversion succeeds.

Returns:

Stream

The stream used for loading; after successful conversion this is the encoded PNG stream.

Splits a string on the specified separator while preserving empty entries.

C#
public static string[] Split(this string input, string separator)
Parameters:inputstring

The string to split.

separatorstring

The separator string.

Returns:

string[]

The substrings produced by the split, including empty substrings.

Creates a Padding from a thickness by rounding each side to the nearest integer.

C#
public static Padding ToPadding(this Thickness thickness)
Parameters:thicknessThickness

The thickness whose sides are converted.

Returns:

Padding

A padding with independently rounded left, top, right, and bottom values.

C#
public static Point ToPoint(this PointF point)
Parameters:pointPointFReturns:

Point

C#
public static PointF ToPointF(this Point point)
Parameters:pointPointReturns:

PointF

C#
public static Rect ToRect(this RectangleF rectangle)
Parameters:rectangleRectangleFReturns:

Rect

C#
public static RectangleF ToRectangleF(this Rect rectangle)
Parameters:rectangleRectReturns:

RectangleF

C#
public static SizeF ToSizeF(this Size size)
Parameters:sizeSizeReturns:

SizeF

Copies the padding's left, top, right, and bottom values into the corresponding thickness sides without rounding.

C#
public static Thickness ToThickness(this Padding padding)
Parameters:paddingPadding

The padding values to convert.

Returns:

Thickness

A thickness with the same values for each side.