Skip to content

Button

Summary

Represents the button.

Signature

1
public class Button : Control

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
28
29
30
31
32
33
34
35
36
37
38
39
40
 using cAlgo.API;
 using System;
 using System.Linq;
 namespace cAlgo
 {
     // This sample indicator shows how to use Button control and handle its clicked event
     [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class ButtonSample : Indicator
     {
         protected override void Initialize()
         {
             var stackPanel = new StackPanel
             {
                 HorizontalAlignment = HorizontalAlignment.Center,
                 VerticalAlignment = VerticalAlignment.Center,
                 BackgroundColor = Color.Gold,
                 Opacity = 0.7
             };
             for (int i = 0; i < 5; i++)
             {
                 var button = new Button
                 {
                     Text = "Button #" + i,
                     Margin = 10
                 };
                 button.Click += Button_Click;
                 stackPanel.AddChild(button);
             }
             Chart.AddControl(stackPanel);
         }
         private void Button_Click(ButtonClickEventArgs obj)
         {
             var textSplit = obj.Button.Text.Split(' ').TakeWhile(text => !text.Equals("Clicked", StringComparison.OrdinalIgnoreCase)).ToArray();
             obj.Button.Text = string.Join(" ", textSplit) + " Clicked";
         }
         public override void Calculate(int index)
         {
         }
     }
 }

See Also

Properties

Text

Summary

Gets or sets the text.

Signature

1
public string Text {get; set;}

Return Value

string

CornerRadius

Summary

Gets or sets the border corner radius. Property value can be set using CornerRadius, number, or a string: newCornerRadius(5), new CornerRadius(1, 2, 3, 4).

Signature

1
public CornerRadius CornerRadius {get; set;}

Return Value

CornerRadius

Related Tutorials

BorderColor

Summary

Gets or sets the border line color. Check the Color class for the ARGB (alpha, red, green, blue) color values, oruse the strings Color.Red, Color.FromName("Red"), Color.FromArgb(255, 0, 0), Color.FromHex("#ff0000"), "Red","#ff0000".

Signature

1
public Color BorderColor {get; set;}

Return Value

Color

BorderThickness

Summary

Gets or sets the border thickness.

Signature

1
public Thickness BorderThickness {get; set;}

Return Value

Thickness

Content

Summary

Gets or sets the content.

Signature

1
public ControlBase Content {get; set;}

Return Value

ControlBase

Events

Click

Summary

Occurs when the button is clicked.

Signature

1
public event Action<ButtonClickEventArgs> Click;