The primary element of the RadSyntaxEditor control that provides syntax highlighting, text editing, and code visualization capabilities.
Definition
Namespace:Telerik.WinControls.UI
Assembly:Telerik.WinControls.SyntaxEditor.dll
Syntax:
public class RadSyntaxEditorElement : FrameworkElement, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IStylableNode, ISupportDrop, ITextDocumentEditor, IDisposable
Inheritance: objectDisposableObjectRadObjectRadElementVisualElementUIElementFrameworkElementRadSyntaxEditorElement...
Implements:
Inherited Members
Constructors
Initializes a new instance of the RadSyntaxEditorElement class with default settings for syntax highlighting and text editing.
public RadSyntaxEditorElement()
Fields
Registers the AcceptsReturn property.
public static readonly RadProperty AcceptsReturnProperty
Registers the AllowScaling dependency property.
public static readonly RadProperty AllowScalingProperty
public static readonly RadProperty BorderColorProperty
Registers the CaretBrush dependency property.
public static readonly RadProperty CaretBrushProperty
public static readonly string DEFAULT_NAMESPACE
Registers the EditorFontFamily dependency property.
public static readonly RadProperty EditorFontFamilyProperty
Registers the EditorFontSize dependency property.
public static readonly RadProperty EditorFontSizeProperty
Registers the dependency property.
public static readonly RadProperty EditorFontStretchProperty
Registers the dependency property.
public static readonly RadProperty EditorFontStyleProperty
Registers the dependency property.
public static readonly RadProperty EditorFontWeightProperty
Registers the HorizontalScrollBarVisibility dependency property.
public static readonly RadProperty HorizontalScrollBarVisibilityProperty
Registers the IndentProvider property.
public static readonly RadProperty IndentProviderProperty
Registers the InsertMode property.
public static readonly RadProperty InsertModeProperty
Registers the IsCaretVisible dependency property.
public static readonly RadProperty IsCaretVisibleProperty
Registers the IsReadOnly property.
public static readonly RadProperty IsReadOnlyProperty
Registers the IsSelectionEnabled dependency property.
public static readonly RadProperty IsSelectionEnabledProperty
Registers the IsWordWrapEnabledProperty dependency property.
public static readonly RadProperty IsWordWrapEnabledProperty
Registers the Palette dependency property.
public static readonly RadProperty PaletteProperty
Registers the ScaleFactor dependency property.
public static readonly RadProperty ScaleFactorProperty
public static readonly RadProperty SelectionFillColorProperty
Registers the SelectionFill dependency property.
public static readonly RadProperty SelectionFillProperty
public static readonly RadProperty SelectionStrokeColorProperty
Registers the SelectionStroke dependency property.
public static readonly RadProperty SelectionStrokeProperty
Registers the ShouldTaggersProcessEntireLinesProperty dependency property.
public static readonly RadProperty ShouldTaggersProcessEntireLinesProperty
Registers the ShowLineNumbers dependency property.
public static readonly RadProperty ShowLineNumbersProperty
Registers the VerticalScrollBarVisibility dependency property.
public static readonly RadProperty VerticalScrollBarVisibilityProperty
Properties
Gets or sets a value indicating whether [accepts return].
public bool AcceptsReturn { get; set; }
true if [accepts return]; otherwise, false.
Gets or sets a value indicating whether the content of the syntax editor can be scaled (zoomed in or out).
public bool AllowScaling { get; set; }
Gets or sets the color of the border around the syntax editor.
[VsbBrowsable(true)]
public Color BorderColor { get; set; }
Gets or sets the brush used to render the text cursor (caret) in the syntax editor.
public Brush CaretBrush { get; set; }
Gets or sets the color of the text cursor (caret) in the syntax editor.
public Color CaretColor { get; set; }
Gets or sets the visual style of the text cursor (caret) in the syntax editor, such as block, underline, or normal vertical line.
public CaretDisplayMode CaretDisplayMode { get; set; }
Gets the current position of the text cursor (caret) within the document.
public CaretPosition CaretPosition { get; }
Gets or sets the width of the text cursor (caret) in the syntax editor.
public double CaretWidth { get; set; }
Gets the collection of available editor commands that can be executed on this syntax editor.
public SyntaxEditorCommands Commands { get; }
Gets or sets the current insert mode.
public string CurrentInsertMode { get; set; }
The current insert mode.
Gets or sets the text document that is being displayed and edited in the syntax editor.
public TextDocument Document { get; set; }
Implements:
Gets or sets the font family used to render text in the syntax editor.
public FontFamily EditorFontFamily { get; set; }
Gets or sets the font size used to render text in the syntax editor.
public double EditorFontSize { get; set; }
Gets the presenter component responsible for rendering and displaying the text content in the syntax editor.
public SyntaxEditorPresenter EditorPresenter { get; }
Gets the component responsible for handling code folding functionality, allowing collapsing and expanding of code regions.
public FoldingManager FoldingManager { get; }
Gets the horizontal scroll bar element that enables scrolling through content that extends beyond the visible width of the editor.
public RadScrollBarElement HorizontalScrollBar { get; }
Gets or sets the indent provider.
public ISmartIndentProvider IndentProvider { get; set; }
The indent provider.
Gets or sets an instance of SyntaxEditorInputBehavior that will handle user input.
public SyntaxEditorInputBehavior InputHandler { get; set; }
Gets the intelli prompts.
public SyntaxEditorIntelliPrompts IntelliPrompts { get; }
The intelli prompts.
Gets or sets a value indicating whether the text cursor (caret) is visible in the syntax editor.
public bool IsCaretVisible { get; set; }
Gets a value indicating whether this instance is in undo group.
public bool IsInUndoGroup { get; }
true if this instance is in undo group; otherwise, false.
Gets or sets a value indicating whether this instance is overwrite mode enabled.
public bool IsOverwriteModeEnabled { get; set; }
true if this instance is overwrite mode enabled; otherwise, false.
Gets or sets a value indicating whether this instance is read only.
public bool IsReadOnly { get; set; }
true if this instance is read only; otherwise, false.
Gets or sets a value indicating whether text selection is enabled in the syntax editor.
public bool IsSelectionEnabled { get; set; }
Gets or sets a value indicating whether text should automatically wrap to the next line when it exceeds the width of the editor.
public bool IsWordWrapEnabled { get; set; }
Gets the margins collection that defines the space around the text content in the syntax editor.
public SyntaxEditorMargins Margins { get; }
Gets or sets the palette of syntax elements' colors used for this RadSyntaxEditorElement instance.
public SyntaxEditorPalette Palette { get; set; }
Gets the collection of properties that control the behavior and appearance of the syntax editor.
public SyntaxEditorProperties Properties { get; }
Gets or sets the zoom level of the syntax editor content as a multiplier value (1.0 is normal size, 2.0 is double size, etc.).
public double ScaleFactor { get; set; }
Gets the popup control that provides find and replace functionality in the editor.
public FindReplacePopup SearchPanel { get; }
Gets the selection.
public Selection Selection { get; }
The selection.
Gets or sets the selection fill.
public Brush SelectionFill { get; set; }
The selection fill.
Gets or sets the selection stroke.
public Brush SelectionStroke { get; set; }
The selection stroke.
Gets or sets a value indicating whether line numbers are displayed in the margin of the syntax editor.
public bool ShowLineNumbers { get; set; }
Gets the registry of taggers that provide syntax highlighting and other text analysis functionality for the editor.
public TaggersRegistry TaggersRegistry { get; }
Gets the stack of text format definitions that control the visual appearance of text in the syntax editor.
public TextFormatDefinitionStack TextFormatDefinitions { get; }
Gets or sets the builder component responsible for creating and managing the visual layers in the syntax editor.
public UILayersBuilder UILayersBuilder { get; set; }
Gets or sets a value indicating whether to apply rendering optimizations for monospaced fonts in the syntax editor.
public bool UseMonospacedFontOptimization { get; set; }
Gets or sets a value indicating whether the Shift key is required to extend text selection with arrow keys.
public bool UseShiftKeyInSelection { get; set; }
Gets the vertical scroll bar element that controls scrolling through the document vertically.
public RadScrollBarElement VerticalScrollBar { get; }
Gets the visible rectangular area of the document currently displayed in the editor.
public Rect Viewport { get; }
Gets the drop-down list element that allows selecting different zoom levels for the editor content.
public RadDropDownListElement ZoomComboBox { get; }
Methods
Applies any cached property values to the syntax editor element.
protected virtual void ApplyCachedProperties(bool clearCache = true)
Determines whether the properties cache will be cleared after applying values.
Arranges the inner margins of the editor content area.
protected virtual RectangleF ArrangeInnerMargins(RectangleF clientRect)
The client rectangle available for the editor content.
Returns:A rectangle that represents the area after applying inner margins.
Arranges the outer margins of the editor within the available client rectangle.
protected virtual RectangleF ArrangeOuterMargins(RectangleF clientRect)
The client rectangle available for the editor.
Returns:A rectangle that represents the area after applying outer margins.
Arranges the syntax editor element and its children within the final allocated area.
Backspaces this instance.
public void Backspace()
Begins the undo group.
public void BeginUndoGroup()
Cancels the undo group.
public void CancelUndoGroup()
Closes the find dialog.
public void CloseFindDialog()
Completes the code.
public void CompleteCode()
Copies the current selection to the clipboard. If no text is selected, copies the entire current line.
public void Copy()
Creates a new syntax editor presenter that will display and manage the text content.
protected virtual SyntaxEditorPresenter CrateSyntaxEditorPresenter()
A new instance of SyntaxEditorPresenter.
Creates the child elements that make up the structure of the editor.
protected override void CreateChildElements()
Overrides:
Creates the state of the code editor history.
public SyntaxEditorHistoryState CreateSyntaxEditorHistoryState()
SyntaxEditorHistoryState.
Creates the zoom drop-down element used for scaling the editor content.
protected virtual RadDropDownListElement CreateZoomElement()
A new RadDropDownListElement configured for zoom level selection.
Cuts this instance.
public void Cut()
Decreases the line indent.
public void DecreaseLineIndent()
Deletes this instance.
public void Delete()
Deletes the full line.
public void DeleteFullLine()
Deletes the word to left.
public void DeleteWordToLeft()
Deletes the word to right.
public void DeleteWordToRight()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Implements:
Releases unmanaged and - optionally - managed resources.
protected virtual void Dispose(bool disposing)
true to release both managed and unmanaged resources; false to release only unmanaged resources.
Ends the undo group.
public void EndUndoGroup()
Calculates the content rectangle based on the available space, accounting for scroll bars and other elements.
protected virtual RectangleF GetContentRect(RectangleF availableRect)
The rectangle representing the available space.
Returns:A rectangle representing the area for the editor content.
Gets the bounding rectangle for a specific line in the document.
public Rect GetLineBoundingRectangleByLineNumber(int lineNumber, bool cutToBaseline = false)
The zero-based line number.
cutToBaselineboolIf true, adjusts the rectangle to only include up to the text baseline.
Returns:A rectangle representing the bounds of the specified line.
Gets the bounding rectangle for a specific portion of text within the document.
public Rect GetLinePartBoundingRectangle(Span span, bool cutToBaseline = false)
The span of text to get the bounds for.
cutToBaselineboolIf true, adjusts the rectangle to only include up to the text baseline.
Returns:A rectangle representing the bounds of the specified text span.
Converts a document caret position to screen coordinates in the editor.
public Point GetPointFromPosition(CaretPosition position)
The caret position in the document.
Returns:The point in screen coordinates corresponding to the caret position.
Converts a screen coordinate point to a document caret position.
public CaretPosition GetPositionFromControlPoint(Point point)
The point in screen coordinates relative to the control.
Returns:A caret position in the document corresponding to the specified point.
Gets the text between the specified start and end positions.
public string GetText(CaretPosition start, CaretPosition end)
Gets the text within the current word which is to the left of the caret.
Gets the text within the current word which is to the right of the caret.
Tries to highlight all span matches via all registered TextSearchHighlightTaggers.
Increases the line indent.
public void IncreaseLineIndent()
Indents this instance.
public void Indent()
Initializes the default field values for the editor element.
protected override void InitializeFields()
Overrides:
Inserts the specified text.
Inserts the new line.
public void InsertNewLine()
Inserts the tab.
public void InsertTab()
Invalidates the layout of the editor, forcing a recalculation of text positions and visual elements.
public void InvalidateEditorLayout()
Invalidates the layout of the editor, forcing a recalculation of text positions and visual elements.
public void InvalidateEditorLayout(bool force)
When true, forces a complete layout recalculation regardless of any optimization conditions.
Measures the inner margins of the editor content area.
protected virtual RectangleF MeasureInnerMargins(RectangleF clientRect)
The client rectangle available for the editor content.
Returns:A rectangle that represents the area after applying inner margins.
Measures the outer margins of the editor within the available client rectangle.
protected virtual RectangleF MeasureOuterMargins(RectangleF clientRect)
The client rectangle available for the editor.
Returns:A rectangle that represents the area after applying outer margins.
Measures the desired size of the syntax editor element based on the available space.
Moves the current line to top.
public void MoveCurrentLineToTop()
Navigates to the next matched text in the editor.
Navigates to the next matched text in the editor.
When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate().
public override void OnApplyTemplate()
Overrides:
Raises the CommandError event when a command execution results in an error.
protected virtual void OnCommandError(CommandErrorEventArgs args)
The CommandErrorEventArgs instance containing information about the error and the command that failed.
Raises the CommandExecuted event after a command has been successfully executed in the syntax editor.
protected virtual void OnCommandExecuted(CommandExecutedEventArgs e)
The CommandExecutedEventArgs instance containing information about the executed command.
Raises the CommandExecuting event before a command is executed, allowing subscribers to cancel or modify the command execution.
protected virtual void OnCommandExecuting(CommandExecutingEventArgs args)
The CommandExecutingEventArgs instance containing information about the command to be executed and allowing cancellation.
Called when the document in the syntax editor has changed, raising the DocumentChanged event.
protected virtual void OnDocumentChanged()
Called before the document in the syntax editor changes, raising the DocumentChanging event.
protected virtual void OnDocumentChanging()
Handles the event.
protected virtual void OnDocumentContentChanged(TextContentChangedEventArgs args)
The TextContentChangedEventArgs instance containing the event data.
Handles the event.
protected virtual void OnDocumentContentChanging(TextContentChangingEventArgs args)
The TextContentChangingEventArgs instance containing the event data.
Called when the syntax editor element receives input focus, ensuring the caret becomes visible.
protected override void OnGotFocus(EventArgs e)
The event arguments.
Overrides:
Raises the IsReadOnlyChanged event when the read-only state of the syntax editor changes.
protected virtual void OnIsReadOnlyChanged(EventArgs e)
The event arguments.
Raises the LayoutPropertiesChanged event when layout properties of the syntax editor have been modified.
protected virtual void OnLayoutPropertiesChanged()
Called when the element has been successfully loaded. That includes loading of all its children as well.
protected override void OnLoaded()
Overrides:
Called when mouse wheel zoom is requested. Handles changing the scale factor of the editor content based on mouse wheel movement.
Raises the PreviewSyntaxEditorInput event when text input is detected in the syntax editor, allowing for processing or cancellation of the input.
protected virtual void OnPreviewSyntaxEditorInput(PreviewSyntaxEditorInputEventArgs args)
The PreviewSyntaxEditorInputEventArgs instance containing the event data and providing options to handle or cancel the input.
Handles the event.
protected virtual void OnPreviewSyntaxEditorKeyDown(PreviewSyntaxEditorKeyEventArgs args)
The PreviewSyntaxEditorKeyEventArgs instance containing the event data.
Raises the PreviewSyntaxEditorKeyUp event when a key up action is detected in the syntax editor.
protected virtual void OnPreviewSyntaxEditorKeyUp(PreviewSyntaxEditorKeyEventArgs args)
The event arguments containing information about the key action.
Raises the PreviewSyntaxEditorMouseLeftButtonDown event when a mouse left button down action is detected.
protected virtual void OnPreviewSyntaxEditorMouseLeftButtonDown(PreviewSyntaxEditorMouseButtonEventArgs args)
The event arguments containing information about the mouse action.
Raises the PreviewSyntaxEditorMouseRightButtonDown event when a mouse right button down action is detected.
protected virtual void OnPreviewSyntaxEditorMouseRightButtonDown(PreviewSyntaxEditorMouseButtonEventArgs args)
The event arguments containing information about the mouse action.
Called when a property value changes, allowing for handling specific property changes in the syntax editor.
protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
Event arguments containing information about the property that changed.
Overrides:
Called when the zoom level of the editor changes, raising the ScaleFactorChanged event and updating the layout.
protected virtual void OnScaleFactorChanged()
Ensures that the scale factor value is within the valid range between minimum and maximum scale factors.
Raises the SelectionChanged event when the text selection in the syntax editor changes.
protected virtual void OnSelectionChanged()
Raises the ViewportChanged event when the visible area of the syntax editor changes due to scrolling or resizing.
protected virtual void OnViewportChanged()
Opens the find dialog with the specified searchText in the search textbox.
Pages down.
public void PageDown()
Pages up.
public void PageUp()
Pastes this instance.
public void Paste()
Populates the zoom drop-down element with the default scale factors (20% to 400%).
protected virtual void PopulateZoomElement()
Replaces all matches.
Replaces the next match.
public bool ReplaceNextMatch(string searchText, int startIndex, string replaceText, bool matchCase, bool useRegularExpression)
The search text.
startIndexintThe start index.
replaceTextstringThe replace text.
matchCaseboolThe match case.
useRegularExpressionboolThe use regular expression.
Returns:System.Boolean.
Restores the state of the code editor history.
public void RestoreSyntaxEditorHistoryState(SyntaxEditorHistoryState historyState)
State of the history.
Selects all text content in the document.
public void SelectAll()
Determines whether a child element should be arranged during the layout process.
protected override bool ShouldArrangeChild(RadElement child)
The child element to check.
Returns:True if the child should be arranged; otherwise, false.
Overrides:
Determines whether a child element should be measured during the layout process.
protected override bool ShouldMeasureChild(RadElement child)
The child element to check.
Returns:True if the child should be measured; otherwise, false.
Overrides:
Toggles the insert mode.
public void ToggleInsertMode()
Unindents this instance.
public void Unindent()
Updates the visual representation of the current text selection in the editor.
public void UpdateSelection()
Increases the zoom level of the editor content.
public void ZoomIn(double zoomFactor = 1.1)
The zoom increase factor. Should be a number greater than 1. Default value is 1.1.
Decreases the zoom level of the editor content.
public void ZoomOut(double zoomFactor = 0.91)
The zoom decrease factor. Should be a number less than 1. Default value is 0.91.
Sets the zoom level of the editor content to a specific scale factor.
public void ZoomTo(double zoomLevel)
The scale factor to set (1.0 is normal size, 2.0 is double size, etc.). The minimum supported zoom level is 0.2 and the maximum supported is 4.
Exceptions:Thrown when zoomLevel is negative.
Events
Occurs when a command execution in the syntax editor results in an error, providing details about the error and the command that failed.
public event EventHandler<CommandErrorEventArgs> CommandError
Occurs after a command has been successfully executed in the syntax editor, providing information about the executed command.
public event EventHandler<CommandExecutedEventArgs> CommandExecuted
Occurs before a command is executed, allowing you to cancel or modify the command execution.
public event EventHandler<CommandExecutingEventArgs> CommandExecuting
Occurs after the document in the syntax editor has been changed, such as when a new document is loaded or created.
public event EventHandler DocumentChanged
Implements:
Occurs before the document in the syntax editor is changed, allowing you to perform actions before a new document is loaded or created.
public event EventHandler DocumentChanging
Implements:
Occurs when document content has been changed.
public event EventHandler<TextContentChangedEventArgs> DocumentContentChanged
Implements:
Occurs when document content is being changed.
public event EventHandler<TextContentChangingEventArgs> DocumentContentChanging
Occurs when the read-only state of the syntax editor changes, indicating whether editing operations are allowed or restricted.
public event EventHandler IsReadOnlyChanged
Occurs when the layout properties of the editor change, affecting how text is displayed.
public event EventHandler LayoutPropertiesChanged
Occurs before text input is processed by the syntax editor, allowing you to intercept and modify the input.
public event EventHandler<PreviewSyntaxEditorInputEventArgs> PreviewSyntaxEditorInput
Occurs before a key down event is processed by the syntax editor, allowing you to intercept and handle keyboard input.
public event EventHandler<PreviewSyntaxEditorKeyEventArgs> PreviewSyntaxEditorKeyDown
Occurs before a key up event is processed by the syntax editor, allowing you to intercept and handle keyboard input.
public event EventHandler<PreviewSyntaxEditorKeyEventArgs> PreviewSyntaxEditorKeyUp
Occurs before a mouse left button down event is processed by the syntax editor, allowing you to intercept and handle mouse input.
public event EventHandler<PreviewSyntaxEditorMouseButtonEventArgs> PreviewSyntaxEditorMouseLeftButtonDown
Occurs before a mouse right button down event is processed by the syntax editor, allowing you to intercept and handle context menu or other right-click actions.
public event EventHandler<PreviewSyntaxEditorMouseButtonEventArgs> PreviewSyntaxEditorMouseRightButtonDown
Occurs when the scale factor (zoom level) of the syntax editor changes, affecting the display size of text and UI elements.
public event EventHandler ScaleFactorChanged
Occurs when the text selection within the editor changes, either by user interaction or programmatically.
public event EventHandler SelectionChanged
Occurs when the visible portion (viewport) of the editor content changes due to scrolling or resizing.
public event EventHandler ViewportChanged