Most of the objects visualized with Nevron Graphics have associated texts. The appearance of these texts is controlled by an instance of the NTextStyle class. Following is a list of the major text appearance aspects, controlled by this style:
The FontStyle property is the most important property of the NTextStyle class, because it gives you full control over the font used to display the text. The default font used in Nevron controls is Arial 9pt, but some objects can modify it. For example the header and footer labels in the chart use Arial 12pt. The code below changes the font to "Tahoma", 13pt:
C# |
Copy Code
|
someObject.TextStyle.FontStyle.Name = "Tahoma";
someObject.TextStyle.FontStyle.EmSize = new NLength(13, NGraphicsUnit.Point);
|
Visual Basic |
Copy Code
|
someObject.TextStyle.FontStyle.Name = "Tahoma"
someObject.TextStyle.FontStyle.EmSize = New NLength(13, NGraphicsUnit.Point)
|
Note that it is recommended to use relative measurement units (like point, parent percentage etc.) instead of pixels, because they will scale better when you print the control.
The filling of the text is controlled by the FillStyle property of the NTextStyle class. This property allows you to apply solid color, gradient, image, hatch or advanced gradient fill style to the text object. The following code sets a solid color for the text:
C# |
Copy Code
|
someObject.TextStyle.FillStyle = new NColorFillStyle(Color.Aqua);
|
Visual Basic |
Copy Code
|
someObject.TextStyle.FillStyle = new NColorFillStyle(Color.Aqua)
|
You can use the backplane style of the text for various purposes for example to draw the user attention to the text or to increase the readability. A typical case is if you have a dark background color and the text color is black. In this case you have to enable the text backplane, because otherwise the text will simply merge with the background and become unreadable. The text backplane is represented by the NBackplaneStyle object accessible from the BackplaneStyle property of the NTextStyle:
C# |
Copy Code
|
someObject.TextStyle.BackplaneStyle.Visible = true;
someObject.TextStyle.BackplaneStyle.FillStyle = new NColorFillStyle(Color.Red);
|
Visual Basic |
Copy Code
|
someObject.TextStyle.BackplaneStyle.Visible = True
someObject.TextStyle.BackplaneStyle.FillStyle = new NColorFillStyle(Color.Red)
|
When rendering texts the control automatically calculates the coordinates where texts should appear. These coordinates are called base points and are dependent on the scene logic. For example when you have a bar chart it will position the base points for the bar label texts at the top of each bar. The origin point of a text is always specified relative to the base point. This is achieved with the help of the Offset property of the text. It is defined by a NPointL structure allowing you to move the text relative to its base point. The following example offsets the origin point of a text from its base point with ten points (right and down):
C# |
Copy Code
|
someObject.TextStyle.Offset = new NPointL(new NLength(10, NGraphicsUnit.Pixel), new NLength(10, NGraphicsUnit.Point));
|
Visual Basic |
Copy Code
|
someObject.TextStyle.Offset = New NPointL(New NLength(10, NGraphicsUnit.Pixel), New NLength(10, NGraphicsUnit.Point))
|
Text orientation is specified with the Orientation property of the NTextStyle class rather than with the orientation property of the associated font. The Orientation property is specified in degrees (counter clockwise) and by default is 0. The example below creates a vertically oriented text:
C# |
Copy Code
|
someObject.TextStyle.Orientation = 90;
|
Visual Basic |
Copy Code
|
someObject.TextStyle.Orientation = 90
|
When texts are displayed in 3D they also have an associated depth coordinate (Z order). In certain cases you may wish to push texts in front of all other objects. This is very helpful if you want to increase readability and that's why this feature is enabled by default. The following will instruct text control to render with the original depth value.
C# |
Copy Code
|
someObject.TextStyle.TextOverlapsImage = false;
|
Visual Basic |
Copy Code
|
someObject.TextStyle.TextOverlapsImage = False
|