Skip to content

TextAlignment

enum cAlgo.API

DesktopCLICloud

The text alignment regarding the anchor point.

Definition

public enum TextAlignment

Namespace: cAlgo.API · Group: Controls

Examples

using cAlgo.API;

namespace cAlgo
{
    // This sample indicator shows how to use TextAlignment property to align the text
    public partial class TextAlignmentSample : Indicator
    {
        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)
        {
        }
    }
}
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"
        textBlock.TextAlignment = api.TextAlignment

        stackPanel.AddChild(textBlock)

        api.Chart.AddControl(stackPanel)
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "IsOverlay": true,
  "Parameters": [
    {
      "Name": "TextAlignment",
      "DisplayName": "Text Alignment",
      "Type": "Enum",
      "EnumTypeFullName": "cAlgo.API.TextAlignment",
      "DefaultValue": "Center"
    }
  ]
}

Values

Name Value Description
Left 0 Align the text left.
Right 1 Align the text right.
Center 2 Center the text vertically.
Justify 3 Justify the text.