Click or drag to resize
AB4D logo

TextBlockVisual3D Class

TextBlockVisual3D class is used to create a Visual3D that can show TextBlock and Border elements on a 3D Plane. This makes showing text with border in 3D very easy.
Inheritance Hierarchy

Namespace: Ab3d.Visuals
Assembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 11.2.9104.2045
Syntax
C#
public class TextBlockVisual3D : BaseVisual3D, 
	IDisposable

The TextBlockVisual3D type exposes the following members.

Constructors
 NameDescription
Public methodTextBlockVisual3D Creates a new instance of TextBlockVisual3D
Public methodTextBlockVisual3D(String) Creates a new instance of TextBlockVisual3D
Top
Properties
 NameDescription
Public propertyBackground Gets or sets the Brush that fill the background of the textBorder.
Public propertyBackMaterial Gets a Material that is used to show the text and border on the back side of the plane model defined by the textGeometryModel3D. Back material can be changed from a derived class with changing the protected backMaterial field.
Public propertyBorderBrush Gets or sets the Brush of the border.
Public propertyBorderSize Gets or sets a Size that can be set to define the 2D size of the Border element. By default BorderSize is set to Size.Empty. This automatically scales the Border element to show the whole TextBlock element. But when you want to trim the text, you need to set the BorderSize to a valid size value.
Public propertyBorderThickness Gets or sets the thickness of the border.
Public propertyFontFamily Gets or sets the FontFamily of the text.
Public propertyFontSize Gets or sets the size of the text
Public propertyFontWeight Gets or sets the FontWeight of the text.
Public propertyForeground Gets or sets the foreground brush of the text.
Public propertyInlines Gets InlineCollection from the TextBlock Inlines property. This property can be used to show text with different colors and fonts. After Inlines are manually added, you need to call Refresh method to update the size and rendering of the TextBlockVisual3D.
Public propertyIsBackSidedTextFlipped Gets or sets a Boolean that specifies if the text on the back side is horizontally flipped so that it appears correct when viewing from the back side. When false (by default), the text on front and back side is the same. This property has effect only when IsTwoSidedText property is set to true.
Public propertyIsDisposed Gets a Boolean that specified is this TextBlockVisual3D has been disposed.
Public propertyIsTwoSidedText Gets or sets a Boolean that specifies if the plane 3D models shows text on both front and back sides. If IsTwoSidedText is false, then only the front material is set. This can improve performance because the text is rendered only once. Default value is true. To control orientation of the back sided text, see also the IsBackSidedTextFlipped property.
Public propertyMaterial Gets a Material that is used to show the text and border on the front side of the plane model defined by the textGeometryModel3D. Front material can be changed from a derived class with changing the protected frontMaterial field.
Public propertyPosition Gets or sets the position of the text. What point on 3D model is represented by this property is specified by PositionType property (TopLeft by default).
Public propertyPositionType Gets or sets a PositionTypes the what point on the 3D model the Position property represents. Default value is TopLeft.
Public propertyRenderBitmapSize When set to a valid size value (not Empty or with 0 Width or Height), then TextBlock and Border elements are rendered to bitmap and that bitmap is then shown on a 3D model. When set to Empty then TextBlockVisual3D is using a DiffuseMaterial with a VisualBrush that show TextBlock and Border. Setting RenderBitmapSize can increase initialization time but can significantly improve rendering performance. When used in DXEngine it is highly recommended to set this property. Default value is Size.Empty; but when rendered with Ab3d.DXEngine the default value is set to DefaultDXEngineRenderBitmapSize (512 x 256).
Public propertySize Gets or sets a Size of the 3D plane model that will show the text. When the Size is Empty (by default), the BorderSize will be used. If BorderSize is also Empty, then TextBlock will be measured and its desired size will be used. It is also possible to set only Size.Height and leave Size.Width 0 or NaN. In this case the used width will be calculated from BorderSize or TextBlock size. This way it is easy to specify only the desired text height in 3D space and the TextBlockVisual3D will automatically calculate the width of the model.
Public propertyText Gets or sets the text that is displayed with 3D lines.
Public propertyTextAlignment Gets or sets a value that indicates the horizontal alignment of text content.
Public propertyTextDirection Gets or sets the Vector3D that is pointing in the direction in which the text is drawn. Default value is (1,0,0).
Public propertyTextHorizontalAlignment Gets or sets a HorizontalAlignment that specifies the horizontal alignment of the TextBlock inside the Border element. BorderSize property needs to be set for this property to have any effect. Default value is Left.
Public propertyTextPadding Gets or sets a Thickness that specifies the padding of the TextBlock element inside the textBorder element.
Public propertyTextTrimming Gets or sets the TextTrimming of the text. This property will have no effect if BorderSize is not set because the default behavior without BorderSize set is to adjust the size of the text to fit the allotted space. Note that if this property is set to TextTrimming.CharacterEllipsis and the text consists of multiple lines of text where each line is separated by a line feed, then an ellipsis will appear on each line that exceeds the allocated space. See also TextWrapping property.
Public propertyTextVerticalAlignment Gets or sets a VerticalAlignment that specifies the horizontal alignment of the TextBlock inside the Border element. BorderSize property needs to be set for this property to have any effect. Default value is Center.
Public propertyTextWrapping Gets or sets the TextBlockVisual3D should wrap the text. Default is NoWarp. For TextWrapping to have effect, you need to set the BorderSize property (it should not be set to Size.Empty).
Public propertyUpDirection Gets or sets the Vector3D that is pointing in the text's up direction. Default value is (0,1,0).
Public propertyUseMatrixTransform3D When UseMatrixTransform3D is true then this TextBlockVisual3D is created with a standard and shared MeshGeometry3D and uses a UseMatrixTransform3D to position, scale and orient the plane to the desired location, size and direction. This gives a big performance improvement. When false, each TextBlockVisual3D is using a unique MeshGeometry3D that is updated according to the position, scale and direction. This means that on each property change a new MeshGeometry3D is created. Default value is true.
Top
Methods
 NameDescription
Public methodAlignWithCamera(BaseCamera) AlignWithCamera method aligns the TextBlockVisual3D to be oriented so that it faces the specified camera.
Public methodAlignWithCamera(ProjectionCamera) AlignWithCamera method aligns the TextBlockVisual3D to be oriented so that it faces the specified camera.
Protected methodCreateModel Creates this Model3D
(Overrides BaseVisual3DCreateModel)
Public methodDispose Dispose method frees the VisualBrushes and RenderTargetBitmaps that are created by this TextBlockVisual3D object.
Protected methodStatic memberOnBorderPropertyChanged OnBorderPropertyChanged
Protected methodStatic memberOnPlaneMeshPropertyChanged OnPlaneMeshPropertyChanged
Protected methodStatic memberOnRenderBitmapSizePropertyChanged OnRenderBitmapSizePropertyChanged
Protected methodStatic memberOnTextBlockPropertyChanged OnTextBlockPropertyChanged
Protected methodOnVisualParentChanged OnVisualParentChanged
(Overrides BaseVisual3DOnVisualParentChanged(DependencyObject))
Public methodRefresh Refresh method measures and recreates the elements and 3D models.
Protected methodUpdateBorder UpdateBorder method updates the properties of the textBorder Border element. This method can be overridden by a derived class to allow applying custom settings on the Border element.
Protected methodUpdatePlaneMesh UpdatePlaneMesh sets the value of textGeometryModel3D.Geometry with a new MeshGeometry3D. The new MeshGeometry3D represents the plane where the text texture will be shown. The plane is defined by the CenterPosition, Size, TextDirection and UpDirection properties. This method can be overridden by a derived class to provide custom MeshGeometry3D.
Protected methodUpdateTextBlock UpdateTextBlock method updates the properties of the textBlock TextBlock element. This method can be overridden by a derived class to allow applying custom settings on the TextBlock element.
Top
Fields
 NameDescription
Public fieldStatic memberBackgroundProperty BorderThicknessProperty
Protected fieldbackMaterial frontMaterial is a Material that is used to show the text and border on the back side of the plane model defined by the textGeometryModel3D.
Protected fieldbackTextVisualBrush backTextVisualBrush is VisualBrush that is used to show Border and TextBlock on a the back side of the 3D model.
Public fieldStatic memberBorderBrushProperty BorderThicknessProperty
Public fieldStatic memberBorderSizeProperty BorderSizeProperty
Public fieldStatic memberBorderThicknessProperty BorderThicknessProperty
Public fieldStatic memberDefaultDXEngineRenderBitmapSize DefaultDXEngineRenderBitmapSize defines the RenderBitmapSize that is used in case TextBlockVisual3D is rendered with Ab3d.DXEngine and user does not specify its own value for RenderBitmapSize. By default the Size is set to 512 x 256.
Public fieldStatic memberFontFamilyProperty FontSizeProperty
Public fieldStatic memberFontSizeProperty FontSizeProperty
Public fieldStatic memberFontWeightProperty FontWeightProperty
Public fieldStatic memberForegroundProperty ForegroundProperty
Protected fieldfrontMaterial frontMaterial is a Material that is used to show the text and border on the front side of the plane model defined by the textGeometryModel3D.
Public fieldStatic memberIsBackSidedTextFlippedProperty IsBackSidedTextFlippedProperty
Public fieldStatic memberIsTwoSidedTextProperty IsTwoSidedTextProperty
Public fieldStatic memberPositionProperty PositionProperty
Public fieldStatic memberPositionTypeProperty PositionTypeProperty
Public fieldStatic memberRenderBitmapSizeProperty RenderBitmapSizeProperty
Public fieldStatic memberSizeProperty SizeProperty
Public fieldStatic memberTextAlignmentProperty TextAlignmentProperty
Protected fieldtextBlock TextBlock used to define how the text is rendered
Protected fieldtextBorder textBorder is a parent Border element to textBlock and is used to define the border of the TextBlock.
Public fieldStatic memberTextDirectionProperty TextDirectionProperty
Protected fieldtextGeometryModel3D textGeometryModel3D defines the GeometryModel3D that is shown with this TextBlockVisual3D. This GeometryModel3D is set to the Content property.
Public fieldStatic memberTextHorizontalAlignmentProperty TextHorizontalAlignmentProperty
Public fieldStatic memberTextPaddingProperty TextPaddingProperty
Public fieldStatic memberTextProperty TextProperty
Public fieldStatic memberTextTrimmingProperty TextTrimmingProperty
Public fieldStatic memberTextVerticalAlignmentProperty TextVerticalAlignmentProperty
Protected fieldtextVisualBrush textVisualBrush is VisualBrush that is used to show Border and TextBlock on a 3D model.
Public fieldStatic memberTextWrappingProperty TextWrappingProperty
Public fieldStatic memberUpDirectionProperty UpDirectionProperty
Top
Extension Methods
 NameDescription
Public Extension MethodDumpHierarchy Display details about the hierarchy of Visual3D children to Debug console (for example to Visual Studio's Immediate window).
(Defined by Extensions)
Public Extension MethodForEachGeometryModel3D Performs the specified action on each GeometryModel3D inside the rootModelVisual3D.
(Defined by Extensions)
Public Extension MethodForEachVisual3D Performs the specified action on each ModelVisual3D inside the rootModelVisual3D.
(Defined by Extensions)
Public Extension MethodGetName Gets name of the Visual3D that was previously set by SetName extension method.
(Defined by Extensions)
Public Extension MethodSetName Sets Name property to Visual3D. Note that if name is not correct for WPF, it can be corrected (name must start with a letter or the underscore character (_), and must contain only letters, digits, or underscores). In this case the SetName method will set the corrected name to the object and return false (in this case you can call GetName to get the corrected name). True is returned when the original name is set to the object.
(Defined by Extensions)
Top
See Also