Class
TelerikAlignHelper

Provides static utility methods for alignment and positioning calculations in Telerik WinControls.

Definition

Namespace:Telerik.WinControls

Assembly:Telerik.WinControls.dll

Syntax:

cs-api-definition
public class TelerikAlignHelper

Inheritance: objectTelerikAlignHelper

Constructors

TelerikAlignHelper()

Declaration

cs-api-definition
public TelerikAlignHelper()

Methods

ImageAlignToRelation(ContentAlignment)

Converts a ContentAlignment value to the corresponding TextImageRelation for image positioning.

Declaration

cs-api-definition
public static TextImageRelation ImageAlignToRelation(ContentAlignment alignment)

Parameters

alignment

ContentAlignment

The content alignment value representing where the image should be positioned.

Returns

TextImageRelation

A TextImageRelation value indicating the spatial relationship between image and text based on the specified alignment.

Remarks

This method uses a pre-computed lookup table to quickly determine the appropriate text-image relationship based on how the image should be aligned. The conversion considers both horizontal and vertical positioning preferences.

This is useful when you have an image alignment preference and need to determine how the image should be positioned relative to text content for optimal layout.

RtlTranslateContent(ContentAlignment)

Translates a ContentAlignment value for right-to-left (RTL) layout by flipping horizontal alignments.

Declaration

cs-api-definition
public static ContentAlignment RtlTranslateContent(ContentAlignment align)

Parameters

align

ContentAlignment

The content alignment value to translate for RTL layout.

Returns

ContentAlignment

The translated ContentAlignment with horizontal alignment flipped: left alignments become right alignments and vice versa, while center and non-horizontal alignments remain unchanged.

Remarks

This method is essential for supporting right-to-left languages and layouts. It automatically flips horizontal alignments while preserving vertical alignment information.

Translation examples:

  • TopLeft ↔ TopRight
  • MiddleLeft ↔ MiddleRight
  • BottomLeft ↔ BottomRight
  • Center alignments and non-horizontal alignments remain unchanged

This method is commonly used in RTL-aware controls to automatically adjust alignment behavior based on the current reading direction.

RtlTranslateRelation(TextImageRelation)

Translates a TextImageRelation value for right-to-left (RTL) layout by flipping horizontal relationships.

Declaration

cs-api-definition
public static TextImageRelation RtlTranslateRelation(TextImageRelation relation)

Parameters

relation

TextImageRelation

The text-image relation to translate for RTL layout.

Returns

TextImageRelation

The translated TextImageRelation with horizontal relationships flipped: ImageBeforeText becomes TextBeforeImage and vice versa, while other relations remain unchanged.

Remarks

This method ensures that text-image relationships are properly adjusted for right-to-left layouts. In RTL languages, the concept of "before" and "after" is reversed horizontally.

Translation logic:

  • ImageBeforeText → TextBeforeImage
  • TextBeforeImage → ImageBeforeText
  • All other relations (vertical or overlay) remain unchanged

TextAlignToRelation(ContentAlignment)

Converts a ContentAlignment value to the corresponding TextImageRelation for text positioning.

Declaration

cs-api-definition
public static TextImageRelation TextAlignToRelation(ContentAlignment alignment)

Parameters

alignment

ContentAlignment

The content alignment value representing where the text should be positioned.

Returns

TextImageRelation

A TextImageRelation value indicating the spatial relationship between text and image based on the specified text alignment preference.

Remarks

This method first determines what the image relationship would be for the given alignment using ImageAlignToRelation(ContentAlignment), then returns the opposite relationship to represent where the text should be positioned relative to the image.

This is useful when you have a text alignment preference and need to determine how the text should be positioned relative to image content for optimal layout.

TranslateAlignment(ContentAlignment)

Converts a ContentAlignment value to the corresponding StringAlignment for horizontal alignment in GDI+ rendering.

Declaration

cs-api-definition
public static StringAlignment TranslateAlignment(ContentAlignment align)

Parameters

align

ContentAlignment

The content alignment value to convert.

Returns

StringAlignment

A StringAlignment value representing the horizontal alignment: Far for right alignments, Center for center alignments, or Near for left alignments.

Remarks

This method extracts the horizontal component of a ContentAlignment and translates it to the appropriate StringAlignment for use with GDI+ text rendering methods like Graphics.DrawString.

The conversion logic:

  • TopRight, MiddleRight, BottomRight → StringAlignment.Far
  • TopCenter, MiddleCenter, BottomCenter → StringAlignment.Center
  • TopLeft, MiddleLeft, BottomLeft → StringAlignment.Near

TranslateAlignmentForGDI(ContentAlignment)

Converts a ContentAlignment value to the corresponding TextFormatFlags for vertical text alignment in GDI rendering.

Declaration

cs-api-definition
public static TextFormatFlags TranslateAlignmentForGDI(ContentAlignment align)

Parameters

align

ContentAlignment

The content alignment value to convert.

Returns

TextFormatFlags

A TextFormatFlags value representing the vertical alignment: Bottom for bottom alignments, VerticalCenter for middle alignments, or GlyphOverhangPadding for top alignments.

Remarks

This method extracts the vertical component of a ContentAlignment and translates it to the appropriate TextFormatFlags for use with GDI text rendering methods like TextRenderer.DrawText.

The conversion logic:

  • BottomLeft, BottomCenter, BottomRight → TextFormatFlags.Bottom
  • MiddleLeft, MiddleCenter, MiddleRight → TextFormatFlags.VerticalCenter
  • TopLeft, TopCenter, TopRight → TextFormatFlags.GlyphOverhangPadding (default)

TranslateLineAlignment(ContentAlignment)

Converts a ContentAlignment value to the corresponding StringAlignment for vertical line alignment in GDI+ rendering.

Declaration

cs-api-definition
public static StringAlignment TranslateLineAlignment(ContentAlignment align)

Parameters

align

ContentAlignment

The content alignment value to convert.

Returns

StringAlignment

A StringAlignment value representing the vertical alignment: Far for bottom alignments, Center for middle alignments, or Near for top alignments.

Remarks

This method extracts the vertical component of a ContentAlignment and translates it to the appropriate StringAlignment for use with GDI+ text rendering methods as the LineAlignment property.

The conversion logic:

  • BottomLeft, BottomCenter, BottomRight → StringAlignment.Far
  • MiddleLeft, MiddleCenter, MiddleRight → StringAlignment.Center
  • TopLeft, TopCenter, TopRight → StringAlignment.Near

TranslateLineAlignmentForGDI(ContentAlignment)

Converts a ContentAlignment value to the corresponding TextFormatFlags for horizontal text alignment in GDI rendering.

Declaration

cs-api-definition
public static TextFormatFlags TranslateLineAlignmentForGDI(ContentAlignment align)

Parameters

align

ContentAlignment

The content alignment value to convert.

Returns

TextFormatFlags

A TextFormatFlags value representing the horizontal alignment: Right for right alignments, HorizontalCenter for center alignments, or GlyphOverhangPadding for left alignments.

Remarks

This method extracts the horizontal component of a ContentAlignment and translates it to the appropriate TextFormatFlags for use with GDI text rendering methods.

The conversion logic:

  • TopRight, MiddleRight, BottomRight → TextFormatFlags.Right
  • TopCenter, MiddleCenter, BottomCenter → TextFormatFlags.HorizontalCenter
  • TopLeft, MiddleLeft, BottomLeft → TextFormatFlags.GlyphOverhangPadding (default)