In This Article

TextStylePreview Class

Represents a syntax-highlighting code editor control.

[ToolboxBitmap(typeof(TextStylePreview))]
public class TextStylePreview : UIControl, IUIControl, IUIElement, ILogicalTreeNode, IDpiAwareElement, IDisposable
Inheritance:
object MarshalByRefObject Component Control ScrollableControl UIControl object
Implements:
IUIControl IUIElement ILogicalTreeNode IDpiAwareElement IDisposable

Constructors

TextStylePreview()

Initializes an instance of the class.

public TextStylePreview()

Properties

BackColor

Gets or sets the background color for the control.

public override Color BackColor { get; set; }

Property Value

Color:

A Color that represents the background color of the control. The default is the value of the DefaultBackColor property.

DefaultSize

Gets the default size of the control.

protected override Size DefaultSize { get; }

Property Value

Size:

The default Size of the control.

Font

Gets or sets the font of the text displayed by the control.

public override Font Font { get; set; }

Property Value

Font:

The Font to apply to the text displayed by the control. The default is the value of the DefaultFont property.

ForeColor

Gets or sets the foreground color of the control.

public override Color ForeColor { get; set; }

Property Value

Color:

The foreground Color of the control. The default is the value of the DefaultForeColor property.

HighlightingStyle

The IHighlightingStyle to apply to the preview.

public IHighlightingStyle? HighlightingStyle { get; set; }

Property Value

IHighlightingStyle

HighlightingStyleRegistry

The optional alternate IHighlightingStyleRegistry to use.

public IHighlightingStyleRegistry? HighlightingStyleRegistry { get; set; }

Property Value

IHighlightingStyleRegistry

Remarks

If this property is null, the AmbientHighlightingStyleRegistry will be used.

Padding

The padding for the control.

public Padding Padding { get; set; }

Property Value

Padding

Text

The text to preview.

public override string Text { get; set; }

Property Value

string:

The default value is ij = I::oO(0xB81l);.

Methods

ArrangeOverride(Size)

Positions child elements and determines an arrange size.

protected override Size ArrangeOverride(Size finalSize)
Parameter Type Description
finalSize Size

The final area within the parent that this element should use to arrange itself and its children.

Returns

Size:

The actual size used.

Remarks

Element authors should override this method, call Arrange(Rectangle) on each visible child element and position each child element. It is required that a parent element calls Arrange(Rectangle) on each child or they won't be rendered.

CreateChildren()

Invoked when the collection of child elements is to be created.

protected override IList<ILogicalTreeNode>? CreateChildren()

Returns

IList<ILogicalTreeNode>:

The list that should be assigned to the Children property.

Remarks

By default, no child collection is created.

MeasureOverride(Graphics?, Size)

Measures the size in layout required for child elements and determines a size for the element itself.

protected override Size MeasureOverride(Graphics? g, Size availableSize)
Parameter Type Description
g Graphics

The Graphics object to use for measurement.

availableSize Size

The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.

Returns

Size:

The size that this element determines it needs during layout, based on its calculations of child element sizes.

Remarks

Element authors should override this method, call Measure(Graphics?, Size) on each visible child element and determine the total size required.

OnDraw(CanvasDrawEventArgs)

Occurs when the canvas should be rendered.

protected virtual void OnDraw(CanvasDrawEventArgs e)
Parameter Type Description
e CanvasDrawEventArgs

The event data.

OnPropertyChanged(PropertyChangedEventArgs)

Raises the PropertyChanged event.

protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
Parameter Type Description
e PropertyChangedEventArgs

The event data.

OnPropertyChanged(string?)

Raises the PropertyChanged event.

protected void OnPropertyChanged(string? propertyName = null)
Parameter Type Description
propertyName string

(Optional) The name of the property that changed.

ResetBackColor()

Resets the BackColor property to its default value.

public override void ResetBackColor()

ResetFont()

Resets the Font property to its default value.

public override void ResetFont()

ResetForeColor()

Resets the ForeColor property to its default value.

public override void ResetForeColor()

ResetPadding()

Resets the Padding property to its default value.

public virtual void ResetPadding()

ResetTabStop()

Resets the TabStop property to its default value.

public virtual void ResetTabStop()

SetProperty<T>(ref T, T, string?)

Called from a property setter to change the backing field's value and raise PropertyChanged notification events if the new value is not equal to the current value.

protected bool SetProperty<T>(ref T field, T newValue, string? propertyName = null)
Type Parameters:
T -

The type of the property that changed.

Parameter Type Description
field T

The backing field that holds the property's value, which may be updated.

newValue T

The new property value.

propertyName string

(Optional) The name of the property that changed.

Returns

bool:

true if the property was changed; otherwise, false.

ShouldSerializeBackColor()

Indicates whether the BackColor property should be persisted.

protected virtual bool ShouldSerializeBackColor()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

ShouldSerializeFont()

Indicates whether the Font property should be persisted.

protected virtual bool ShouldSerializeFont()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

ShouldSerializeForeColor()

Indicates whether the ForeColor property should be persisted.

protected virtual bool ShouldSerializeForeColor()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

ShouldSerializePadding()

Indicates whether the Padding property should be persisted.

protected virtual bool ShouldSerializePadding()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

ShouldSerializeTabStop()

Indicates whether the TabStop property should be persisted.

protected virtual bool ShouldSerializeTabStop()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

Events

PropertyChanged

Occurs when a property value changes.

public event PropertyChangedEventHandler? PropertyChanged

Event Type

PropertyChangedEventHandler

Inherited Members

Extension Methods