Skip to content

TextAlignment

Summary

The text alignment regarding the anchor point.

Signature

1
public enum TextAlignment

Namespace

cAlgo.API

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 using cAlgo.API;
 namespace cAlgo
 {
     // This sample indicator shows how to use TextAlignment property to align the text
     [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class TextAlignmentSample : Indicator
     {
         [Parameter("Text Alignment", DefaultValue = TextAlignment.Center)]
         public TextAlignment TextAlignment { get; set; }
         protected override void Initialize()
         {
             var stackPanel = new StackPanel
             {
                 BackgroundColor = Color.Gold,
                 HorizontalAlignment = HorizontalAlignment.Center,
                 VerticalAlignment = VerticalAlignment.Center,
                 Opacity = 0.6,
                 Width = 200
             };
             stackPanel.AddChild(new TextBlock { Text = "Sample text", TextAlignment = TextAlignment });
             Chart.AddControl(stackPanel);
         }
         public override void Calculate(int index)
         {
         }
     }
 }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
 import clr
 clr.AddReference("cAlgo.API")
 from cAlgo.API import *
 class Test():    
     def initialize(self):
         stackPanel = StackPanel()
         stackPanel.BackgroundColor = Color.Gold
         stackPanel.HorizontalAlignment = HorizontalAlignment.Center
         stackPanel.VerticalAlignment = VerticalAlignment.Center
         stackPanel.Opacity = 0.6
         stackPanel.Width = 200
         textBlock = TextBlock()
         textBlock.Text = "Sample Text"
         # TextAlignment is a parameter of type TextAlignment
         # defined in indicator C# file
         textBlock.TextAlignment = api.TextAlignment
         stackPanel.AddChild(textBlock)
         api.Chart.AddControl(stackPanel)

Fields

Left

Summary

Align the text left.

Signature

1
TextAlignment.Left;

Return Value

TextAlignment

Summary

Align the text right.

Signature

1
TextAlignment.Right;

Return Value

TextAlignment

Center

Summary

Center the text vertically.

Signature

1
TextAlignment.Center;

Return Value

TextAlignment

Justify

Summary

Justify the text.

Signature

1
TextAlignment.Justify;

Return Value

TextAlignment