Button
class cAlgo.API
Represents the button.
Environment behaviour
CLI — not supported. Accepted without error but never displayed, so control events such as Click are never raised.
Cloud — not supported. Accepted without error but never displayed, so control events such as Click are never raised.
Definition
public class Button : Control
Namespace: cAlgo.API · Group: Controls · Inherits: Control, ControlBase
Examples
using cAlgo.API;
using System;
using System.Linq;
namespace cAlgo
{
// This sample indicator shows how to use Button control and handle its clicked event
public partial 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)
{
}
}
}
import clr
clr.AddReference("cAlgo.API")
from cAlgo.API import *
class Test():
def initialize(self):
stackPanel = StackPanel()
stackPanel.HorizontalAlignment = HorizontalAlignment.Center
stackPanel.VerticalAlignment = VerticalAlignment.Center
stackPanel.BackgroundColor = Color.Gold
stackPanel.Opacity = 0.7
for i in range(5):
button = Button()
button.Text = f"Button # {i}"
button.Margin = Thickness(10)
button.Click += self.on_button_clicked
stackPanel.AddChild(button)
api.Chart.AddControl(stackPanel)
def on_button_clicked(self, args):
textSplit = args.Button.Text.split(' ')[:2]
args.Button.Text = f"{' '.join(textSplit)} Clicked"
{
"AccessRights": "None",
"TimeZone": "UTC",
"IsOverlay": true
}
Constructors
| Name | Description |
|---|---|
| ButtonDesktopCLICloud | Initializes a new instance of the Button class. |
Properties
| Name | Description |
|---|---|
BorderColorDesktopCLICloudColor | Gets or sets the border line color. Check the Color class for the ARGB (alpha, red, green, blue) color values, or use the strings Color.Red, Color.FromName("Red"), Color.FromArgb(255, 0, 0), Color.FromHex("#ff0000"), "Red", "#ff0000". |
BorderThicknessDesktopCLICloudThickness | Gets or sets the border thickness. |
ContentDesktopCLICloudControlBase | Gets or sets the content. |
CornerRadiusDesktopCLICloudCornerRadius | Gets or sets the border corner radius. Property value can be set using CornerRadius, number, or a string: new CornerRadius(5), new CornerRadius(1, 2, 3, 4). |
TextDesktopCLICloudstring | Gets or sets the text. |
Events
| Name | Description |
|---|---|
ClickDesktopCLICloudAction<ButtonClickEventArgs> | Occurs when the button is clicked. |
Inherited members
From Control: ForegroundColor, BackgroundColor, Padding, VerticalContentAlignment, HorizontalContentAlignment, FontWeight, FontStyle, FontFamily, FontSize
From ControlBase: ResetProperty, UniqueId, Style, Left, Top, Right, Bottom, Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight, IsEnabled, IsVisible, Opacity, Margin, VerticalAlignment, HorizontalAlignment, Dock, IsHitTestVisible