Skip to content

ColorPicker

class cAlgo.API Since 5.1

DesktopCLICloud

Represents the ColorPicker control.

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 ColorPicker : ControlBase

Namespace: cAlgo.API · Group: Controls · Inherits: ControlBase

Examples

using cAlgo.API;

namespace cAlgo.Robots;

public partial class TestExample : Robot
{
   protected override void OnStart()
   {
       var colorPicker = new ColorPicker {SelectedColor = Color.FromHex("#eb4034"), IsStretched = true};

       var hexColorTextBox = new TextBox {Text = "#eb4034"};

       colorPicker.SelectedColorChanged += args => hexColorTextBox.Text = colorPicker.SelectedColor.ToHexString();

       var changeColorButton = new Button {Text = "Change Color"};

       changeColorButton.Click += args => colorPicker.SelectedColor = Color.FromHex(hexColorTextBox.Text);

       var panel = new StackPanel
       {
            Orientation = Orientation.Vertical,
            HorizontalAlignment = HorizontalAlignment.Center,
            VerticalAlignment = VerticalAlignment.Center
       };

       panel.AddChild(colorPicker);
       panel.AddChild(hexColorTextBox);
       panel.AddChild(changeColorButton);

       Chart.AddControl(panel);
   }
}
import clr
clr.AddReference("cAlgo.API")
# Import cAlgo API types
from cAlgo.API import *
# Import trading wrapper functions
from robot_wrapper import *

class Test():
    def on_start(self):
        self.colorPicker = ColorPicker()
        self.colorPicker.SelectedColor = Color.FromHex("#eb4034")
        self.colorPicker.IsStretched = True

        self.hexColorTextBox = TextBox()
        self.hexColorTextBox.Text = "#eb4034"

        self.colorPicker.SelectedColorChanged += self.on_selected_color_changed

        changeColorButton = Button()
        changeColorButton.Text = "Change Color"
        changeColorButton.Click += self.on_change_color_button_clicked

        panel = StackPanel()
        panel.Orientation = Orientation.Vertical
        panel.HorizontalAlignment = HorizontalAlignment.Center
        panel.VerticalAlignment = VerticalAlignment.Center

        panel.AddChild(self.colorPicker)
        panel.AddChild(self.hexColorTextBox)
        panel.AddChild(changeColorButton)

        api.Chart.AddControl(panel)

    def on_selected_color_changed(self, args):
        self.hexColorTextBox.Text = args.ColorPicker.SelectedColor.ToHexString()

    def on_change_color_button_clicked(self, args):
        self.colorPicker.SelectedColor = Color.FromHex(self.hexColorTextBox.Text)
{
  "AccessRights": "None"
}

Constructors

Name Description
ColorPickerDesktopCLICloud Initializes a new instance of the ColorPicker class.

Properties

Name Description
IsStretchedDesktopCLICloudbool Gets or sets if color picker is stretched or not.
SelectedColorDesktopCLICloudColor Gets or sets selected color.

Events

Name Description
SelectedColorChangedDesktopCLICloudAction<ColorPickerSelectedColorChangedEventArgs> Occurs when selected color is changed.

Inherited members

From ControlBase: ResetProperty, UniqueId, Style, Left, Top, Right, Bottom, Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight, IsEnabled, IsVisible, Opacity, Margin, VerticalAlignment, HorizontalAlignment, Dock, IsHitTestVisible