skip navigation
  • Product Bundles

    DevCraft

    All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:

    • NEW: Design Kits for Figma
    • Online Training
    • Document Processing Library
    • Embedded Reporting for web and desktop

    Web

    Kendo UI UI for Angular UI for Vue UI for jQuery KendoReact UI for Blazor UI for ASP.NET Core UI for ASP.NET MVC UI for ASP.NET AJAX

    Mobile

    UI for .NET MAUI

    Document Management

    Telerik Document Processing

    Desktop

    UI for .NET MAUI UI for WinUI UI for WinForms UI for WPF

    Reporting

    Telerik Reporting Telerik Report Server

    Testing & Mocking

    Test Studio Telerik JustMock

    CMS

    Sitefinity

    AI Productivity Tools

    AI Coding Assistants

    UI/UX Tools

    ThemeBuilder Design System Kit Templates and Building Blocks

    Debugging

    Fiddler Fiddler Everywhere Fiddler Classic Fiddler Everywhere Reporter FiddlerCore

    Free Tools

    KendoReact Free VB.NET to C# Converter Testing Framework
    View all products
  • Overview
  • Demos
    • What's New
    • Roadmap
    • Release History
  • Support and Learning

    • Support and Learning Hub
    • First Steps
    • Docs
    • Demos
    • Virtual Classroom
    • Forums
    • Videos
    • Blogs
    • Accessibility
    • Submit a Ticket

    Productivity and Design Tools

    • Visual Studio Extensions
    • Visual Studio Templates
    • Embedded Reporting
  • Pricing
  • Shopping cart
    • Account Overview
    • Your Licenses
    • Downloads
    • Support Center
    • Forum Profile
    • Payment Methods
    • Edit Profile
    • Log out
  • Login
  • Contact Us
  • Try now

Class ExtensionMethods

This class contains extension methods for layout operations in Telerik Windows Documents.

Inheritance
System.Object
ExtensionMethods
Namespace: Telerik.Windows.Documents.Layout
Assembly: Telerik.Windows.Controls.RichTextBox.dll

Syntax

public static class ExtensionMethods : Object

Methods

AddWidth(Size, Size)

Adds the width of two System.Windows.Size instances.

Declaration
public static Size AddWidth(this Size size1, Size size2)
Parameters
System.Windows.Size size1

The first System.Windows.Size instance to be added.

System.Windows.Size size2

The second System.Windows.Size instance to be added.

Returns
System.Windows.Size

A new System.Windows.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
RectangleF rect1

The first rectangle to compare.

RectangleF rect2

The second rectangle to compare.

Returns
System.Boolean

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
System.Windows.Media.Color color

The first color to blend.

System.Windows.Media.Color backColor

The second color to blend.

Returns
System.Windows.Media.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
System.Windows.Media.Color color

The color to be darkened.

Returns
System.Windows.Media.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
System.Windows.Media.Color color

The color to be darkened.

System.Byte factor

The amount by which to darken the color, represented as a byte value.

Returns
System.Windows.Media.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
System.Windows.UIElement element

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
public static SectionLayoutBox GetCurrentSectionBox(this LayoutBox box)
Parameters
LayoutBox box

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
public static T GetElement<T>(this HierarchicalIndex index, RadDocument document)
    where T : DocumentElement
Parameters
HierarchicalIndex index

The hierarchical index from which to retrieve the element.

RadDocument 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.

Type Parameters
T

GetLocation(Rect)

Retrieves the location of a specified rectangle within the layout.

Declaration
public static Point GetLocation(this Rect rect)
Parameters
System.Windows.Rect rect

The rectangle whose location is to be retrieved.

Returns
System.Windows.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
System.Windows.Rect rect

The rectangle for which to calculate the size.

Returns
System.Windows.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
System.Windows.Rect rect

The first rectangle to check for intersection.

System.Windows.Rect rect1

The second rectangle to check for intersection.

Returns
System.Boolean

True if the two rectangles intersect; otherwise, false.

Lighter(Color)

Creates a lighter version of the specified System.Windows.Media.Color.

Declaration
public static Color Lighter(this Color color)
Parameters
System.Windows.Media.Color color

The System.Windows.Media.Color to be lightened.

Returns
System.Windows.Media.Color

A new System.Windows.Media.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
System.Windows.Media.Color color

The color to be lightened.

System.Byte factor

The amount by which to lighten the color. A positive value increases brightness.

Returns
System.Windows.Media.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
System.Windows.Media.Color color

The color to be lightened.

Returns
System.Windows.Media.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
System.Collections.Generic.Queue<T> queue

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.

Type Parameters
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
System.Collections.Generic.Stack<T> stack

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.

Type Parameters
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
System.Collections.Generic.Stack<T> stack

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.

Type Parameters
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
System.Windows.UIElement element

The UI element to associate with the layout box.

LayoutBox 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
System.Windows.Media.Imaging.BitmapImage bitmapImage

The BitmapImage to which the source will be set.

System.IO.Stream imageStream

The Stream that contains the image data.

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
System.Windows.Media.Imaging.BitmapImage bitmapImage

The BitmapImage to set the source for.

System.Byte[] imageBytes

The byte array representing the source data.

System.String extension

A reference string that may be modified by the method.

Returns
System.Byte[]

A boolean value indicating whether the operation was successful.

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
System.Windows.Media.Imaging.BitmapImage bitmapImage

The BitmapImage to set the source for.

System.IO.Stream imageStream

The Stream containing the image data.

System.String extension

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

Returns
System.IO.Stream

Returns true if the source was successfully set, otherwise returns false.

Split(String, String)

Splits the input string into two parts based on the specified delimiter.

Declaration
public static string[] Split(this string input, string separator)
Parameters
System.String input

The string to be split.

System.String separator

The string that delimits the split.

Returns
System.String[]

A tuple containing the two segments of the split string.

ToPadding(Thickness)

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

Declaration
public static Padding ToPadding(this Thickness thickness)
Parameters
System.Windows.Thickness thickness

A System.Windows.Thickness structure that defines the padding values.

Returns
Padding

A System.Windows.Thickness instance representing the padding in the layout.

ToPoint(PointF)

Converts a PointF to a point representation used in layout.

Declaration
public static Point ToPoint(this PointF point)
Parameters
PointF point

The PointF instance to be converted.

Returns
System.Windows.Point

A point representation of the provided PointF.

ToPointF(Point)

Converts a System.Windows.Point to a PointF representation.

Declaration
public static PointF ToPointF(this Point point)
Parameters
System.Windows.Point point

The System.Windows.Point to be converted.

Returns
PointF

A PointF that represents the specified System.Windows.Point.

ToRect(RectangleF)

Converts a RectangleF to a System.Windows.Rect.

Declaration
public static Rect ToRect(this RectangleF rectangle)
Parameters
RectangleF rectangle

The rectangle to be converted.

Returns
System.Windows.Rect

A System.Windows.Rect that represents the converted rectangle.

ToRectangleF(Rect)

Converts a System.Windows.Rect to a RectangleF.

Declaration
public static RectangleF ToRectangleF(this Rect rectangle)
Parameters
System.Windows.Rect rectangle

The System.Windows.Rect instance to be converted.

Returns
RectangleF

A RectangleF that represents the converted rectangle.

ToSizeF(Size)

Converts a System.Windows.Size structure to a SizeF structure.

Declaration
public static SizeF ToSizeF(this Size size)
Parameters
System.Windows.Size size

The System.Windows.Size structure to be converted.

Returns
SizeF

A SizeF structure that represents the converted size.

ToThickness(Padding)

Converts a Padding instance into a System.Windows.Thickness instance.

Declaration
public static Thickness ToThickness(this Padding padding)
Parameters
Padding padding

The padding to convert.

Returns
System.Windows.Thickness

A System.Windows.Thickness that represents the converted padding.

Getting Started
  • Install Now
  • Demos
  • SDK Samples Browser
  • Sample Applications
Support Resources
  • Code Library
  • Knowledge Base
  • MVVM Support
  • Videos
  • GitHub SDK Repository
Community
  • Forums
  • Blogs
  • XAML Feedback Portal
  • Document Processing Feedback Portal

Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.