TelerikAlignHelper
Provides static utility methods for alignment and positioning calculations in Telerik WinControls.
Definition
Namespace:Telerik.WinControls
Assembly:Telerik.WinControls.dll
Syntax:
public class TelerikAlignHelper
Inheritance: objectTelerikAlignHelper
Constructors
public TelerikAlignHelper()
Methods
Converts a ContentAlignment value to the corresponding TextImageRelation for image positioning.
public static TextImageRelation ImageAlignToRelation(ContentAlignment alignment)
The content alignment value representing where the image should be positioned.
Returns:A TextImageRelation value indicating the spatial relationship between image and text based on the specified alignment.
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.
Translates a ContentAlignment value for right-to-left (RTL) layout by flipping horizontal alignments.
public static ContentAlignment RtlTranslateContent(ContentAlignment align)
The content alignment value to translate for RTL layout.
Returns:The translated ContentAlignment with horizontal alignment flipped: left alignments become right alignments and vice versa, while center and non-horizontal alignments remain unchanged.
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.
Translates a TextImageRelation value for right-to-left (RTL) layout by flipping horizontal relationships.
public static TextImageRelation RtlTranslateRelation(TextImageRelation relation)
The text-image relation to translate for RTL layout.
Returns:The translated TextImageRelation with horizontal relationships flipped: ImageBeforeText becomes TextBeforeImage and vice versa, while other relations remain unchanged.
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
Converts a ContentAlignment value to the corresponding TextImageRelation for text positioning.
public static TextImageRelation TextAlignToRelation(ContentAlignment alignment)
The content alignment value representing where the text should be positioned.
Returns:A TextImageRelation value indicating the spatial relationship between text and image based on the specified text alignment preference.
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.
Converts a ContentAlignment value to the corresponding StringAlignment for horizontal alignment in GDI+ rendering.
public static StringAlignment TranslateAlignment(ContentAlignment align)
The content alignment value to convert.
Returns:A StringAlignment value representing the horizontal alignment: Far for right alignments, Center for center alignments, or Near for left alignments.
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
Converts a ContentAlignment value to the corresponding TextFormatFlags for vertical text alignment in GDI rendering.
public static TextFormatFlags TranslateAlignmentForGDI(ContentAlignment align)
The content alignment value to convert.
Returns:A TextFormatFlags value representing the vertical alignment: Bottom for bottom alignments, VerticalCenter for middle alignments, or GlyphOverhangPadding for top alignments.
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)
Converts a ContentAlignment value to the corresponding StringAlignment for vertical line alignment in GDI+ rendering.
public static StringAlignment TranslateLineAlignment(ContentAlignment align)
The content alignment value to convert.
Returns:A StringAlignment value representing the vertical alignment: Far for bottom alignments, Center for middle alignments, or Near for top alignments.
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
Converts a ContentAlignment value to the corresponding TextFormatFlags for horizontal text alignment in GDI rendering.
public static TextFormatFlags TranslateLineAlignmentForGDI(ContentAlignment align)
The content alignment value to convert.
Returns:A TextFormatFlags value representing the horizontal alignment: Right for right alignments, HorizontalCenter for center alignments, or GlyphOverhangPadding for left alignments.
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)